CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
TrVisMaterialDef.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23// GLES2 device material definition
24
25#ifndef ODTRVISMATERIALDEF
26#define ODTRVISMATERIALDEF
27
28#include "TD_PackPush.h"
29
30#include "TrVisMaterialColor.h"
31#include "TrVisTextureDef.h"
32
37{
38 // Main material channel color.
40 // Factor to blend between material channel color and vertex color [0 - full material color, 1 - full vertex color]
42 // Material transparency [0 - completely transparent, 1 - opaque]
43 float m_opacityLevel; // [Have sense for diffuse channel only]
44 // Channel coefficient [have different meaning for different channels]. Must be non-zero to make channel active.
45 // For specular channel: specular color (shininnes) component.
46 // For bump and normal map channels: bump (normal) map scale.
47 // For reflection and refracion channel: reflectance (refraction) coefficient.
48 // For other channels it is can provide color intensity or blending opacity multiplier and typically set as 1.
50 // Factor to blend between texture and channel color [0 - full channel color, 1 - full texture color]
52 // Texture ID
54 // Texture brightness
56 // Texture flags
58 // Texture tiling (wrapping) method
66
68 {
69 kInvertTexture = (1 << 0),
71 };
76
77 // Setup channel defaults
78 void setDefault(float channelColor = 0.0f, float blendFactor = 0.0f, float channelValue = 0.0f)
79 {
80 m_channelColor[0] = m_channelColor[1] = m_channelColor[2] = channelColor;
81 m_blendFactor = blendFactor;
82 m_opacityLevel = 1.0f;
83 m_channelValue = channelValue;
84 m_textureBlend = 0.0f;
86 m_texBrightness = 1.0f;
87 m_texFlags = 0;
89 }
90 // Check that channel enabled
91 bool isEnabled() const { return !OdTrVisFPZero(m_channelValue); }
92};
93
98{
99 // Realistic material channel component
101 // Material channel component for non-realistic modes
103
104 // Setup channel defaults
105 void setDefault(float realisticColor = 0.0f, float shadingColor = 0.0f, float blendFactor = 0.0f, float channelValue = 0.0f)
106 {
107 m_realisticComponent.setDefault(realisticColor, blendFactor, channelValue);
108 m_shadingComponent.setDefault(shadingColor, blendFactor, channelValue);
109 }
110 // Copy realistic material component to shading material component
112 // Copy shading material component to realistic material component
114 // Check that channel enabled
115 bool isEnabled() const { return m_realisticComponent.isEnabled(); }
116 // Check that shading component enabled
117 bool hasShadingComponent() const { return m_shadingComponent.isEnabled(); }
118};
119
124{
125 // Ambient material channel
127 // Diffuse material channel
129 // Specular material channel
131 // Emission material channel
133 // Opacity material channel
135 // Bump material channel
137 // Reflection material channel
139 // Refraction material channel
141 // Normal map material channel
143 // Tint material channel
145 // Roughness material channel
147 // Cutouts material channel
149 // Environment material channel
151 // Additional flags
153
155 {
156 kTwoSided = (1 << 0)
157 };
158 bool twoSidedMaterial() const { return GETBIT(m_mtlFlags, kTwoSided); }
159 void setTwoSidedMaterial(bool bTwoSided) { SETBIT(m_mtlFlags, kTwoSided, bTwoSided); }
160
161 void resetFlags(OdUInt32 nFlags = 0) { m_mtlFlags = nFlags; }
162
163 // Setup material defaults
165 {
166 m_ambientChannel.setDefault(0.0f, 0.0f, 0.0f, 1.0f);
167 m_diffuseChannel.setDefault(0.0f, 0.0f, 0.0f, 1.0f);
168 m_specularChannel.setDefault(1.0f, 0.0f, 1.0f, 50.0f);
169 m_emissionChannel.setDefault();
170 m_opacityChannel.setDefault();
171 m_bumpMapChannel.setDefault();
172 m_reflectChannel.setDefault();
173 m_refractChannel.setDefault(0.0f, 0.0f, 0.0f, 1.0f);
174 m_normMapChannel.setDefault();
175 m_tintChannel.setDefault();
176 m_roughnessChannel.setDefault();
177 m_cutoutsChannel.setDefault();
178 m_environmentChannel.setDefault();
179 resetFlags();
180 }
181 // Copy realistic material component to shading material component
183 {
184 m_ambientChannel.shadingFromRealistic();
185 m_diffuseChannel.shadingFromRealistic();
186 m_specularChannel.shadingFromRealistic();
187 m_emissionChannel.shadingFromRealistic();
188 m_opacityChannel.shadingFromRealistic();
189 m_bumpMapChannel.shadingFromRealistic();
190 m_reflectChannel.shadingFromRealistic();
191 m_refractChannel.shadingFromRealistic();
192 m_normMapChannel.shadingFromRealistic();
193 m_tintChannel.shadingFromRealistic();
194 m_roughnessChannel.shadingFromRealistic();
195 m_cutoutsChannel.shadingFromRealistic();
196 m_environmentChannel.shadingFromRealistic();
197 }
198 // Copy shading material component to realistic material component
200 {
201 m_ambientChannel.realisticFromShading();
202 m_diffuseChannel.realisticFromShading();
203 m_specularChannel.realisticFromShading();
204 m_emissionChannel.realisticFromShading();
205 m_opacityChannel.realisticFromShading();
206 m_bumpMapChannel.realisticFromShading();
207 m_reflectChannel.realisticFromShading();
208 m_refractChannel.realisticFromShading();
209 m_normMapChannel.realisticFromShading();
210 m_tintChannel.realisticFromShading();
211 m_roughnessChannel.realisticFromShading();
212 m_cutoutsChannel.realisticFromShading();
213 m_environmentChannel.realisticFromShading();
214 }
215};
216
221{
222 // Reflection plane flags
224 // Blur amount
226
228 {
230 };
231
240
243
244 void setSoftness(OdUInt16 blurAmount) { m_softness = blurAmount; }
245 OdUInt16 softness() const { return m_softness; }
246
247 OdTrVisSectionPlane &base() { return *this; }
248 const OdTrVisSectionPlane &base() const { return *this; }
249
250 bool operator ==(const OdTrVisRefPlaneDef &rp) const
251 { return OdTrVisSectionPlane::operator ==(rp) && (softness() == rp.softness()) && (m_rpFlags == rp.m_rpFlags); }
252 bool operator !=(const OdTrVisRefPlaneDef &rp) const
253 { return OdTrVisSectionPlane::operator !=(rp) || (softness() != rp.softness()) || (m_rpFlags != rp.m_rpFlags); }
254};
255
256#include "TD_PackPop.h"
257
258#endif // ODTRVISMATERIALDEF
unsigned int OdUInt32
unsigned short OdUInt16
#define SETBIT(flags, bit, value)
Definition OdaDefs.h:516
#define GETBIT(flags, bit)
Definition OdaDefs.h:517
const OdTrVisId kTrVisNullId
Definition TrVisDefs.h:141
OD_FORCEINLINE bool OdTrVisFPZero(float a, float tol=1.e-8f)
Definition TrVisDefs.h:280
OdTrVisId OdTrVisTextureId
Definition TrVisDefs.h:108
enum OdTrVisMaterialChannelComponent::WrapType m_vWrap
OdTrVisMaterialColor m_channelColor
void setTextureBrightnessInverted(bool bSet)
enum OdTrVisMaterialChannelComponent::WrapType m_uWrap
void setDefault(float channelColor=0.0f, float blendFactor=0.0f, float channelValue=0.0f)
void setDefault(float realisticColor=0.0f, float shadingColor=0.0f, float blendFactor=0.0f, float channelValue=0.0f)
OdTrVisMaterialChannelComponent m_realisticComponent
OdTrVisMaterialChannelComponent m_shadingComponent
OdTrVisMaterialChannelDef m_normMapChannel
OdTrVisMaterialChannelDef m_bumpMapChannel
OdTrVisMaterialChannelDef m_reflectChannel
OdTrVisMaterialChannelDef m_cutoutsChannel
OdTrVisMaterialChannelDef m_environmentChannel
OdTrVisMaterialChannelDef m_refractChannel
void resetFlags(OdUInt32 nFlags=0)
void setTwoSidedMaterial(bool bTwoSided)
OdTrVisMaterialChannelDef m_roughnessChannel
bool twoSidedMaterial() const
OdTrVisMaterialChannelDef m_emissionChannel
OdTrVisMaterialChannelDef m_ambientChannel
OdTrVisMaterialChannelDef m_diffuseChannel
OdTrVisMaterialChannelDef m_opacityChannel
OdTrVisMaterialChannelDef m_specularChannel
OdTrVisMaterialChannelDef m_tintChannel
void setSoftness(OdUInt16 blurAmount)
OdTrVisSectionPlane & base()
bool applyBackground() const
void enableBackgroundApplying(bool bEnable)
bool operator==(const OdTrVisRefPlaneDef &rp) const
bool operator!=(const OdTrVisRefPlaneDef &rp) const
const OdTrVisSectionPlane & base() const
OdUInt16 softness() const
OdTrVisRefPlaneDef(const OdGePoint3d &position, const OdGeVector3d &normal, OdUInt16 softness=0, OdUInt16 flags=0)
OdGeVector3d normal() const
Definition TrVisDefs.h:250
bool operator==(const OdTrVisSectionPlane &sp) const
Definition TrVisDefs.h:287
OdGePoint3d position() const
Definition TrVisDefs.h:249
bool operator!=(const OdTrVisSectionPlane &sp) const
Definition TrVisDefs.h:292
void set(const OdGePoint3d &position, const OdGeVector3d &normal)
Definition TrVisDefs.h:244