Neo  0.5.0
Developer Documentation
Material.h
Go to the documentation of this file.
1 //========================================================================
2 // Copyright (c) 2003-2011 Anael Seghezzi <www.maratis3d.com>
3 // Copyright (c) 2014-2015 Yannick Pflanzer <www.neo-engine.de>
4 //
5 // This software is provided 'as-is', without any express or implied
6 // warranty. In no event will the authors be held liable for any damages
7 // arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it
11 // freely, subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented; you must not
14 // claim that you wrote the original software. If you use this software
15 // in a product, an acknowledgment in the product documentation would
16 // be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such, and must not
19 // be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source
22 // distribution.
23 //
24 //========================================================================
25 
26 #ifndef __MATERIAL_H
27 #define __MATERIAL_H
28 
29 namespace Neo
30 {
38 class NEO_ENGINE_EXPORT TexturePass
39 {
40 public:
41  TexturePass(Texture *texture, TEX_COMBINE_MODES combineMode,
42  unsigned int mapChannel)
43  : m_mapChannel(mapChannel),
44  m_texture(texture),
45  m_combineMode(combineMode)
46  {
47  }
48 
49  TexturePass(const TexturePass &texturePass)
50  : m_mapChannel(texturePass.m_mapChannel),
51  m_texture(texturePass.m_texture),
52  m_combineMode(texturePass.m_combineMode)
53  {
54  }
55 
56 private:
57  // texture
58  unsigned int m_mapChannel;
59  Texture *m_texture;
60 
61  // combine mode
62  TEX_COMBINE_MODES m_combineMode;
63 
64 public:
69  inline void setMapChannel(unsigned int mapChannel)
70  {
71  m_mapChannel = mapChannel;
72  }
73 
78  inline void setTexture(Texture *texture) { m_texture = texture; }
79 
84  inline unsigned int getMapChannel(void) { return m_mapChannel; }
85 
90  inline Texture *getTexture(void) { return m_texture; }
91 
99  inline void setCombineMode(TEX_COMBINE_MODES combineMode)
100  {
101  m_combineMode = combineMode;
102  }
103 
109  inline TEX_COMBINE_MODES getCombineMode(void) { return m_combineMode; }
110 };
111 
118 class NEO_ENGINE_EXPORT Material
119 {
120 public:
121  Material(void);
122  Material(const Material &material);
123  ~Material(void);
124 
125 private:
126  // type
127  int m_type;
128 
129  // FX
130  FXRef *m_FXRef;
131  FXRef *m_ZFXRef;
132 
133  // blend mode
134  BLENDING_MODES m_blendMode;
135 
136  // properties
137  float m_opacity;
138  float m_shininess;
139  float m_customValue;
140  Vector3 m_diffuse;
141  Vector3 m_specular;
142  Vector3 m_emit;
143  Vector3 m_customColor;
144 
145  // textures pass
146  unsigned int m_texturesPassNumber;
147  TexturePass **m_texturesPass;
148 
149 public:
154  inline void setType(int type) { m_type = type; }
155 
160  inline int getType(void) { return m_type; }
161 
162  // FX
163  inline void setFXRef(FXRef *FXRef) { m_FXRef = FXRef; }
164  inline void setZFXRef(FXRef *ZFXRef) { m_ZFXRef = ZFXRef; }
165  inline FXRef *getFXRef(void) { return m_FXRef; }
166  inline FXRef *getZFXRef(void) { return m_ZFXRef; }
167 
174  inline void setBlendMode(BLENDING_MODES blendMode)
175  {
176  m_blendMode = blendMode;
177  }
178 
185  inline BLENDING_MODES getBlendMode(void) { return m_blendMode; }
186 
195  inline void setOpacity(float opacity) { m_opacity = opacity; }
196 
204  inline void setShininess(float shininess) { m_shininess = shininess; }
205 
210  inline void setCustomValue(float customValue)
211  {
212  m_customValue = customValue;
213  }
214 
221  inline void setDiffuse(const Vector3 &diffuse) { m_diffuse = diffuse; }
222 
229  inline void setSpecular(const Vector3 &specular) { m_specular = specular; }
230 
237  inline void setEmit(const Vector3 &emit) { m_emit = emit; }
238 
245  inline void setCustomColor(const Vector3 &customColor)
246  {
247  m_customColor = customColor;
248  }
249 
254  inline float getOpacity(void) { return m_opacity; }
255 
260  inline float getShininess(void) { return m_shininess; }
261 
266  inline float getCustomValue(void) { return m_customValue; }
267 
272  inline Vector3 getEmit(void) const { return m_emit; }
273 
278  inline Vector3 getDiffuse(void) const { return m_diffuse; }
279 
284  inline Vector3 getSpecular(void) const { return m_specular; }
285 
290  inline Vector3 getCustomColor(void) const { return m_customColor; }
291 
296  void allocTexturesPass(unsigned int size);
297 
301  void clearTexturesPass(void);
302 
309  void addTexturePass(Texture *texture, TEX_COMBINE_MODES combineMode,
310  unsigned int mapChannel);
311 
316  inline unsigned int getTexturesPassNumber(void)
317  {
318  return m_texturesPassNumber;
319  }
320 
325  inline TexturePass *getTexturePass(unsigned int id)
326  {
327  return m_texturesPass[id];
328  }
329 };
330 }
331 #endif
Definition: Texture.h:31
void setTexture(Texture *texture)
Sets the texture to use.
Definition: Material.h:78
void setCustomColor(const Vector3 &customColor)
Sets the custom color.
Definition: Material.h:245
Texture * getTexture(void)
Returns the texture that is used.
Definition: Material.h:90
Vector3 getCustomColor(void) const
Returns the current custom color.
Definition: Material.h:290
void setType(int type)
Sets the type of the material.
Definition: Material.h:154
BLENDING_MODES
Definition: RenderingContext.h:32
Definition: Vector3.h:31
void setOpacity(float opacity)
Sets the opacity value.
Definition: Material.h:195
void setCombineMode(TEX_COMBINE_MODES combineMode)
Sets the combine mode when using multiple passes for one material.
Definition: Material.h:99
TEX_COMBINE_MODES getCombineMode(void)
Returns the combine mode.
Definition: Material.h:109
float getShininess(void)
Returns the current shininess.
Definition: Material.h:260
unsigned int getMapChannel(void)
Returns the map channel.
Definition: Material.h:84
The Material class contains the implementation of a material used by 3D meshes for rendering differen...
Definition: Material.h:118
void setEmit(const Vector3 &emit)
Sets the emit color.
Definition: Material.h:237
void setFXRef(FXRef *FXRef)
Definition: Material.h:163
FXRef * getZFXRef(void)
Definition: Material.h:166
float getOpacity(void)
Returns the current opacity.
Definition: Material.h:254
Vector3 getEmit(void) const
Returns the current emit color.
Definition: Material.h:272
void setDiffuse(const Vector3 &diffuse)
Sets the diffuse color.
Definition: Material.h:221
Definition: FXManager.h:32
TexturePass(Texture *texture, TEX_COMBINE_MODES combineMode, unsigned int mapChannel)
Definition: Material.h:41
void setMapChannel(unsigned int mapChannel)
Sets the map channel.
Definition: Material.h:69
void setCustomValue(float customValue)
Sets the custom value.
Definition: Material.h:210
int getType(void)
Returns the type of the material.
Definition: Material.h:160
void setShininess(float shininess)
Sets the shininess value.
Definition: Material.h:204
TexturePass(const TexturePass &texturePass)
Definition: Material.h:49
Vector3 getSpecular(void) const
Returns the current specular color.
Definition: Material.h:284
TexturePass * getTexturePass(unsigned int id)
Returns a texture pass by ID from the internal array.
Definition: Material.h:325
void setSpecular(const Vector3 &specular)
Sets the specular color.
Definition: Material.h:229
void setZFXRef(FXRef *ZFXRef)
Definition: Material.h:164
float getCustomValue(void)
Returns the current custom value.
Definition: Material.h:266
TEX_COMBINE_MODES
Definition: RenderingContext.h:102
The texture pass class implements some basic primitives to manage and use multi-texture materials...
Definition: Material.h:38
FXRef * getFXRef(void)
Definition: Material.h:165
unsigned int getTexturesPassNumber(void)
Returns the number of texture passes.
Definition: Material.h:316
Definition: Color.h:29
Vector3 getDiffuse(void) const
Returns the current diffuse color.
Definition: Material.h:278
void setBlendMode(BLENDING_MODES blendMode)
Changes the current blend mode.
Definition: Material.h:174
BLENDING_MODES getBlendMode(void)
Returns the current blend mode.
Definition: Material.h:185