RioEngine  0.1
My first attempt to create a 3D WYSIWYG Game Engine
clphong.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 "clengine/clphongchild.h"
31 #include "clengine/clphong.h"
32 
33 //-----------------------------------------------------------------------------
34 
35 CLPhong::CLPhong(const CLPhong& original_obj) : CObject() {
36  copyValuesFromObject(original_obj);
37 }
38 
39 //-----------------------------------------------------------------------------
40 
42  m_ambient = NULL;
43  m_diffuse = NULL;
44  m_emission = NULL;
45  m_specular = NULL;
46  m_shininess = NULL;
47  m_indexOfRefraction = NULL;
48 }
49 
50 //-----------------------------------------------------------------------------
51 
52 CLPhong& CLPhong::operator=(const CLPhong& original_obj) {
53  if (this == &original_obj) {
54  return *this;
55  }
56 
57  copyValuesFromObject(original_obj);
58 
59  return *this;
60 }
61 
62 //-----------------------------------------------------------------------------
63 
64 void CLPhong::copyValuesFromObject(const CLPhong& original_obj) {
65  m_ambient = (CLPhongChild*)original_obj.getAmbient()->retain();
66  m_diffuse = (CLPhongChild*)original_obj.getDiffuse()->retain();
67  m_emission = (CLPhongChild*)original_obj.getEmission()->retain();
68  m_specular = (CLPhongChild*)original_obj.getSpecular()->retain();
69  m_shininess = (CLPhongChild*)original_obj.getShininess()->retain();
70  m_indexOfRefraction = (CLPhongChild*)original_obj.getIndexOfRefraction()->retain();
71 }
72 
73 //-----------------------------------------------------------------------------
74 
76  RE_ASSERT(emission);
77  SAFE_RELEASE(m_emission);
78  SAFE_RETAIN(emission);
79  m_emission = emission;
80 }
81 
82 //-----------------------------------------------------------------------------
83 
85  return m_emission;
86 }
87 
88 //-----------------------------------------------------------------------------
89 
91  RE_ASSERT(ambient);
92  SAFE_RELEASE(m_ambient);
93  SAFE_RETAIN(ambient);
94  m_ambient = ambient;
95 }
96 
97 //-----------------------------------------------------------------------------
98 
100  return m_ambient;
101 }
102 
103 //-----------------------------------------------------------------------------
104 
106  RE_ASSERT(diffuse);
107  SAFE_RELEASE(m_diffuse);
108  SAFE_RETAIN(diffuse);
109  m_diffuse = diffuse;
110 }
111 
112 //-----------------------------------------------------------------------------
113 
115  return m_diffuse;
116 }
117 
118 //-----------------------------------------------------------------------------
119 
121  RE_ASSERT(specular);
122  SAFE_RELEASE(m_specular);
123  SAFE_RETAIN(specular);
124  m_specular = specular;
125 }
126 
127 //-----------------------------------------------------------------------------
128 
130  return m_specular;
131 }
132 
133 //-----------------------------------------------------------------------------
134 
136  RE_ASSERT(shininess);
137  SAFE_RELEASE(m_shininess);
138  SAFE_RETAIN(shininess);
139  m_shininess = shininess;
140 }
141 
142 //-----------------------------------------------------------------------------
143 
145  return m_shininess;
146 }
147 
148 //-----------------------------------------------------------------------------
149 
150 void CLPhong::setIndexOfRefraction(CLPhongChild* index_of_refraction) {
151  RE_ASSERT(index_of_refraction);
152  SAFE_RELEASE(m_indexOfRefraction);
153  SAFE_RETAIN(index_of_refraction);
154  m_indexOfRefraction = index_of_refraction;
155 }
156 
157 //-----------------------------------------------------------------------------
158 
160  return m_indexOfRefraction;
161 }
162 
163 //-----------------------------------------------------------------------------
164 
166  SAFE_RELEASE(m_emission);
167  SAFE_RELEASE(m_ambient);
168  SAFE_RELEASE(m_diffuse);
169  SAFE_RELEASE(m_specular);
170  SAFE_RELEASE(m_shininess);
171  SAFE_RELEASE(m_indexOfRefraction);
172 }
~CLPhong(void)
Definition: clphong.cpp:165
CLPhongChild * getIndexOfRefraction() const
Definition: clphong.cpp:159
void setShininess(CLPhongChild *shininess)
Definition: clphong.cpp:135
CLPhongChild * getEmission() const
Definition: clphong.cpp:84
void setDiffuse(CLPhongChild *diffuse)
Definition: clphong.cpp:105
virtual void copyValuesFromObject(const CLPhong &phong)
Definition: clphong.cpp:64
void setAmbient(CLPhongChild *ambient)
Definition: clphong.cpp:90
void setSpecular(CLPhongChild *specular)
Definition: clphong.cpp:120
CLPhongChild * getSpecular() const
Definition: clphong.cpp:129
void setEmission(CLPhongChild *emission)
Definition: clphong.cpp:75
#define SAFE_RELEASE(x)
Definition: cobject.h:36
CLPhong()
Definition: clphong.cpp:41
#define SAFE_RETAIN(x)
Definition: cobject.h:35
CLPhongChild * getDiffuse() const
Definition: clphong.cpp:114
#define RE_ASSERT
Definition: macro.h:57
void setIndexOfRefraction(CLPhongChild *index_of_refraction)
Definition: clphong.cpp:150
CLPhongChild * getAmbient() const
Definition: clphong.cpp:99
CLPhong & operator=(const CLPhong &)
Definition: clphong.cpp:52
CLPhongChild * getShininess() const
Definition: clphong.cpp:144
CObject * retain()
Definition: cobject.cpp:66