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<f32> const & Positions,
73  vector<f32> const & Normals = vector<f32>(),
74  vector<f32> const & TexCoords = vector<f32>());
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  void ReverseFaces();
84  void SeparateTriangles();
85  void CalculateNormalsPerFace();
86  void CalculateNormalsPerVertex(bool CombineNear = true, f32 const NearTolerance = 0.0001f);
87 
88  void WriteOBJ(string const & FileName) const;
89 
90  box3f CalculateBoundingBox() const;
91 
92  SharedPointer<Graphics::IIndexBuffer> CreateIndexBuffer();
93  SharedPointer<Graphics::IVertexBuffer> CreateVertexBuffer();
94 
95 
96  };
97 
98  }
99 }
Graphics::CUniform< color3f > Diffuse
Definition: CSimpleMesh.h:21
Graphics::CUniform< f32 > Shininess
Definition: CSimpleMesh.h:23
Definition: SColor.h:8
vec3f Tangent
Definition: CSimpleMesh.h:51
vec2< f32 > vec2f
Definition: SVector2.h:558
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
std::shared_ptr< T > SharedPointer
Definition: ionSmartPointer.h:22
vec3< f32 > vec3f
Definition: SVector3.h:634
vec3f Normal
Definition: CSimpleMesh.h:63
void LoadTextures()
Definition: CSimpleMesh.cpp:18
Customized variant of vec3 that intelligently handles conversion between floating point and integer c...
Definition: SColor.h:67
SharedPointer< Graphics::ITexture > DiffuseTexture
Definition: CSimpleMesh.h:28
unsigned int uint
Definition: ionTypes.h:99
CImage * DiffuseImage
Definition: CSimpleMesh.h:25
float f32
Definition: ionTypes.h:94
vector< SVertex > Vertices
Definition: CSimpleMesh.h:67
Graphics::CUniform< color3f > Specular
Definition: CSimpleMesh.h:22
Definition: CCatmullRomAdvancedSplineInterpolator.h:7
SSimpleMaterial Material
Definition: CSimpleMesh.h:69
3D axis-aligned bounding box
Definition: SBoundingBox3.h:11
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
Definition: CImage.h:10
SharedPointer< Graphics::ITexture > AmbientTexture
Definition: CSimpleMesh.h:29
SSimpleMaterial()
Definition: CSimpleMesh.cpp:10