Vortex Studio SDK Classes Documentation
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Vx::VxTriangleMeshUVGrid Class Reference

Triangle mesh geometry with spatial hashing of triangles in a hierarchical UV grid. More...

#include <Vx/VxTriangleMeshUVGrid.h>

+ Inheritance diagram for Vx::VxTriangleMeshUVGrid:

Classes

struct  CellInfo
 Cell information object. More...
 
class  Parameters
 The nested Parameters class is used to specify parameters for subdivision of a VxTriangleMeshUVGrid. More...
 

Public Types

typedef std::function< bool(size_t)> CancelCallbackFn
 Cancel callback function used during terrain creation. More...
 
- Public Types inherited from Vx::VxGeometry
enum  eSmallestEnclosingLockedAxes {
  kNoAxis = -1, kXAxis, kYAxis, kZAxis,
  kAllAxes
}
 Enum for specifying locked axes. More...
 

Public Member Functions

 VxTriangleMeshUVGrid (unsigned int iTriangleCount=0)
 Constructor. More...
 
virtual VxTriangleMeshUVGridclone () const
 Clones the geometry. More...
 
void computeVerticesNormal (double hardEdgeThreshold=0)
 Precomputes all vertex normals (and allocates the memory). More...
 
bool createTerrain (const CancelCallbackFn *cancelCB=nullptr)
 Creates terrain with its current terrain parameters . More...
 
bool createTerrain (const Parameters &params, const CancelCallbackFn *cancelCB=nullptr)
 Creates a terrain from the provided input Parameters. More...
 
bool createTerrain (int uAxis, int vAxis, int subdivisionCountU, int subdivisionCountV, int maxDepth, int deepSubdivisionCount, int trianglePerBinMinCount, double radius=0.0, const CancelCallbackFn *cancelCB=nullptr)
 Creates the terrain from the vertices and triangles given via setExternalVertices(). More...
 
void deform ()
 Updates all the cells containing modified vertices and clears modification memory. More...
 
void flattenOrphanEdges (bool b)
 Allows forcing collision normals on orphan edges to be the triangle normals. More...
 
void getCellInfo (int u, int v, CellInfo &outCell) const
 Gets cell information for cell (u,v). More...
 
void getCellInfo (VxArray< CellInfo > &inOutCells) const
 Gets cell info for all leaf cells inside this grid. More...
 
void getCellSize (double *sizeu, double *sizev) const
 Returns the terrain cell sizes along U and V (optimally sizeu/sizev ~ 1).
 
size_t getCellTriangleCount (int uCell, int vCell) const
 Returns the number of triangles in the given cell. More...
 
void getCellTriangleCountStatistics (int &aveTriangleCount, int &minTriangleCount, int &maxTriangleCount, int &triangleRefCount, int &cellCount) const
 Gets statistics about the number of triangles referenced in the cells of this grid; the average, minimum and maximum triangle count in the cells, and the number of leaf cells (the cells at the finest level). More...
 
virtual const char * getClassName () const
 Returns the class name.
 
int getCreateTerrainLastID ()
 Returns the ID of the last created terrain mesh ID becomes incremented each time createTerrain is called.
 
int getCurrentTriangleBufferSize () const
 Gets the maximum triangle list size, that is, the maximum number of triangles that can be tested against in a given interaction during collision detection.
 
double getElevation (double U, double V, VxReal3Ptr outNormal, int *outTriangleIndex, double maxHeight=VX_INFINITY) const
 Returns the terrain elevation at horizontal position U and V, its normal and the normal's index if the triangle has a normal.
 
double getElevation (VxReal3 pos, VxReal3Ptr outNormal, int *outTriangleIndex, double maxHeight=VX_INFINITY) const
 Returns the terrain elevation at the input position, its normal and the normal's index if the triangle has a normal. More...
 
int getMaxDepth () const
 Returns the maximum number of hierarchical subdivisions allowable.
 
double getMinMaxElevation (VxReal4 pos, double rad, double *outMinHeight, double *outMaxHeight) const
 Returns the minimum and maximum terrain elevation under input bounding sphere.
 
double getMinMaxElevation (VxReal3 bbmin, VxReal3 bbmax, double *outMinHeight, double *outMaxHeight) const
 Returns the minimum and maximum terrain elevation under the input bounding box.
 
void getNumCellGrid (int &nu, int &nv) const
 Returns the number of cells along the U and V axes.
 
bool getSurfaceNormal (int triIndex, const VxReal3 &p, VxReal3 &n, double hardEdgeTreshold=0) const
 Returns the interpolated normal the specified of triangle and its position p inside the triangle in local geometry frame. More...
 
const ParametersgetTerrainParameters () const
 Gets the subdivision parameters for this VxTriangleMeshUVGrid.
 
void getTriangle (int i, VxReal3 p0, VxReal3 p1, VxReal3 p2, VxReal3 normal) const
 Returns the vertices and normal for the specified triangle.
 
size_t getTriangleCount () const
 Gets the total number of triangles.
 
void getTriangleInfo (int triangleIndex, VxReal3 vertex0, VxReal3 vertex1, VxReal3 vertex2, VxReal3 normal, int mateIndices[3], VxReal3 mateNormalCos, VxReal3 mateNormalSin) const
 Gets information about the specified triangle. More...
 
void getTriangles (const VxOBB &inOBB, Vx::VxArray< size_t > &outTriIndices) const
 Gets indices of triangles overlapping the given oriented bounding box inOBB. More...
 
int getTriangleTag (int i) const
 Gets the triangle tag for specified triangle. More...
 
void getTriangleVertexAndNormalPointers (int i, VxReal3Ptr *p0, VxReal3Ptr *p1, VxReal3Ptr *p2, VxReal3Ptr *normal) const
 Returns pointers to the vertices and normal of the specified triangle.
 
void getTriangleVertexPointers (int i, VxReal3Ptr *p0, VxReal3Ptr *p1, VxReal3Ptr *p2) const
 Returns pointers to the vertices of the specified triangle.
 
int getUpAxis () const
 Returns the coordinate index of the up axis or -1 if the terrain has not been created.
 
bool getVerticesNormal (int triIndex, VxReal3 n0, VxReal3 n1, VxReal3 n2) const
 Returns the vertices normals for the specified triangle . More...
 
int intersectWithAABB (VxReal3 bbmin, VxReal3 bbmax, VxArray< int > *outTriIndices) const
 Generates an array of indices for the terrain triangles (returned in outTriIndices), which overlap the specified bounding box. More...
 
bool loadFromObjFile (const char *fileName, double scale=1, bool merge=false, double mergeEps=0.0, bool flipNormals=false, VxReal44 tm=0, VxTriangleFilter *filter=0)
 Creates a terrain from an .obj file. More...
 
void removeTriangleFromGrid (int index)
 Removes the specified triangle from the terrain grid. More...
 
void setExternalVertices (VxReal3 *vertices, VxReal3Ptr *verticesPtr, int vCount, int tCount)
 Sets the vertex and triangle list. More...
 
void setInitialTriangleBufferSize (int maxsize)
 Sets the maximum triangle list size. More...
 
void setMaxDepth (int iDepth)
 Sets the maximum number of hierarchical subdivisions allowable. More...
 
void setTriangleAngles (int triangleIndex, int edgeIndex, double mateNormalCos, double mateNormalSin)
 Sets the cosine and sine values between normals of the specified triangle at the given edgeIndex (0, 1 or 2). More...
 
void setTriangleHeightAndNormal (int triangleIndex, double h0, double h1, double h2, VxReal3 tn=NULL)
 Sets the height (along the Up-axis in the local subdivision frame of the terrain) of the 3 vertices of a triangle and its normal. More...
 
void setTriangleTag (int i, int tag)
 Sets the triangle tag for the specified triangle.
 
void takeVertexOwnership ()
 Tells the terrain to take ownership of an externally provided vertex and triangle list. More...
 
- Public Member Functions inherited from Vx::VxGeometry
VXCORE_SYMBOL VxGeometry ()
 Default constructor.
 
virtual VXCORE_SYMBOL ~VxGeometry ()
 Destructor.
 
VXCORE_SYMBOL void addOwner (Vx::VxCollisionGeometry *owner)
 Adds the collision geometry as owner .
 
virtual VXCORE_SYMBOL bool build ()
 Build this geometry. More...
 
virtual VXCORE_SYMBOL void computeSmallestEnclosing (const VxArray< VxVector3 > &points, VxTransform *inOutTM, VxGeometry::eSmallestEnclosingLockedAxes lockedAxes=VxGeometry::kNoAxis, bool isPositionLocked=false)
 Resizes the geometry and computes the new global position and orientation (inOutTm), such that the given set of points is covered while minimizing the volume. More...
 
virtual VXCORE_SYMBOL void computeSmallestEnclosing (const VxVector3 *inPoints, size_t numPoints, VxTransform *inOutTM, VxGeometry::eSmallestEnclosingLockedAxes lockedAxes=VxGeometry::kNoAxis, bool isPositionLocked=false)
 Resizes the geometry and computes the new global position and orientation (inOutTm), such that the given set of points is covered while minimizing the volume. More...
 
VXCORE_SYMBOL const
MaterialPointerArray
createMaterialMap (int size, VxMaterial *iDefaultMaterial)
 Creates a new material map of the specified size and with the specified default material. More...
 
VXCORE_SYMBOL void getBoundingBox (const VxReal44 tm, VxReal3 minCorner, VxReal3 maxCorner) const
 Gets the axis aligned bounding box for the geometry in a specified coordinate system. More...
 
VXCORE_SYMBOL void getBoundingSphere (VxReal3 center, double *radius) const
 Gets the bounding sphere of the geometry in local space. More...
 
VXCORE_SYMBOL double getBoundingSphereRadius () const
 Returns the bounding sphere radius in local coordinates.
 
VXCORE_SYMBOL const VxVector3getCOM ()
 Gets the center of mass from this geometry's mass properties . More...
 
VXCORE_SYMBOL void getExtremePoint (const VxReal44 tm, const VxReal3 inDir, VxReal3 outPoint) const
 Returns the extreme point in the specified direction on the geometry. More...
 
const MaterialPointerArraygetMaterialMap () const
 Returns the material map Only use getMaterialMap() to inspect the materials used in the VxGeometry. More...
 
VXCORE_SYMBOL const VxArray
< VxCollisionGeometry * > & 
getOwners () const
 Returns a list of the VxCollisionGeometry objects that own this geometry. More...
 
VXCORE_SYMBOL double getVolume ()
 Gets the volume from this geometry's mass properties . More...
 
VXCORE_SYMBOL bool hasOwner (Vx::VxCollisionGeometry *owner) const
 Returns true if the specified collision geometry owns this geometry.
 
virtual VXCORE_SYMBOL bool isBuilt () const
 Returns true if geometry was successfully built.
 
VXCORE_SYMBOL bool isHole () const
 Returns true if the geometry type is one of the following: More...
 
VXCORE_SYMBOL void removeOwner (Vx::VxCollisionGeometry *owner)
 Removes the collision geometry as owner .
 
virtual VXCORE_SYMBOL void setDimensions (const Vx::VxVector3 &)
 Sets the size dimensions for the geometry. More...
 
VXCORE_SYMBOL bool setMaterial (int index, VxMaterial *material)
 Assigns a material to the geometry feature with the given index. More...
 
VXCORE_SYMBOL void updateOwners ()
 Updates the owners of this geometry (see addOwner() and VxCollisionGeometry::setAutomaticGeometryOwner). More...
 
- Public Member Functions inherited from Vx::VxBaseUserData
VXCORE_SYMBOL VxBaseUserData ()
 Default constructor.
 
virtual VXCORE_SYMBOL ~VxBaseUserData ()
 Destructor.
 
void * getUserDataPtr () const
 Get pointer to generic user data.
 
void setUserDataPtr (void *dataPtr)
 Set pointer to generic user data. More...
 
VXCORE_SYMBOL const
VxUserDataContainer
userData () const
 Accessor for user data (const version)
 
VXCORE_SYMBOL VxUserDataContaineruserData ()
 Accessor for user data.
 
- Public Member Functions inherited from Vx::VxBase
unsigned int getCreationIndex () const
 Access the creation index of the instance.
 
const char * getName () const
 Retrieves the name. More...
 
void setCombinedName (const char *base, const char *name, size_t i=0)
 Utility to set the name to a concatenate string = base_name_i.
 
virtual void setName (const char *name)
 Sets the name.
 
- Public Member Functions inherited from Vx::VxRefCount
VxRefCountoperator= (const VxRefCount &rhs)=delete
 Assignment operator must not be used.
 
void ref () const
 Increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
int referenceCount () const
 Return the number pointers currently referencing this object.
 
void unref () const
 Decrement the reference count by one, indicating that a pointer to this object is no longer referencing it. More...
 
void unref_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 

Static Public Attributes

Mate Indices

Defines information about the triangles adjacent to this one (from VxTriangleBin class).

static int kNoNeighbor
 No mate.
 
static int kNoAngle
 Not a valid angle.
 
static int kDirtyAngle
 Dirty angle. More...
 

Protected Member Functions

bool loadFromFile (const char *fileName, double scale=1, bool merge=false, double mergeEps=0.0, bool flipNormals=false, VxReal44 tm=0, VxTriangleFilter *filter=0)
 Loads triangles from an obj or ase file. More...
 

Protected Attributes

int mTriListSize
 Maximum number of triangles in a cell.
 

Additional Inherited Members

- Static Public Member Functions inherited from Vx::VxGeometry
static VXCORE_SYMBOL int getDefaultRequestID (const VxGeometry *g)
 Returns the default request id for the given geometry. More...
 

Detailed Description

Triangle mesh geometry with spatial hashing of triangles in a hierarchical UV grid.

Subdivides the environment into rectangular cells along local U and V axes based on the given subdivision parameters . If a maximal subdivision depth is given at creation, the cells can be subdivided recursively creating a hierarchical grid.

Member Typedef Documentation

typedef std::function<bool (size_t )> Vx::VxTriangleMeshUVGrid::CancelCallbackFn

Cancel callback function used during terrain creation.

If ongoing operation should be cancelled function must return true. Current subdivision depth is provided as input argument to the function.

Constructor & Destructor Documentation

Vx::VxTriangleMeshUVGrid::VxTriangleMeshUVGrid ( unsigned int  iTriangleCount = 0)

Constructor.

The user needs to specify triangles , then call createTerrain() to specify the terrain creation parameters. If the number of triangles that the VxTriangleMeshUVGrid will contain is known, it can be specified by setting iTriangleCount. This argument defaults to zero.

If, at the end of the creation, the terrain contains less triangles than iTriangleCount, the extra memory is not returned.

Member Function Documentation

virtual VxTriangleMeshUVGrid* Vx::VxTriangleMeshUVGrid::clone ( ) const
virtual

Clones the geometry.

Reimplemented in each sub-class.

Implements Vx::VxGeometry.

void Vx::VxTriangleMeshUVGrid::computeVerticesNormal ( double  hardEdgeThreshold = 0)

Precomputes all vertex normals (and allocates the memory).

Parameters
[in]hardEdgeThresholdDefines the min dot product between 2 adjacent triangles's hard edge consideration.
bool Vx::VxTriangleMeshUVGrid::createTerrain ( const CancelCallbackFn cancelCB = nullptr)

Creates terrain with its current terrain parameters .

Ongoing terrain creation process can be cancelled via optional cancel callback function cancelCB. When cancelled, hierarchical subdivision process is halted at the current depth.

Returns
true on success.
bool Vx::VxTriangleMeshUVGrid::createTerrain ( const Parameters params,
const CancelCallbackFn cancelCB = nullptr 
)

Creates a terrain from the provided input Parameters.

Ongoing terrain creation process can be cancelled via optional cancel callback function cancelCB. When cancelled, hierarchical subdivision process is halted at the current depth.

Returns
true on success.
bool Vx::VxTriangleMeshUVGrid::createTerrain ( int  uAxis,
int  vAxis,
int  subdivisionCountU,
int  subdivisionCountV,
int  maxDepth,
int  deepSubdivisionCount,
int  trianglePerBinMinCount,
double  radius = 0.0,
const CancelCallbackFn cancelCB = nullptr 
)

Creates the terrain from the vertices and triangles given via setExternalVertices().

Parameters
[in]uAxisThe axis of the local frame corresponding to the U axis in the terrain subdivision frame (0->x,1->y,2->z)
[in]vAxisThe axis of the local frame corresponding to the V axis in the terrain subdivision frame (0->x,1->y,2->z)
[in]subdivisionCountUThe number of subdivision cells at the coarsest level in the U axis of the terrain
[in]subdivisionCountVThe number of subdivision cells at the coarsest level in the V axis of the terrain
[in]maxDepthThe maximal number of hierarchical subdivisions (0 == no subdivision => only one level)
[in]deepSubdivisionCountThe number of subdivision cells at a deep level in the longer axis of the terrain
[in]trianglePerBinMinCountThe minimal number of triangles desired in a cell (if this number is reached, the cell won't be subdivided)
[in]radiusOptional and only for advanced users. If zero, an object can collide with triangles from more than one cell (normal use). If not zero, only triangles of one cell + neighbors triangles closer than radius distance can collide.
Note
If maxDepth==0 then deepSubdivisionCount and trianglePerBinMinCount are not used
Returns
true on success.
void Vx::VxTriangleMeshUVGrid::deform ( )

Updates all the cells containing modified vertices and clears modification memory.

Modifications are created by calling VxTriangleMeshUVGrid::setTriangleHeightAndNormal().

Warning
This function is only available for a non-hierarchical terrain, that is, if Parameters::getMaxDepth is zero.
The terrain must not be static (terrainPart->setControl(VxPart::kControlStatic);)
Note
A call to this function can be made after several setTriangleHeightAndNormal() calls in order to limit the computations. In fact, it is recommended to call this function more than once if several sufficiently separate zones in the mesh are modified. Calling this function once per separate zone after the modifications of the given zone are finished will greatly reduce workload.
void Vx::VxTriangleMeshUVGrid::flattenOrphanEdges ( bool  b)

Allows forcing collision normals on orphan edges to be the triangle normals.

This option may be useful for collision detection with terrain with cracks. If b is false the terrain is restored to its original state.

void Vx::VxTriangleMeshUVGrid::getCellInfo ( int  u,
int  v,
CellInfo outCell 
) const

Gets cell information for cell (u,v).

See Also
CellInfo
void Vx::VxTriangleMeshUVGrid::getCellInfo ( VxArray< CellInfo > &  inOutCells) const

Gets cell info for all leaf cells inside this grid.

See Also
CellInfo
size_t Vx::VxTriangleMeshUVGrid::getCellTriangleCount ( int  uCell,
int  vCell 
) const

Returns the number of triangles in the given cell.

Note
The specified U and V values must be smaller than maximum values in U and V.
void Vx::VxTriangleMeshUVGrid::getCellTriangleCountStatistics ( int &  aveTriangleCount,
int &  minTriangleCount,
int &  maxTriangleCount,
int &  triangleRefCount,
int &  cellCount 
) const

Gets statistics about the number of triangles referenced in the cells of this grid; the average, minimum and maximum triangle count in the cells, and the number of leaf cells (the cells at the finest level).

Parameters
[out]aveTriangleCountAverage number of triangles referenced in the leaf cells of this grid.
[out]minTriangleCountMinimum number of triangles referenced in the leaf cells of this grid.
[out]maxTriangleCountMaximum number of triangles referenced in the leaf cells of this grid.
[out]triangleRefCountSum of triangle references in all cells
[out]cellCountNumber of cells in this grid.
double Vx::VxTriangleMeshUVGrid::getElevation ( VxReal3  pos,
VxReal3Ptr  outNormal,
int *  outTriangleIndex,
double  maxHeight = VX_INFINITY 
) const

Returns the terrain elevation at the input position, its normal and the normal's index if the triangle has a normal.

Note
If the terrain is not yet constructed, output arguments are left untouched.
bool Vx::VxTriangleMeshUVGrid::getSurfaceNormal ( int  triIndex,
const VxReal3 p,
VxReal3 n,
double  hardEdgeTreshold = 0 
) const

Returns the interpolated normal the specified of triangle and its position p inside the triangle in local geometry frame.

This function requires the vertex normals (see setVerticesNormal()).

Computes and returns the interpolated normal of the specified triangle at the given position.

Parameters
[in]triIndexSpecify the index of the triangle to consider
[in]pPosition at which to interpolate the normal set in local reference frame of this geometry. The position must be located on the triangle or on its edges (not validated).
[in,out]nInterpolated normal calculated and returned by this function set in local reference frame of this geometry
[in]hardEdgeTresholdDefines the min dot product between 2 adjacent triangles.
Note
This function requires the vertex normals to be computed (see setVerticesNormal()).
Returns
false if vertex normals were not computed or if the given triangle is degenerated.
true otherwise
void Vx::VxTriangleMeshUVGrid::getTriangleInfo ( int  triangleIndex,
VxReal3  vertex0,
VxReal3  vertex1,
VxReal3  vertex2,
VxReal3  normal,
int  mateIndices[3],
VxReal3  mateNormalCos,
VxReal3  mateNormalSin 
) const

Gets information about the specified triangle.

Parameters
[in]triangleIndexThe index of the triangle to consider
[out]vertex0The position of the first vertex of the triangle
[out]vertex1The position of the second vertex of the triangle
[out]vertex2The position of the third vertex of the triangle
[out]normalThe Normal of the triangle
[out]mateIndicesThe indices of the 3 mates: triangles adjacent to this one (kNoNeighbor == -1 == no neighbor)
[out]mateNormalCosThe cosine between the triangle's normals with all mates (kNoAngle == -2 == not a valid cosine, kDirtyAngle == -3 == a dirty cos -> call deform())
[out]mateNormalSinThe sine between the triangle's normals with all mates (kNoAngle == -2 == not a valid cosine, kDirtyAngle == -3 == a dirty cos -> call deform())
void Vx::VxTriangleMeshUVGrid::getTriangles ( const VxOBB inOBB,
Vx::VxArray< size_t > &  outTriIndices 
) const

Gets indices of triangles overlapping the given oriented bounding box inOBB.

The oriented bounding box is defined in the terrain's frame of reference.

int Vx::VxTriangleMeshUVGrid::getTriangleTag ( int  i) const

Gets the triangle tag for specified triangle.

Initially after build(), it is the triangle index in the user triangle list as set by setExternalVertices() or loadFromFile(), before the optional filter subscribers were applied and before flat triangles were culled.

This tag can be read in the universe intersect subscriber by using the VxIntersectResult::getContactIndices() function

bool Vx::VxTriangleMeshUVGrid::getVerticesNormal ( int  triIndex,
VxReal3  n0,
VxReal3  n1,
VxReal3  n2 
) const

Returns the vertices normals for the specified triangle .

If the vertices normals were not computed, computeVertexNormals will compute them with hard-edge to 0.

int Vx::VxTriangleMeshUVGrid::intersectWithAABB ( VxReal3  bbmin,
VxReal3  bbmax,
VxArray< int > *  outTriIndices 
) const

Generates an array of indices for the terrain triangles (returned in outTriIndices), which overlap the specified bounding box.

Note
This method assumes the bounding box to be transformed into terrain space.
bool Vx::VxTriangleMeshUVGrid::loadFromFile ( const char *  fileName,
double  scale = 1,
bool  merge = false,
double  mergeEps = 0.0,
bool  flipNormals = false,
VxReal44  tm = 0,
VxTriangleFilter filter = 0 
)
protected

Loads triangles from an obj or ase file.

Warning
A call to createTerrain() is required after this method.

If merge is true, vertices with coordinates that differ by no more than mergeEps will be merged. Merging the triangles greatly improves collision detection as the adjacent triangle is used to validate contact normals.

If flipNormals is true, triangles will be reversed leading to flipped normals.

Warning
If some triangles are rejected, the triangle's tag won't match the triangle's index in the resulting terrain. The tags can be reset (see setTriangleTag()).
bool Vx::VxTriangleMeshUVGrid::loadFromObjFile ( const char *  fileName,
double  scale = 1,
bool  merge = false,
double  mergeEps = 0.0,
bool  flipNormals = false,
VxReal44  tm = 0,
VxTriangleFilter filter = 0 
)
inline

Creates a terrain from an .obj file.

Warning
A call to createTerrain() is required after this method.

If merge is true, vertices with coordinates that differ by no more than mergeEps will be merged. Merging the triangles greatly improves collision detection as the adjacent triangle is used to validate contact normals.

If flipNormals is true, triangles will be reversed leading to flipped normals.

void Vx::VxTriangleMeshUVGrid::removeTriangleFromGrid ( int  index)

Removes the specified triangle from the terrain grid.

The removed triangle won't collide anymore. The triangle count is not affected by this call.

void Vx::VxTriangleMeshUVGrid::setExternalVertices ( VxReal3 vertices,
VxReal3Ptr *  verticesPtr,
int  vCount,
int  tCount 
)

Sets the vertex and triangle list.

Parameters
[in]verticesThe complete list of vertices. The block of memory pointed to by this list must not be deleted during the life time of this VxTriangleMeshUVGrid.
[in]verticesPtrList of vertex pointers on the vertices list so that the first 3 represent the first triangle, the next 3 the second triangle, and so on.
[in]vCountThe vertices count
[in]tCountThe triangle count (see takeVertexOwnership()).
Note
The triangle vertices must be oriented counter-clockwise when looking from the outside of the object in order to obtain correct collision normals. In addition, thin constructs that might be approached from both sides such as zero thickness fences or walls will not work properly if approached from one of the sides. Displaying dynamic contacts might help in solving such problems. Contacts should point from the terrain outside.
This call must be followed by a call to createTerrain().
Warning
Triangles used for collision are effectively copies, so modifying the input array has no effect on the collision. A terrain can be deformed by calling setTriangleHeightAndNormal() and then deform().
void Vx::VxTriangleMeshUVGrid::setInitialTriangleBufferSize ( int  maxsize)

Sets the maximum triangle list size.

Must be called before createTerrain().

This value might be overridden during terrain creation if it is smaller than the maximum number of triangles in a cell. Note that this value might still be too small since an object could collide against more than one cell at a given time, in which case the value will be increased again.

void Vx::VxTriangleMeshUVGrid::setMaxDepth ( int  iDepth)

Sets the maximum number of hierarchical subdivisions allowable.

Warning
The value of iDepth must be <= to the max depth used during the construction of the terrain.
Note
This call has no effect before the terrain is created (see createTerrain()).
void Vx::VxTriangleMeshUVGrid::setTriangleAngles ( int  triangleIndex,
int  edgeIndex,
double  mateNormalCos,
double  mateNormalSin 
)

Sets the cosine and sine values between normals of the specified triangle at the given edgeIndex (0, 1 or 2).

If the edge has a neighbor triangle, the neighbor is also changed.

void Vx::VxTriangleMeshUVGrid::setTriangleHeightAndNormal ( int  triangleIndex,
double  h0,
double  h1,
double  h2,
VxReal3  tn = NULL 
)

Sets the height (along the Up-axis in the local subdivision frame of the terrain) of the 3 vertices of a triangle and its normal.

Parameters
[in]triangleIndexThe index of the considered triangle
[in]h0The height of the first vertex of the triangle
[in]h1The height of the second vertex of the triangle
[in]h2The height of the third vertex of the triangle
[in]tnThe normal of the triangle (if NULL, it is computed automatically)
Warning
This function is only available for a non-hierarchical terrain, that is, if Parameters::getMaxDepth is zero.
To update the terrain, the VxTriangleMeshUVGrid::deform() function must be called.
void Vx::VxTriangleMeshUVGrid::takeVertexOwnership ( )

Tells the terrain to take ownership of an externally provided vertex and triangle list.

This means that the lists will be deleted by the terrain by its destructor (see setExternalVertices()).

Giving ownership to VxTriangleMeshUVGrid allows serializing the vertices when the VxTriangleMeshUVGrid is saved.

Note
The externally provided vertex must not be deleted during the life time of this VxTriangleMeshUVGrid.
Make sure that the externally provided vertex is allocated dynamically and not directly allocated from the stack.

Member Data Documentation

int Vx::VxTriangleMeshUVGrid::kDirtyAngle
static

Dirty angle.

The deform() function should be called to update angles by taking into account triangle modifications.