RioEngine  0.1
My first attempt to create a 3D WYSIWYG Game Engine
cltriangles.cpp
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 #include "cengine/carray.h"
31 #include "clengine/cltriangles.h"
32 
33 //-----------------------------------------------------------------------------
34 
36  m_normalsIndices = NULL;
37  m_verticesIndices = NULL;
38  m_textureCoordIndices = NULL;
39 }
40 
41 //-----------------------------------------------------------------------------
42 
43 CLTriangles::CLTriangles(const CLTriangles& original_obj) : CObject() {
44  copyValuesFromObject(original_obj);
45 }
46 
47 //-----------------------------------------------------------------------------
48 
49 void CLTriangles::copyValuesFromObject(const CLTriangles& original_obj) {
50  m_normalsIndices = (CArray<int>*)original_obj.getNormalsIndices()->retain();
51  m_textureCoordIndices = (CArray<int>*)original_obj.getTextureCoordIndices()->retain();
52  m_verticesIndices = (CArray<int>*)original_obj.getVerticesIndices()->retain();
53 
54  setMaterialId(original_obj.getMaterialId());
55 }
56 
57 //-----------------------------------------------------------------------------
58 
60  if (this == &original_obj) {
61  return *this;
62  }
63 
64  copyValuesFromObject(original_obj);
65 
66  return *this;
67 }
68 
69 //-----------------------------------------------------------------------------
70 
71 void CLTriangles::setMaterialId(const std::string& material_id) {
72  m_materialId = material_id;
73 }
74 
75 //-----------------------------------------------------------------------------
76 
77 const std::string& CLTriangles::getMaterialId() const {
78  return m_materialId;
79 }
80 
81 //-----------------------------------------------------------------------------
82 
84  return m_verticesIndices;
85 }
86 
87 //-----------------------------------------------------------------------------
88 
90  return m_normalsIndices;
91 }
92 
93 //-----------------------------------------------------------------------------
94 
96  return m_textureCoordIndices;
97 }
98 
99 //-----------------------------------------------------------------------------
100 
102  RE_ASSERT(indices);
103  SAFE_RELEASE(m_verticesIndices);
104  SAFE_RETAIN(indices);
105  m_verticesIndices = indices;
106 }
107 
108 //-----------------------------------------------------------------------------
109 
111  RE_ASSERT(indices);
112  SAFE_RELEASE(m_normalsIndices);
113  SAFE_RETAIN(indices);
114  m_normalsIndices = indices;
115 }
116 
117 //-----------------------------------------------------------------------------
118 
120  RE_ASSERT(indices);
121  SAFE_RELEASE(m_textureCoordIndices);
122  SAFE_RETAIN(indices);
123  m_textureCoordIndices = indices;
124 }
125 
126 //-----------------------------------------------------------------------------
127 
129  SAFE_RELEASE(m_normalsIndices);
130  SAFE_RELEASE(m_verticesIndices);
131  SAFE_RELEASE(m_textureCoordIndices);
132 }
void setMaterialId(const std::string &material_id)
Definition: cltriangles.cpp:71
CLTriangles & operator=(const CLTriangles &triangles_obj)
Definition: cltriangles.cpp:59
~CLTriangles(void)
CArray< int > * getVerticesIndices() const
Definition: cltriangles.cpp:83
CArray< int > * getTextureCoordIndices() const
Definition: cltriangles.cpp:95
void setVerticesIndices(CArray< int > *indices)
#define SAFE_RELEASE(x)
Definition: cobject.h:36
CArray< int > * getNormalsIndices() const
Definition: cltriangles.cpp:89
#define SAFE_RETAIN(x)
Definition: cobject.h:35
#define RE_ASSERT
Definition: macro.h:57
void setNormalsIndices(CArray< int > *indices)
const std::string & getMaterialId() const
Definition: cltriangles.cpp:77
CLTriangles(void)
Definition: cltriangles.cpp:35
CObject * retain()
Definition: cobject.cpp:66
void setTextureCoordsIndices(CArray< int > *indices)