CSimpleMesh.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include <ionCore.h>
5 #include <ionMath.h>
6 #include <ionGraphics.h>
7 
8 
9 namespace ion
10 {
11  namespace Scene
12  {
13 
15  {
16 
18  void LoadTextures();
19 
24 
25  CImage * DiffuseImage = nullptr;
26  CImage * AmbientImage = nullptr;
27 
30 
31  };
32 
34  {
35 
36  public:
37 
38  struct SVertex
39  {
40 
41  SVertex();
42  SVertex(
43  vec3f const & position,
44  vec3f const & normal = vec3f(),
45  vec2f const & texture = vec2f(),
46  vec3f const & tangent = vec3f());
47 
50  color3f Color = 1.f;
53 
54  };
55 
56  struct STriangle
57  {
58 
59  STriangle();
60  STriangle(uint const index0, uint const index1, uint const index2);
61 
62  uint Indices[3];
64 
65  };
66 
67  vector<SVertex> Vertices;
68  vector<STriangle> Triangles;
70 
71  static CSimpleMesh * FromAttributes(vector<uint> Indices,
72  vector<float> const & Positions,
73  vector<float> const & Normals = vector<float>(),
74  vector<float> const & TexCoords = vector<float>());
75 
76  SBoundingBox3f GetBoundingBox() const;
77 
78  void Clear();
79  CSimpleMesh * ResizeMesh(vec3f const & Scale);
80  CSimpleMesh * ApplyScaleFactor(vec3f const & Scale);
81  CSimpleMesh * ApplyOffset(vec3f const & Offset);
82  CSimpleMesh * ApplyTransformation(glm::mat4 const & Transform);
83  CSimpleMesh * Intersect(CSimpleMesh const * Other, vec3f const & Offset = 0);
84  void ReverseFaces();
85  void SeparateTriangles();
86  void CalculateNormalsPerFace();
87  void CalculateNormalsPerVertex(bool CombineNear = true, float const NearTolerance = 0.0001f);
88 
89  void WriteOBJ(string const & FileName) const;
90 
91  box3f CalculateBoundingBox() const;
92 
93  SharedPointer<Graphics::IIndexBuffer> CreateIndexBuffer();
94  SharedPointer<Graphics::IVertexBuffer> CreateVertexBuffer();
95 
96 
97  };
98 
99  }
100 }
Graphics::CUniform< color3f > Diffuse
Definition: CSimpleMesh.h:21
vec3f Tangent
Definition: CSimpleMesh.h:51
Definition: CSimpleMesh.h:38
vector< STriangle > Triangles
Definition: CSimpleMesh.h:68
vec2f TextureCoordinates
Definition: CSimpleMesh.h:52
Definition: CSimpleMesh.h:33
Definition: CSimpleMesh.h:14
vec3f Normal
Definition: CSimpleMesh.h:63
void LoadTextures()
Definition: CSimpleMesh.cpp:18
Graphics::CUniform< float > Shininess
Definition: CSimpleMesh.h:23
vec3< float > vec3f
Definition: vec3.h:638
SharedPointer< Graphics::ITexture > DiffuseTexture
Definition: CSimpleMesh.h:28
CImage * DiffuseImage
Definition: CSimpleMesh.h:25
vector< SVertex > Vertices
Definition: CSimpleMesh.h:67
vec2< float > vec2f
Definition: vec2.h:574
Graphics::CUniform< color3f > Specular
Definition: CSimpleMesh.h:22
Definition: CCatmullRomAdvancedSplineInterpolator.h:7
SSimpleMaterial Material
Definition: CSimpleMesh.h:69
unsigned int uint
Definition: ionTypes.h:42
vec3f Position
Definition: CSimpleMesh.h:48
CImage * AmbientImage
Definition: CSimpleMesh.h:26
Helper class to easily add a uniform as a member or local variable.
Definition: IUniform.h:158
Definition: CSimpleMesh.h:56
Graphics::CUniform< color3f > Ambient
Definition: CSimpleMesh.h:20
vec3f Normal
Definition: CSimpleMesh.h:49
3D axis-aligned bounding box
Definition: SBoundingBox3.h:14
Definition: CImage.h:11
std::shared_ptr< T > SharedPointer
Definition: ionSmartPointer.h:25
SharedPointer< Graphics::ITexture > AmbientTexture
Definition: CSimpleMesh.h:29
SSimpleMaterial()
Definition: CSimpleMesh.cpp:10