RenderMesh.h
1 /*
2 
3 Copyright (c) 2018, Johnathan Corkery. (jcorkery@umich.edu)
4 All rights reserved.
5 
6 This file is part of the Dynacoe project (https://github.com/jcorks/Dynacoe)
7 Dynacoe was released under the MIT License, as detailed below.
8 
9 
10 
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is furnished
16 to do so, subject to the following conditions:
17 
18 The above copyright notice and this permission notice shall
19 be included in all copies or substantial portions of the Software.
20 
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 DEALINGS IN THE SOFTWARE.
28 
29 
30 
31 */
32 
33 #ifndef H_DC_RENDER_MESH
34 #define H_DC_RENDER_MESH
35 
36 #include <Dynacoe/Backends/Renderer/StaticState.h>
37 #include <Dynacoe/Material.h>
38 #include <Dynacoe/AssetID.h>
39 #include <Dynacoe/Mesh.h>
40 #include <Dynacoe/Spatial.h>
41 
42 namespace Dynacoe {
43 using CameraID = Dynacoe::LookupID;
50 class RenderMesh : public Component, public Spatial {
51  public:
52 
53 
54 
55  RenderMesh();
56  ~RenderMesh();
57  RenderMesh & operator=(const RenderMesh &);
58  RenderMesh(const RenderMesh &);
59 
62  void AddMesh(const Mesh &);
63 
64 
69  void AddMesh(
70  const std::vector<Vector> & vertices,
71  const std::vector<uint32_t> & faces,
72  const std::vector<Vector> & UVs = std::vector<Vector>(),
73  const std::vector<Vector> & normals = std::vector<Vector>(),
74  const std::vector<Vector> & userData = std::vector<Vector>()
75  );
76 
77 
78 
81  Mesh & GetMesh(uint32_t);
82 
85  uint32_t GetMeshCount();
86 
89  void Clear();
90 
91 
95 
96 
97 
98 
99 
102  void SetRenderPrimitive(Renderer::Polygon);
103 
106  Renderer::Polygon GetRenderPrimitive();
107 
108 
109 
110  void RenderSelf(Renderer *);
111  void OnDraw();
112  std::string GetInfo();
113  private:
114 
115  void Alloc();
116  void initValues();
117  void OnUpdateTransform();
118 
119  std::vector<Mesh*> meshes;
120  Dynacoe::Material mat;
121 
122  RenderBufferID modelTransform;
123 
124  Entity::ID framebufferID;
125  Renderer::Polygon prim;
126 
127 
128 };
129 
130 
131 }
132 
133 #endif
Mesh & GetMesh(uint32_t)
Retrieves the given mesh instance owned.
uint32_t GetMeshCount()
Returns how many meshes are attached.
void SetRenderPrimitive(Renderer::Polygon)
Sets the rendering primitive. The default (and most useful) is Triangle.
std::string GetInfo()
Returns a string containing human-readable information on the state of the component.
Renderer::Polygon GetRenderPrimitive()
Returns the current rendering primitive.
Definition: AssetID.h:37
void AddMesh(const Mesh &)
Forms the aspect into a 3D mesh based on the stored Mesh asset.
3D object defined by triangle primitives.
Definition: Mesh.h:50
void Clear()
Resets the Aspect.
Dynacoe::Material & Material()
Sets the material.
Defines how an AspectMesh is visualized.
Definition: Material.h:44
Aspect representing a 3D object that reduces to a Mesh.
Definition: RenderMesh.h:50
Class that extends the functionality of an Entity, but as a removable and addable object...
Definition: Component.h:66
Uniquely identifies an Entity.
Definition: Entity.h:67
void OnDraw()
Function that is called upon each Draw iteration. Component Draw()s are run before the entity's draw ...