Skip to main content

Post-processing tools 2023 R2

GLTFTechnique.h

Last update: 17.04.2023
1 /*
2  * Copyright 2018-2021 ANSYS, Inc. Unauthorized use, distribution, or duplication is prohibited.
3  *
4  * Restricted Rights Legend
5  *
6  * Use, duplication, or disclosure of this
7  * software and its documentation by the
8  * Government is subject to restrictions as
9  * set forth in subdivision [(b)(3)(ii)] of
10  * the Rights in Technical Data and Computer
11  * Software clause at 52.227-7013.
12  */
13 #ifndef __INCLUDED_GLTF_GLTFTECHNIQUE__
14 #define __INCLUDED_GLTF_GLTFTECHNIQUE__
15 
16 #include "GLTFCommon.h"
17 #include "GLTFObject.h"
18 
19 namespace ANSYS { namespace Nexus { namespace GLTFWriter {
20  class GLTF;
21  class Program;
22  class Value;
23 
28  class Parameter : public Object
29  {
30  public:
33  {
34 // PT_BYTE = 5120,
35 // PT_USIGNED_BYTE = 5121,
36 // PT_SHORT = 5122,
37 // PT_UNSIGNED_SHORT = 5123,
38  PT_INT = 5124,
39 // PT_UNSIGNED_INT = 5125,
40  PT_FLOAT = 5126,
41  PT_FLOAT_VEC2 = 35664,
42  PT_FLOAT_VEC3 = 35665,
43  PT_FLOAT_VEC4 = 35666,
44  PT_INT_VEC2 = 35667,
45  PT_INT_VEC3 = 35668,
46  PT_INT_VEC4 = 35669,
47  PT_BOOL = 35670,
48 // PT_BOOL_VEC2 = 35671,
49 // PT_BOOL_VEC3 = 35672,
50 // PT_BOOL_VEC4 = 35673,
51 // PT_FLOAT_MAT2 = 35674,
52  PT_FLOAT_MAT3 = 35675,
53  PT_FLOAT_MAT4 = 35676,
54  PT_SAMPLER_2D = 35678
55  };
56 
57  protected:
58  virtual ~Parameter() {}
59 
60  public:
64  static GLTFWRITERSPEC Parameter *Create(GLTF *gltf,
65  const char *shaderName,
66  const char *externalName,
67  ParameterType type,
68  const Value *defaultValue = 0
69  );
72  static GLTFWRITERSPEC Parameter *CreateModelViewMatrix(GLTF *gltf,
73  const char *shaderName
74  );
78  static GLTFWRITERSPEC Parameter *CreateModelMatrix(GLTF *gltf,
79  const char *shaderName
80  );
84  static GLTFWRITERSPEC Parameter *CreateViewMatrix(GLTF *gltf,
85  const char *shaderName
86  );
90  static GLTFWRITERSPEC Parameter *CreateProjectionMatrix(GLTF *gltf,
91  const char *shaderName
92  );
96  static GLTFWRITERSPEC Parameter *CreateNormalMatrix(GLTF *gltf,
97  const char *shaderName
98  );
103  static GLTFWRITERSPEC Parameter *CreateViewport(GLTF *gltf,
104  const char *shaderName
105  );
109  static GLTFWRITERSPEC Parameter *CreateTexture(GLTF *gltf,
110  const char *shaderName,
111  unsigned int num
112  );
116  static GLTFWRITERSPEC Parameter *CreatePosition(GLTF *gltf,
117  const char *shaderName
118  );
122  static GLTFWRITERSPEC Parameter *CreateColor(GLTF *gltf,
123  const char *shaderName,
124  ParameterType type
125  );
129  static GLTFWRITERSPEC Parameter *CreatePointSize(GLTF *gltf,
130  const char *shaderName
131  );
135  static GLTFWRITERSPEC Parameter* CreateDisplacementScale(GLTF* gltf,
136  const char* shaderName
137  );
141  static GLTFWRITERSPEC Parameter *CreateNormal(GLTF *gltf,
142  const char *shaderName
143  );
147  static GLTFWRITERSPEC Parameter *CreateTexCoord(GLTF *gltf,
148  const char *shaderName,
149  unsigned int num
150  );
151  };
152 
155  class State : public Object
156  {
157  public:
160  {
162 // ST_BLENDCOLOR, // RED, //(0.0), 0.0 - 1.0
163  // GREEN, //(0.0), 0.0 - 1.0
164  // BLUE, //(0.0), 0.0 - 1.0
165  // ALPHA, //(0.0), 0.0 - 1.0
167 // ST_BLENDEQUATION, //(32774), FUNC_ADD(32774), FUNC_SUBTRACT(32778), FUNC_REVERSE_SUBTRACT(32779)
168 // ST_BLENDEQUATIONSEPARATE, // RGB, //(32774), FUNC_ADD(32774), FUNC_SUBTRACT(32778), FUNC_REVERSE_SUBTRACT(32779)
169  // ALPHA, //(32774), FUNC_ADD(32774), FUNC_SUBTRACT(32778), FUNC_REVERSE_SUBTRACT(32779)
170 // ST_BLENDFUNC, // SFACTOR, //(1), ZERO(0), ONE(1), SRC_COLOR(768), ONE_MINUS_SOURCE_COLOR(769), DST_COLOR(774), ONE_MINUS_DST_COLOR(775), SRC_ALPHA(770), ONE_MINUS_SRC_ALPHA(771), DST_ALPHA(772), ONE_MINUS_DST_ALPHA(773), CONSANT_COLOR(32769), ONE_MINUS_CONSTANT_COLOR(32770), CONSTANT_ALPHA(32771), ONE_MINUS_CONSTANT_ALPHA(32772), SRC_ALPHA_SATURATE(776)
171  // DFACTOR, //(0), ZERO(0), ONE(1), SRC_COLOR(768), ONE_MINUS_SOURCE_COLOR(769), DST_COLOR(774), ONE_MINUS_DST_COLOR(775), SRC_ALPHA(770), ONE_MINUS_SRC_ALPHA(771), DST_ALPHA(772), ONE_MINUS_DST_ALPHA(773), CONSANT_COLOR(32769), ONE_MINUS_CONSTANT_COLOR(32770), CONSTANT_ALPHA(32771), ONE_MINUS_CONSTANT_ALPHA(32772), SRC_ALPHA_SATURATE(776)
172 // ST_BLENDFUNCSEPARATE, // SRCRGB, //(1), ZERO(0), ONE(1), SRC_COLOR(768), ONE_MINUS_SOURCE_COLOR(769), DST_COLOR(774), ONE_MINUS_DST_COLOR(775), SRC_ALPHA(770), ONE_MINUS_SRC_ALPHA(771), DST_ALPHA(772), ONE_MINUS_DST_ALPHA(773), CONSANT_COLOR(32769), ONE_MINUS_CONSTANT_COLOR(32770), CONSTANT_ALPHA(32771), ONE_MINUS_CONSTANT_ALPHA(32772), SRC_ALPHA_SATURATE(776)
173  // SRCALPHA, //(1), ZERO(0), ONE(1), SRC_COLOR(768), ONE_MINUS_SOURCE_COLOR(769), DST_COLOR(774), ONE_MINUS_DST_COLOR(775), SRC_ALPHA(770), ONE_MINUS_SRC_ALPHA(771), DST_ALPHA(772), ONE_MINUS_DST_ALPHA(773), CONSANT_COLOR(32769), ONE_MINUS_CONSTANT_COLOR(32770), CONSTANT_ALPHA(32771), ONE_MINUS_CONSTANT_ALPHA(32772), SRC_ALPHA_SATURATE(776)
174  // DSTRGB, //(0), ZERO(0), ONE(1), SRC_COLOR(768), ONE_MINUS_SOURCE_COLOR(769), DST_COLOR(774), ONE_MINUS_DST_COLOR(775), SRC_ALPHA(770), ONE_MINUS_SRC_ALPHA(771), DST_ALPHA(772), ONE_MINUS_DST_ALPHA(773), CONSANT_COLOR(32769), ONE_MINUS_CONSTANT_COLOR(32770), CONSTANT_ALPHA(32771), ONE_MINUS_CONSTANT_ALPHA(32772), SRC_ALPHA_SATURATE(776)
175  // DSTALPHA, //(0), ZERO(0), ONE(1), SRC_COLOR(768), ONE_MINUS_SOURCE_COLOR(769), DST_COLOR(774), ONE_MINUS_DST_COLOR(775), SRC_ALPHA(770), ONE_MINUS_SRC_ALPHA(771), DST_ALPHA(772), ONE_MINUS_DST_ALPHA(773), CONSANT_COLOR(32769), ONE_MINUS_CONSTANT_COLOR(32770), CONSTANT_ALPHA(32771), ONE_MINUS_CONSTANT_ALPHA(32772), SRC_ALPHA_SATURATE(776)
176 // ST_COLORMASK, // RED, //(1), FALSE(0), TRUE(1)
177  // GREEN, //(1), FALSE(0), TRUE(1)
178  // BLUE, //(1), FALSE(0), TRUE(1)
179  // ALPHA, //(1), FALSE(0), TRUE(1)
184 // ST_DEPTHRANGE, // ZNEAR, //(0.0), 0.0 - 1.0
185  // ZFAR, //(1.0), 0.0 - 1.0
187 // ST_DITHERENABLE, //(1), FALSE(0), TRUE(1)
190 // ST_POINTSIZE,
193 // ST_SAMPLEALPHATOCOVERAGEENABLE, //(0), FALSE(0), TRUE(0)
194 // ST_SAMPLECOVERAGE, // VALUE, //(1.0), 0.0 - 1.0
195  // INVERT, //(0) FALSE(0), TRUE(1)
196 // ST_SAMPLECOVERAGEENABLE, //(0), FALSE(0), TRUE(1)
197 // ST_SCISSOR, // X, //(0), > 0
198  // Y, //(0), > 0
199  // WIDTH, //(0), > 0
200  // HEIGHT, //(0), > 0
201 // ST_SCISSORTESTENABLE, //(0), FALSE(0), TRUE(1)
202 // ST_STENCILFUNC, // FUNC, //(519), NEVER(512), LESS(513), LEQUAL(515), EQUAL(514), GREATER(516), NOTEQUAL(517), GEQUAL(518), ALWAYS(519)
203  // REF, //(0), 0 - 2^n-1 where n is number of bit planes in stencil buffer
204  // MASK, //(0xFFFFFFFF), 0 - 0xFFFFFFFF
205 // ST_STENCILFUNCSEPARATE, // FACE, //(?), FRONT(1028), BACK(1029), FRONT_AND_BACK(1032)
206  // FUNC, //(519), NEVER(512), LESS(513), LEQUAL(515), EQUAL(514), GREATER(516), NOTEQUAL(517), GEQUAL(518), ALWAYS(519)
207  // REF, //(0), 0 - 2^n-1 where n is number of bit planes in stencil buffer
208  // MASK, //(0xFFFFFFFF), 0 - 0xFFFFFFFF
209 // ST_STENCILMASK, //(0xFFFFFFFF), 0 - 0xFFFFFFFF
210 // ST_STENCILMASKSEPARATE, // FACE, //(?), FRONT(1028), BACK(1029), FRONT_AND_BACK(1032)
211  // MASK, //(0xFFFFFFFF), 0 - 0xFFFFFFFF
212 // ST_STENCILOP, // SFAIL, //(7680), KEEP(7680), ZERO(0), REPLACE(7681), INCR(7682), DECR(7683), INVERT(5386), INCR_WRAP(34055), DECR_WRAP(34056)
213  // DPFAIL, //(7680), KEEP(7680), ZERO(0), REPLACE(7681), INCR(7682), DECR(7683), INVERT(5386), INCR_WRAP(34055), DECR_WRAP(34056)
214  // DPPASS, //(7680), KEEP(7680), ZERO(0), REPLACE(7681), INCR(7682), DECR(7683), INVERT(5386), INCR_WRAP(34055), DECR_WRAP(34056)
215 // ST_STENCILOPSEPARATE, // FACE, //(?), FRONT(1028), BACK(1029), FRONT_AND_BACK(1032)
216  // SFAIL, //(7680), KEEP(7680), ZERO(0), REPLACE(7681), INCR(7682), DECR(7683), INVERT(5386), INCR_WRAP(34055), DECR_WRAP(34056)
217  // DPFAIL, //(7680), KEEP(7680), ZERO(0), REPLACE(7681), INCR(7682), DECR(7683), INVERT(5386), INCR_WRAP(34055), DECR_WRAP(34056)
218  // DPPASS, //(7680), KEEP(7680), ZERO(0), REPLACE(7681), INCR(7682), DECR(7683), INVERT(5386), INCR_WRAP(34055), DECR_WRAP(34056)
219 // ST_STENCILTESTENABLE //(0), FALSE(0), TRUE(1)
220  };
221 
222  protected:
223  virtual ~State() {}
224 
225  public:
228  static GLTFWRITERSPEC State *Create(GLTF *gltf,
229  StateType type,
230  double v1,
231  double v2 = 0,
232  double v3 = 0,
233  double v4 = 0
234  );
235  };
236 
239  class Technique : public Object
240  {
241  protected:
242  virtual ~Technique() {}
243 
244  public:
247  static GLTFWRITERSPEC Technique *Create(GLTF *gltf,
248  Program *program = 0,
249  bool is2D = false
250  );
251 
254  GLTFWRITERSPEC virtual Technique *Mirror() = 0;
257  GLTFWRITERSPEC virtual bool AppendParameter(Parameter *parameter
258  ) = 0;
261  GLTFWRITERSPEC virtual bool AppendState(State *state
262  ) = 0;
263  };
264 
265 } } }
266 
267 #endif
This is the main class of the GLTFWriter.
Definition: GLTFGLTF.h:32
Parameters describe how and from where program attributes and uniforms are derived.
Definition: GLTFTechnique.h:29
static Parameter * CreatePosition(GLTF *gltf, const char *shaderName)
static Parameter * CreateNormal(GLTF *gltf, const char *shaderName)
static Parameter * Create(GLTF *gltf, const char *shaderName, const char *externalName, ParameterType type, const Value *defaultValue=0)
static Parameter * CreateProjectionMatrix(GLTF *gltf, const char *shaderName)
static Parameter * CreateTexCoord(GLTF *gltf, const char *shaderName, unsigned int num)
static Parameter * CreateNormalMatrix(GLTF *gltf, const char *shaderName)
static Parameter * CreateColor(GLTF *gltf, const char *shaderName, ParameterType type)
static Parameter * CreateViewport(GLTF *gltf, const char *shaderName)
static Parameter * CreatePointSize(GLTF *gltf, const char *shaderName)
@ PT_FLOAT_MAT4
4x4 (16) PT_FLOAT's
Definition: GLTFTechnique.h:53
static Parameter * CreateModelViewMatrix(GLTF *gltf, const char *shaderName)
static Parameter * CreateTexture(GLTF *gltf, const char *shaderName, unsigned int num)
static Parameter * CreateViewMatrix(GLTF *gltf, const char *shaderName)
static Parameter * CreateModelMatrix(GLTF *gltf, const char *shaderName)
static Parameter * CreateDisplacementScale(GLTF *gltf, const char *shaderName)
Programs are the GLSL executable code for rendering the primitives.
Definition: GLTFProgram.h:28
States are GL state settings.
static State * Create(GLTF *gltf, StateType type, double v1, double v2=0, double v3=0, double v4=0)
@ ST_DEPTHFUNC
Describes type of depth buffer comparison. Possible values are:
@ ST_LINEWIDTH
Defines the width of drawn lines. The value is > 0.0 (Linewidth other than 1.0 is not supported by mo...
@ ST_BLENDENABLE
Enables blending of fragment colors. Possible values are:
@ ST_CULLFACE
Describes which faces to cull. Possible values are:
@ ST_DEPTHMASK
Enables writing into the depth buffer. Possible values are:
@ ST_DEPTHTESTENABLE
Enables testing of depth buffer. Possible values are:
@ ST_FRONTFACE
Describes how to detect front face from vertex ordering. Possible values are:
@ ST_POLYGONOFFSET
Defines the Factor and units for the draw offset of polygons. The first argument is FACTOR which is >...
@ ST_CULLFACEENABLE
Enables culling of faces. Possible values are:
@ ST_POLYGONOFFSETFILLENABLE
Enables polygon offset. Possible values are:
Techniques performs the rendering of primitives.
virtual bool AppendState(State *state)=0
static Technique * Create(GLTF *gltf, Program *program=0, bool is2D=false)
virtual bool AppendParameter(Parameter *parameter)=0
virtual Technique * Mirror()=0
Values are objects for storing single and multiple numbers and strings.
Definition: GLTFValue.h:26
GLTFWriter API Documentation.
Definition: GLTFAnimation.h:19