RioEngine  0.1
My first attempt to create a 3D WYSIWYG Game Engine
clinstancegeometry.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 "misc/genericshelper.hpp"
31 #include "cengine/carray.h"
33 
34 //-----------------------------------------------------------------------------
35 
37  m_meshUrl = "";
38  m_instanceMaterials = NULL;
39 }
40 
41 //-----------------------------------------------------------------------------
42 
44  copyValuesFromObject(original_obj);
45 }
46 
47 //-----------------------------------------------------------------------------
48 
50  m_meshUrl = std::string(original_obj.getMeshURL());
51  m_instanceMaterials = (CArray<CLInstanceMaterial>*)original_obj.getInstanceMaterials()->retain();
52 }
53 
54 //-----------------------------------------------------------------------------
55 
57  if (this == &original_obj) {
58  return *this;
59  }
60 
61  copyValuesFromObject(original_obj);
62 
63  return *this;
64 }
65 
66 //-----------------------------------------------------------------------------
67 
69  RE_ASSERT(instance_materials);
70  SAFE_RELEASE(m_instanceMaterials);
71  SAFE_RETAIN(instance_materials);
72  m_instanceMaterials = instance_materials;
73 }
74 
75 //-----------------------------------------------------------------------------
76 
78  return m_instanceMaterials;
79 }
80 
81 //-----------------------------------------------------------------------------
82 
83 void CLInstanceGeometry::setMeshURL(const std::string& url) {
84  m_meshUrl = url;
85 }
86 
87 //-----------------------------------------------------------------------------
88 
89 const std::string& CLInstanceGeometry::getMeshURL() const {
90  return m_meshUrl;
91 }
92 
93 //-----------------------------------------------------------------------------
94 
96  return QString::fromStdString(m_meshUrl);
97 }
98 
99 //-----------------------------------------------------------------------------
100 
101 void CLInstanceGeometry::setMeshURL(const QString& url) {
102  m_meshUrl = url.toStdString();
103 }
104 
105 //-----------------------------------------------------------------------------
106 
107 QList<CLInstanceMaterial> CLInstanceGeometry::instanceMaterials() {
108  QList<CLInstanceMaterial> vec = QList<CLInstanceMaterial>();
109  for (uint i = 0; i < m_instanceMaterials->size(); i++) {
110  vec.append(CLInstanceMaterial(m_instanceMaterials->objectAtIndex(i)));
111  }
112  return vec;
113 }
114 
115 //-----------------------------------------------------------------------------
116 
117 void CLInstanceGeometry::setInstanceMaterials(QList<CLInstanceMaterial> instance_materials) {
118  SAFE_RELEASE(m_instanceMaterials);
119  std::vector<CLInstanceMaterial> std_vec = std::vector<CLInstanceMaterial>();
120  for (QList<CLInstanceMaterial>::iterator it = instance_materials.begin();
121  it != instance_materials.end();
122  ++it) {
123  std_vec.push_back(*it);
124  }
126 }
127 
128 //-----------------------------------------------------------------------------
129 
131  SAFE_RELEASE(m_instanceMaterials);
132 }
void setMeshURL(const std::string &url)
virtual void copyValuesFromObject(const CLInstanceGeometry &original_obj)
CLInstanceGeometry & operator=(const CLInstanceGeometry &original_obj)
T objectAtIndex(unsigned int index) const
Definition: carray.h:83
#define SAFE_RELEASE(x)
Definition: cobject.h:36
#define SAFE_RETAIN(x)
Definition: cobject.h:35
#define RE_ASSERT
Definition: macro.h:57
const std::string & getMeshURL() const
void setInstanceMaterials(CArray< CLInstanceMaterial > *instance_materials)
unsigned int size() const
Definition: carray.h:104
QList< CLInstanceMaterial > instanceMaterials()
CObject * retain()
Definition: cobject.cpp:66
CArray< CLInstanceMaterial > * getInstanceMaterials() const