RioEngine  0.1
My first attempt to create a 3D WYSIWYG Game Engine
clmesh.h
Go to the documentation of this file.
1 //--------------------------------------------------------------- @License begins
2 // RioEngine: The late night Coke -without whores- debugging sessions
3 // 2012-2015 Leopoldo Lomas Flores. Torreon, Coahuila. MEXICO
4 // leopoldolomas [at] gmail
5 // www.rioengine.com
6 // www.leopoldolomas.info
7 // "You have a problem, you face it like a man."
8 //
9 // This is free and unencumbered software released into the public domain.
10 //
11 // Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
12 // software, either in source code form or as a compiled binary, for any purpose,
13 // commercial or non-commercial, and by any means.
14 //
15 // In jurisdictions that recognize copyright laws, the author or authors of this
16 // software dedicate any and all copyright interest in the software to the public
17 // domain. We make this dedication for the benefit of the public at large and to
18 // the detriment of our heirs and successors. We intend this dedication to be
19 // an overt act of relinquishment in perpetuity of all present and future
20 // rights to this software under copyright law.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS
24 // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
26 // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //--------------------------------------------------------------- @License ends
29 
30 #ifndef RIOENGINE_CLENGINE_CLMESH_H_
31 #define RIOENGINE_CLENGINE_CLMESH_H_
32 
33 #include <vector>
34 #include "cengine/cobject.h"
35 
36 template <class T> class CArray;
37 class CLTriangles;
38 class CLPolygon;
39 struct TextureCoord;
40 
47 class CLMesh : public CObject {
48 public:
49  CLMesh(void);
50  CLMesh(const CLMesh& mesh);
51  CLMesh& operator=(const CLMesh& mesh);
52 
55  void setMapArray (CArray<TextureCoord>* map_array);
56  void setTriangles(CArray<CLTriangles>* triangles_array);
57 
58  CArray<btVector3>* normals() const;
62 
66  CLPolygon getPolygonForTrianglesIndex(unsigned int index);
67 
72 
73  CArray<CLPolygon>* fixPolygonsArray(std::vector<CLPolygon>* polygons_array);
74 
75  template<class T>
77  CArray<int>* indices_array) {
78  if (!locations_array) {
79  return NULL;
80  }
81 
82  RE_ASSERT(indices_array);
83 
84  btAlignedObjectArray<T> vec = btAlignedObjectArray<T>();
85 
86  for (unsigned int i = 0; i < indices_array->size(); i++) {
87  T original_obj = locations_array->objectAtIndex(indices_array->objectAtIndex(i));
88  vec.push_back(T(original_obj));
89  }
91  vec.clear();
92  return array;
93  }
94 
95  ~CLMesh(void);
96 
97 protected:
98  virtual void copyValuesFromObject(const CLMesh& mesh);
99 
100 private:
101  CArray<btVector3>* m_positions;
102  CArray<btVector3>* m_normals;
103  CArray<TextureCoord>* m_textureCoords;
104  CArray<CLTriangles>* m_triangles;
105 };
106 
107 #endif // RIOENGINE_CLENGINE_CLMESH_H_
Definition: clmesh.h:47
CArray< btVector3 > * normals() const
Definition: clmesh.cpp:116
CArray< T > * getLocationsArrayHavingIndicesArray(CArray< T > *locations_array, CArray< int > *indices_array)
Definition: clmesh.h:76
static CArray * fromBtAlignedObjectArray(btAlignedObjectArray< T > *vec)
Definition: carray.h:150
CArray< btVector3 > * positions() const
Definition: clmesh.cpp:101
void setTriangles(CArray< CLTriangles > *triangles_array)
Definition: clmesh.cpp:77
void setNormals(CArray< btVector3 > *normals)
Definition: clmesh.cpp:107
CArray< CLTriangles > * triangles() const
Definition: clmesh.cpp:86
void setMapArray(CArray< TextureCoord > *map_array)
Definition: clmesh.cpp:122
CLMesh(void)
Definition: clmesh.cpp:41
~CLMesh(void)
Definition: clmesh.cpp:248
void setPositions(CArray< btVector3 > *positions)
Definition: clmesh.cpp:92
Definition: carray.h:43
CArray< CLPolygon > * getPolygonsArray()
Definition: clmesh.cpp:162
T objectAtIndex(unsigned int index) const
Definition: carray.h:83
CLMesh & operator=(const CLMesh &mesh)
Definition: clmesh.cpp:50
CArray< TextureCoord > * mapArray() const
Definition: clmesh.cpp:131
virtual void copyValuesFromObject(const CLMesh &mesh)
Definition: clmesh.cpp:68
#define RE_ASSERT
Definition: macro.h:57
CArray< CLPolygon > * fixPolygonsArray(std::vector< CLPolygon > *polygons_array)
Definition: clmesh.cpp:180
CLPolygon getPolygonForTrianglesIndex(unsigned int index)
Definition: clmesh.cpp:137
unsigned int size() const
Definition: carray.h:104