arsa  2.7
SOverrideMaterial.h
Go to the documentation of this file.
1 // Copyright (C) 2017 Michael Zeilfelder
2 // This file is part of the "Irrlicht Engine".
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
4 
5 #ifndef __S_OVERRIDE_MATERIAL_H_INCLUDED__
6 #define __S_OVERRIDE_MATERIAL_H_INCLUDED__
7 
8 #include "SMaterial.h"
9 
10 namespace irr
11 {
12 namespace video
13 {
14 
16  {
19 
21 
23 
26 
29 
32 
34 
36 
38 
43  bool Enabled;
44 
46  {
47  SMaterialTypeReplacement(s32 original, u32 replacement) : Original(original), Replacement(replacement) {}
48  SMaterialTypeReplacement(u32 replacement) : Original(-1), Replacement(replacement) {}
49 
53 
56  };
57 
60 
63  {
64  }
65 
67  void reset()
68  {
69  EnableFlags = 0;
70  EnablePasses = 0;
71  Enabled = false;
72  for (u32 i = 0; i < MATERIAL_MAX_TEXTURES; ++i)
73  {
74  EnableLayerFlags[i] = true; // doesn't do anything unless EnableFlags is set, just saying by default all texture layers are affected by flags
75  EnableTextures[i] = false;
76  EnableLayers[i] = false;
77  }
78  MaterialTypes.clear();
79  }
80 
82  void apply(SMaterial& material)
83  {
84  if (Enabled)
85  {
86  for (u32 i = 0; i < MaterialTypes.size(); ++i)
87  {
89  if (mtr.Original < 0 || (s32)mtr.Original == material.MaterialType)
91  }
92  for (u32 f=0; f<32; ++f)
93  {
94  const u32 num=(1<<f);
95  if (EnableFlags & num)
96  {
97  switch (num)
98  {
99  case EMF_WIREFRAME: material.Wireframe = Material.Wireframe; break;
100  case EMF_POINTCLOUD: material.PointCloud = Material.PointCloud; break;
102  case EMF_LIGHTING: material.Lighting = Material.Lighting; break;
103  case EMF_ZBUFFER: material.ZBuffer = Material.ZBuffer; break;
104  case EMF_ZWRITE_ENABLE: material.ZWriteEnable = Material.ZWriteEnable; break;
107  case EMF_BILINEAR_FILTER:
108  for ( u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
109  {
110  if ( EnableLayerFlags[i] )
111  {
113  }
114  }
115  break;
117  for ( u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
118  {
119  if ( EnableLayerFlags[i] )
120  {
122  }
123  }
124  break;
126  for ( u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
127  {
128  if ( EnableLayerFlags[i] )
129  {
131  }
132  }
133  break;
134  case EMF_FOG_ENABLE: material.FogEnable = Material.FogEnable; break;
136  case EMF_TEXTURE_WRAP:
137  for ( u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
138  {
139  if ( EnableLayerFlags[i] )
140  {
144  }
145  }
146  break;
147  case EMF_ANTI_ALIASING: material.AntiAliasing = Material.AntiAliasing; break;
148  case EMF_COLOR_MASK: material.ColorMask = Material.ColorMask; break;
149  case EMF_COLOR_MATERIAL: material.ColorMaterial = Material.ColorMaterial; break;
150  case EMF_USE_MIP_MAPS: material.UseMipMaps = Material.UseMipMaps; break;
152  case EMF_BLEND_FACTOR: material.BlendFactor = Material.BlendFactor; break;
153  case EMF_POLYGON_OFFSET:
158  break;
159  }
160  }
161  }
162  for(u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i )
163  {
164  if ( EnableLayers[i] )
165  {
166  material.TextureLayer[i] = Material.TextureLayer[i];
167  }
168  else if ( EnableTextures[i] )
169  {
171  }
172  }
173  }
174  }
175 
176  };
177 
178 } // end namespace video
179 } // end namespace irr
180 
181 #endif // __S_OVERRIDE_MATERIAL_H_INCLUDED__
182 
SMaterial Material
The Material values.
u8 ZBuffer
Is the ZBuffer enabled? Default: ECFN_LESSEQUAL.
Definition: SMaterial.h:450
Is backface culling enabled? Default: true.
u32 EnableFlags
Which values are overridden.
bool FrontfaceCulling
Is frontface culling enabled? Default: false.
Definition: SMaterial.h:542
GLuint num
Is fog enabled? Default: false.
E_MATERIAL_TYPE MaterialType
Type of the material. Specifies how everything is blended together.
Definition: SMaterial.h:382
E_MATERIAL_TYPE
Abstracted and easy to use fixed function/programmable pipeline material modes.
u8 ColorMaterial
Defines the interpretation of vertex color in the lighting equation.
Definition: SMaterial.h:470
bool PointCloud
Draw as point cloud or filled triangles? Default: false.
Definition: SMaterial.h:525
Is the ZBuffer enabled? Default: true.
bool UseMipMaps
Shall mipmaps be used if available.
Definition: SMaterial.h:553
bool TrilinearFilter
Is trilinear filtering enabled? Default: false.
u8 ColorMask
Defines the enabled color planes.
Definition: SMaterial.h:462
Flag for blend operation.
bool GouraudShading
Flat or Gouraud shading? Default: true.
Definition: SMaterial.h:528
bool EnableLayers[MATERIAL_MAX_TEXTURES]
Overwrite complete layers (settings of EnableLayerFlags and EnableTextures don't matter then for laye...
f32 PolygonOffsetDepthBias
A constant z-buffer offset for a polygon/line/point.
Definition: SMaterial.h:507
u8 TextureWrapU
Texture Clamp Mode.
void reset()
disable overrides and reset all flags
bool EnableLayerFlags[MATERIAL_MAX_TEXTURES]
For those flags in EnableFlags which affect layers, set which of the layers are affected.
f32 PolygonOffsetSlopeScale
Variable Z-Buffer offset based on the slope of the polygon.
Definition: SMaterial.h:516
bool EnableTextures[MATERIAL_MAX_TEXTURES]
Which textures are overridden.
Everything in the Irrlicht Engine can be found in this namespace.
Definition: CARSADPad.h:6
bool Enabled
Global enable flag, overwritten by the SceneManager in each pass.
ColorMaterial enum for vertex color interpretation.
E_BLEND_OPERATION BlendOperation
Store the blend operation of choice.
Definition: SMaterial.h:474
const u32 MATERIAL_MAX_TEXTURES
Maximum number of texture an SMaterial can have.
Definition: SMaterial.h:283
f32 BlendFactor
Store the blend factors.
Definition: SMaterial.h:486
ColorMask bits, for enabling the color planes.
SOverrideMaterial()
Default constructor.
Is bilinear filtering enabled? Default: true.
unsigned short u16
16 bit unsigned variable.
Definition: irrTypes.h:44
signed int s32
32 bit signed variable.
Definition: irrTypes.h:70
bool BackfaceCulling
Is backface culling enabled? Default: true.
Definition: SMaterial.h:539
u8 AntiAliasing
Sets the antialiasing mode.
Definition: SMaterial.h:455
GLfloat f
Normalizes normals. Default: false.
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:62
ITexture * Texture
Texture.
Flag for blend factor.
u8 PolygonOffsetFactor
DEPRECATED. Will be removed after Irrlicht 1.9. Please use PolygonOffsetDepthBias instead.
Definition: SMaterial.h:493
bool NormalizeNormals
Should normals be normalized?
Definition: SMaterial.h:549
Is anisotropic filtering? Default: false.
Flag for enabling/disabling mipmap usage.
bool FogEnable
Is fog enabled? Default: false.
Definition: SMaterial.h:545
u8 AnisotropicFilter
Is anisotropic filtering enabled? Default: 0, disabled.
bool BilinearFilter
Is bilinear filtering enabled? Default: true.
May be written to the zbuffer or is it readonly. Default: true.
Will this material be lighted? Default: true.
Self reallocating template array (like stl vector) with additional features.
Definition: irrArray.h:22
E_ZWRITE ZWriteEnable
Is the zbuffer writable or is it read-only. Default: EZW_AUTO.
Definition: SMaterial.h:536
u16 EnablePasses
Set in which render passes the material override is active.
bool Lighting
Will this material be lighted? Default: true.
Definition: SMaterial.h:531
SMaterialLayer TextureLayer[MATERIAL_MAX_TEXTURES]
Texture layer array.
Definition: SMaterial.h:379
E_POLYGON_OFFSET PolygonOffsetDirection
DEPRECATED. Will be removed after Irrlicht 1.9.
Definition: SMaterial.h:498
core::array< SMaterialTypeReplacement > MaterialTypes
To overwrite SMaterial::MaterialType.
bool Wireframe
Draw as wireframe or filled triangles? Default: false.
Definition: SMaterial.h:522
Flat or Gouraud shading? Default: true.
void apply(SMaterial &material)
Apply the enabled overrides.
Access to all layers texture wrap settings. Overwrites separate layer settings.
Is trilinear filtering enabled? Default: false.
Struct for holding parameters for a material renderer.
Definition: SMaterial.h:304
Draw as wireframe or filled triangles? Default: false.
u32 Replacement
MaterialType to used to override Original (either one of E_MATERIAL_TYPE or a shader material id)
Is frontface culling enabled? Default: false.
Draw as point cloud or filled triangles? Default: false.
Flag for polygon offset.