Skip to main content

Post-processing tools 2024 R1

ANSYS::Nexus::GLTFWriter::Attribute Class Reference

Last update: 16.07.2025

#include <GLTFWriter.h>

Inheritance diagram for ANSYS::Nexus::GLTFWriter::Attribute:

Public Types

enum  AttributeType {
  AT_INT = 5124 , AT_FLOAT = 5126 , AT_FLOAT_VEC2 = 35664 , AT_FLOAT_VEC3 = 35665 ,
  AT_FLOAT_VEC4 = 35666 , AT_FLOAT_MAT4 = 35676
}
 

Public Member Functions

virtual bool SetMinMax (AttributeType type, const int *mn, const int *mx)=0
 
virtual bool SetMinMax (AttributeType type, const float *mn, const float *mx)=0
 
virtual void SetLogarithmic (bool log)=0
 

Static Public Member Functions

static Attribute * Create (GLTF *gltf, const char *name, AttributeType type, unsigned int count, const int *data, Buffer *buffer=0)
 
static Attribute * Create (GLTF *gltf, const char *name, AttributeType type, unsigned int count, const float *data, Buffer *buffer=0)
 
static Attribute * CreatePosition (GLTF *gltf, unsigned int count, const float *data, Buffer *buffer=0)
 
static Attribute * CreateColor (GLTF *gltf, AttributeType type, unsigned int count, const float *data, Buffer *buffer=0)
 
static Attribute * CreatePointSize (GLTF *gltf, unsigned int count, const float *data, Buffer *buffer=0)
 
static Attribute * CreateDisplacementScale (GLTF *gltf, unsigned int count, const float *data, Buffer *buffer=0)
 
static Attribute * CreateNormal (GLTF *gltf, unsigned int count, const float *data, Buffer *buffer=0)
 
static Attribute * CreateTextureCoord (GLTF *gltf, unsigned int num, unsigned int count, const float *data, Buffer *buffer=0)
 

Detailed Description

There must be an attributes that defines the vertices to use for the element indices. Other attributes defining colors, normals, texture coordinates, etc., may be defined.

Attributes are part of the primitive and are eventually passed to the vertex shader. All attributes of the vertex shader must have a corresponding attribute defined in the primitive.

Examples
Test002.cpp, Test005.cpp, Test006.cpp, Test008.cpp, Test009.cpp, Test010.cpp, Test013.cpp, and Test014.cpp.

Definition at line 31 of file GLTFAttribute.h.

Member Enumeration Documentation

◆ AttributeType

Type of attribute.

Enumerator
AT_INT 

4 byte integer

AT_FLOAT 

4 byte float

AT_FLOAT_VEC2 

2 AT_FLOATs

AT_FLOAT_VEC3 

3 AT_FLOATs

AT_FLOAT_VEC4 

4 AT_FLOATs

AT_FLOAT_MAT4 

4x4 (16) AT_FLOATs

Definition at line 35 of file GLTFAttribute.h.

Constructor & Destructor Documentation

◆ ~Attribute()

virtual ANSYS::Nexus::GLTFWriter::Attribute::~Attribute ( )
inlineprotectedvirtual

Definition at line 51 of file GLTFAttribute.h.

Member Function Documentation

◆ Create() [1/2]

static Attribute * ANSYS::Nexus::GLTFWriter::Attribute::Create ( GLTF *  gltf,
const char *  name,
AttributeType  type,
unsigned int  count,
const float *  data,
Buffer *  buffer = 0 
)
static

Creates an attribute of the given type and name. There are several names that are reserved for special use:

  • POSITION - vertices of element index, this attribute must be defined
  • TEXCOORD0 - variable value at element index
Returns
Attribute object. Do not delete this pointer.
Parameters
[in]gltfGLTF object.
[in]nameName of attribute.
[in]typeAttribute::AttributeType defining type of attribute.
[in]countNumber of attributes. Number is relative to sizeof type.
[in]dataData for attribute. data type is base type of attribute.
[in]bufferOptional, Buffer into which to write attribute data. Data is appended to buffer.

◆ Create() [2/2]

static Attribute * ANSYS::Nexus::GLTFWriter::Attribute::Create ( GLTF *  gltf,
const char *  name,
AttributeType  type,
unsigned int  count,
const int *  data,
Buffer *  buffer = 0 
)
static

Creates an attribute of the given type and name. There are several names that are reserved for special use:

  • POSITION - vertices of element index, this attribute must be defined
  • TEXCOORD0 - variable value at element index
Returns
Attribute object. Do not delete this pointer.
Parameters
[in]gltfGLTF object.
[in]nameName of attribute.
[in]typeAttribute::AttributeType defining type of attribute.
[in]countNumber of attributes. Number is relative to sizeof type.
[in]dataData for attribute. data type is base type of attribute.
[in]bufferOptional, Buffer into which to write attribute data. Data is appended to buffer.

◆ CreateColor()

static Attribute * ANSYS::Nexus::GLTFWriter::Attribute::CreateColor ( GLTF *  gltf,
AttributeType  type,
unsigned int  count,
const float *  data,
Buffer *  buffer = 0 
)
static

Creates an attribute of name "COLOR". The "COLOR" attribute is usually optional.

Returns
Attribute object. Do not delete this pointer.
Parameters
[in]gltfGLTF object.
[in]typeAttribute::AttributeType defining type of attribute.
[in]countNumber of attributes.
[in]dataData for attribute. data type is base type of attribute.
[in]bufferOptional, Buffer into which to write attribute data. Data is appended to buffer.

◆ CreateDisplacementScale()

static Attribute * ANSYS::Nexus::GLTFWriter::Attribute::CreateDisplacementScale ( GLTF *  gltf,
unsigned int  count,
const float *  data,
Buffer *  buffer = 0 
)
static

Creates an attribute of type AT_FLOAT_VEC4 and name "DISPLACEMENTSCALE". The "DISPLACEMENTSCALE" attribute is usually optional. It specifies a translation XYZ and a uniform scale S as a four float tuple XYZS

Returns
Attribute object. Do not delete this pointer.
Parameters
[in]gltfGLTF object.
[in]countNumber of attributes. Number is relative to sizeof type.
[in]dataData for attribute. data type is base type of attribute.
[in]bufferOptional, Buffer into which to write attribute data. Data is appended to buffer.

◆ CreateNormal()

static Attribute * ANSYS::Nexus::GLTFWriter::Attribute::CreateNormal ( GLTF *  gltf,
unsigned int  count,
const float *  data,
Buffer *  buffer = 0 
)
static

Creates an attribute of type AT_FLOAT_VEC3 and name "NORMAL". The normal data must be normalized. The "NORMAL" attribute is usually optional. It is required for lighting calculations and spherical texture coordinate mapping.

Returns
Attribute object. Do not delete this pointer.
Parameters
[in]gltfGLTF object.
[in]countNumber of attributes. Number is relative to sizeof type.
[in]dataData for attribute. data type is base type of attribute.
[in]bufferOptional, Buffer into which to write attribute data. Data is appended to buffer.

◆ CreatePointSize()

static Attribute * ANSYS::Nexus::GLTFWriter::Attribute::CreatePointSize ( GLTF *  gltf,
unsigned int  count,
const float *  data,
Buffer *  buffer = 0 
)
static

Creates an attribute of type AT_FLOAT and name "POINTSIZE". The "POINTSIZE" attribute is usually optional.

Returns
Attribute object. Do not delete this pointer.
Parameters
[in]gltfGLTF object.
[in]countNumber of attributes. Number is relative to sizeof type.
[in]dataData for attribute. data type is base type of attribute.
[in]bufferOptional, Buffer into which to write attribute data. Data is appended to buffer.

◆ CreatePosition()

static Attribute * ANSYS::Nexus::GLTFWriter::Attribute::CreatePosition ( GLTF *  gltf,
unsigned int  count,
const float *  data,
Buffer *  buffer = 0 
)
static

Creates an attribute of type AT_FLOAT_VEC3 and name "POSITION". Every primitive must have an attribute with the name "POSITION". The GLTF Viewer uses the "POSITION" to perform hit detection and probing.

Returns
Attribute object. Do not delete this pointer.
Parameters
[in]gltfGLTF object.
[in]countNumber of attributes. Number is relative to sizeof type.
[in]dataData for attribute. data type is base type of attribute.
[in]bufferOptional, Buffer into which to write attribute data. Data is appended to buffer.

◆ CreateTextureCoord()

static Attribute * ANSYS::Nexus::GLTFWriter::Attribute::CreateTextureCoord ( GLTF *  gltf,
unsigned int  num,
unsigned int  count,
const float *  data,
Buffer *  buffer = 0 
)
static

Creates an attribute of type AT_FLOAT_VEC and name "TEXCOORDnum". This creates a texture coordinate of type AT_FLOAT. Use Create to create texture coordinates into 2D textures. Texture coordinates are optional, but generally required for texture mapped materials. If the primitive has a "TEXCOORD0", the texture coordinate must be a 1D texture coordinate, as in the value of results variable. The GLTF Viewer will use this texture coordinate to perform probing. The value at the probe point will be the value of the texture coordinate.

Returns
Attribute object. Do not delete this pointer.
Parameters
[in]gltfGLTF object.
[in]numTexture coordinate number.
[in]countNumber of attributes. Number is relative to sizeof type.
[in]dataData for attribute. data type is base type of attribute.
[in]bufferOptional, Buffer into which to write attribute data. Data is appended to buffer.

◆ SetLogarithmic()

virtual void ANSYS::Nexus::GLTFWriter::Attribute::SetLogarithmic ( bool  log)
pure virtual

Sets a flag indicating whether to log the data values. Only used for results type data.

Parameters
[in]loglog flag.
Examples
Test013.cpp.

◆ SetMinMax() [1/2]

virtual bool ANSYS::Nexus::GLTFWriter::Attribute::SetMinMax ( AttributeType  type,
const float *  mn,
const float *  mx 
)
pure virtual

Sets the min and max value of an attribute. The min and max value is required for all attributes. If SetMinMax is not called, the min and max values are automatically calculated from the attribute. Under some situations this is not the desired value. When programs are auto-generated, and the primitive has a "TEXCOORD0", the generated program will use the min/max of the texture coordinate to normalize the texture coordinate value for use as a texture lookup value.

Returns
Status of SetMinMax.
Parameters
[in]typeAttribute::AttributeType defining type of attribute.
[in]mnMinimum value of attribute.
[in]mxMaximum value of attribute.

◆ SetMinMax() [2/2]

virtual bool ANSYS::Nexus::GLTFWriter::Attribute::SetMinMax ( AttributeType  type,
const int *  mn,
const int *  mx 
)
pure virtual

Sets the min and max value of an attribute. The min and max value is required for all attributes. If SetMinMax is not called, the min and max values are automatically calculated from the attribute. Under some situations this is not the desired value. When programs are auto-generated, and the primitive has a "TEXCOORD0", the generated program will use the min/max of the texture coordinate to normalize the texture coordinate value for use as a texture lookup value.

Returns
Status of SetMinMax.
Parameters
[in]typeAttribute::AttributeType defining type of attribute.
[in]mnMinimum value of attribute.
[in]mxMaximum value of attribute.
Examples
Test009.cpp, and Test014.cpp.

The documentation for this class was generated from the following file:

Connect with Ansys