NvModel Class Reference

Non-rendering geometry model. More...

#include <NvModel.h>

List of all members.

Public Member Functions

bool loadModelFromFileDataObj (char *fileData)
 Load raw model from OBJ data.
void compileModel (NvModelPrimType::Enum prim=NvModelPrimType::TRIANGLES)
 Process a model into rendering-friendly form.
void computeBoundingBox (nv::vec3f &minVal, nv::vec3f &maxVal)
 Computes an AABB from the data.
void rescale (float radius)
 Rescale the model to the desired radius.
void rescaleToOrigin (float radius)
 Rescale the model to the desired radius and centers it at the origin.
void rescaleWithCenter (nv::vec3f center, nv::vec3f r, float radius)
 Rescale the model to the desired radius.
void addToAllPositions (nv::vec3f center)
 Translate the model vertices by a given vector.
void computeTangents ()
 Compute tangent vectors in the "S" UV direction.
void computeNormals ()
 Compute per-vertex normals.
void removeDegeneratePrims ()
 Remove zero-area/length primitives.
int32_t getIndexCount () const
 Get the length of the index arrays.
const float * getCompiledVertices () const
 Get the array of compiled vertices.
const uint32_t * getCompiledIndices (NvModelPrimType::Enum prim=NvModelPrimType::TRIANGLES) const
 Get the array of compiled indices for the given prim type.
int32_t getCompiledVertexSize () const
 Get the size of a compiled vertex.
int32_t getCompiledVertexCount () const
 Get the count of vertices in the compiled array.
int32_t getCompiledIndexCount (NvModelPrimType::Enum prim=NvModelPrimType::TRIANGLES) const
 The rendering index count.
int32_t getOpenEdgeCount () const
bool hasNormals () const
bool hasTexCoords () const
bool hasTangents () const
bool hasColors () const
int32_t getPositionSize () const
int32_t getNormalSize () const
int32_t getTexCoordSize () const
int32_t getTangentSize () const
int32_t getColorSize () const
void clearNormals ()
void clearTexCoords ()
void clearTangents ()
void clearColors ()
const float * getPositions () const
const float * getNormals () const
const float * getTexCoords () const
const float * getTangents () const
const float * getColors () const
const uint32_t * getPositionIndices () const
const uint32_t * getNormalIndices () const
const uint32_t * getTexCoordIndices () const
const uint32_t * getTangentIndices () const
const uint32_t * getColorIndices () const
int32_t getPositionCount () const
int32_t getNormalCount () const
int32_t getTexCoordCount () const
int32_t getTangentCount () const
int32_t getColorCount () const
int32_t getCompiledPositionOffset () const
int32_t getCompiledNormalOffset () const
int32_t getCompiledTexCoordOffset () const
int32_t getCompiledTangentOffset () const
int32_t getCompiledColorOffset () const

Static Public Member Functions

static NvModelCreate ()
 Create a model.


Detailed Description

Non-rendering geometry model.

Graphics-API-agnostic geometric model class, including model loading from OBJ file data, optimization, bounding volumes and rescaling. Can compute addition items such as facet normals and tangents as needed.


Member Function Documentation

void NvModel::addToAllPositions ( nv::vec3f  center  ) 

Translate the model vertices by a given vector.

Adds the given vector to each vertex.

Parameters:
[in] center the vector to add

void NvModel::clearColors (  ) 

Vertex data removal functions. Removes the given per-vertex attributes from all vertices. Must be called before the model is compiled for rendering!

void NvModel::clearNormals (  ) 

Vertex data removal functions. Removes the given per-vertex attributes from all vertices. Must be called before the model is compiled for rendering!

void NvModel::clearTangents (  ) 

Vertex data removal functions. Removes the given per-vertex attributes from all vertices. Must be called before the model is compiled for rendering!

void NvModel::clearTexCoords (  ) 

Vertex data removal functions. Removes the given per-vertex attributes from all vertices. Must be called before the model is compiled for rendering!

void NvModel::compileModel ( NvModelPrimType::Enum  prim = NvModelPrimType::TRIANGLES  ) 

Process a model into rendering-friendly form.

This function takes the raw model data in the internal structures, and attempts to bring it to a format directly accepted for vertex array style rendering. This means that a unique compiled vertex will exist for each unique combination of position, normal, tex coords, etc that are used in the model. The prim parameter, tells the model what type of index list to compile. By default it compiles a simple triangle mesh with no connectivity.

Parameters:
[in] prim the desired primitive type that will be used for rendering; the target of the compilation operation

void NvModel::computeBoundingBox ( nv::vec3f &  minVal,
nv::vec3f &  maxVal 
)

Computes an AABB from the data.

This function returns the points defining the axis- aligned bounding box containing the model.

Parameters:
[out] minVal the returned minimum corner of the AABB
[out] maxVal the returned maximum corner of the AABB

void NvModel::computeNormals (  ) 

Compute per-vertex normals.

This function computes vertex normals for a model which did not have them. It computes them on the raw data, so it should be done before compiling the model into a HW friendly format.

void NvModel::computeTangents (  ) 

Compute tangent vectors in the "S" UV direction.

This function computes tangents in the s direction on the model. It operates on the raw data, so it should only be used before compiling a model into a HW friendly form. This can cause model expansion, since it can keep vertices from being shared. Thus it should be used only when the results are required by the rendering method

static NvModel* NvModel::Create (  )  [static]

Create a model.

Creates an empty model

int32_t NvModel::getColorCount (  )  const

Raw array length functions.

Returns:
the length (in vertices) of each raw data array Each array has a different length because sharing in the raw data is done per attribute

const uint32_t* NvModel::getColorIndices (  )  const

Raw data index access functions. These arrays map from primitives to the raw per-attribute arrays. Note that in raw form, each vertex attribute array has its own index array. The data in raw form does NOT have the concept of each primitive having indices so a single vertex with all per-vertex data together

const float* NvModel::getColors (  )  const

Raw data access functions. These are to be used to get the raw array data from the file, not the compiled rendering data. Note that in raw form, each vertex attribute array has its own index array

Returns:
a pointer to the raw float array data. This must be used in conjunction with the get*Size functions to determine the number of floats per vertex per attribute

int32_t NvModel::getColorSize (  )  const

Vertex data size queries.

Returns:
the number of elements per vertex for the given attribute (e.g. xyz positions are 3)

int32_t NvModel::getCompiledColorOffset (  )  const

Get the offset within the vertex of each attrib.

Returns:
the offset (in number of floats) of each attrib from the base of the vertex

int32_t NvModel::getCompiledIndexCount ( NvModelPrimType::Enum  prim = NvModelPrimType::TRIANGLES  )  const

The rendering index count.

Parameters:
[in] prim the primitive type of the array whose length is to be returned
Returns:
the number of indices in the given array

const uint32_t* NvModel::getCompiledIndices ( NvModelPrimType::Enum  prim = NvModelPrimType::TRIANGLES  )  const

Get the array of compiled indices for the given prim type.

Computes and returns the array of indices for the given primitive type

Parameters:
[in] prim the primitive type for which indices should be generated
Returns:
pointer to the array of indices

int32_t NvModel::getCompiledNormalOffset (  )  const

Get the offset within the vertex of each attrib.

Returns:
the offset (in number of floats) of each attrib from the base of the vertex

int32_t NvModel::getCompiledPositionOffset (  )  const

Get the offset within the vertex of each attrib.

Returns:
the offset (in number of floats) of each attrib from the base of the vertex

int32_t NvModel::getCompiledTangentOffset (  )  const

Get the offset within the vertex of each attrib.

Returns:
the offset (in number of floats) of each attrib from the base of the vertex

int32_t NvModel::getCompiledTexCoordOffset (  )  const

Get the offset within the vertex of each attrib.

Returns:
the offset (in number of floats) of each attrib from the base of the vertex

int32_t NvModel::getCompiledVertexCount (  )  const

Get the count of vertices in the compiled array.

Returns:
the vertex count in the compiled (renderable) array

int32_t NvModel::getCompiledVertexSize (  )  const

Get the size of a compiled vertex.

Returns:
the size of the merged vertex (in number of floats)

const float* NvModel::getCompiledVertices (  )  const

Get the array of compiled vertices.

The array of the optimized, compiled vertices for rendering

Returns:
the pointer to the start of the first vertex

int32_t NvModel::getIndexCount (  )  const

Get the length of the index arrays.

Returns:
the number of indices in each index array

int32_t NvModel::getNormalCount (  )  const

Raw array length functions.

Returns:
the length (in vertices) of each raw data array Each array has a different length because sharing in the raw data is done per attribute

const uint32_t* NvModel::getNormalIndices (  )  const

Raw data index access functions. These arrays map from primitives to the raw per-attribute arrays. Note that in raw form, each vertex attribute array has its own index array. The data in raw form does NOT have the concept of each primitive having indices so a single vertex with all per-vertex data together

const float* NvModel::getNormals (  )  const

Raw data access functions. These are to be used to get the raw array data from the file, not the compiled rendering data. Note that in raw form, each vertex attribute array has its own index array

Returns:
a pointer to the raw float array data. This must be used in conjunction with the get*Size functions to determine the number of floats per vertex per attribute

int32_t NvModel::getNormalSize (  )  const

Vertex data size queries.

Returns:
the number of elements per vertex for the given attribute (e.g. xyz positions are 3)

int32_t NvModel::getPositionCount (  )  const

Raw array length functions.

Returns:
the length (in vertices) of each raw data array Each array has a different length because sharing in the raw data is done per attribute

const uint32_t* NvModel::getPositionIndices (  )  const

Raw data index access functions. These arrays map from primitives to the raw per-attribute arrays. Note that in raw form, each vertex attribute array has its own index array. The data in raw form does NOT have the concept of each primitive having indices so a single vertex with all per-vertex data together

const float* NvModel::getPositions (  )  const

Raw data access functions. These are to be used to get the raw array data from the file, not the compiled rendering data. Note that in raw form, each vertex attribute array has its own index array

Returns:
a pointer to the raw float array data. This must be used in conjunction with the get*Size functions to determine the number of floats per vertex per attribute

int32_t NvModel::getPositionSize (  )  const

Vertex data size queries.

Returns:
the number of elements per vertex for the given attribute (e.g. xyz positions are 3)

int32_t NvModel::getTangentCount (  )  const

Raw array length functions.

Returns:
the length (in vertices) of each raw data array Each array has a different length because sharing in the raw data is done per attribute

const uint32_t* NvModel::getTangentIndices (  )  const

Raw data index access functions. These arrays map from primitives to the raw per-attribute arrays. Note that in raw form, each vertex attribute array has its own index array. The data in raw form does NOT have the concept of each primitive having indices so a single vertex with all per-vertex data together

const float* NvModel::getTangents (  )  const

Raw data access functions. These are to be used to get the raw array data from the file, not the compiled rendering data. Note that in raw form, each vertex attribute array has its own index array

Returns:
a pointer to the raw float array data. This must be used in conjunction with the get*Size functions to determine the number of floats per vertex per attribute

int32_t NvModel::getTangentSize (  )  const

Vertex data size queries.

Returns:
the number of elements per vertex for the given attribute (e.g. xyz positions are 3)

int32_t NvModel::getTexCoordCount (  )  const

Raw array length functions.

Returns:
the length (in vertices) of each raw data array Each array has a different length because sharing in the raw data is done per attribute

const uint32_t* NvModel::getTexCoordIndices (  )  const

Raw data index access functions. These arrays map from primitives to the raw per-attribute arrays. Note that in raw form, each vertex attribute array has its own index array. The data in raw form does NOT have the concept of each primitive having indices so a single vertex with all per-vertex data together

const float* NvModel::getTexCoords (  )  const

Raw data access functions. These are to be used to get the raw array data from the file, not the compiled rendering data. Note that in raw form, each vertex attribute array has its own index array

Returns:
a pointer to the raw float array data. This must be used in conjunction with the get*Size functions to determine the number of floats per vertex per attribute

int32_t NvModel::getTexCoordSize (  )  const

Vertex data size queries.

Returns:
the number of elements per vertex for the given attribute (e.g. xyz positions are 3)

bool NvModel::hasColors (  )  const

Vertex data existence queries.

Returns:
true if the given vertex attribute exists in the primitive and false if not

bool NvModel::hasNormals (  )  const

Vertex data existence queries.

Returns:
true if the given vertex attribute exists in the primitive and false if not

bool NvModel::hasTangents (  )  const

Vertex data existence queries.

Returns:
true if the given vertex attribute exists in the primitive and false if not

bool NvModel::hasTexCoords (  )  const

Vertex data existence queries.

Returns:
true if the given vertex attribute exists in the primitive and false if not

bool NvModel::loadModelFromFileDataObj ( char *  fileData  ) 

Load raw model from OBJ data.

Loads a model from the given block of raw OBJ-file data

Parameters:
[in] fileData a pointer to the in-memory representation of the OBJ file. This data is not cached locally and can be freed once the function returns
Returns:
true on success and false on failure

void NvModel::removeDegeneratePrims (  ) 

Remove zero-area/length primitives.

Removes primitives that will add nothing to the rendered result

void NvModel::rescale ( float  radius  ) 

Rescale the model to the desired radius.

Rescales object based on bounding box such that the new bounding box "radius" (half the diagonal of the bounding box) is the given target value

Parameters:
[in] radius the desired target radius of the geometry

void NvModel::rescaleToOrigin ( float  radius  ) 

Rescale the model to the desired radius and centers it at the origin.

Rescales object based on bounding box such that the new bounding box "radius" (half the diagonal of the bounding box) is the given target value and translates the vertices so that the bounding box is centered at the origin

Parameters:
[in] radius the desired target radius of the geometry

void NvModel::rescaleWithCenter ( nv::vec3f  center,
nv::vec3f  r,
float  radius 
)

Rescale the model to the desired radius.

Rescales object about the given center-point, based on bounding box such that the new bounding box "radius" (half the diagonal of the bounding box) is the given target value. Scaling factor is the ratio of the max component of the old radius versus the target radius

Parameters:
[in] center the centerpoint about which to scale
[in] r the old "radius" vector
[in] radius the desired target radius of the geometry


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