PVRAssets Classes#

AnimationData#

Nested Relationships#

Nested Types#

Class Documentation#

class AnimationData#

Specifies animation data.

Public Functions

inline AnimationData()#

Constructor..

inline void setAnimationName(const std::string &animationName)#

Setter for the name of the animation.

Parameters:

animationName – The name of the animation

inline const std::string &getAnimationName() const#

Getter for the name of the animation.

Returns:

The name of the animation

void computeDuration()#

Computes the begin and end times of the animation.

inline size_t getNumKeyFrames() const#

Getter for the number of key frames.

Returns:

The number of key frames

inline void allocateKeyFrames(uint32_t keyFrames)#

Allocates a number of key frames.

Parameters:

keyFrames – The number of key frames to allocate

inline KeyFrameData &getAnimationData(uint32_t index)#

Getter animation data for a specified key frame.

Parameters:

index – The key frames for which to retrieve animation data

Returns:

The key frame data for the given frame

inline float getTotalTimeInSec() const#

Getter for the total time taken for the animation in seconds.

Returns:

The total time taken for the animation in seconds

inline float getTotalTimeInMs() const#

Getter for the total time taken for the animation in milli seconds.

Returns:

The total time taken for the animation in milli seconds

inline float getStartTimeInSec() const#

Getter for the start time of the animation in seconds.

Returns:

The time (in seconds) at the first keyframe

inline float getEndTimeInSec() const#

Getter for the end time of the animation in seconds.

Returns:

The time (in seconds) at the last keyframe

glm::mat4x4 getTransformationMatrix(uint32_t frame = 0, float interp = 0) const#

Get the transformation matrix of specific frame and amount of interpolation.

If the animation consists of Transformation Matrices, they will NOT be interpolated as this would be a very expensive operation. Rather, the closest matrix will be returned. If the transformation consists of Scale/ translation vectors and Rotation quaternia, Scale and Translation will be Linear Interpolated, and Rotation will be SLERPed (Smooth Linear Interpolation) as normal.

Parameters:
  • frame – The first frame for which the transformation matrix will be returned

  • interp – Interpolation value used between the frames

Returns:

The transformation matrix for the point in time that is at point interp between frame frame and frame frame+1

uint32_t getNumFrames() const#

Get number of frames in this animation.

Returns:

The number of frames

uint32_t getFlags() const#

Get the flags data on this animation.

Returns:

The flags

const float *getPositions() const#

Get a pointer to the position data of this animation.

Returns:

Position data - null if indexed

const uint32_t *getPositionIndices() const#

Get a pointer to the indices of the position data of this animation.

Returns:

Position indexes - null if not indexed

const float *getRotations() const#

Get a pointer to the rotation data of this animation (normally quaternions).

Returns:

Rotation data - null if indexed

const uint32_t *getRotationIndices() const#

Get a pointer to the indices of the rotation data of this animation.

Returns:

Rotation indexes - null if not indexed

const float *getScales() const#

Get a pointer to the Scale data of this animation.

Returns:

Scales - null if indexed

const uint32_t *getScaleIndices() const#

Get a pointer to the indices of the Scale data.

Returns:

Scale indexes - null if not indexed

const float *getMatrices() const#

Get a pointer to the transformation matrices of this animation.

Returns:

Matrices - null if indexed

const uint32_t *getMatrixIndices() const#

Get a pointer to the indices of the transformation matrices of this animation.

Returns:

Matrix indexes - null if not indexed

void setPositions(uint32_t numFrames, const float *data, const uint32_t *indices = nullptr)#

Set the position transformation data for this animation.

Parameters:
  • numFrames – The number of frames of animation to set

  • data – The position data that will be copied. Must be packed floats, each successive 3 of which will be interpreted as x,y,z values.

  • indices – If this array is not NULL, the position data will be indexed. Default NULL.

Returns:

True on success, false if passing the wrong amount of data for the number of frames in the animation

void setRotations(uint32_t numFrames, const float *const data, const uint32_t *const indices = nullptr)#

Set the rotation transformation data for this animation.

Parameters:
  • numFrames – The number of frames of animation to set

  • data – The rotation data that will be copied. Must be packed floats, each successive 4 of which will be interpreted as x,y,z,w quaternion values.

  • indices – If this array is not NULL, the position data will be indexed. Default NULL.

Returns:

True on success, false if passing the wrong amount of data for the number of frames in the animation

void setScales(uint32_t numFrames, const float *const data, const uint32_t *const indices = nullptr)#

Set the scale transformation data for this animation.

Parameters:
  • numFrames – The number of frames of animation to set

  • data – The rotation data that will be copied. Must be packed floats, each successive 3 of which will be interpreted as x,y,z scale factors

  • indices – If this array is not NULL, the position data will be indexed. Default NULL.

Returns:

True on success, false if passing the wrong amount of data for the number of frames in the animation

void setMatrices(uint32_t numFrames, const float *const data, const uint32_t *const indices = nullptr)#

Set the transformation matrices data for this animation.

Parameters:
  • numFrames – The number of frames of animation to set

  • data – The Transformation Matrices data that will be copied. Must be packed floats, each successive 16 of which will be interpreted as a matrix packed in the usual way (Column-major, with each column of the matrix stored successively in

  • indices – If this array is not NULL, the position data will be indexed. Default NULL.

Returns:

True on success, false if passing the wrong amount of data for the number of frames in the animation

InternalData &getInternalData()#

Gets a direct, modifiable pointer to the data representation of this object. Advanced tasks only.

Returns:

A pointer to the internal structure of this object

struct InternalData#

Raw internal structure of the Animation.

Public Functions

inline InternalData()#

Constructor. Initializing.

Public Members

uint32_t flags#

Stores which animation arrays are stored.

std::vector<uint32_t> positionIndices#

Index to positions.

std::vector<uint32_t> rotationIndices#

Index to rotations.

std::vector<uint32_t> scaleIndices#

Index to scales.

std::vector<uint32_t> matrixIndices#

Index to matrices.

uint32_t numFrames#

The number of frames of animation.

std::string animationName#

The name of the animation.

std::vector<float> timeInSeconds#

The time is seconds at which the animation occurs.

std::vector<KeyFrameData> keyFrames#

Specifies key frame animation data.

float startTime#
float endTime#

Time at the first keyframe (in seconds)

CustomData formattedUserData#

Time at the last keyframe (in seconds)

Optionally, formatted user data (json-style)

Camera#

Nested Relationships#

Nested Types#

Class Documentation#

class Camera#

Contains all information necessary to recreate a Camera in the scene.

Public Functions

inline int32_t getTargetNodeIndex() const#

If the camera points to a specific point, get index to the target node.

Returns:

The target node index

inline void setTargetNodeIndex(int32_t idx)#

Sets the specified node as the look-at target of the camera.

Parameters:

idx – Node index of the desired target.

inline uint32_t getNumFrames() const#

Get the number of frames that this camera’s animation supports.

Returns:

The number of frames

inline float getFar() const#

Get the far clipping plane distance.

Returns:

The far clipping plane distance (z)

inline void setFar(float farClip)#

Get the near clipping plane distance.

Parameters:

farClip – The Z coord (distance) of the far clipping plane

inline float getNear() const#

Get near clip plan distance.

Returns:

The near clipping plane distance (z)

inline void setNear(float nearClip)#

Set the near clipping plane distance.

Parameters:

nearClip – The Z coord (distance) of the near clipping plane

float getFOV(float timeInMs = 0) const#

Get field of view for a specific time in ms.

Parameters:

timeInMs – The time in ms to retrieve the field of view for.

Returns:

The field of vision in radians.

void setFOV(float fov)#

Set field of view (Radians)

Parameters:

fov – The FOV to set, in radians

void setFOV(uint32_t numFrames, const float *fovs, const float *timeInSec)#

Set a field of view animation for a number of frame.

Parameters:
  • numFrames – The number of frames to set the Fov to.

  • fovs – An array of packed floats, which will be interpreted as

  • timeInSec – The time in ms for which to set the fov at

inline InternalData &getInternalData()#

Get a reference to the internal data of this object. Handle with care.

Returns:

A (modifiable) reference to the internal data.

inline CustomData &getFormattedUserData()#
struct InternalData#

Raw internal structure of the Camera.

Public Functions

inline InternalData()#

Default constructor.

Public Members

int32_t targetNodeIdx#

Index of the target object.

float farClip#

Far clip plane.

float nearClip#

Near clip plane.

std::vector<FovAnimationData> fovs#

A list of field of view values to use.

struct FovAnimationData#

Contains perframe fov data.

Public Members

float timeInSec#

Frame time in seconds.

float fov#

Fov.

CustomData#

Class Documentation#

class CustomData#

Public Types

enum class Type#

Values:

enumerator NONE#
enumerator NUMBER#
enumerator INT#
enumerator BOOL#
enumerator STRING#
enumerator ARRAY#
enumerator BINARY#
enumerator OBJECT#
typedef std::vector<CustomData> Array#
typedef std::map<std::string, CustomData> Object#

Public Functions

inline CustomData()#
inline explicit CustomData(bool b)#
inline explicit CustomData(int i)#
inline explicit CustomData(double n)#
inline explicit CustomData(const std::string &s)#
inline explicit CustomData(const unsigned char *p, size_t n)#
inline explicit CustomData(const Array &a)#
inline explicit CustomData(const Object &o)#
inline Type GetType() const#
inline bool IsBool() const#
inline bool IsInt() const#
inline bool IsNumber() const#
inline bool IsString() const#
inline bool IsBinary() const#
inline bool IsArray() const#
inline bool IsObject() const#
template<typename T>
const T &Get() const#
template<typename T>
T &Get()#
inline bool GetBool() const#
inline int GetInt() const#
inline double GetDouble() const#
inline const std::string &GetString() const#
inline const Array &GetArray() const#
inline const CustomData &Get(std::size_t idx) const#
inline const CustomData &Get(const std::string &key) const#
inline bool GetFromPath(const std::string &path, CustomData &out) const#
inline std::size_t ArrayLen() const#
inline bool Has(const std::string &key) const#
inline std::vector<std::string> Keys() const#
inline std::size_t Size() const#

Protected Attributes

Type type = Type::NONE#
int intValue = -1#
double numberValue = 0.0#
std::string stringValue = std::string()#
std::vector<uint8_t> binaryValue#
Array arrayValue#
Object objectValue#
bool booleanValue = false#
uint8_t pad[3] = {0, 0, 0}#
int pad0 = 0#

Light#

Nested Relationships#

Nested Types#

Class Documentation#

class Light#

Represents a Light source in the scene.

Public Types

enum LightType#

The type of the light.

Values:

enumerator Point#

Point light.

enumerator Directional#

Directional light.

enumerator Spot#

Spot light.

enumerator NumLightTypes#

number of supported light type

Public Functions

int32_t getTargetIdx() const#

Get the node ID of the target of a light with a direction.

Returns:

The Node ID of the target of a light with a direction

const glm::vec3 &getColor() const#

Get light color.

Returns:

RGB color triplet in a glm::vec3

LightType getType() const#

Get light type (spot, point, directional).

Returns:

The light type

float getConstantAttenuation() const#

Get the Constant attenuation of a spot or point light.

Returns:

The Constant attenuation

float getLinearAttenuation() const#

Get the Linear attenuation of a spot or point light.

Returns:

The Linear attenuation

float getQuadraticAttenuation() const#

Get the Quadratic attenuation of a spot or point light. (If gamma correct, quadratic attenuation should be the closest approximation to physically correct).

Returns:

The Quadratic attenuation

float getFalloffAngle() const#

Get the Falloff angle of a spot light. (minimum angle where penumbra starts)

Returns:

The fallof angle

float getFalloffExponent() const#

Get the Falloff exponent of a spot light. (number defining who fast the falloff is)

Returns:

The fallof exponent

void setTargetNodeIdx(int32_t idx)#

Set a Target for a spot light. (The spotlight will be always “looking” at the target.

Parameters:

idx – The node index of the target of the spotlight.

void setColor(float r, float g, float b)#

Set light color.

Parameters:
  • r – Red color channel ([0..1])

  • g – Green color channel ([0..1])

  • b – Blue color channel ([0..1])

void setType(LightType t)#

Set light type.

Parameters:

t – The type of the light

void setConstantAttenuation(float c)#

Set constant attenuation.

Parameters:

c – Constant attenuation factor

void setLinearAttenuation(float l)#

Set linear attenuation.

Parameters:

l – Linear attenuation factor

void setQuadraticAttenuation(float q)#

Set Quadratic attenuation.

Parameters:

q – Quadratic attenuation factor

void setFalloffAngle(float fa)#

Set spot Falloff angle. This is the angle inside of which the spotlight is full strength.

Parameters:

fa – Falloff angle

void setFalloffExponent(float fe)#

Set a spot Falloff exponent.

Parameters:

fe – Falloff exponent

InternalData &getInternalData()#

Get a reference to the internal representation of this object. Handle with care.

Returns:

A reference to the internal representation of this object

struct InternalData#

Raw internal structure of the Light.

Public Functions

inline InternalData()#

Public Members

int32_t spotTargetNodeIdx#

Index of the target object

glm::vec3 color#

Light color (0.0f -> 1.0f for each channel)

LightType type#

Light type (point, directional, spot etc.)

float constantAttenuation#

Constant attenuation

float linearAttenuation#

Linear attenuation

float quadraticAttenuation#

Quadratic attenuation

float falloffAngle#

Falloff angle (in radians)

float falloffExponent#

Falloff exponent

Mesh#

Nested Relationships#

Nested Types#

Class Documentation#

class Mesh#

Mesh class. Represent a Mesh, a collection of primitives (usually, but not necessarily, triangles) together with their per-vertex information. A mesh’s is a grouping where all vertices/primitives will have the same basic transformation (but can then be skinned) and material applied.

Public Types

typedef IndexedArray<VertexAttributeData, StringHash> VertexAttributeContainer#

This container is automatically kept sorted.

Public Functions

inline const FreeValue *getMeshSemantic(const StringHash &semantic) const#

Return the value of a Per-Mesh semantic as a FreeValue, null if it does not exist.

Parameters:

semantic – The semantic name to retrieve

Returns:

A pointer to a FreeValue containing the value of the semantic. If the semantic does not exist, return NULL

inline const std::shared_ptr<void> &getUserDataPtr() const#

Get the UserData of this mesh, if such user data exist.

Returns:

A pointer to the UserData, as a Reference Counted Void pointer. Cast to appropriate (ref counted)type

inline std::shared_ptr<void> getUserDataPtr()#

Get the UserData of this mesh, if such user data exist.

Returns:

A pointer to the UserData, as a Reference Counted Void pointer. Cast to appropriate (ref counted)type

inline void setUserDataPtr(const std::shared_ptr<void> &ptr)#

Set the UserData of this mesh (wrap the data into a std::shared_ptr and cast to Ref Counted void pointer.

Parameters:

ptr – The UserData. Must be wrapped in an appropriate std::shared_ptr, and then cast into a std::shared_ptr to void

void setStride(uint32_t index, uint32_t stride)#

Set the stride of a Data block.

Parameters:
  • index – The ordinal of the data block (as it was defined by the addData call). If no block exists, it will be created along with all the ones before it, as blocks are always assumed to be continuous

  • stride – The stride that the block (index) will be set to.

int32_t addData(const uint8_t *data, uint32_t size, uint32_t stride)#

Implicitly append a block of vertex data to the mesh and (optionally) populate it with data.

With this call, a new data block will be appended to the end of the mesh, and will be populated with (size) bytes of data copied from the (data) pointer. (stride) will be saved as metadata with the data of the block and will be queriable with the (getStride) call with the same index as the data.

Parameters:
  • data – A pointer to data that will be copied to the new block. If data is NULL, the block remains uninitialized.

  • size – The ordinal of the data block. If no block exists, it will be created along with all the ones before it, as

  • stride – The stride that the block index will be set to.

Returns:

The index of the block that was just created.

The index of the block that was just created.

int32_t addData(const uint8_t *data, uint32_t size, uint32_t stride, uint32_t index)#

Add a block of vertex data to the mesh at the specified index and (optionally) populate it with data.

With this call, a new data block will be added to the specified index of the mesh, and will be populated with (size) bytes of data copied from the (data) pointer. (stride) will be saved as metadata with the data of the block and will be queriable with the (getStride) call with the same index as the data.

Parameters:
  • data – A pointer to data that will be copied to the new block. If data is NULL, the block remains uninitialized.

  • size – The ordinal of the data block. If no block exists, it will be created along with all the ones before it, as

  • stride – The stride that the block index will be set to.

  • index – The index where this block will be created on.

Returns:

The index of the block that was just created.

void removeData(uint32_t index)#

Delete a block of data.

Parameters:

index – The index of the block to delete

inline void clearAllData()#

Remove all data blocks.

inline const void *getData(uint32_t index) const#

Get a pointer to the data of a specified Data block. Read only overload.

Parameters:

index – The index of the data block

Returns:

A const pointer to the specified data block.

inline uint8_t *getData(uint32_t index)#

Get a pointer to the data of a specified Data block. Read/write overload.

Parameters:

index – The index of the data block

Returns:

A pointer to the specified data block.

inline size_t getDataSize(uint32_t index) const#

Get the size of the specified Data block.

Parameters:

index – The index of the data block

Returns:

The size in bytes of the specified Data block.

inline uint32_t getStride(uint32_t index) const#

Get distance in bytes from vertex in an array to the next.

Parameters:

index – The index of the data block whose stride to get

Returns:

The distance in bytes from one array entry to the next.

void addFaces(const uint8_t *data, uint32_t size, const IndexType indexType)#

Add face information to the mesh.

Parameters:
  • data – A pointer to the face data

  • size – The size, in bytes, of the face data

  • indexType – The actual datatype contained in (data). (16 or 32 bit)

int32_t addVertexAttribute(const VertexAttributeData &element, bool forceReplace = false)#

Add a vertex attribute to the mesh.

Parameters:
  • element – The vertex attribute to add

  • forceReplace – If set to true, the element will be replaced if it already exists. Otherwise, the insertion will fail.

Returns:

The index where the element was added (or where the already existing item was)

int32_t addVertexAttribute(const StringHash &semanticName, const DataType &type, uint32_t width, uint32_t offset, uint32_t dataIndex, bool forceReplace = false)#

Add a vertex attribute to the mesh.

Parameters:
  • semanticName – The semantic that the vertex attribute to add represents

  • type – The DataType of the Vertex Attribute

  • width – The number of (type) values per Vertex Attribute

  • offset – The Offset of this Vertex Attribute from the start of its DataBlock

  • dataIndex – The DataBlock this Vertex Attribute belongs to

  • forceReplace – force replace the attribute

Returns:

The index where the element was added (or where the already existing item was)

void removeVertexAttribute(const StringHash &semanticName)#

Remove a vertex attribute to the mesh.

Parameters:

semanticName – The semantic that the vertex attribute to remove has

void removeAllVertexAttributes()#

Remove all vertex attribute to the mesh.

inline uint32_t getNumVertices() const#

Get the number of vertices that comprise this mesh.

Returns:

The number of vertices

inline uint32_t getNumFaces() const#

Get the number of faces that comprise this mesh.

Returns:

The number of faces

inline uint32_t getNumIndices() const#

Get the number of indices that comprise this mesh. Takes TriangleStrips into consideration.

Returns:

The number of indexes

inline uint32_t getNumElements() const#

Get the number of different vertex attributes that this mesh has.

Returns:

The number of vertex attributes

inline uint32_t getNumDataElements() const#

Get the number of vertex data blocks that this mesh has.

Returns:

The number of data blocks

inline uint32_t getNumBoneBatches() const#

Get the number of BoneBatches the bones of this mesh are organised into.

Returns:

The number of bone batches

inline PrimitiveTopology getPrimitiveType() const#

Get the primitive topology that the data in this Mesh represent.

Returns:

The primitive topology that the data in this Mesh represent (Triangles, TriangleStrips, TriangleFans, Patch etc.)

inline void setPrimitiveType(const PrimitiveTopology &type)#

Set the primitive topology that the data in this Mesh represent.

Parameters:

type – The primitive topology that the data in this Mesh will represent (Triangles, TriangleStrips, TriangleFans, Patch etc.)

inline const MeshInfo &getMeshInfo() const#

Get information on this Mesh.

Returns:

A Mesh::MeshInfo object containing information on this Mesh

inline MeshInfo &getMeshInfo()#

Get information on this Mesh.

Returns:

A Mesh::MeshInfo object containing information on this Mesh

inline int32_t getSkeletonId() const#

Retrieves the skeleton identifier (const).

Returns:

The Skeleton identifier

inline const glm::mat4x4 &getUnpackMatrix() const#

Get the Unpack Matrix of this Mesh. The unpack matrix is used for some exotic types of vertex position compression.

Returns:

The unpack matrix

inline void setUnpackMatrix(const glm::mat4x4 &unpackMatrix)#

Set the Unpack Matrix of this Mesh. The unpack matrix is used for some exotic types of vertex position compression.

Parameters:

unpackMatrix – An unpack matrix

inline const std::vector<StridedBuffer> &getVertexData() const#

Get all DataBlocks of this Mesh.

Use as char arrays and additionally use the getStride() method to get the element stride

Returns:

The datablocks, as an std::vector of StridedBuffers that additionally have a stride member.

inline const StridedBuffer &getVertexData(uint32_t n) const#

Get all DataBlocks of this Mesh.

Use as char arrays and additionally use the getStride() method to get the element stride

Returns:

The datablocks, as an std::vector of StridedBuffers that additionally have a stride member.

inline const FaceData &getFaces() const#

Get all face data of this mesh.

Returns:

A reference to the face data object of this mesh

inline FaceData &getFaces()#

Get all face data of this mesh.

Returns:

A reference to the face data object of this mesh

inline uint32_t getNumBones() const#

Get the information of a VertexAttribute by its SemanticName.

This method does lookup in O(logN) time. Prefer to call the getVertexAttributeID and then use the constant-time O(1) getVertexAttribute(int32_t) method

Returns:

A VertexAttributeData object with information on this attribute. (layout, index etc.) Null if failed

inline const VertexAttributeData *getVertexAttributeByName(const StringHash &semanticName) const#

Get the information of a VertexAttribute by its SemanticName (return NULL if not exist)

This method does lookup in O(logN) time. Prefer to call the getVertexAttributeID and then use the constant-time O(1) getVertexAttribute(int32_t) method

Parameters:

semanticName – A semantic name with which to look for a vertex attribute.

Returns:

A VertexAttributeData object with information on this attribute. (layout, index etc.) Null if failed

inline int32_t getVertexAttributeIndex(const char *semanticName) const#

Get the Index of a VertexAttribute by its SemanticName.

Use this method to get the Index of a vertex attribute in O(logN) time and then be able to retrieve it by index with getVertexAttribute in constant time

Parameters:

semanticName – A semantic name with which to look for a vertex attribute.

Returns:

The Index of the vertexAttribute.

inline const VertexAttributeData *getVertexAttribute(int32_t idx) const#

Get the information of a VertexAttribute by its SemanticName.

This method does lookup in constant O(1) time. Use the getVertexAttributeIndex() to get the index to use this method

Parameters:

idx – A semantic id with which to retrieve a vertex attribute.

Returns:

A VertexAttributeData object with information on this attribute. (layout, data index etc.) Null if failed

inline uint32_t getVertexAttributesSize() const#

Get number of vertex attributes.

Returns:

The number of vertex attributes

inline void setVertexAttributeIndex(const char *attributeName, size_t userIndex)#

Locate the specified Attribute in a specific position in the vertex attribute array. Can be used to sort the vertex attributes according to a specific order.

Parameters:
  • attributeName – The name of an attribute

  • userIndex – The index to put this attribute to. If another attribute is there, indices will be swapped.

inline VertexAttributeContainer &getVertexAttributes()#

Get all the vertex attributes.

Returns:

A reference to the actual container the Vertex Attributes are stored in.

inline const VertexAttributeContainer &getVertexAttributes() const#

Get all the vertex attributes.

Returns:

A const reference to the actual container the Vertex Attributes are stored in.

inline uint32_t getNumStrips() const#

Get the number of Triangle Strips (if any) that comprise this Mesh.

Returns:

The number of Triangle Strips (if any) that comprise this Mesh. 0 if the Mesh is not made of strips

inline const uint32_t *getStripLengths() const#

Get an array containing the Triangle Strip lengths.

Returns:

An array of 32 bit values representing the Triangle Strip lengths. Use getNumStrips for the length of the array.

inline uint32_t getStripLength(uint32_t strip) const#

Get the length of the specified triangle strip.

Parameters:

strip – The index of the strip of which to return the length

Returns:

The length of the TriangleStrip with index (strip)

inline void setStripData(uint32_t numStrips, const uint32_t *lengths)#

Set the TriangleStrip number and lengths.

Parameters:
  • numStrips – The number of TriangleStrips

  • lengths – An array of size numStrips containing the length of each TriangleStrip, respectively

inline void setNumVertices(uint32_t numVertices)#

Set the total number of vertices. Will not change the actual Vertex Data.

Parameters:

numVertices – Set the number of vertices

inline void setNumFaces(uint32_t numFaces)#

Set the total number of faces. Will not change the actual Face Data.

Parameters:

numFaces – Set the number of faces

inline InternalData &getInternalData()#

Get a reference to the internal representation and data of this Mesh. Handle with care.

Returns:

The internal representation of this object.

class FaceData#

The FaceData class contains the information of the Indices that defines the Faces of a Mesh.

Public Functions

FaceData()#

Constructor.

inline IndexType getDataType() const#

Get the data type of the face data (16-bit or 32 bit integer).

Returns:

The data type of index data

inline const uint8_t *getData() const#

Get a pointer to the actual face data.

Returns:

A pointer to the actual index data

inline uint8_t *getData()#

Get a pointer to the actual face data.

Returns:

A pointer to the actual index data

inline uint32_t getDataSize() const#

Get total size of the face data.

Returns:

The total size of the data

inline uint32_t getDataTypeSize() const#

Get the size of this face data type in Bits.

Returns:

The size of each index, in Bits

void setData(const uint8_t *data, uint32_t size, const IndexType indexType = IndexType::IndexType16Bit)#

Set all the data of this instance.

Parameters:
  • data – Pointer to the data. Will be copied

  • size – The amount of data, in bytes, to copy from the pointer

  • indexType – The type of index data (16/32 bit)

Protected Attributes

IndexType _indexType#

The index type.

UInt8Buffer _data#

The data.

struct InternalData#

Raw internal structure of the Mesh.

Public Functions

inline InternalData()#

Default constructor.

Public Members

std::map<StringHash, FreeValue> semantics#

Container that stores semantic values.

VertexAttributeContainer vertexAttributes#

Contains information on the vertices, such as semantic names, strides etc.

std::vector<StridedBuffer> vertexAttributeDataBlocks#

Contains the actual raw data (as in, the bytes of information)

uint32_t numBones#

Faces information.

FaceData faces#

Faces information.

MeshInfo primitiveData#

Primitive data information.

int32_t skeleton#

Skeleton identifier.

glm::mat4x4 unpackMatrix#

This matrix is used to move from an int16_t representation to a float.

std::shared_ptr<void> userDataPtr#

This is a pointer that is in complete control of the user, used for per-mesh data.

struct MeshInfo#

Contains mesh information.

Public Functions

inline MeshInfo()#

Constructor.

Public Members

uint32_t numVertices#

Number of vertices in this mesh.

uint32_t numFaces#

Number of faces in this mesh.

std::vector<uint32_t> stripLengths#

If triangle strips exist, the length of each. Otherwise empty.

uint32_t numPatchSubdivisions#

Number of Patch subdivisions.

uint32_t numPatches#

Number of Patches.

uint32_t numControlPointsPerPatch#

Number of Control points per patch.

float units#

Scaling of the units.

PrimitiveTopology primitiveType#

Type of primitive in this Mesh.

bool isIndexed#

Contains indices (as opposed to being a flat list of vertices)

bool isSkinned#

Contains indices (as opposed to being a flat list of vertices)

glm::vec3 min#

The minimum vertex.

glm::vec3 max#

The maximum vertex.

class VertexAttributeData#

Definition of a single VertexAttribute.

Public Functions

inline VertexAttributeData()#

Constructor.

inline VertexAttributeData(const StringHash &semantic, DataType type, uint8_t n, uint16_t offset, uint16_t dataIndex)#

Constructor.

Parameters:
  • semantic – The semantic that this Vertex Attribute represents.

  • type – The type of the data of this attribute.

  • n – The number of values of DataType that form each attribute

  • offset – The offset from the begining of its Buffer that this attribute begins

  • dataIndex – The index of this attribute

inline const StringHash &getSemantic() const#

Get the semantic of this attribute.

Returns:

The semantic of this attribute

inline uint32_t getOffset() const#

Get the offset of this attribute.

Returns:

The offset of this attribute

inline const VertexAttributeLayout &getVertexLayout() const#

Get the layout of this attribute.

Returns:

The layout of this attribute

inline uint32_t getN() const#

Get number of values per vertex.

Returns:

The number of values (aka width. For example, a vec4 would return 4)

inline uint32_t getDataIndex() const#

Get the index of the data for this attribute. Would only be different to 0 if the vertex attributes were split into different data blocks. Each data block would normally map to a single VBO binding.

Returns:

The index of the data block for this attribute.

inline void setSemantic(const StringHash &semantic)#

Set the Semantic Name of this vertex attribute. A semantic name can take ANY value, but forms a “contract” with users of this class, i.e. the application must be aware of them. There are also, by convention, some semantics normally used, like “POSITION”, “NORMAL”, “UV0”-“UV9”, “TANGENT”, “BINORMAL”, “BONEWEIGHT”, “BONEINDEX”…

Parameters:

semantic – The semantic name to associate to this vertex attribute.

void setDataType(DataType type)#

Set the DataType of this vertex attribute.

Parameters:

type – The data type of this attribute

void setOffset(uint32_t offset)#

Set the Offset of this vertex attribute.

Parameters:

offset – The offset from the beginning of the data block of the first item of this attribute

void setN(uint8_t n)#

Set the number of values of each entry of this vertex attribute.

Parameters:

n – The number of values (width) of this attribute

void setDataIndex(uint16_t dataIndex)#

Set the Index of this vertex attribute.

Parameters:

dataIndex – The data block (binding id) of this attribute

inline bool operator==(const VertexAttributeData &rhs)#

Checks if the semantics of the attributes test equal. DOES NOT CHECK ACTUAL DATA.

Parameters:

rhs – The right hand side

Returns:

True if the semantics are equal, otherwise false

inline bool operator<(const VertexAttributeData &rhs)#

Checks if the semantics of the left attribute test “less than” the right attribute. USE FOR SORTING AND MAPS - DOES NOT CHECK ACTUAL DATA.

Parameters:

rhs – The right hand side

Returns:

True if the semantic of lhs test less than rhs, otherwise false

Mesh::FaceData#

Nested Relationships#

This class is a nested type of Mesh.

Class Documentation#

class FaceData

The FaceData class contains the information of the Indices that defines the Faces of a Mesh.

Public Functions

FaceData()

Constructor.

inline IndexType getDataType() const

Get the data type of the face data (16-bit or 32 bit integer).

Returns:

The data type of index data

inline const uint8_t *getData() const

Get a pointer to the actual face data.

Returns:

A pointer to the actual index data

inline uint8_t *getData()

Get a pointer to the actual face data.

Returns:

A pointer to the actual index data

inline uint32_t getDataSize() const

Get total size of the face data.

Returns:

The total size of the data

inline uint32_t getDataTypeSize() const

Get the size of this face data type in Bits.

Returns:

The size of each index, in Bits

void setData(const uint8_t *data, uint32_t size, const IndexType indexType = IndexType::IndexType16Bit)

Set all the data of this instance.

Parameters:
  • data – Pointer to the data. Will be copied

  • size – The amount of data, in bytes, to copy from the pointer

  • indexType – The type of index data (16/32 bit)

Protected Attributes

IndexType _indexType

The index type.

UInt8Buffer _data

The data.

Mesh::PredicateVertAttribMinOffset#

Nested Relationships#

This class is a nested type of Mesh.

Class Documentation#

class PredicateVertAttribMinOffset#

Public Functions

inline PredicateVertAttribMinOffset(const VertexAttributeContainer &container)#
inline bool operator()(uint16_t lhs, uint16_t rhs)#

Public Members

const VertexAttributeContainer &container#

Mesh::VertexAttributeData#

Nested Relationships#

This class is a nested type of Mesh.

Class Documentation#

class VertexAttributeData

Definition of a single VertexAttribute.

Public Functions

inline VertexAttributeData()

Constructor.

inline VertexAttributeData(const StringHash &semantic, DataType type, uint8_t n, uint16_t offset, uint16_t dataIndex)

Constructor.

Parameters:
  • semantic – The semantic that this Vertex Attribute represents.

  • type – The type of the data of this attribute.

  • n – The number of values of DataType that form each attribute

  • offset – The offset from the begining of its Buffer that this attribute begins

  • dataIndex – The index of this attribute

inline const StringHash &getSemantic() const

Get the semantic of this attribute.

Returns:

The semantic of this attribute

inline uint32_t getOffset() const

Get the offset of this attribute.

Returns:

The offset of this attribute

inline const VertexAttributeLayout &getVertexLayout() const

Get the layout of this attribute.

Returns:

The layout of this attribute

inline uint32_t getN() const

Get number of values per vertex.

Returns:

The number of values (aka width. For example, a vec4 would return 4)

inline uint32_t getDataIndex() const

Get the index of the data for this attribute. Would only be different to 0 if the vertex attributes were split into different data blocks. Each data block would normally map to a single VBO binding.

Returns:

The index of the data block for this attribute.

inline void setSemantic(const StringHash &semantic)

Set the Semantic Name of this vertex attribute. A semantic name can take ANY value, but forms a “contract” with users of this class, i.e. the application must be aware of them. There are also, by convention, some semantics normally used, like “POSITION”, “NORMAL”, “UV0”-“UV9”, “TANGENT”, “BINORMAL”, “BONEWEIGHT”, “BONEINDEX”…

Parameters:

semantic – The semantic name to associate to this vertex attribute.

void setDataType(DataType type)

Set the DataType of this vertex attribute.

Parameters:

type – The data type of this attribute

void setOffset(uint32_t offset)

Set the Offset of this vertex attribute.

Parameters:

offset – The offset from the beginning of the data block of the first item of this attribute

void setN(uint8_t n)

Set the number of values of each entry of this vertex attribute.

Parameters:

n – The number of values (width) of this attribute

void setDataIndex(uint16_t dataIndex)

Set the Index of this vertex attribute.

Parameters:

dataIndex – The data block (binding id) of this attribute

inline bool operator==(const VertexAttributeData &rhs)

Checks if the semantics of the attributes test equal. DOES NOT CHECK ACTUAL DATA.

Parameters:

rhs – The right hand side

Returns:

True if the semantics are equal, otherwise false

inline bool operator<(const VertexAttributeData &rhs)

Checks if the semantics of the left attribute test “less than” the right attribute. USE FOR SORTING AND MAPS - DOES NOT CHECK ACTUAL DATA.

Parameters:

rhs – The right hand side

Returns:

True if the semantic of lhs test less than rhs, otherwise false

Model#

Nested Relationships#

Nested Types#

Class Documentation#

class Model#

The Model class represents an entire Scene, or Model. It is mainly a Node structure, allowing various different kinds of data to be stored in the Nodes. The class contains a tree-like structure of Nodes. Each Node can be a Mesh node (containing a Mesh), Camera node or Light node. The tree-structure assumes transformational hierarchy (as usual). Transformations are expressed through Animation objects (a static transform is an animation with a single frame) There is an implicit order in the nodes - First in the array the Mesh nodes will be laid out, then Camera and Light nodes.

Public Types

typedef assets::Mesh Mesh#

Brings the Mesh class name into this class.

Public Functions

inline const FreeValue *getModelSemantic(const StringHash &semantic) const#

Return the value of a Model-wide semantic as a FreeValue, null if it does not exist.

Parameters:

semantic – The semantic name to retrieve

Returns:

A pointer to a FreeValue containing the value of the semantic. If the semantic does not exist, return NULL

inline const std::shared_ptr<void> &getUserDataPtr() const#

Get a pointer to the UserData of this model, if such data exist.

Returns:

A pointer to the UserData, as a Reference Counted Void pointer. Cast to appropriate (ref counted)type

inline std::shared_ptr<void> getUserDataPtr()#

Get a pointer to the UserData of this model.

Returns:

A pointer to the UserData, as a Reference Counted Void pointer. Cast to appropriate (ref counted)type

inline void setUserDataPtr(const std::shared_ptr<void> &ptr)#

Set the UserData of this model (wrap the data into a std::shared_ptr and cast to Ref Counted void pointer.

Parameters:

ptr – The UserData. Must be wrapped in an appropriate std::shared_ptr, and then cast into a std::shared_ptr to void

inline void releaseVertexData()#

Free the vertex data (Vertex attribute values, Vertex Index values) of all meshes to free memory. Usually called after VBOs/IBOs have been created. Any other data of the Mesh are unaffected.

inline void releaseVertexData(uint32_t meshId)#

Free the vertex data (Vertex attribute values, Vertex Index values) of a single mesh to free memory. Usually called after VBOs/IBOs have been created. Any other data of the Mesh are unaffected.

Parameters:

meshId – The meshId of the mesh whose vertex data to free

glm::vec3 getLightPosition(uint32_t lightId) const#

Return the world-space position of a light. Corresponds to the Model’s current frame of animation.

Parameters:

lightId – The node for which to return the world matrix.

Returns:

Return The world matrix of (nodeId).

inline size_t getNumAnimationData() const#

Get number of animation data.

Returns:

Return number of animation data

inline const AnimationData &getAnimationData(uint32_t index) const#

Get animation data.

Parameters:

index – animation data index

Returns:

Return animation data

inline const AnimationData *getAnimationData(const char *name) const#

Get Animation Data.

Parameters:

name – Animation data name

Returns:

Returns animation data

inline const AnimationInstance &getAnimationInstance(uint32_t index) const#

Get animation instance.

Parameters:

index – Animation instance index

Returns:

Returns animation instance

inline AnimationInstance &getAnimationInstance(uint32_t index)#

Get animation instance.

Parameters:

index – Animation instance index

Returns:

Returns animation instance

inline size_t getNumAnimationInstances() const#

Get number of animation instances.

Returns:

Return number of animation instances

inline size_t addAnimationInstance(const AnimationInstance &animationInstance)#

Add new animation instance.

Parameters:

animationInstance – Animation instance to add

Returns:

Return animation instance id

glm::mat4x4 getWorldMatrix(uint32_t nodeId) const#

Return the model-to-world matrix of a node. Corresponds to the Model’s current frame of animation. This version will store a copy of the matrix in an internal cache so that repeated calls for it will use the cached copy of it. Will also store the cached versions of all parents of this node, or use cached versions of them if they exist. Use this if you have long hierarchies and/or repeated calls per frame.

Parameters:

nodeId – The node for which to return the world matrix.

Returns:

Return The world matrix of (nodeId).

glm::mat4x4 getWorldMatrixNoCache(uint32_t nodeId) const#

Return the model-to-world matrix of a node. Corresponds to the Model’s current frame of animation. This version will not use caching and will recalculate the matrix. Faster if the matrix is only used a few times.

Parameters:

nodeId – The node for which to return the world matrix

Returns:

return The world matrix of (nodeId)

glm::mat4x4 getBoneWorldMatrix(uint32_t skinNodeID, uint32_t boneId) const#

Return the model-to-world matrix of a specified bone. Corresponds to the Model’s current frame of animation. This version will use caching.

Parameters:
  • skinNodeID – The node for which to return the world matrix

  • boneId – The bone for which to return the world matrix

Returns:

Return The world matrix of (nodeId, boneID)

inline glm::mat4x4 toWorldMatrix(uint32_t nodeId, const glm::mat4 &localMatrix) const#

Transform a custom matrix with a node’s parent’s transformation. Allows a custom matrix to be applied to a node, while honoring the hierarchical transformations applied by its parent hierarchy.

This function can be used to implement custom procedural animation/kinematics schemes, in which case some nodes may need to have their animations customly defined, but must still honor their parents’ transformations.

Parameters:
  • nodeId – The node whose parents will be applied to the transformation.

  • localMatrix – The matrix to transform

Returns:

Return The localMatrix transformation, modified by the hierarchical transformations of the node.

inline const Skeleton &getSkeleton(uint32_t skeletonIndex) const#

Get skeleton.

Parameters:

skeletonIndexSkeleton index

Returns:

Return skeleton

inline size_t getNumSkeletons() const#

Get number of skeletons.

Returns:

Return number of skeleton

inline const float *getBackgroundColor() const#

Get the clear color (background) (float array R,G,B,A).

Returns:

The clear color (float array R,G,B,A).

inline uint32_t getNumCameras() const#

Get the number of distinct camera objects. May be different than the actual number of Camera Instances (Nodes).

Returns:

Return The number of distinct camera objects.

inline uint32_t getNumCameraNodes() const#

Get the number of Camera nodes in this model.

Returns:

Return The number of Camera instances (Nodes) in this Model.

inline const Camera &getCamera(uint32_t cameraIndex) const#

Get a Camera from this model.

Parameters:

cameraIndex – The index of the camera. Valid values (0 to getNumCameras()-1)

Returns:

Return the camera

inline Camera &getCamera(uint32_t cameraIndex)#

Get a Camera from this model.

Parameters:

cameraIndex – The index of the camera. Valid values (0 to getNumCameras()-1)

Returns:

Return the camera

inline const Node &getCameraNode(uint32_t cameraNodeIndex) const#

Get a specific CameraNode.

Parameters:

cameraNodeIndex – The Index of a Camera Node. It is not the same as the NodeID. Valid values: (0 .. getNumCameraNodes()-1)

Returns:

Return The Camera Node

inline Node &getCameraNode(uint32_t cameraNodeIndex)#

Get a specific CameraNode.

Parameters:

cameraNodeIndex – The Index of a Camera Node. It is not the same as the NodeID. Valid values: (0 .. getNumCameraNodes()-1)

Returns:

Return The Camera Node

inline size_t getNumAnimations() const#

Get number of animation instances.

Returns:

Returns number of animation instances<returns>

inline uint32_t getNodeIdFromCameraId(uint32_t cameraNodeIndex) const#

Get the (global) Node Index of a specific CameraNode.

Parameters:

cameraNodeIndex – The Index of a Camera Node that will be used to calculate the NodeID. Valid values: (0 to getNumCameraNodes()-1)

Returns:

Return The Node index of the specified camera node. Normally, it is the same as getNumMeshes + getNumLights + cameraNodeIndex

inline uint32_t getNumLights() const#

Get the number of distinct Light objects. May be different than the actual number of Light Instances (Nodes).

Returns:

Return The number of distinct Light objects in this Model.

inline uint32_t getNumLightNodes() const#

Get the number of Light nodes.

Returns:

Return The number of Light instances (Nodes) in this Model.

inline const Light &getLight(uint32_t lightIndex) const#

Get the light object with the specific Light Index.

Parameters:

lightIndex – The index of the light. Valid values (0..getNumLights()-1)

Returns:

Return the light

inline Light &getLight(uint32_t lightIndex)#

Get the light object with the specific Light Index.

Parameters:

lightIndex – The index of the light. Valid values (0..getNumLights()-1)

Returns:

Return the light

inline const Node &getLightNode(uint32_t lightNodeIndex) const#

Get a specific Light Node.

Parameters:

lightNodeIndex – The Index of the Light Node. It is not the same as the NodeID. Valid values: (0 to getNumLightNodes()-1)

Returns:

Return the light node

inline uint32_t getNodeIdFromLightNodeId(uint32_t lightNodeIndex) const#

Get the GLOBAL index of a specific Light Node.

Parameters:

lightNodeIndex – The Index of the Light Node. It is not the same as the NodeID. Valid values: (0 to getNumLightNodes()-1)

Returns:

Return the Node index of the same index. It is the same as getNumMeshNodes() + lightNodeIndex.

inline uint32_t getNumMeshes() const#

Get the number of distinct Mesh objects. Unless each Mesh appears at exactly one Node, may be different than the actual number of Mesh instances.

Returns:

Return The number of different Mesh objects in this Model.

inline uint32_t getNumMeshNodes() const#

Get the number of Mesh nodes.

Returns:

Return The number of Mesh instances (Nodes) in this Model.

inline const Mesh &getMesh(uint32_t meshIndex) const#

Get the Mesh object with the specific Mesh Index. Constant overload.

Parameters:

meshIndex – The index of the Mesh. Valid values (0..getNumMeshes()-1)

Returns:

The mesh with id meshIndex. Const ref.

inline void allocateAnimationsData(uint32_t numAnimation)#

Allocate memory for animation data.

Parameters:

numAnimation – Number of animation data to allocate

inline void allocateAnimationInstances(uint32_t numAnimation)#

Allocate memory for animation instances.

Parameters:

numAnimation – Number of animation instances to allocate

inline Mesh &getMesh(uint32_t index)#

Get the Mesh object with the specific Mesh Index.

Parameters:

index – The index of the Mesh. Valid values (0..getNumMeshes()-1)

Returns:

Return the mesh from this model

inline const Node &getMeshNode(uint32_t meshIndex) const#

Get a specific Mesh Node.

Parameters:

meshIndex – The Index of the Mesh Node. For meshes, it is the same as the NodeID. Valid values: (0 to getNumMeshNodes()-1)

Returns:

Return the Mesh Node from this model

inline Node &getMeshNode(uint32_t meshIndex)#

Get a specific Mesh Node.

Parameters:

meshIndex – The Index of the Mesh Node. For meshes, it is the same as the NodeID. Valid values: (0 to getNumMeshNodes()-1)

Returns:

Return he Mesh Node from this model

inline void connectMeshWithMeshNode(uint32_t meshId, uint32_t meshNodeId)#

Connect mesh to a mesh node (i.e. set the node’s mesh to the mesh.

Parameters:
  • meshId – The mesh id

  • meshNodeId – The mesh node id to connect to

inline void connectMeshWithMeshNodes(uint32_t meshId, uint32_t beginMeshNodeId, uint32_t endMeshNodeId)#

Connect mesh to number of mesh nodes.

Parameters:
  • meshId – The mesh id

  • beginMeshNodeId – Begin mesh node id (inclusive)

  • endMeshNodeId – End mesh node id (inclusive)

inline void assignMaterialToMeshNodes(uint32_t materialIndex, uint32_t beginMeshNodeId, uint32_t endMeshNodeId)#

Assign material id to number of mesh nodes.

Parameters:
  • materialIndex – Material id

  • beginMeshNodeId – Begin mesh node id (inclusive)

  • endMeshNodeId – end mesh node id (inclusive)

inline uint32_t getNodeIdForMeshNodeId(uint32_t meshNodeIndex) const#

Get the (global) Node Index of a specific MeshNode. This function is provided for completion, as NodeID == MeshNodeID.

Parameters:

meshNodeIndex – The Index of a Mesh Node that will be used to calculate the NodeID. Valid values: (0 to getNumMeshNodes()-1)

Returns:

Return the Node index of the specified Mesh node. This function just returns the meshNodeIndex (but is harmless and inlined).

inline std::vector<Mesh>::iterator beginMeshes()#

Get an iterator to the beginning of the meshes.

Returns:

Return an iterator

inline std::vector<Mesh>::iterator endMeshes()#

Get an iterator past the end of the meshes.

Returns:

Iterator to one past the last item of the mesh array

inline std::vector<Mesh>::const_iterator beginMeshes() const#

Get a const_iterator to the beginning of the meshes.

Returns:

Iterator to the start of the mesh array

inline std::vector<Mesh>::const_iterator endMeshes() const#

Get a const_iterator past the end of the meshes.

Returns:

Iterator to one past the last item of the mesh array

inline uint32_t getNumNodes() const#

Get the total number of nodes (Meshes, Cameras, Lights, others (helpers etc)).

Returns:

Return number of nodes in this model

inline const Node &getNode(uint32_t index) const#

Get the node with the specified index.

Parameters:

index – The index of the node to get

Returns:

Return The Node from this scene

inline Node &getNode(uint32_t index)#

Get the node with the specified index.

Parameters:

index – The index of the node to get

Returns:

Return The Node from this scene

inline uint32_t getNumTextures() const#

Get the number of distinct Textures in the scene.

Returns:

Return number of distinct textures

inline const Texture &getTexture(uint32_t index) const#

Get the texture with the specified index.

Parameters:

index – The index of the texture to get

Returns:

Return a texture from this scene

inline uint32_t getNumMaterials() const#

Get the number of distinct Materials in the scene.

Returns:

Return number of materials in this scene

inline const Material &getMaterial(uint32_t index) const#

Get the material with the specified index.

Parameters:

index – The index of material to get

Returns:

Return a material from this scene

inline uint32_t addMaterial(const Material &material)#

Add a material to this model, and gets its (just created) material id.

Parameters:

material – The the material to add to the materials of this model

Returns:

The material id generated for the new material.

inline Material &getMaterial(uint32_t index)#

Get the material with the specified index.

Parameters:

index – The index of material to get

Returns:

Return a material from this scene

inline uint32_t getNumFrames() const#

Get the total number of frames in the scene. The total number of usable animated frames is limited to exclude (numFrames - 1) but include any partial number up to (numFrames - 1). Example: If there are 100 frames of animation, the highest frame number allowed is 98, since that will blend between frames 98 and 99. (99 being of course the 100th frame.)

Returns:

Return the number of frames in this model

float getCurrentFrame()#

Get the current frame of the scene.

Returns:

Return the current frame

inline void setFPS(float fps)#

Set the expected FPS of the animation.

Parameters:

fps – FPS of the animation

inline float getFPS() const#

Get the FPS this animation was created for.

Returns:

Get the expected FPS of the animation.

void setUserData(uint32_t size, const char *data)#

Set custom user data.

Parameters:
  • size – The size, in bytes, of the data.

  • data – Pointer to the raw data. (size) bytes will be copied as-is from this pointer.

void allocCameras(uint32_t count)#

Only used for custom model creation. Allocate an number of cameras.

Parameters:

count – Number of camera to allocate in this scene

void allocLights(uint32_t count)#

Only used for custom model creation. Allocate a number of lights.

Parameters:

count – number of lights to allocate in this scene

void allocMeshes(uint32_t count)#

Only used for custom model creation. Allocate a number of meshes.

Parameters:

count – number of meshes to allocate in this scene

void allocNodes(uint32_t count)#

Only used for custom model creation. Allocate a number of nodes.

Parameters:

count – number of nodes to allocate in this scene

inline InternalData &getInternalData()#

Get a reference to the internal data of this Model. Handle with care.

Returns:

Return internal data

inline CustomData &getFormattedUserData()#
void getCameraProperties(uint32_t cameraIdx, float &fov, glm::vec3 &from, glm::vec3 &to, glm::vec3 &up, float frameTimeInMs = 0.f) const#

Get the properties of a camera. This is additional info on the class (remarks or documentation).

If cameraIdx >= number of cameras, an error will be logged and this function will have no effect.

Parameters:
  • cameraIdx – The index of the camera.

  • fovCamera field of view.

  • fromCamera position in world.

  • toCamera target point in world.

  • upCamera tilt up (roll) vector in world.

  • frameTimeInMs – The time in milli seconds to retrieve camera properties for.

void getCameraProperties(uint32_t cameraIdx, float &fov, glm::vec3 &from, glm::vec3 &to, glm::vec3 &up, float &nearClip, float &farClip, float frameTimeInMs = 0.f) const#

Get the properties of a camera.

If cameraIdx >= number of cameras, an error will be logged and this function will have no effect.

Parameters:
  • cameraIdx – The index of the camera.

  • fovCamera field of view in world.

  • fromCamera position in world.

  • toCamera target point in world.

  • upCamera tilt up (roll) vector in world.

  • nearClipCamera near clipping plane distance

  • farClipCamera far clipping plane distance

  • frameTimeInMs – The time in milli seconds to retrieve camera properties for.

void getLightDirection(uint32_t lightIdx, glm::vec3 &direction) const#

Get the direction of a spot or directional light.

If lightIdx >= number of lights, an error will be logged and this function will have no effect.

Parameters:
  • lightIdx – index of the light.

  • direction – The direction of the light.

void getLightPosition(uint32_t lightIdx, glm::vec3 &position) const#

Get the position of a point or spot light.

If lightIdx >= number of lights, an error will be logged and this function will have no effect.

Parameters:
  • lightIdx – light index.

  • position – The position of the light.

Returns:

False if lightIdx does not exist

void getLightPosition(uint32_t lightIdx, glm::vec4 &position) const#

Get the position of a point or spot light.

If lightIdx >= number of lights, an error will be logged and this function will have no effect.

Parameters:
  • lightIdx – light index.

  • position – The position of the light.

inline void destroy()#

Free the resources of this model.

void allocMeshNodes(uint32_t no)#

Allocate the specified number of mesh nodes.

Parameters:

no – The number of mesh nodes to allocate

inline int32_t addTexture(const Texture &tex)#

Add new texture.

Parameters:

tex – Texture to add

Returns:

returns texture index

struct InternalData#

Struct containing the internal data of the Model.

Public Functions

inline InternalData()#

Constructor. Initializing to empty.

Public Members

std::map<StringHash, FreeValue> semantics#

Store of the semantics.

float clearColor[3]#

Background color.

float ambientColor[3]#

Ambient color.

std::vector<Mesh> meshes#

Mesh array. Any given mesh can be referenced by multiple Nodes.

std::vector<Camera> cameras#

Camera array. Any given mesh can be referenced by multiple Nodes.

std::vector<Light> lights#

Light array. Any given mesh can be referenced by multiple Nodes.

std::vector<Texture> textures#

Textures in this Model.

std::vector<Material> materials#

Materials in this Model.

std::vector<Node> nodes#

Nodes array. The nodes are sorted thus: First Mesh Nodes, then Light Nodes, then Camera nodes.

std::vector<Skeleton> skeletons#

Skeleton array.

std::vector<AnimationData> animationsData#

Animation data.

std::vector<AnimationInstance> animationInstances#

Animation instance data.

uint32_t numMeshNodes#

Number of items in the nodes array which are Meshes.

uint32_t numLightNodes#

Number of items in the nodes array which are Meshes.

uint32_t numCameraNodes#

Number of items in the nodes array which are Meshes.

uint32_t numFrames#

Number of frames of animation.

float currentFrame#

Current frame in the animation.

float FPS#

The frames per second the animation should be played at.

UInt8Buffer userData#

Custom raw data stored by the user.

float units#

Unit scaling.

uint32_t flags#

Flags.

std::shared_ptr<void> userDataPtr#

Can be used to store any kind of data that the user wraps in a std::shared_ptr resource.

CustomData formattedUserData#

Optionally, formatted user data (json-style)

class Material#

Class which stores model material info.

Public Types

enum BlendFunction#

A blend function.

Values:

enumerator BlendFuncZero#

BlendFunction (Zero)

enumerator BlendFuncOne#

BlendFunction (One)

enumerator BlendFuncFactor#

BlendFunction (Factor)

enumerator BlendFuncOneMinusBlendFactor#

BlendFunction (One Minus Blend Factor)

enumerator BlendFuncSrcColor#

BlendFunction (source Color)

enumerator BlendFuncOneMinusSrcColor#

BlendFunction (One Minus Source Color)

enumerator BlendFuncSrcAlpha#

BlendFunction (Source Alpha)

enumerator BlendFuncOneMinusSrcAlpha#

BlendFunction (One Minus Source Alpha)

enumerator BlendFuncDstAlpha#

BlendFunction (Destination Alpha)

enumerator BlendFuncOneMinusDstAlpha#

BlendFunction (One Minus Destination Alpha)

enumerator BlendFuncDstColor#

BlendFunction (Destination Alpha)

enumerator BlendFuncOneMinusDstColor#

BlendFunction (One Minus Destination Color)

enumerator BlendFuncSrcAlphaSaturate#

BlendFunction (Source Alpha Saturate)

enumerator BlendFuncConstantColor#

BlendFunction (Constant Color)

enumerator BlendFuncOneMinusConstantColor#

BlendFunction (One Minus Constant Color)

enumerator BlendFuncConstantAlpha#

BlendFunction (Constant Alpha)

enumerator BlendFuncOneMinusConstantAlpha#

BlendFunction (One Minus Constant Alpha)

enum BlendOperation#

A blend operation.

Values:

enumerator BlendOpAdd#

Blend Operation (Add)

enumerator BlendOpMin#

Blend Operation (Min)

enumerator BlendOpMax#

Blend Operation (Max)

enumerator BlendOpSubtract#

Blend Operation (Subtract)

enumerator BlendOpReverseSubtract#

Blend Operation (Reverse Subtract)

enum class GLTFAlphaMode#

Specifies the alpha mode used.

Values:

enumerator Opaque#
enumerator Mask#
enumerator Blend#

Public Functions

inline Material()#

Constructor. Non initializing.

inline const DefaultMaterialSemantics &defaultSemantics() const#

Get a Default Semantics adapter for this object. This is just a convenience object to access the default semantics through compile time functions.

Returns:

The default semantics for this object.

inline void setMaterialAttribute(const StringHash &semantic, const FreeValue &value)#

Set a material attribute by Semantic Name. Any semantic name may be passed, but some of them may be additionally accessed through Default Semantics.

Parameters:
  • semantic – The semantic to set

  • value – The value to set

inline const FreeValue *getMaterialAttribute(const StringHash &semantic) const#

Retrieve a material attribute by Semantic Name. If it does not exist, NULL will be returned.

Parameters:

semantic – The semantic to retrieve

Returns:

A pointer to the value of the semantic with name semantic . If the semantic does not exist, returns null

template<typename Type>
inline const Type getMaterialAttributeWithDefault(const StringHash &semantic, const Type &defaultAttrib) const#

Retrieve a material attribute value, by Semantic Name, as a specific type. If it does not exist, the default value will be returned.

Template Parameters:

Type – The type that the value will be interpreded as

Parameters:
  • semantic – The semantic name of the value to retrieve

  • defaultAttrib – The default value. This will be returned if semantic does not exist

Returns:

The value of the semantic with name semantic . If the semantic does not exist, returns the default value

template<typename Type>
inline const Type *getMaterialAttributeAs(const StringHash &semantic) const#

Retrieve a material attribute value, by Semantic Name, as a specific type. If it does not exist, null will be returned.

Template Parameters:

Type – The type that the value will be interpreded as

Parameters:

semantic – The semantic name of the value to retrieve

Returns:

A pointer to the value of the semantic with name semantic . If the semantic does not exist, returns Null

inline bool hasSemantic(const StringHash &semantic) const#

Query if a semantic exists (Either texture or attribute)

Parameters:

semantic – The semantic name to check.

Returns:

True if either a texture or a material attribute with the specified semantic exists, otherwise false

inline bool hasMaterialTexture(const StringHash &semantic) const#

Check if a material texture with the specified semantic exists.

Parameters:

semantic – The semantic of the material texture to check.

Returns:

True if the material texture exists, otherwise false

inline bool hasMaterialAttribute(const StringHash &semantic) const#

Check if a material attribute with the specified semantic exists.

Parameters:

semantic – The semantic of the material attribute to check.

Returns:

True if the material attribute exists, otherwise false

inline void setEffectName(const StringHash &name)#

Set material effect name.

Parameters:

name – Material effect name

inline void setEffectFile(const StringHash &name)#

Set material effect file name.

Parameters:

name – Effect file name

inline uint32_t getTextureIndex(const StringHash &semantic) const#

Find a texture with the specified semantic. If it exists, returns its index otherwise -1.

Parameters:

semantic – The semantic of the texture to retrieve.

Returns:

If the index with this semantic exists, return its index. Otherwise, return -1.

inline void setTextureIndex(const StringHash &semantic, uint32_t index)#

Set texture with the specified semantic and index.

Parameters:
  • semantic – The semantic of the texture.

  • index – texture index

inline const StringHash &getName() const#

Get this material name.

Returns:

return the material name

inline const StringHash &getEffectFile() const#

Get this material effect file name.

Returns:

Retuurn Material effect file name

inline const StringHash &getEffectName() const#

Get this material effect name.

Returns:

Return material effect name

inline InternalData &getInternalData()#

Return a reference to the material’s internal data structure. Handle with care.

Returns:

Return reference to the internal data

inline const InternalData &getInternalData() const#
class DefaultMaterialSemantics#

This class is provided for convenient compile-time access of the semantic values.

Public Functions

inline DefaultMaterialSemantics(const Material &material)#

Constructor from a parent material (in order to initialize the material reference).

Parameters:

material – The material that will be the parent of this object.

inline glm::vec3 getAmbient() const#

Get material ambient (semantic “AMBIENT”)

Returns:

Material ambient

inline glm::vec3 getDiffuse() const#

Get material diffuse (semantic “DIFFUSE”)

Returns:

Material diffuse

inline glm::vec3 getSpecular() const#

Get material specular (semantic “SPECULAR”)

Returns:

Material specular

inline float getShininess() const#

Get material shininess (semantic “SHININESS”)

Returns:

Material shininess

inline uint32_t getDiffuseTextureIndex() const#

Get the diffuse color texture’s index (semantic “DIFFUSETEXTURE”, return-1 if not exist)

Returns:

Return the diffuse texture index, if exists, otherwise return -1

inline uint32_t getAmbientTextureIndex() const#

Return the ambient color texture’s index (semantic “AMBIENTTEXTURE”, return-1 if not exist)

Returns:

Return the Ambient texture index, if exists

inline uint32_t getSpecularColorTextureIndex() const#

Get the specular color texture’s index (semantic “SPECULARCOLORTEXTURE”, return-1 if not exist)

Returns:

Return the specular color texture index

inline uint32_t getSpecularLevelTextureIndex() const#

Get the specular level texture’s index (semantic “SPECULARLEVELTEXTURE”, return-1 if not exist)

Returns:

Return the specular level texture index

inline uint32_t getBumpMapTextureIndex() const#

Get bumpmap texture index (semantic “NORMALTEXTURE”, return-1 if not exist)

Returns:

Return the bumpmap texture index

inline uint32_t getEmissiveTextureIndex() const#

Get emissive texture’s index (semantic “EMISSIVETEXTURE”, return-1 if not exist)

Returns:

Return the emissive texture index

inline uint32_t getGlossinessTextureIndex() const#

Get glossiness texture’s index (semantic “GLOSSINESSTEXTURE”, return-1 if not exist)

Returns:

Return the glossiness texture index

inline uint32_t getOpacityTextureIndex() const#

Get opacity texture’s index (semantic “OPACITYTEXTURE”, return-1 if not exist)

Returns:

Return the opacity texture index

inline uint32_t getReflectionTextureIndex() const#

Get reflection texture’s index (semantic “REFLECTIONTEXTURE”, return-1 if not exist)

Returns:

Return the reflection texture index

inline uint32_t getRefractionTextureIndex() const#

Return refraction texture’s index (semantic “REFRACTIONTEXTURE”, return-1 if not exist)

Returns:

Return the refraction texture index

inline float getOpacity() const#

Get this material opacity (semantic “OPACITY”)

Returns:

Return the material opacity

inline BlendFunction getBlendSrcRGB() const#

Get the blend function for Source Color (semantic “BLENDSRCCOLOR”)

Returns:

Return source color blend function

inline BlendFunction getBlendSrcA() const#

Get the blend function for Source Alpha (semantic “BLENDSRCALPHA”)

Returns:

Return source alpha blend function

inline BlendFunction getBlendDstRGB() const#

Get the blend function for Destination Color (semantic “BLENDDSTCOLOR”)

Returns:

Return destination color blend function

inline BlendFunction getBlendDstA() const#

Get the blend function for Destination Alpha (semantic “BLENDDSTALPHA”)

Returns:

Return destination alpha blend function

inline BlendOperation getBlendOpRGB() const#

Get the blend operation for Color (semantic “BLENDOPCOLOR”)

Returns:

Return the color’s blend operator

inline BlendOperation getBlendOpA() const#

Return the blend operation for Alpha (semantic “BLENDOPALPHA”)

Returns:

Return the alpha’s blend operator

inline glm::vec4 getBlendColor() const#

Get the blend color (semantic “BLENDCOLOR”)

Returns:

Return blend color

inline glm::vec4 getBlendFactor() const#

Return the blend factor (semantic “BLENDFACTOR”)

Returns:

Return blend factor

class GLTFMetallicRoughnessSemantics : public pvr::assets::Model::Material::PBRSemantics#

This class provides accessor for gltf metallic roughness semantics.

Public Functions

inline GLTFMetallicRoughnessSemantics(Material &material)#

Constructor.

Parameters:

material – Material

inline void setBaseColor(const glm::vec4 &color)#

Set the base color of the material. The base color has two different interpretations depending on the value of metalness. When the material is a metal, the base color is the specific measured reflectance value at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color of the material. In this model it is not possible to specify a F0 value for non-metals, and a linear value of 4% (0.04) is used.

Parameters:

color – base color

inline glm::vec4 getBaseColor() const#

Get the base color of the material. The base color has two different interpretations depending on the value of metalness. When the material is a metal, the base color is the specific measured reflectance value at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color of the material. In this model it is not possible to specify a F0 value for non-metals, and a linear value of 4% (0.04) is used.

Returns:

base color

inline void setBaseColorTextureIndex(uint32_t index)#

Set the base color texture. This texture contains RGB(A) components in sRGB color space. The first three components (RGB) specify the base color of the material. If the fourth component (A) is present, it represents the alpha coverage of the material. Otherwise, an alpha of 1.0 is assumed. The alphaMode property specifies how alpha is interpreted. The stored texels must not be premultiplied.

Parameters:

index – base color texture index

inline uint32_t getBaseColorTextureIndex() const#

Get the base color texture. This texture contains RGB(A) components in sRGB color space. The first three components (RGB) specify the base color of the material. If the fourth component (A) is present, it represents the alpha coverage of the material. Otherwise, an alpha of 1.0 is assumed. The alphaMode property specifies how alpha is interpreted. The stored texels must not be premultiplied.

Returns:

base color texture index

inline void setMetallicity(float metallic)#

Set the metalness of the material. A value of 1.0 means the material is a metal. A value of 0.0 means the material is a dielectric. Values in between are for blending between metals and dielectrics such as dirty metallic surfaces. This value is linear. If a metallicRoughnessTexture is specified, this value is multiplied with the metallic texel values.

Parameters:

metallic – metallic factor

inline float getMetallicity() const#

Set the metalness of the material. A value of 1.0 means the material is a metal. A value of 0.0 means the material is a dielectric. Values in between are for blending between metals and dielectrics such as dirty metallic surfaces. This value is linear. If a metallicRoughnessTexture is specified, this value is multiplied with the metallic texel values.

Returns:

metallic factor

inline void setRoughness(float roughness)#

Set the roughness of the material. A value of 1.0 means the material is completely rough. A value of 0.0 means the material is completely smooth. This value is linear. If a metallicRoughnessTexture is specified, this value is multiplied with the roughness texel values.

Parameters:

roughness – roughness factor

inline float getRoughness() const#

Get the roughness of the material. A value of 1.0 means the material is completely rough. A value of 0.0 means the material is completely smooth. This value is linear. If a metallicRoughnessTexture is specified, this value is multiplied with the roughness texel values.

Returns:

roughness factor

inline float getAlphaCutOff() const#

Get the alpha cutoff value of the material. Specifies the cutoff threshold when in MASK mode. If the alpha value is greater than or equal to this value then it is rendered as fully opaque, otherwise, it is rendered as fully transparent. A value greater than 1.0 will render the entire material as fully transparent. This value is ignored for other modes.

Returns:

The alpha cutoff value of the material.

inline void setAlphaCutOff(float cutoff)#

Get the alpha cutoff value of the material. Specifies the cutoff threshold when in MASK mode. If the alpha value is greater than or equal to this value then it is rendered as fully opaque, otherwise, it is rendered as fully transparent. A value greater than 1.0 will render the entire material as fully transparent. This value is ignored for other modes.

Parameters:

cutoff – cutoff factor

inline bool isDoubleSided() const#

Return whether the material is double sided. When this value is false, back-face culling is enabled. When this value is true, back-face culling is disabled and double sided lighting is enabled. The back-face must have its normals reversed before the lighting equation is evaluated.

Returns:

Return true whether is double sided

inline void setDoubleSided(bool doubleSided)#

Set the material is double sided or not. When this value is false, back-face culling is enabled. When this value is true, back-face culling is disabled and double sided lighting is enabled. The back-face must have its normals reversed before the lighting equation is evaluated.

Parameters:

doubleSided – set the material is double sided or not

inline GLTFAlphaMode getAlphaMode()#

Get the material’s alpha rendering mode enumeration specifying the interpretation of the alpha value of the main factor and texture.

Returns:

Returns alpha mode

inline void setAlphaMode(GLTFAlphaMode alphaMode) const#

Set the material’s alpha rendering mode enumeration specifying the interpretation of the alpha value of the main factor and texture.

Parameters:

alphaMode – set the alpha mode

struct InternalData#

Raw internal structure of the Material.

Public Members

std::map<StringHash, FreeValue> materialSemantics#

storage for the per-material semantics

std::map<StringHash, uint32_t> textureIndices#

Map of texture (semantic) names to indexes.

StringHash name#

Name of the material.

StringHash effectFile#

Effect filename if using an effect.

StringHash effectName#

Effect name (in the filename) if using an effect.

UInt8Buffer userData#

Raw user data.

CustomData formattedUserData#

Optionally, formatted user data (json-style)

class PBRSemantics#

Base class for Physically-based-rendering(PBR) semantics.

Subclassed by pvr::assets::Model::Material::GLTFMetallicRoughnessSemantics, pvr::assets::Model::Material::PODMetallicRoughnessSemantics

Public Functions

inline virtual ~PBRSemantics()#

Destructor.

inline PBRSemantics(Material &mat)#

Constructor.

Parameters:

mat – Material

inline uint32_t getOcclusionTextureIndex() const#

Get occlusion texture index.

Returns:

Occlusion texture index

inline void setOcclusionTextureIndex(uint32_t index)#

Set occlusion texture index.

Parameters:

index – Occlusion texture index

inline uint32_t getNormalTextureIndex() const#

Get normal texture index.

Returns:

normal texture index

inline void setNormalTextureIndex(uint32_t index)#

Set normal texture index.

Parameters:

index – normal texture index

inline glm::vec3 getEmissiveColor() const#

Get the RGB components of the emissive color of the material. These values are linear. If an emissiveTexture is specified, this value is multiplied with the texel values.

Returns:

emissive color

inline void setEmissiveColor(const glm::vec3 &color)#

Set the RGB components of the emissive color of the material. These values are linear. If an emissiveTexture is specified, this value is multiplied with the texel values.

Parameters:

color – emissive color

inline void setEmissiveTextureIndex(uint32_t index)#

Set the emissive texture index.

Parameters:

index – emissive texture index

inline uint32_t getEmissiveTextureIndex() const#

Get the emissive texture index.

Returns:

Returns emissive texture index

inline void setRoughnessTextureIndex(uint32_t index)#

Set the roughness texture index.

Parameters:

index – roughness texture index

inline uint32_t getRoughnessTextureIndex()#

Get the roughness texture index.

Returns:

Returns roughness texture index

inline void setMetallicityTextureIndex(uint32_t index)#

Set the metallicity texture index.

Parameters:

index – metallicity texture index

inline uint32_t getMetallicityTextureIndex()#

Get the metallicity texture index.

Returns:

Returns metallicity texture index

Protected Attributes

Material &_material#

Material used.

class PODMetallicRoughnessSemantics : public pvr::assets::Model::Material::PBRSemantics#

POD Metallic roughness semantics.

Public Functions

inline PODMetallicRoughnessSemantics(Material &mat)#

Constructor.

Parameters:

mat – Material

inline void setEmissionLuminance(float luminance)#

set emission luminance

Parameters:

luminance – luminance

inline float getEmissionLuminance() const#

The Physical Material supports an emissive component, additive light on top of other shading. Emission identity is defined by the weight and color multiplied by the luminence, and also tinted by the Kelvin color temperature (where 6500=white).

Returns:

Returns emission luminance

inline void setEmissionKelvin(float kelvin)#

Set emission kelvin.

Parameters:

kelvin – Kelvin

inline float getEmissionKelvin() const#

Get emission kelvin.

Returns:

Returns emission kelvin

class Node#

The Node represents a Mesh, Camera or Light. A Node has its own parenting, material, animation and custom user data. The tree-structure assumes transformational hierarchy (as usual), so parent transformations should be applied to children. Transformations are expressed through Animation objects (a static transform is an animation with a single frame). Note: Node ID and MeshID can sometimes be confusing: They will always be the same (when a MeshID makes sense) because Meshes are always laid out first in the internal list of Nodes.

Public Functions

inline uint32_t getObjectId() const#

Get which Mesh, Camera or Light this object refers to.

Returns:

The index of the Mesh, Camera or Light array of this node (depending on its type)

inline const StringHash &getName() const#

Get this Node’s name.

Returns:

The name of this object

inline uint32_t getParentID() const#

Get this Node’s parent id.

Returns:

The ID of this Node’s parent Node.

inline uint32_t getMaterialIndex() const#

Get this Node’s material id.

Returns:

The ID of this Node’s Material

inline void setMaterialIndex(uint32_t materialId)#

Associate a material with this node (Assign a material id to this node)

Parameters:

materialId – The material ID to associate with

inline const uint8_t *getUserData() const#

Get this Node’s user data.

Returns:

The user data of this Node

inline const CustomData &getFormattedUserData() const#
inline uint32_t getUserDataSize() const#

Get the size of this Node’s user data.

Returns:

Return The size in bytes of the user data of this Node

inline void setIndex(uint32_t index)#

Set mesh id. Must correlate with the actual position of this node in the data.

Parameters:

index – The id to set the index of this node.

inline void setName(const StringHash &name)#

Set the name of this node.

Parameters:

name – The std::string to set this node’s name to.

inline void setParentID(uint32_t parentID)#

Set the parent of this node.

Parameters:

parentID – the ID of this node’s parent

inline void setUserData(uint32_t size, const char *data)#

Set the user data of this node. A bit copy of the data will be made.

Parameters:
  • size – The size, in bytes, of the data

  • data – A pointer from which (size) data will be copied.

inline void setFormattedUserData(const CustomData &cd)#
inline InternalData &getInternalData()#

Get a reference to the internal data of this object. Handle with care.

Returns:

Return a reference to the internal data of this object.

inline const InternalData &getInternalData() const#

Get a const reference to the data object carrying all internal data of this model.

Returns:

Return a reference to the internal data of this object.

struct InternalData#

Raw internal structure of the Node.

Public Types

enum TransformFlags#

Transformation flags.

Values:

enumerator Identity#

Transformation Identity.

enumerator Scale#

Transformation has Scale.

enumerator Rotate#

Transformation has Rotation.

enumerator Translate#

Transformation has Translation.

enumerator SRT#

SRT.

enumerator Matrix#

has matrix

Public Functions

inline glm::vec3 &getFrameScaleAnimation()#

Get current frame scale animation.

Returns:

Returns scale

inline glm::quat &getFrameRotationAnimation()#

Get current frame rotation animation.

Returns:

Returns rotation

inline glm::vec3 &getFrameTranslationAnimation()#

Get current frame translation animation.

Returns:

Returns translation

inline const glm::vec3 &getFrameScaleAnimation() const#

Get current frame scale animation (const)

Returns:

Returns scale

inline const glm::quat &getFrameRotationAnimation() const#

Get current frame rotation animation (const)

Returns:

Returns rotation

inline const glm::vec3 &getFrameTranslationAnimation() const#

Get current frame translation animation (const)

Returns:

Returns rotation

inline glm::vec3 &getScale()#

Get local space scale.

Returns:

Returns local space scale<returns>

inline glm::quat &getRotate()#

Get local space rotation.

Returns:

Returns local space rotation<returns>

inline glm::vec3 &getTranslation()#

Get local space translation.

Returns:

Returns local space translation<returns>

inline const glm::vec3 &getScale() const#

Get local space scale.

Returns:

Returns local space scale<returns>

inline const glm::quat &getRotate() const#

Get local space rotation.

Returns:

Returns local space rotation<returns>

inline const glm::vec3 &getTranslation() const#

Get local space translation.

Returns:

Returns local space translation<returns>

inline InternalData()#

Default constructor.

Public Members

StringHash name#

Name of object.

uint32_t objectIndex#

Index into mesh, light or camera array, depending on which object list contains this Node.

uint32_t materialIndex#

Index of material used on this mesh.

uint32_t parentIndex#

Index into Node array; recursively apply ancestor’s transforms after this instance’s.

UInt8Buffer userData#

Optionally, user data.

CustomData formattedUserData#

Optionally, formatted user data (json-style)

float frameTransform[16]#

contains interpolated SRT or Matrix for an frame else single Matrix for non animated node. Rotations are stored as quaternion in the format xyzw

glm::vec3 scale#

Node’s local space scale.

glm::quat rotation#

Node’s local space rotation.

glm::vec3 translation#

Node’s local space translation.

uint32_t transformFlags#

keep an flag whether the transformation data is stored as SRT or Matrix or Identity.

int32_t skin#

Skin index for mesh nodes.

bool hasAnimation#

Has animation data.

class Texture#

Internal class which stores Texture information of the model (name).

Public Functions

inline Texture()#

Default Constructor.

inline Texture(const StringHash &&name)#

Constructor.

Parameters:

name – Texture name

inline const pvr::StringHash &getName() const#

Get the name of the texture.

Returns:

Return the texture name

inline pvr::StringHash &getName()#

Get a reference to the name of the texture.

Returns:

Return reference to the texture name

inline void setName(const StringHash &name)#

Set the name of the texture.

Parameters:

name – The std::string to set this texture name to.

Model::Material#

Nested Relationships#

This class is a nested type of Model.

Nested Types#

Class Documentation#

class Material

Class which stores model material info.

Public Types

enum BlendFunction

A blend function.

Values:

enumerator BlendFuncZero

BlendFunction (Zero)

enumerator BlendFuncOne

BlendFunction (One)

enumerator BlendFuncFactor

BlendFunction (Factor)

enumerator BlendFuncOneMinusBlendFactor

BlendFunction (One Minus Blend Factor)

enumerator BlendFuncSrcColor

BlendFunction (source Color)

enumerator BlendFuncOneMinusSrcColor

BlendFunction (One Minus Source Color)

enumerator BlendFuncSrcAlpha

BlendFunction (Source Alpha)

enumerator BlendFuncOneMinusSrcAlpha

BlendFunction (One Minus Source Alpha)

enumerator BlendFuncDstAlpha

BlendFunction (Destination Alpha)

enumerator BlendFuncOneMinusDstAlpha

BlendFunction (One Minus Destination Alpha)

enumerator BlendFuncDstColor

BlendFunction (Destination Alpha)

enumerator BlendFuncOneMinusDstColor

BlendFunction (One Minus Destination Color)

enumerator BlendFuncSrcAlphaSaturate

BlendFunction (Source Alpha Saturate)

enumerator BlendFuncConstantColor

BlendFunction (Constant Color)

enumerator BlendFuncOneMinusConstantColor

BlendFunction (One Minus Constant Color)

enumerator BlendFuncConstantAlpha

BlendFunction (Constant Alpha)

enumerator BlendFuncOneMinusConstantAlpha

BlendFunction (One Minus Constant Alpha)

enum BlendOperation

A blend operation.

Values:

enumerator BlendOpAdd

Blend Operation (Add)

enumerator BlendOpMin

Blend Operation (Min)

enumerator BlendOpMax

Blend Operation (Max)

enumerator BlendOpSubtract

Blend Operation (Subtract)

enumerator BlendOpReverseSubtract

Blend Operation (Reverse Subtract)

enum class GLTFAlphaMode

Specifies the alpha mode used.

Values:

enumerator Opaque
enumerator Mask
enumerator Blend

Public Functions

inline Material()

Constructor. Non initializing.

inline const DefaultMaterialSemantics &defaultSemantics() const

Get a Default Semantics adapter for this object. This is just a convenience object to access the default semantics through compile time functions.

Returns:

The default semantics for this object.

inline void setMaterialAttribute(const StringHash &semantic, const FreeValue &value)

Set a material attribute by Semantic Name. Any semantic name may be passed, but some of them may be additionally accessed through Default Semantics.

Parameters:
  • semantic – The semantic to set

  • value – The value to set

inline const FreeValue *getMaterialAttribute(const StringHash &semantic) const

Retrieve a material attribute by Semantic Name. If it does not exist, NULL will be returned.

Parameters:

semantic – The semantic to retrieve

Returns:

A pointer to the value of the semantic with name semantic . If the semantic does not exist, returns null

template<typename Type>
inline const Type getMaterialAttributeWithDefault(const StringHash &semantic, const Type &defaultAttrib) const

Retrieve a material attribute value, by Semantic Name, as a specific type. If it does not exist, the default value will be returned.

Template Parameters:

Type – The type that the value will be interpreded as

Parameters:
  • semantic – The semantic name of the value to retrieve

  • defaultAttrib – The default value. This will be returned if semantic does not exist

Returns:

The value of the semantic with name semantic . If the semantic does not exist, returns the default value

template<typename Type>
inline const Type *getMaterialAttributeAs(const StringHash &semantic) const

Retrieve a material attribute value, by Semantic Name, as a specific type. If it does not exist, null will be returned.

Template Parameters:

Type – The type that the value will be interpreded as

Parameters:

semantic – The semantic name of the value to retrieve

Returns:

A pointer to the value of the semantic with name semantic . If the semantic does not exist, returns Null

inline bool hasSemantic(const StringHash &semantic) const

Query if a semantic exists (Either texture or attribute)

Parameters:

semantic – The semantic name to check.

Returns:

True if either a texture or a material attribute with the specified semantic exists, otherwise false

inline bool hasMaterialTexture(const StringHash &semantic) const

Check if a material texture with the specified semantic exists.

Parameters:

semantic – The semantic of the material texture to check.

Returns:

True if the material texture exists, otherwise false

inline bool hasMaterialAttribute(const StringHash &semantic) const

Check if a material attribute with the specified semantic exists.

Parameters:

semantic – The semantic of the material attribute to check.

Returns:

True if the material attribute exists, otherwise false

inline void setEffectName(const StringHash &name)

Set material effect name.

Parameters:

name – Material effect name

inline void setEffectFile(const StringHash &name)

Set material effect file name.

Parameters:

name – Effect file name

inline uint32_t getTextureIndex(const StringHash &semantic) const

Find a texture with the specified semantic. If it exists, returns its index otherwise -1.

Parameters:

semantic – The semantic of the texture to retrieve.

Returns:

If the index with this semantic exists, return its index. Otherwise, return -1.

inline void setTextureIndex(const StringHash &semantic, uint32_t index)

Set texture with the specified semantic and index.

Parameters:
  • semantic – The semantic of the texture.

  • index – texture index

inline const StringHash &getName() const

Get this material name.

Returns:

return the material name

inline const StringHash &getEffectFile() const

Get this material effect file name.

Returns:

Retuurn Material effect file name

inline const StringHash &getEffectName() const

Get this material effect name.

Returns:

Return material effect name

inline InternalData &getInternalData()

Return a reference to the material’s internal data structure. Handle with care.

Returns:

Return reference to the internal data

inline const InternalData &getInternalData() const
class DefaultMaterialSemantics

This class is provided for convenient compile-time access of the semantic values.

Public Functions

inline DefaultMaterialSemantics(const Material &material)

Constructor from a parent material (in order to initialize the material reference).

Parameters:

material – The material that will be the parent of this object.

inline glm::vec3 getAmbient() const

Get material ambient (semantic “AMBIENT”)

Returns:

Material ambient

inline glm::vec3 getDiffuse() const

Get material diffuse (semantic “DIFFUSE”)

Returns:

Material diffuse

inline glm::vec3 getSpecular() const

Get material specular (semantic “SPECULAR”)

Returns:

Material specular

inline float getShininess() const

Get material shininess (semantic “SHININESS”)

Returns:

Material shininess

inline uint32_t getDiffuseTextureIndex() const

Get the diffuse color texture’s index (semantic “DIFFUSETEXTURE”, return-1 if not exist)

Returns:

Return the diffuse texture index, if exists, otherwise return -1

inline uint32_t getAmbientTextureIndex() const

Return the ambient color texture’s index (semantic “AMBIENTTEXTURE”, return-1 if not exist)

Returns:

Return the Ambient texture index, if exists

inline uint32_t getSpecularColorTextureIndex() const

Get the specular color texture’s index (semantic “SPECULARCOLORTEXTURE”, return-1 if not exist)

Returns:

Return the specular color texture index

inline uint32_t getSpecularLevelTextureIndex() const

Get the specular level texture’s index (semantic “SPECULARLEVELTEXTURE”, return-1 if not exist)

Returns:

Return the specular level texture index

inline uint32_t getBumpMapTextureIndex() const

Get bumpmap texture index (semantic “NORMALTEXTURE”, return-1 if not exist)

Returns:

Return the bumpmap texture index

inline uint32_t getEmissiveTextureIndex() const

Get emissive texture’s index (semantic “EMISSIVETEXTURE”, return-1 if not exist)

Returns:

Return the emissive texture index

inline uint32_t getGlossinessTextureIndex() const

Get glossiness texture’s index (semantic “GLOSSINESSTEXTURE”, return-1 if not exist)

Returns:

Return the glossiness texture index

inline uint32_t getOpacityTextureIndex() const

Get opacity texture’s index (semantic “OPACITYTEXTURE”, return-1 if not exist)

Returns:

Return the opacity texture index

inline uint32_t getReflectionTextureIndex() const

Get reflection texture’s index (semantic “REFLECTIONTEXTURE”, return-1 if not exist)

Returns:

Return the reflection texture index

inline uint32_t getRefractionTextureIndex() const

Return refraction texture’s index (semantic “REFRACTIONTEXTURE”, return-1 if not exist)

Returns:

Return the refraction texture index

inline float getOpacity() const

Get this material opacity (semantic “OPACITY”)

Returns:

Return the material opacity

inline BlendFunction getBlendSrcRGB() const

Get the blend function for Source Color (semantic “BLENDSRCCOLOR”)

Returns:

Return source color blend function

inline BlendFunction getBlendSrcA() const

Get the blend function for Source Alpha (semantic “BLENDSRCALPHA”)

Returns:

Return source alpha blend function

inline BlendFunction getBlendDstRGB() const

Get the blend function for Destination Color (semantic “BLENDDSTCOLOR”)

Returns:

Return destination color blend function

inline BlendFunction getBlendDstA() const

Get the blend function for Destination Alpha (semantic “BLENDDSTALPHA”)

Returns:

Return destination alpha blend function

inline BlendOperation getBlendOpRGB() const

Get the blend operation for Color (semantic “BLENDOPCOLOR”)

Returns:

Return the color’s blend operator

inline BlendOperation getBlendOpA() const

Return the blend operation for Alpha (semantic “BLENDOPALPHA”)

Returns:

Return the alpha’s blend operator

inline glm::vec4 getBlendColor() const

Get the blend color (semantic “BLENDCOLOR”)

Returns:

Return blend color

inline glm::vec4 getBlendFactor() const

Return the blend factor (semantic “BLENDFACTOR”)

Returns:

Return blend factor

class GLTFMetallicRoughnessSemantics : public pvr::assets::Model::Material::PBRSemantics

This class provides accessor for gltf metallic roughness semantics.

Public Functions

inline GLTFMetallicRoughnessSemantics(Material &material)

Constructor.

Parameters:

material – Material

inline void setBaseColor(const glm::vec4 &color)

Set the base color of the material. The base color has two different interpretations depending on the value of metalness. When the material is a metal, the base color is the specific measured reflectance value at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color of the material. In this model it is not possible to specify a F0 value for non-metals, and a linear value of 4% (0.04) is used.

Parameters:

color – base color

inline glm::vec4 getBaseColor() const

Get the base color of the material. The base color has two different interpretations depending on the value of metalness. When the material is a metal, the base color is the specific measured reflectance value at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color of the material. In this model it is not possible to specify a F0 value for non-metals, and a linear value of 4% (0.04) is used.

Returns:

base color

inline void setBaseColorTextureIndex(uint32_t index)

Set the base color texture. This texture contains RGB(A) components in sRGB color space. The first three components (RGB) specify the base color of the material. If the fourth component (A) is present, it represents the alpha coverage of the material. Otherwise, an alpha of 1.0 is assumed. The alphaMode property specifies how alpha is interpreted. The stored texels must not be premultiplied.

Parameters:

index – base color texture index

inline uint32_t getBaseColorTextureIndex() const

Get the base color texture. This texture contains RGB(A) components in sRGB color space. The first three components (RGB) specify the base color of the material. If the fourth component (A) is present, it represents the alpha coverage of the material. Otherwise, an alpha of 1.0 is assumed. The alphaMode property specifies how alpha is interpreted. The stored texels must not be premultiplied.

Returns:

base color texture index

inline void setMetallicity(float metallic)

Set the metalness of the material. A value of 1.0 means the material is a metal. A value of 0.0 means the material is a dielectric. Values in between are for blending between metals and dielectrics such as dirty metallic surfaces. This value is linear. If a metallicRoughnessTexture is specified, this value is multiplied with the metallic texel values.

Parameters:

metallic – metallic factor

inline float getMetallicity() const

Set the metalness of the material. A value of 1.0 means the material is a metal. A value of 0.0 means the material is a dielectric. Values in between are for blending between metals and dielectrics such as dirty metallic surfaces. This value is linear. If a metallicRoughnessTexture is specified, this value is multiplied with the metallic texel values.

Returns:

metallic factor

inline void setRoughness(float roughness)

Set the roughness of the material. A value of 1.0 means the material is completely rough. A value of 0.0 means the material is completely smooth. This value is linear. If a metallicRoughnessTexture is specified, this value is multiplied with the roughness texel values.

Parameters:

roughness – roughness factor

inline float getRoughness() const

Get the roughness of the material. A value of 1.0 means the material is completely rough. A value of 0.0 means the material is completely smooth. This value is linear. If a metallicRoughnessTexture is specified, this value is multiplied with the roughness texel values.

Returns:

roughness factor

inline float getAlphaCutOff() const

Get the alpha cutoff value of the material. Specifies the cutoff threshold when in MASK mode. If the alpha value is greater than or equal to this value then it is rendered as fully opaque, otherwise, it is rendered as fully transparent. A value greater than 1.0 will render the entire material as fully transparent. This value is ignored for other modes.

Returns:

The alpha cutoff value of the material.

inline void setAlphaCutOff(float cutoff)

Get the alpha cutoff value of the material. Specifies the cutoff threshold when in MASK mode. If the alpha value is greater than or equal to this value then it is rendered as fully opaque, otherwise, it is rendered as fully transparent. A value greater than 1.0 will render the entire material as fully transparent. This value is ignored for other modes.

Parameters:

cutoff – cutoff factor

inline bool isDoubleSided() const

Return whether the material is double sided. When this value is false, back-face culling is enabled. When this value is true, back-face culling is disabled and double sided lighting is enabled. The back-face must have its normals reversed before the lighting equation is evaluated.

Returns:

Return true whether is double sided

inline void setDoubleSided(bool doubleSided)

Set the material is double sided or not. When this value is false, back-face culling is enabled. When this value is true, back-face culling is disabled and double sided lighting is enabled. The back-face must have its normals reversed before the lighting equation is evaluated.

Parameters:

doubleSided – set the material is double sided or not

inline GLTFAlphaMode getAlphaMode()

Get the material’s alpha rendering mode enumeration specifying the interpretation of the alpha value of the main factor and texture.

Returns:

Returns alpha mode

inline void setAlphaMode(GLTFAlphaMode alphaMode) const

Set the material’s alpha rendering mode enumeration specifying the interpretation of the alpha value of the main factor and texture.

Parameters:

alphaMode – set the alpha mode

struct InternalData

Raw internal structure of the Material.

Public Members

std::map<StringHash, FreeValue> materialSemantics

storage for the per-material semantics

std::map<StringHash, uint32_t> textureIndices

Map of texture (semantic) names to indexes.

StringHash name

Name of the material.

StringHash effectFile

Effect filename if using an effect.

StringHash effectName

Effect name (in the filename) if using an effect.

UInt8Buffer userData

Raw user data.

CustomData formattedUserData

Optionally, formatted user data (json-style)

class PBRSemantics

Base class for Physically-based-rendering(PBR) semantics.

Subclassed by pvr::assets::Model::Material::GLTFMetallicRoughnessSemantics, pvr::assets::Model::Material::PODMetallicRoughnessSemantics

Public Functions

inline virtual ~PBRSemantics()

Destructor.

inline PBRSemantics(Material &mat)

Constructor.

Parameters:

mat – Material

inline uint32_t getOcclusionTextureIndex() const

Get occlusion texture index.

Returns:

Occlusion texture index

inline void setOcclusionTextureIndex(uint32_t index)

Set occlusion texture index.

Parameters:

index – Occlusion texture index

inline uint32_t getNormalTextureIndex() const

Get normal texture index.

Returns:

normal texture index

inline void setNormalTextureIndex(uint32_t index)

Set normal texture index.

Parameters:

index – normal texture index

inline glm::vec3 getEmissiveColor() const

Get the RGB components of the emissive color of the material. These values are linear. If an emissiveTexture is specified, this value is multiplied with the texel values.

Returns:

emissive color

inline void setEmissiveColor(const glm::vec3 &color)

Set the RGB components of the emissive color of the material. These values are linear. If an emissiveTexture is specified, this value is multiplied with the texel values.

Parameters:

color – emissive color

inline void setEmissiveTextureIndex(uint32_t index)

Set the emissive texture index.

Parameters:

index – emissive texture index

inline uint32_t getEmissiveTextureIndex() const

Get the emissive texture index.

Returns:

Returns emissive texture index

inline void setRoughnessTextureIndex(uint32_t index)

Set the roughness texture index.

Parameters:

index – roughness texture index

inline uint32_t getRoughnessTextureIndex()

Get the roughness texture index.

Returns:

Returns roughness texture index

inline void setMetallicityTextureIndex(uint32_t index)

Set the metallicity texture index.

Parameters:

index – metallicity texture index

inline uint32_t getMetallicityTextureIndex()

Get the metallicity texture index.

Returns:

Returns metallicity texture index

Protected Attributes

Material &_material

Material used.

class PODMetallicRoughnessSemantics : public pvr::assets::Model::Material::PBRSemantics

POD Metallic roughness semantics.

Public Functions

inline PODMetallicRoughnessSemantics(Material &mat)

Constructor.

Parameters:

mat – Material

inline void setEmissionLuminance(float luminance)

set emission luminance

Parameters:

luminance – luminance

inline float getEmissionLuminance() const

The Physical Material supports an emissive component, additive light on top of other shading. Emission identity is defined by the weight and color multiplied by the luminence, and also tinted by the Kelvin color temperature (where 6500=white).

Returns:

Returns emission luminance

inline void setEmissionKelvin(float kelvin)

Set emission kelvin.

Parameters:

kelvin – Kelvin

inline float getEmissionKelvin() const

Get emission kelvin.

Returns:

Returns emission kelvin

Material::DefaultMaterialSemantics#

Nested Relationships#

This class is a nested type of Model::Material.

Class Documentation#

class DefaultMaterialSemantics

This class is provided for convenient compile-time access of the semantic values.

Public Functions

inline DefaultMaterialSemantics(const Material &material)

Constructor from a parent material (in order to initialize the material reference).

Parameters:

material – The material that will be the parent of this object.

inline glm::vec3 getAmbient() const

Get material ambient (semantic “AMBIENT”)

Returns:

Material ambient

inline glm::vec3 getDiffuse() const

Get material diffuse (semantic “DIFFUSE”)

Returns:

Material diffuse

inline glm::vec3 getSpecular() const

Get material specular (semantic “SPECULAR”)

Returns:

Material specular

inline float getShininess() const

Get material shininess (semantic “SHININESS”)

Returns:

Material shininess

inline uint32_t getDiffuseTextureIndex() const

Get the diffuse color texture’s index (semantic “DIFFUSETEXTURE”, return-1 if not exist)

Returns:

Return the diffuse texture index, if exists, otherwise return -1

inline uint32_t getAmbientTextureIndex() const

Return the ambient color texture’s index (semantic “AMBIENTTEXTURE”, return-1 if not exist)

Returns:

Return the Ambient texture index, if exists

inline uint32_t getSpecularColorTextureIndex() const

Get the specular color texture’s index (semantic “SPECULARCOLORTEXTURE”, return-1 if not exist)

Returns:

Return the specular color texture index

inline uint32_t getSpecularLevelTextureIndex() const

Get the specular level texture’s index (semantic “SPECULARLEVELTEXTURE”, return-1 if not exist)

Returns:

Return the specular level texture index

inline uint32_t getBumpMapTextureIndex() const

Get bumpmap texture index (semantic “NORMALTEXTURE”, return-1 if not exist)

Returns:

Return the bumpmap texture index

inline uint32_t getEmissiveTextureIndex() const

Get emissive texture’s index (semantic “EMISSIVETEXTURE”, return-1 if not exist)

Returns:

Return the emissive texture index

inline uint32_t getGlossinessTextureIndex() const

Get glossiness texture’s index (semantic “GLOSSINESSTEXTURE”, return-1 if not exist)

Returns:

Return the glossiness texture index

inline uint32_t getOpacityTextureIndex() const

Get opacity texture’s index (semantic “OPACITYTEXTURE”, return-1 if not exist)

Returns:

Return the opacity texture index

inline uint32_t getReflectionTextureIndex() const

Get reflection texture’s index (semantic “REFLECTIONTEXTURE”, return-1 if not exist)

Returns:

Return the reflection texture index

inline uint32_t getRefractionTextureIndex() const

Return refraction texture’s index (semantic “REFRACTIONTEXTURE”, return-1 if not exist)

Returns:

Return the refraction texture index

inline float getOpacity() const

Get this material opacity (semantic “OPACITY”)

Returns:

Return the material opacity

inline BlendFunction getBlendSrcRGB() const

Get the blend function for Source Color (semantic “BLENDSRCCOLOR”)

Returns:

Return source color blend function

inline BlendFunction getBlendSrcA() const

Get the blend function for Source Alpha (semantic “BLENDSRCALPHA”)

Returns:

Return source alpha blend function

inline BlendFunction getBlendDstRGB() const

Get the blend function for Destination Color (semantic “BLENDDSTCOLOR”)

Returns:

Return destination color blend function

inline BlendFunction getBlendDstA() const

Get the blend function for Destination Alpha (semantic “BLENDDSTALPHA”)

Returns:

Return destination alpha blend function

inline BlendOperation getBlendOpRGB() const

Get the blend operation for Color (semantic “BLENDOPCOLOR”)

Returns:

Return the color’s blend operator

inline BlendOperation getBlendOpA() const

Return the blend operation for Alpha (semantic “BLENDOPALPHA”)

Returns:

Return the alpha’s blend operator

inline glm::vec4 getBlendColor() const

Get the blend color (semantic “BLENDCOLOR”)

Returns:

Return blend color

inline glm::vec4 getBlendFactor() const

Return the blend factor (semantic “BLENDFACTOR”)

Returns:

Return blend factor

Material::GLTFMetallicRoughnessSemantics#

Nested Relationships#

This class is a nested type of Model::Material.

Inheritance Relationships#

Base Type#

Class Documentation#

class GLTFMetallicRoughnessSemantics : public pvr::assets::Model::Material::PBRSemantics

This class provides accessor for gltf metallic roughness semantics.

Public Functions

inline GLTFMetallicRoughnessSemantics(Material &material)

Constructor.

Parameters:

material – Material

inline void setBaseColor(const glm::vec4 &color)

Set the base color of the material. The base color has two different interpretations depending on the value of metalness. When the material is a metal, the base color is the specific measured reflectance value at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color of the material. In this model it is not possible to specify a F0 value for non-metals, and a linear value of 4% (0.04) is used.

Parameters:

color – base color

inline glm::vec4 getBaseColor() const

Get the base color of the material. The base color has two different interpretations depending on the value of metalness. When the material is a metal, the base color is the specific measured reflectance value at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color of the material. In this model it is not possible to specify a F0 value for non-metals, and a linear value of 4% (0.04) is used.

Returns:

base color

inline void setBaseColorTextureIndex(uint32_t index)

Set the base color texture. This texture contains RGB(A) components in sRGB color space. The first three components (RGB) specify the base color of the material. If the fourth component (A) is present, it represents the alpha coverage of the material. Otherwise, an alpha of 1.0 is assumed. The alphaMode property specifies how alpha is interpreted. The stored texels must not be premultiplied.

Parameters:

index – base color texture index

inline uint32_t getBaseColorTextureIndex() const

Get the base color texture. This texture contains RGB(A) components in sRGB color space. The first three components (RGB) specify the base color of the material. If the fourth component (A) is present, it represents the alpha coverage of the material. Otherwise, an alpha of 1.0 is assumed. The alphaMode property specifies how alpha is interpreted. The stored texels must not be premultiplied.

Returns:

base color texture index

inline void setMetallicity(float metallic)

Set the metalness of the material. A value of 1.0 means the material is a metal. A value of 0.0 means the material is a dielectric. Values in between are for blending between metals and dielectrics such as dirty metallic surfaces. This value is linear. If a metallicRoughnessTexture is specified, this value is multiplied with the metallic texel values.

Parameters:

metallic – metallic factor

inline float getMetallicity() const

Set the metalness of the material. A value of 1.0 means the material is a metal. A value of 0.0 means the material is a dielectric. Values in between are for blending between metals and dielectrics such as dirty metallic surfaces. This value is linear. If a metallicRoughnessTexture is specified, this value is multiplied with the metallic texel values.

Returns:

metallic factor

inline void setRoughness(float roughness)

Set the roughness of the material. A value of 1.0 means the material is completely rough. A value of 0.0 means the material is completely smooth. This value is linear. If a metallicRoughnessTexture is specified, this value is multiplied with the roughness texel values.

Parameters:

roughness – roughness factor

inline float getRoughness() const

Get the roughness of the material. A value of 1.0 means the material is completely rough. A value of 0.0 means the material is completely smooth. This value is linear. If a metallicRoughnessTexture is specified, this value is multiplied with the roughness texel values.

Returns:

roughness factor

inline float getAlphaCutOff() const

Get the alpha cutoff value of the material. Specifies the cutoff threshold when in MASK mode. If the alpha value is greater than or equal to this value then it is rendered as fully opaque, otherwise, it is rendered as fully transparent. A value greater than 1.0 will render the entire material as fully transparent. This value is ignored for other modes.

Returns:

The alpha cutoff value of the material.

inline void setAlphaCutOff(float cutoff)

Get the alpha cutoff value of the material. Specifies the cutoff threshold when in MASK mode. If the alpha value is greater than or equal to this value then it is rendered as fully opaque, otherwise, it is rendered as fully transparent. A value greater than 1.0 will render the entire material as fully transparent. This value is ignored for other modes.

Parameters:

cutoff – cutoff factor

inline bool isDoubleSided() const

Return whether the material is double sided. When this value is false, back-face culling is enabled. When this value is true, back-face culling is disabled and double sided lighting is enabled. The back-face must have its normals reversed before the lighting equation is evaluated.

Returns:

Return true whether is double sided

inline void setDoubleSided(bool doubleSided)

Set the material is double sided or not. When this value is false, back-face culling is enabled. When this value is true, back-face culling is disabled and double sided lighting is enabled. The back-face must have its normals reversed before the lighting equation is evaluated.

Parameters:

doubleSided – set the material is double sided or not

inline GLTFAlphaMode getAlphaMode()

Get the material’s alpha rendering mode enumeration specifying the interpretation of the alpha value of the main factor and texture.

Returns:

Returns alpha mode

inline void setAlphaMode(GLTFAlphaMode alphaMode) const

Set the material’s alpha rendering mode enumeration specifying the interpretation of the alpha value of the main factor and texture.

Parameters:

alphaMode – set the alpha mode

Material::PBRSemantics#

Nested Relationships#

This class is a nested type of Model::Material.

Inheritance Relationships#

Derived Types#

Class Documentation#

class PBRSemantics

Base class for Physically-based-rendering(PBR) semantics.

Subclassed by pvr::assets::Model::Material::GLTFMetallicRoughnessSemantics, pvr::assets::Model::Material::PODMetallicRoughnessSemantics

Public Functions

inline virtual ~PBRSemantics()

Destructor.

inline PBRSemantics(Material &mat)

Constructor.

Parameters:

mat – Material

inline uint32_t getOcclusionTextureIndex() const

Get occlusion texture index.

Returns:

Occlusion texture index

inline void setOcclusionTextureIndex(uint32_t index)

Set occlusion texture index.

Parameters:

index – Occlusion texture index

inline uint32_t getNormalTextureIndex() const

Get normal texture index.

Returns:

normal texture index

inline void setNormalTextureIndex(uint32_t index)

Set normal texture index.

Parameters:

index – normal texture index

inline glm::vec3 getEmissiveColor() const

Get the RGB components of the emissive color of the material. These values are linear. If an emissiveTexture is specified, this value is multiplied with the texel values.

Returns:

emissive color

inline void setEmissiveColor(const glm::vec3 &color)

Set the RGB components of the emissive color of the material. These values are linear. If an emissiveTexture is specified, this value is multiplied with the texel values.

Parameters:

color – emissive color

inline void setEmissiveTextureIndex(uint32_t index)

Set the emissive texture index.

Parameters:

index – emissive texture index

inline uint32_t getEmissiveTextureIndex() const

Get the emissive texture index.

Returns:

Returns emissive texture index

inline void setRoughnessTextureIndex(uint32_t index)

Set the roughness texture index.

Parameters:

index – roughness texture index

inline uint32_t getRoughnessTextureIndex()

Get the roughness texture index.

Returns:

Returns roughness texture index

inline void setMetallicityTextureIndex(uint32_t index)

Set the metallicity texture index.

Parameters:

index – metallicity texture index

inline uint32_t getMetallicityTextureIndex()

Get the metallicity texture index.

Returns:

Returns metallicity texture index

Protected Attributes

Material &_material

Material used.

Material::PODMetallicRoughnessSemantics#

Nested Relationships#

This class is a nested type of Model::Material.

Inheritance Relationships#

Base Type#

Class Documentation#

class PODMetallicRoughnessSemantics : public pvr::assets::Model::Material::PBRSemantics

POD Metallic roughness semantics.

Public Functions

inline PODMetallicRoughnessSemantics(Material &mat)

Constructor.

Parameters:

mat – Material

inline void setEmissionLuminance(float luminance)

set emission luminance

Parameters:

luminance – luminance

inline float getEmissionLuminance() const

The Physical Material supports an emissive component, additive light on top of other shading. Emission identity is defined by the weight and color multiplied by the luminence, and also tinted by the Kelvin color temperature (where 6500=white).

Returns:

Returns emission luminance

inline void setEmissionKelvin(float kelvin)

Set emission kelvin.

Parameters:

kelvin – Kelvin

inline float getEmissionKelvin() const

Get emission kelvin.

Returns:

Returns emission kelvin

Model::Node#

Nested Relationships#

This class is a nested type of Model.

Nested Types#

Class Documentation#

class Node

The Node represents a Mesh, Camera or Light. A Node has its own parenting, material, animation and custom user data. The tree-structure assumes transformational hierarchy (as usual), so parent transformations should be applied to children. Transformations are expressed through Animation objects (a static transform is an animation with a single frame). Note: Node ID and MeshID can sometimes be confusing: They will always be the same (when a MeshID makes sense) because Meshes are always laid out first in the internal list of Nodes.

Public Functions

inline uint32_t getObjectId() const

Get which Mesh, Camera or Light this object refers to.

Returns:

The index of the Mesh, Camera or Light array of this node (depending on its type)

inline const StringHash &getName() const

Get this Node’s name.

Returns:

The name of this object

inline uint32_t getParentID() const

Get this Node’s parent id.

Returns:

The ID of this Node’s parent Node.

inline uint32_t getMaterialIndex() const

Get this Node’s material id.

Returns:

The ID of this Node’s Material

inline void setMaterialIndex(uint32_t materialId)

Associate a material with this node (Assign a material id to this node)

Parameters:

materialId – The material ID to associate with

inline const uint8_t *getUserData() const

Get this Node’s user data.

Returns:

The user data of this Node

inline const CustomData &getFormattedUserData() const
inline uint32_t getUserDataSize() const

Get the size of this Node’s user data.

Returns:

Return The size in bytes of the user data of this Node

inline void setIndex(uint32_t index)

Set mesh id. Must correlate with the actual position of this node in the data.

Parameters:

index – The id to set the index of this node.

inline void setName(const StringHash &name)

Set the name of this node.

Parameters:

name – The std::string to set this node’s name to.

inline void setParentID(uint32_t parentID)

Set the parent of this node.

Parameters:

parentID – the ID of this node’s parent

inline void setUserData(uint32_t size, const char *data)

Set the user data of this node. A bit copy of the data will be made.

Parameters:
  • size – The size, in bytes, of the data

  • data – A pointer from which (size) data will be copied.

inline void setFormattedUserData(const CustomData &cd)
inline InternalData &getInternalData()

Get a reference to the internal data of this object. Handle with care.

Returns:

Return a reference to the internal data of this object.

inline const InternalData &getInternalData() const

Get a const reference to the data object carrying all internal data of this model.

Returns:

Return a reference to the internal data of this object.

struct InternalData

Raw internal structure of the Node.

Public Types

enum TransformFlags

Transformation flags.

Values:

enumerator Identity

Transformation Identity.

enumerator Scale

Transformation has Scale.

enumerator Rotate

Transformation has Rotation.

enumerator Translate

Transformation has Translation.

enumerator SRT

SRT.

enumerator Matrix

has matrix

Public Functions

inline glm::vec3 &getFrameScaleAnimation()

Get current frame scale animation.

Returns:

Returns scale

inline glm::quat &getFrameRotationAnimation()

Get current frame rotation animation.

Returns:

Returns rotation

inline glm::vec3 &getFrameTranslationAnimation()

Get current frame translation animation.

Returns:

Returns translation

inline const glm::vec3 &getFrameScaleAnimation() const

Get current frame scale animation (const)

Returns:

Returns scale

inline const glm::quat &getFrameRotationAnimation() const

Get current frame rotation animation (const)

Returns:

Returns rotation

inline const glm::vec3 &getFrameTranslationAnimation() const

Get current frame translation animation (const)

Returns:

Returns rotation

inline glm::vec3 &getScale()

Get local space scale.

Returns:

Returns local space scale<returns>

inline glm::quat &getRotate()

Get local space rotation.

Returns:

Returns local space rotation<returns>

inline glm::vec3 &getTranslation()

Get local space translation.

Returns:

Returns local space translation<returns>

inline const glm::vec3 &getScale() const

Get local space scale.

Returns:

Returns local space scale<returns>

inline const glm::quat &getRotate() const

Get local space rotation.

Returns:

Returns local space rotation<returns>

inline const glm::vec3 &getTranslation() const

Get local space translation.

Returns:

Returns local space translation<returns>

inline InternalData()

Default constructor.

Public Members

StringHash name

Name of object.

uint32_t objectIndex

Index into mesh, light or camera array, depending on which object list contains this Node.

uint32_t materialIndex

Index of material used on this mesh.

uint32_t parentIndex

Index into Node array; recursively apply ancestor’s transforms after this instance’s.

UInt8Buffer userData

Optionally, user data.

CustomData formattedUserData

Optionally, formatted user data (json-style)

float frameTransform[16]

contains interpolated SRT or Matrix for an frame else single Matrix for non animated node. Rotations are stored as quaternion in the format xyzw

glm::vec3 scale

Node’s local space scale.

glm::quat rotation

Node’s local space rotation.

glm::vec3 translation

Node’s local space translation.

uint32_t transformFlags

keep an flag whether the transformation data is stored as SRT or Matrix or Identity.

int32_t skin

Skin index for mesh nodes.

bool hasAnimation

Has animation data.

Model::Texture#

Nested Relationships#

This class is a nested type of Model.

Class Documentation#

class Texture

Internal class which stores Texture information of the model (name).

Public Functions

inline Texture()

Default Constructor.

inline Texture(const StringHash &&name)

Constructor.

Parameters:

name – Texture name

inline const pvr::StringHash &getName() const

Get the name of the texture.

Returns:

Return the texture name

inline pvr::StringHash &getName()

Get a reference to the name of the texture.

Returns:

Return reference to the texture name

inline void setName(const StringHash &name)

Set the name of the texture.

Parameters:

name – The std::string to set this texture name to.

IndexedArray#

Nested Relationships#

Nested Types#

Class Documentation#

template<typename ValueType_, typename IndexType_ = std::string>
class IndexedArray#

A combination of array (std::vector) with associative container (std::map). Supports association of names with values, and retrieval by index.

An std::vector style array class with the additional feature of associating “names” (IndexType_, std::string by default) with the values stored. Keys are of type IndexType_, correspond to vector position 1:1, so that each vector position (“index”) is associated with a “key”, and only one key. Use: Add pairs of values with insert(key, value). Retrieve indices by key, using getIndex(key) &#8212; O(logn) Retrieve values by index, using indexing operator [] &#8212; O(1) The remove() function destroys the items on which it was called, but a default-constructed object will still exist. Performing insert() after removing an item will use the place of a previously deleted item, if it exists. CAUTION: If remove() has been called, the vector no longer guarantees contiguousness until compact() is called. CAUTION: To manually reclaim all memory and guarantee contiguous allocation, call compact(). Calling compact invalidates all indices, which must then be retrieved anew by “getInxdex”. Calling getIndex on an unknown key returns (size_t)(-1) Accessing an unknown item by index is undefined. Accessing an index not retrieved by getIndex since the last compact() operation is undefined.

Public Types

typedef maptype_::iterator index_iterator#

An Indexed iterator of the IndexedArray class. Will follow the indexing map of the IndexedArray iterating items in their Indexing order.

typedef maptype_::const_iterator const_index_iterator#

An Indexed (Constant) iterator of the IndexedArray class. Will follow the indexing map of the IndexedArray iterating items in their Indexing order.

Public Functions

inline iterator begin()#

Return a Linear iterator to the first non-deleted item in the backing store.

Returns:

A Linear iterator to the first non-deleted item in the backing store.

inline const_iterator begin() const#

Return a Linear const_iterator to the first non-deleted item in the backing store.

Returns:

A Linear const_iterator to the first non-deleted item in the backing store.

inline maptype_::iterator indexed_find(const IndexType_ &key)#

Return an indexed iterator by finding the provided key Indexing map.

Parameters:

key – The key with which to lookup.

Returns:

An indexed_iterator

inline maptype_::const_iterator indexed_find(const IndexType_ &key) const#

Return a const indexed iterator by finding the provided key Indexing map.

Parameters:

key – The key with which to lookup.

Returns:

A const indexed iterator

inline maptype_::iterator indexed_begin()#

Return an indexed_const_iterator to the first item in the map.

Returns:

An indexed iterator to the beginning

inline maptype_::const_iterator indexed_begin() const#

Return a indexed_const_iterator to the first item in the map.

Returns:

A constant indexed iterator to the beginning

inline maptype_::iterator indexed_end()#

Return an indexed_iterator pointing one item past the last item in the map.

Returns:

An indexed iterator to the end

inline maptype_::const_iterator indexed_end() const#

Return an indexed_const_iterator pointing one item past the last item in the map.

Returns:

A const indexed iterator to the end

inline iterator end()#

Return an iterator pointing one item past the last item in the backing array.

Returns:

An iterator to the end of the backing array

inline const_iterator end() const#

Return a const_iterator pointing one item past the last item in the backing array.

Returns:

An iterator to the end of the backing array

inline void insertAt(size_t where, const IndexType_ &key, const ValueType_ &val)#

Insert an item at a specific point in the backing array.

Parameters:
  • where – The index where to insert the new item

  • key – The Key of the new item

  • val – The Value of the new item

inline size_t insert(const IndexType_ &key, const ValueType_ &val)#

Insert an item at the first possible spot in the backing array. If key exists, will update the value.

Parameters:
  • key – The Key of the new item

  • val – The Value of the new item

Returns:

The index, in the backing array, of the inserted/updated item

inline size_t getIndex(const IndexType_ &key) const#

Get the index of a specific key in the backing array. Valid until a reshuffling of the array is done via insert, compact or similar operation.

Parameters:

key – The Key of the item to find

Returns:

The index of key , -1 if key does not exist.

inline void erase(const IndexType_ &key)#

Removes the item with the specified key from the IndexedArray.

This method will find the entry with specified key and remove it. It will not invalidata existing indices, but it will void the contiguousness guarantee the backing array normally has. Call compact() afterwards to make the vector contiguous again (but invalidate existing indices).

Parameters:

key – The Key of the item to erase

inline ValueType_ &operator[](size_t idx)#

Array indexing operator. Constant time. Use getIndex to get the indices of specific items. If idx points to a deleted item or past the last item, the behaviour is undefined.

Parameters:

idx – The backing index to retrieve.

Returns:

Reference to the item at specified index

inline const ValueType_ &operator[](size_t idx) const#

Const array indexing operator. Use getIndex to get the indices of specific items. If idx points to a deleted item or past the last item, the behaviour is undefined.

Parameters:

idx – The backing index to retrieve.

Returns:

Const Reference to the item at specified index

inline ValueType_ &operator[](const IndexType_ &key)#

Indexed indexing operator. Uses std::map find to retrieve the specified value. If the key does not exist, it will be inserted.

Parameters:

key – The key to find.

Returns:

Reference to the item at specified index

inline const ValueType_ &operator[](const IndexType_ &key) const#

Indexed indexing operator. Uses std::map find to retrieve the specified value. If the key does not exist, it will be inserted.

Parameters:

key – The key to find.

Returns:

Reference to the item at specified index

inline void compact()#

Compacts the backing array by removing existing items from the end of the vector and putting them in the place of deleted items, and then updating their index, until no more positions marked as deleted are left. Will ensure the contiguousness of the backing vector, but will invalidate previously gotten item indices.

inline void clear()#

Empties the IndexedArray.

inline size_t size() const#

Gets the number of items in the IndexedArray.

Returns:

The number of items in the IndexedArray.

inline size_t sizeWithDeleted() const#

Gets the number of items in the IndexedArray, including items that have been deleted.

Returns:

The number of items in the IndexedArray, including items that have been deleted.

inline size_t capacity() const#

Gets the current capacity of the backing array of the IndexedArray.

Returns:

The current capacity of the backing array of the IndexedArray.

inline size_t deletedItemsCount() const#

Gets the number of deleted items.

Returns:

The number of deleted items.

inline bool relocate(const IndexType_ &key, size_t index)#

Move a specific item (identified by a key) to a specific index in the list. If an item is already in this spot in the list, their positions are swapped.

Parameters:
  • key – The key of the item to relocate.

  • index – The index where to relocate the item.

Returns:

False if the specified key was not found in the index.

class const_iterator#

An (constant) Linear iterator of the IndexedArray class. Will linearly iterate the backing store skipping empy spots. Unordered.

Public Functions

inline const DictionaryEntry &operator*()#

Dereferencing operator: Return the object this iterator currently points to.

Returns:

The object this iterator currently points to

inline const DictionaryEntry *operator->()#

Dereferencing operator: Access the members of the object this iterator currently points to.

Returns:

A pointer to the object this iterator currently points to

inline size_t getItemIndex()#

The index of the item where this iterator points.

Returns:

The index of the item where this iterator points

inline const_iterator &operator++()#

prefix operator ++

Returns:

This

inline const_iterator operator++(int)#

postfix operator ++

Returns:

This

inline const_iterator &operator--()#

prefix operator &#8212;

Returns:

This

inline const_iterator operator--(int)#

postfix operator &#8212;

Returns:

This

inline bool operator!=(const const_iterator &rhs)#

Inequality.

Parameters:

rhs – Right hand side of the operation

Returns:

True if the items are not equal, otherwise false

inline bool operator==(const const_iterator &rhs)#

Equality.

Parameters:

rhs – Right hand side of the operation

Returns:

True if the items are not equal, otherwise false

class iterator#

An (modifiable) Linear iterator of the IndexedArray class. Will linearly iterate the backing store skipping empy spots. Unordered.

Public Functions

inline iterator(const const_iterator &rhs)#

Copy constructor.

Parameters:

rhs – Object to copy

inline DictionaryEntry &operator*()#

operator *

Returns:

Return this

inline DictionaryEntry *operator->()#

operator ->

Returns:

Return this

inline size_t getItemIndex()#

Get the current index of the pointed-to item.

Returns:

Current index

inline iterator &operator++()#

prefix operator ++

Returns:

This

inline iterator operator++(int)#

postfix operator ++

Returns:

The value of this iterator prior to incrementing

inline iterator &operator--()#

prefix operator &#8212;

Returns:

This

inline iterator operator--(int)#

postfix operator &#8212;

Returns:

The value of this iterator prior to decrementing

inline bool operator!=(const iterator &rhs)#

operator !=

Parameters:

rhs – Right hand side

Returns:

True if this is not equal to rhs

inline bool operator==(const iterator &rhs)#

operator ==

Parameters:

rhs – Right hand side

Returns:

True if this is equal to rhs

IndexedArray::const_iterator#

Nested Relationships#

This class is a nested type of IndexedArray.

Class Documentation#

class const_iterator

An (constant) Linear iterator of the IndexedArray class. Will linearly iterate the backing store skipping empy spots. Unordered.

Public Functions

inline const DictionaryEntry &operator*()

Dereferencing operator: Return the object this iterator currently points to.

Returns:

The object this iterator currently points to

inline const DictionaryEntry *operator->()

Dereferencing operator: Access the members of the object this iterator currently points to.

Returns:

A pointer to the object this iterator currently points to

inline size_t getItemIndex()

The index of the item where this iterator points.

Returns:

The index of the item where this iterator points

inline const_iterator &operator++()

prefix operator ++

Returns:

This

inline const_iterator operator++(int)

postfix operator ++

Returns:

This

inline const_iterator &operator--()

prefix operator &#8212;

Returns:

This

inline const_iterator operator--(int)

postfix operator &#8212;

Returns:

This

inline bool operator!=(const const_iterator &rhs)

Inequality.

Parameters:

rhs – Right hand side of the operation

Returns:

True if the items are not equal, otherwise false

inline bool operator==(const const_iterator &rhs)

Equality.

Parameters:

rhs – Right hand side of the operation

Returns:

True if the items are not equal, otherwise false

IndexedArray::iterator#

Nested Relationships#

This class is a nested type of IndexedArray.

Class Documentation#

class iterator

An (modifiable) Linear iterator of the IndexedArray class. Will linearly iterate the backing store skipping empy spots. Unordered.

Public Functions

inline iterator(const const_iterator &rhs)

Copy constructor.

Parameters:

rhs – Object to copy

inline DictionaryEntry &operator*()

operator *

Returns:

Return this

inline DictionaryEntry *operator->()

operator ->

Returns:

Return this

inline size_t getItemIndex()

Get the current index of the pointed-to item.

Returns:

Current index

inline iterator &operator++()

prefix operator ++

Returns:

This

inline iterator operator++(int)

postfix operator ++

Returns:

The value of this iterator prior to incrementing

inline iterator &operator--()

prefix operator &#8212;

Returns:

This

inline iterator operator--(int)

postfix operator &#8212;

Returns:

The value of this iterator prior to decrementing

inline bool operator!=(const iterator &rhs)

operator !=

Parameters:

rhs – Right hand side

Returns:

True if this is not equal to rhs

inline bool operator==(const iterator &rhs)

operator ==

Parameters:

rhs – Right hand side

Returns:

True if this is equal to rhs

ShadowVolume#

Nested Relationships#

Nested Types#

Inheritance Relationships#

Base Type#

Class Documentation#

class ShadowVolume : public pvr::Volume#

Represents data for handling Shadow volumes of a single Mesh.

Public Types

enum Flags#

Enumerates the different options for different kinds of Shadow volumes.

Values:

enumerator Visible#

The specified part is Visible.

enumerator Cap_front#

The front cap of the volume.

enumerator Cap_back#

The back cap of the volume.

enumerator Zfail#

The specified item is configured as Z-Fail.

Public Functions

~ShadowVolume()#

dtor, releases all resources held by the shadow volume.

void alllocateShadowVolume(uint32_t volumeID)#

Allocate memory for a new shadow volume with the specified ID.

Parameters:

volumeID – The ID of the volume. If exists, it will be overwritten.

bool releaseVolume(uint32_t volumeID)#

Delete the Shadow Volume with the provided ID.

Parameters:

volumeID – shadow volume id

Returns:

pvr::Success of suc

uint32_t getNumIndices(uint32_t volumeID)#

Get the number of indices of the specified shadow volume.

Parameters:

volumeID – Shadow volume id

Returns:

The number of indexes

char *getIndices(uint32_t volumeID)#

Get the indices of the specified shadow volume.

Parameters:

volumeID – shadow volume id

Returns:

A pointer to the Index data

bool isIndexDataInternal(uint32_t volumeID)#

Query if this shadow volume is using internal index data.

Parameters:

volumeID – Shadow volume id

Returns:

Return true if is using internal index data

uint32_t isVisible(const glm::mat4x4 projection, const glm::vec3 &lightModel, bool isPointLight, float cameraZProj, float extrudeLength)#

Query if this shadow volume is visible.

Parameters:
  • projection – A projection matrix to test

  • lightModel – The light source position (if point) or direction (if directional)

  • isPointLight – True if it is a point light, false if it is directional

  • cameraZProj – The Z projection of the camera

  • extrudeLength – The length of extrusion for the volume.

Returns:

True if the volume is visible, otherwise false

bool projectSilhouette(uint32_t volumeID, uint32_t flags, const glm::vec3 &lightModel, bool isPointLight, char **externalIndexBuffer = NULL)#

Find the silhouette of the shadow volume for the specified light and prepare it for projection.

Parameters:
  • volumeID – The Shadow Volume to prepare. Must have had alllocateShadowVolume called on it

  • flags – The properties of the shadow volume to generate (caps, technique)

  • lightModel – The Model-space light. Either point-light(or spot) or directional light supported

  • isPointLight – Pass true for point (or spot) light, false for directional

  • externalIndexBuffer – An external buffer that contains custom, user provided index data.

Returns:

True if successful, otherwise false

Volume#

Nested Relationships#

Nested Types#

Inheritance Relationships#

Derived Type#

Class Documentation#

class Volume#

Represents data for handling volumes of a single Mesh.

Subclassed by pvr::ShadowVolume

Public Functions

virtual ~Volume()#

dtor, releases all resources held by the Volume.

bool init(const assets::Mesh &mesh)#

Initialize a volume from the data of a Mesh.

This method will pre-process the data in the mesh, to calculate all vertices, edges and faces of the mesh as required. In effect it will extract the POSITION semantic data and the face data and use it to create a “light” and cleaned up version of the mesh that will be then used to calculate extruded volumes as required.

Parameters:

mesh – A mesh whose vertex data is used to initialize this Volume instance. The POSITION semantic must be present in the mesh.

Returns:

True if successfully initialized, otherwise false

bool init(const uint8_t *const data, uint32_t numVertices, uint32_t verticesStride, DataType vertexType, const uint8_t *const faceData, uint32_t numFaces, IndexType indexType)#

Initialize a volume from raw data.

This method will pre-process the data in the mesh, to calculate all vertices, edges and faces of the mesh as required

Parameters:
  • data – Pointer to the first POSITION attribute of vertex data (so buffer_start + offset)

  • numVertices – Number of vertices in (data)

  • verticesStride – Stride between each vertex attribute

  • vertexType – The DataType of each position coordinate

  • faceData – Pointer to index data

  • numFaces – Number of Faces contained in (faceData)

  • indexType – Type of indices in faceData (16/32 bit)

Returns:

True if successfully initialized, otherwise false

uint32_t getVertexDataSize()#

Get the size of the vertex attributes in bytes. Is 2 * numVertices * stride.

Returns:

The size of the vertex data

uint32_t getVertexDataStride()#

Return the stride of the vertex attributes, in bytes. Is 3 * 4 + 4 = 16 .

Returns:

The stride of the vertex attributes

uint32_t getVertexDataPositionOffset()#

Return the offset of the Position vertex attribute in bytes. Is 0.

Returns:

The offset of the Position attribute

uint32_t getVertexDataExtrudeOffset()#

Return the extrude offset. Is 3.

Returns:

The size of each vertex attribute

uint8_t *getVertexData()#

Get a pointer to the raw vertex data. Use to bind vertex buffer.

Returns:

The vertex data

uint32_t getIndexDataSize()#

Get the size of the Index data, in bytes.

Returns:

The index data size

uint32_t getIndexDataStride()#

Get the stride of the Index data, in bytes. Is sizeof(IndexType).

Returns:

The index data stride

uint32_t getTriangleCount()#

Get the number of triangles in the volume.

Returns:

The number of triangles

VolumeTriangle getTriangleData(uint32_t triangleIndex)#

Get the triangle data at a particular index in the volume.

Parameters:

triangleIndex – The index of the triangle to retrieve

Returns:

The triangle data

void getVerticesForTriangle(const VolumeTriangle &triangle, glm::vec3 &vertex0, glm::vec3 &vertex1, glm::vec3 &vertex2)#

Get the vertices of a particular triangle.

Parameters:
  • triangle – The triangle from which to return the vertices

  • vertex0 – Output: The first vertex

  • vertex1 – Output: The second vertex

  • vertex2 – Output: The third vertex

bool isVolumeClosed()#

Get if a volume is closed.

Returns:

True if voluem is closed, otherwise false

Protected Functions

uint32_t findOrCreateVertex(const glm::vec3 &vertex, bool &existed)#

Retrieve the index of a vertex by coordinates. If it does not exist, create a new one.

Parameters:
  • vertex – The coordinates of a vertex

  • existed – Output: Is set to true if the vertex already existed, otherwise will be set to false

Returns:

The index of the vertex (existing or new)

uint32_t findOrCreateEdge(const glm::vec3 &v0, const glm::vec3 &v1, bool &existed)#

Retrieve the index of an edge by vertex coordinates. If it does not exist, create a new one.

Parameters:
  • v0 – The coordinates of the first vertex of the edge

  • v1 – The coordinates of the second vertex of the edge

  • existed – Output: Is set to true if the edge already existed, otherwise will be set to false

Returns:

The index of the edge (existing or new)

void findOrCreateTriangle(const glm::vec3 &v0, const glm::vec3 &v1, const glm::vec3 &v2)#

Create a triangle of given coordinates if one does not exist.

Parameters:
  • v0 – The coordinates of the first vertex of the edge

  • v1 – The coordinates of the second vertex of the edge

  • v2 – The coordinates of the third vertex of the edge

Protected Attributes

VolumeMesh _volumeMesh#

The internal data of the mesh.

bool _isClosed#

Is the mesh closed.

struct VolumeEdge#

Represents an edge.

Public Members

uint32_t vertexIndices[2]#

The indexes of the two vertices of the edge.

uint32_t visibilityFlags#

Flags.

struct VolumeMesh#

Preprocessed data needed to create volumes out of a mesh.

Public Functions

inline VolumeMesh()#

Default constructor for a volume mesh.

Public Members

glm::vec3 *vertices#

A pointer to a list of vertices making up the volume.

VolumeEdge *edges#

A pointer to a list of edges between vertices.

VolumeTriangle *triangles#

A pointer to a list of triangles making up the volume.

glm::vec3 minimum#

The minimum vertex.

glm::vec3 maximum#

The maximum vertex.

uint32_t numVertices#

The number of vertices making up the volume.

uint32_t numEdges#

The number of edges making up the volume.

uint32_t numTriangles#

The number of triangles making up the volume.

uint8_t *vertexData#

Vertex data.

bool needs32BitIndices#

Specifies whether 32 bit indicies are required.

struct VolumeTriangle#

Represents an face (triangle).

Public Members

uint32_t vertexIndices[3]#

The indexes of the three vertices of the triangle.

uint32_t edgeIndices[3]#

The indexes of the three vertices of the three edges of the triangle.

glm::vec3 normal#

The normal of the triangle.

int32_t winding#

The winding of the triangle (clockwise / counterclockwise)