gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
Material.inl
Go to the documentation of this file.
1 /*
2 
3 Copyright (c) 2014, Dr Franck P. Vidal (franck.p.vidal@fpvidal.net),
4 http://www.fpvidal.net/
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation and/or
15 other materials provided with the distribution.
16 
17 3. Neither the name of the Bangor University nor the names of its contributors
18 may be used to endorse or promote products derived from this software without
19 specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 
32 */
33 
34 
61 //******************************************************************************
62 // namespace
63 //******************************************************************************
64 namespace gVirtualXRay {
65 
66 
67 //-------------------------
69  m_shininess(50.0)
70 //-------------------------
71 {
73  m_p_ambient_colour[0] = 1.0;
74  m_p_ambient_colour[1] = 1.0;
75  m_p_ambient_colour[2] = 1.0;
76  m_p_ambient_colour[3] = 1.0;
77 
79  m_p_diffuse_colour[0] = 1.0;
80  m_p_diffuse_colour[1] = 1.0;
81  m_p_diffuse_colour[2] = 1.0;
82  m_p_diffuse_colour[3] = 1.0;
83 
85  m_p_specular_colour[0] = 1.0;
86  m_p_specular_colour[1] = 1.0;
87  m_p_specular_colour[2] = 1.0;
88  m_p_specular_colour[3] = 1.0;
89 }
90 
91 
92 //--------------------------------------------------
93 inline Material::Material(const Material& aMaterial)
94 //--------------------------------------------------
95 {
96  *this = aMaterial;
97 }
98 
99 
100 //--------------------------
102 //--------------------------
103 {
104 }
105 
106 
107 //-------------------------------------------------------------
108 inline Material& Material::operator=(const Material& aMaterial)
109 //-------------------------------------------------------------
110 {
111  // Ambient colour
112  memcpy(m_p_ambient_colour, aMaterial.m_p_ambient_colour, sizeof(m_p_ambient_colour));
113 
114  // Diffuse colour
115  memcpy(m_p_diffuse_colour, aMaterial.m_p_diffuse_colour, sizeof(m_p_diffuse_colour));
116 
117  // Specular colour
118  memcpy(m_p_specular_colour, aMaterial.m_p_specular_colour, sizeof(m_p_specular_colour));
119 
120  // Shininess
121  m_shininess = aMaterial.m_shininess;
122 
123  // Return the instance
124  return (*this);
125 }
126 
127 
128 //---------------------------------------------------------
129 inline void Material::setAmbientColour(float aRedChannel,
130  float aGreenChannel,
131  float aBlueChannel,
132  float aAlphaChannel)
133 //---------------------------------------------------------
134 {
135  m_p_ambient_colour[0] = aRedChannel;
136  m_p_ambient_colour[1] = aGreenChannel;
137  m_p_ambient_colour[2] = aBlueChannel;
138  m_p_ambient_colour[3] = aAlphaChannel;
139 }
140 
141 
142 //---------------------------------------------------------
143 inline void Material::setDiffuseColour(float aRedChannel,
144  float aGreenChannel,
145  float aBlueChannel,
146  float aAlphaChannel)
147 //---------------------------------------------------------
148 {
149  m_p_diffuse_colour[0] = aRedChannel;
150  m_p_diffuse_colour[1] = aGreenChannel;
151  m_p_diffuse_colour[2] = aBlueChannel;
152  m_p_diffuse_colour[3] = aAlphaChannel;
153 }
154 
155 
156 
157 //----------------------------------------------------------
158 inline void Material::setSpecularColour(float aRedChannel,
159  float aGreenChannel,
160  float aBlueChannel,
161  float aAlphaChannel)
162 //----------------------------------------------------------
163 {
164  m_p_specular_colour[0] = aRedChannel;
165  m_p_specular_colour[1] = aGreenChannel;
166  m_p_specular_colour[2] = aBlueChannel;
167  m_p_specular_colour[3] = aAlphaChannel;
168 }
169 
170 
171 //-------------------------------------------------------
172 inline void Material::setShininess(float aShininessValue)
173 //-------------------------------------------------------
174 {
175  m_shininess = aShininessValue;
176 }
177 
178 //----------------------------------------------------
179 inline const float* Material::getAmbientColour() const
180 //----------------------------------------------------
181 {
182  return (m_p_ambient_colour);
183 }
184 
185 
186 //----------------------------------------------------
187 inline const float* Material::getDiffuseColour() const
188 //----------------------------------------------------
189 {
190  return (m_p_diffuse_colour);
191 }
192 
193 
194 //-----------------------------------------------------
195 inline const float* Material::getSpecularColour() const
196 //-----------------------------------------------------
197 {
198  return (m_p_specular_colour);
199 }
200 
201 
202 //-----------------------------------------
203 inline float Material::getShininess() const
204 //-----------------------------------------
205 {
206  return (m_shininess);
207 }
208 
209 
210 } // namespace gVirtualXRay
void setShininess(float aShininessValue)
Set the shininess of the material.
Definition: Material.inl:172
float m_shininess
Shininess.
Definition: Material.h:220
Material()
Default constructor.
Definition: Material.inl:68
void setDiffuseColour(float aRedChannel, float aGreenChannel, float aBlueChannel, float aAlphaChannel)
Set the diffuse colour.
Definition: Material.inl:143
Material & operator=(const Material &aMaterial)
Copy operator.
Definition: Material.inl:108
void setSpecularColour(float aRedChannel, float aGreenChannel, float aBlueChannel, float aAlphaChannel)
Set the specular colour.
Definition: Material.inl:158
float m_p_diffuse_colour[4]
Diffuse colour.
Definition: Material.h:212
float m_p_specular_colour[4]
Specular colour.
Definition: Material.h:216
void setAmbientColour(float aRedChannel, float aGreenChannel, float aBlueChannel, float aAlphaChannel)
Set the ambient colour.
Definition: Material.inl:129
float getShininess() const
Accessor on the shininess of the material.
Definition: Material.inl:203
const float * getDiffuseColour() const
Accessor on the diffuse colour.
Definition: Material.inl:187
Material is a class to handle materials.
Definition: Material.h:86
const float * getAmbientColour() const
Accessor on the ambient colour.
Definition: Material.inl:179
~Material()
Destructor.
Definition: Material.inl:101
float m_p_ambient_colour[4]
Ambient colour.
Definition: Material.h:208
const float * getSpecularColour() const
Accessor on the specular colour.
Definition: Material.inl:195