Nirtcpp 2.1.0
Nirtcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
SOverrideMaterial.hpp
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 nirtcpp/nirtcpp.hpp
4
5#ifndef S_OVERRIDE_MATERIAL_HPP_INCLUDED
6#define S_OVERRIDE_MATERIAL_HPP_INCLUDED
7
8#include <nirtcpp/core/engine/SMaterial.hpp>
9
10namespace nirt
11{
12namespace video
13{
14
16 {
17 public:
20
22
24
27
30
33
35
37
39
44 bool Enabled;
45
46 public:
48 {
49 public:
50 SMaterialTypeReplacement(s32 original, u32 replacement) : Original(original), Replacement(replacement) {}
51 SMaterialTypeReplacement(u32 replacement) : Original(-1), Replacement(replacement) {}
52
53 public:
57
60 };
61
62 public:
65
66 public:
69 {
70 }
71
72 public:
74 void reset()
75 {
76 EnableFlags = 0;
77 EnablePasses = 0;
78 Enabled = false;
79 for (u32 i = 0; i < MATERIAL_MAX_TEXTURES; ++i)
80 {
81 EnableLayerFlags[i] = true; // doesn't do anything unless EnableFlags is set, just saying by default all texture layers are affected by flags
82 EnableTextures[i] = false;
83 EnableLayers[i] = false;
84 }
85 MaterialTypes.clear();
86 }
87
89 void apply(SMaterial& material)
90 {
91 if (Enabled)
92 {
93 for (u32 i = 0; i < MaterialTypes.size(); ++i)
94 {
96 if (mtr.Original < 0 || (s32)mtr.Original == material.MaterialType)
98 }
99 for (u32 f=0; f<32; ++f)
100 {
101 const u32 num=(1<<f);
102 if (EnableFlags & num)
103 {
104 switch (num)
105 {
106 case EMF_WIREFRAME: material.Wireframe = Material.Wireframe; break;
107 case EMF_POINTCLOUD: material.PointCloud = Material.PointCloud; break;
109 case EMF_LIGHTING: material.Lighting = Material.Lighting; break;
110 case EMF_ZBUFFER: material.ZBuffer = Material.ZBuffer; break;
111 case EMF_ZWRITE_ENABLE: material.ZWriteEnable = Material.ZWriteEnable; break;
115 for ( u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
116 {
117 if ( EnableLayerFlags[i] )
118 {
120 }
121 }
122 break;
124 for ( u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
125 {
126 if ( EnableLayerFlags[i] )
127 {
129 }
130 }
131 break;
133 for ( u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
134 {
135 if ( EnableLayerFlags[i] )
136 {
138 }
139 }
140 break;
141 case EMF_FOG_ENABLE: material.FogEnable = Material.FogEnable; break;
143 case EMF_TEXTURE_WRAP:
144 for ( u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
145 {
146 if ( EnableLayerFlags[i] )
147 {
149 material.TextureLayer[i].TextureWrapV = Material.TextureLayer[i].TextureWrapV;
150 material.TextureLayer[i].TextureWrapW = Material.TextureLayer[i].TextureWrapW;
151 }
152 }
153 break;
154 case EMF_ANTI_ALIASING: material.AntiAliasing = Material.AntiAliasing; break;
155 case EMF_COLOR_MASK: material.ColorMask = Material.ColorMask; break;
157 case EMF_USE_MIP_MAPS: material.UseMipMaps = Material.UseMipMaps; break;
159 case EMF_BLEND_FACTOR: material.BlendFactor = Material.BlendFactor; break;
165 break;
166 }
167 }
168 }
169 for(u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i )
170 {
171 if ( EnableLayers[i] )
172 {
173 material.TextureLayer[i] = Material.TextureLayer[i];
174 }
175 else if ( EnableTextures[i] )
176 {
178 }
179 }
180 }
181 }
182 };
183
184} // end namespace video
185} // end namespace nirt
186
187#endif // S_OVERRIDE_MATERIAL_HPP_INCLUDED
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
bool TrilinearFilter
Is trilinear filtering enabled? Default: false.
Definition SMaterialLayer.hpp:199
ITexture * Texture
Texture.
Definition SMaterialLayer.hpp:185
u8 TextureWrapU
Texture Clamp Mode.
Definition SMaterialLayer.hpp:189
u8 AnisotropicFilter
Is anisotropic filtering enabled? Default: 0, disabled.
Definition SMaterialLayer.hpp:208
bool BilinearFilter
Is bilinear filtering enabled? Default: true.
Definition SMaterialLayer.hpp:194
Class for holding parameters for a material renderer.
Definition SMaterial.hpp:304
bool UseMipMaps
Shall mipmaps be used if available.
Definition SMaterial.hpp:495
f32 PolygonOffsetDepthBias
A constant z-buffer offset for a polygon/line/point.
Definition SMaterial.hpp:437
bool PointCloud
Draw as point cloud or filled triangles? Default: false.
Definition SMaterial.hpp:467
bool Wireframe
Draw as wireframe or filled triangles? Default: false.
Definition SMaterial.hpp:464
bool NormalizeNormals
Should normals be normalized?
Definition SMaterial.hpp:491
E_BLEND_OPERATION BlendOperation
Store the blend operation of choice.
Definition SMaterial.hpp:416
u8 AntiAliasing
Sets the antialiasing mode.
Definition SMaterial.hpp:397
bool GouraudShading
Flat or Gouraud shading? Default: true.
Definition SMaterial.hpp:470
bool BackfaceCulling
Is backface culling enabled? Default: true.
Definition SMaterial.hpp:481
u8 ColorMaterial
Defines the interpretation of vertex color in the lighting equation.
Definition SMaterial.hpp:412
E_ZWRITE ZWriteEnable
Is the zbuffer writable or is it read-only. Default: EZW_AUTO.
Definition SMaterial.hpp:478
SMaterialLayer TextureLayer[MATERIAL_MAX_TEXTURES]
Texture layer array.
Definition SMaterial.hpp:321
f32 BlendFactor
Store the blend factors.
Definition SMaterial.hpp:428
E_POLYGON_OFFSET PolygonOffsetDirection
DEPRECATED. Will be removed after Nirtcpp 1.9.
Definition SMaterial.hpp:458
u8 ZBuffer
Is the ZBuffer enabled? Default: ECFN_LESSEQUAL.
Definition SMaterial.hpp:392
bool FrontfaceCulling
Is frontface culling enabled? Default: false.
Definition SMaterial.hpp:484
bool Lighting
Will this material be lighted? Default: true.
Definition SMaterial.hpp:473
E_MATERIAL_TYPE MaterialType
Type of the material. Specifies how everything is blended together.
Definition SMaterial.hpp:324
u8 PolygonOffsetFactor
DEPRECATED. Will be removed after Nirtcpp 1.9. Please use PolygonOffsetDepthBias instead.
Definition SMaterial.hpp:453
f32 PolygonOffsetSlopeScale
Variable Z-Buffer offset based on the slope of the polygon.
Definition SMaterial.hpp:446
u8 ColorMask
Defines the enabled color planes.
Definition SMaterial.hpp:404
bool FogEnable
Is fog enabled? Default: false.
Definition SMaterial.hpp:487
s32 Original
Definition SOverrideMaterial.hpp:56
u32 Replacement
MaterialType to used to override Original (either one of E_MATERIAL_TYPE or a shader material id)
Definition SOverrideMaterial.hpp:59
Definition SOverrideMaterial.hpp:16
SOverrideMaterial()
Default constructor.
Definition SOverrideMaterial.hpp:68
bool EnableLayers[MATERIAL_MAX_TEXTURES]
Overwrite complete layers (settings of EnableLayerFlags and EnableTextures don't matter then for laye...
Definition SOverrideMaterial.hpp:32
SMaterial Material
The Material values.
Definition SOverrideMaterial.hpp:19
bool EnableLayerFlags[MATERIAL_MAX_TEXTURES]
For those flags in EnableFlags which affect layers, set which of the layers are affected.
Definition SOverrideMaterial.hpp:26
u16 EnablePasses
Set in which render passes the material override is active.
Definition SOverrideMaterial.hpp:36
bool Enabled
Global enable flag, overwritten by the SceneManager in each pass.
Definition SOverrideMaterial.hpp:44
u32 EnableFlags
Which values are overridden.
Definition SOverrideMaterial.hpp:23
core::array< SMaterialTypeReplacement > MaterialTypes
To overwrite SMaterial::MaterialType.
Definition SOverrideMaterial.hpp:64
bool EnableTextures[MATERIAL_MAX_TEXTURES]
Which textures are overridden.
Definition SOverrideMaterial.hpp:29
void apply(SMaterial &material)
Apply the enabled overrides.
Definition SOverrideMaterial.hpp:89
void reset()
disable overrides and reset all flags
Definition SOverrideMaterial.hpp:74
@ EMF_GOURAUD_SHADING
Flat or Gouraud shading? Default: true.
Definition EMaterialFlags.hpp:23
@ EMF_FOG_ENABLE
Is fog enabled? Default: false.
Definition EMaterialFlags.hpp:58
@ EMF_TEXTURE_WRAP
Access to all layers texture wrap settings. Overwrites separate layer settings.
Definition EMaterialFlags.hpp:72
@ EMF_POINTCLOUD
Draw as point cloud or filled triangles? Default: false.
Definition EMaterialFlags.hpp:20
@ EMF_ZWRITE_ENABLE
May be written to the zbuffer or is it readonly. Default: true.
Definition EMaterialFlags.hpp:33
@ EMF_POLYGON_OFFSET
Flag for polygon offset.
Definition EMaterialFlags.hpp:90
@ EMF_COLOR_MASK
ColorMask bits, for enabling the color planes.
Definition EMaterialFlags.hpp:78
@ EMF_USE_MIP_MAPS
Flag for enabling/disabling mipmap usage.
Definition EMaterialFlags.hpp:84
@ EMF_TRILINEAR_FILTER
Is trilinear filtering enabled? Default: false.
Definition EMaterialFlags.hpp:48
@ EMF_BLEND_FACTOR
Flag for blend factor.
Definition EMaterialFlags.hpp:93
@ EMF_BACK_FACE_CULLING
Is backface culling enabled? Default: true.
Definition EMaterialFlags.hpp:36
@ EMF_BILINEAR_FILTER
Is bilinear filtering enabled? Default: true.
Definition EMaterialFlags.hpp:43
@ EMF_BLEND_OPERATION
Flag for blend operation.
Definition EMaterialFlags.hpp:87
@ EMF_WIREFRAME
Draw as wireframe or filled triangles? Default: false.
Definition EMaterialFlags.hpp:17
@ EMF_NORMALIZE_NORMALS
Normalizes normals. Default: false.
Definition EMaterialFlags.hpp:66
@ EMF_LIGHTING
Will this material be lighted? Default: true.
Definition EMaterialFlags.hpp:26
@ EMF_ZBUFFER
Is the ZBuffer enabled? Default: true.
Definition EMaterialFlags.hpp:29
@ EMF_FRONT_FACE_CULLING
Is frontface culling enabled? Default: false.
Definition EMaterialFlags.hpp:40
@ EMF_COLOR_MATERIAL
ColorMaterial enum for vertex color interpretation.
Definition EMaterialFlags.hpp:81
@ EMF_ANISOTROPIC_FILTER
Is anisotropic filtering? Default: false.
Definition EMaterialFlags.hpp:55
@ EMF_ANTI_ALIASING
AntiAliasing mode.
Definition EMaterialFlags.hpp:75
const u32 MATERIAL_MAX_TEXTURES
Maximum number of texture an SMaterial can have.
Definition SMaterial.hpp:283
E_MATERIAL_TYPE
Abstracted and easy to use fixed function/programmable pipeline material modes.
Definition EMaterialTypes.hpp:15
As of Nirtcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11
unsigned short u16
16 bit unsigned variable.
Definition irrTypes.hpp:46
signed int s32
32 bit signed variable.
Definition irrTypes.hpp:72
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.hpp:64

Nirtcpp    @cppfx.xyz

Esvcpp    esv::print