AGX Dynamics 2.40.0.0
Loading...
Searching...
No Matches
agxUtil::TrimeshReaderWriter Namespace Reference

Functions for generating Trimesh shapes from meshes, and for serializing them. More...

Functions

AGXPHYSICS_EXPORT agxCollide::RenderDatacreateRenderData (const agx::String &filename, const agx::Matrix3x3 &vertexRotateAndScale=agx::Matrix3x3(), const agx::Vec3 &vertexTranslate=agx::Vec3())
 Create a RenderData object from a supported mesh file (See agxIO::MeshReader::FileType).
 
AGXPHYSICS_EXPORT agxCollide::TrimeshcreateTrimesh (const agx::String &filename, uint32_t trimeshOptions=agxCollide::Trimesh::REMOVE_DUPLICATE_VERTICES, const agx::Matrix3x3 &vertexRotateAndScale=agx::Matrix3x3(), const agx::Vec3 &vertexTranslate=agx::Vec3())
 Create a Trimesh shape from a supported mesh file format (See agxIO::MeshReader::FileType) containing mesh data.
 
AGXPHYSICS_EXPORT agxCollide::TrimeshcreateTrimesh (const agx::Vec3Vector &vertices, const agx::UInt32Vector &indices, uint32_t trimeshOptions=agxCollide::Trimesh::REMOVE_DUPLICATE_VERTICES, const agx::Matrix3x3 &vertexRotateAndScale=agx::Matrix3x3(), const agx::Vec3 &vertexTranslate=agx::Vec3())
 Create a Trimesh shape from vertices and indices.
 
AGXPHYSICS_EXPORT agxCollide::TrimeshcreateTrimesh (const agxCollide::HeightField *heightField)
 Creates a trimesh from an agxCollide::HeightField.
 
AGXPHYSICS_EXPORT agxCollide::TrimeshcreateTrimeshTerrain (const agx::String &filename, agx::Real bottomMargin, uint32_t trimeshOptions=agxCollide::Trimesh::REMOVE_DUPLICATE_VERTICES, const agx::Matrix3x3 &vertexRotateAndScale=agx::Matrix3x3(), const agx::Vec3 &vertexTranslate=agx::Vec3())
 Create a Terrain shape from a supported mesh model file (See agxIO::MeshReader::FileType).
 
AGXPHYSICS_EXPORT bool exportTrimesh (const agxCollide::Trimesh *trimesh, const agx::String &filename)
 Exports trimesh vertex and index data to a mesh file (currently only supporting wavefront obj).
 

Detailed Description

Functions for generating Trimesh shapes from meshes, and for serializing them.

Function Documentation

◆ createRenderData()

AGXPHYSICS_EXPORT agxCollide::RenderData * agxUtil::TrimeshReaderWriter::createRenderData ( const agx::String filename,
const agx::Matrix3x3 vertexRotateAndScale = agx::Matrix3x3(),
const agx::Vec3 vertexTranslate = agx::Vec3() 
)

Create a RenderData object from a supported mesh file (See agxIO::MeshReader::FileType).

This RenderData object can then be attached to a shape for rendering of the shape.

Parameters
filenameFile to create Trimesh from
vertexRotateAndScaleRotation and scale of Trimesh
vertexTranslateTranslation of Trimesh
Returns
pointer to new agxCollide::RenderData object, nullptr if file could not be loaded

◆ createTrimesh() [1/3]

AGXPHYSICS_EXPORT agxCollide::Trimesh * agxUtil::TrimeshReaderWriter::createTrimesh ( const agx::String filename,
uint32_t  trimeshOptions = agxCollide::Trimesh::REMOVE_DUPLICATE_VERTICES,
const agx::Matrix3x3 vertexRotateAndScale = agx::Matrix3x3(),
const agx::Vec3 vertexTranslate = agx::Vec3() 
)

Create a Trimesh shape from a supported mesh file format (See agxIO::MeshReader::FileType) containing mesh data.

Parameters
filenameFile to create Trimesh from
trimeshOptionsOptions set to the created Trimesh
vertexRotateAndScaleRotation and scale of Trimesh
vertexTranslateTranslation of Trimesh
Returns
pointer to new Trimesh shape, nullptr if file could not be loaded

◆ createTrimesh() [2/3]

AGXPHYSICS_EXPORT agxCollide::Trimesh * agxUtil::TrimeshReaderWriter::createTrimesh ( const agx::Vec3Vector vertices,
const agx::UInt32Vector indices,
uint32_t  trimeshOptions = agxCollide::Trimesh::REMOVE_DUPLICATE_VERTICES,
const agx::Matrix3x3 vertexRotateAndScale = agx::Matrix3x3(),
const agx::Vec3 vertexTranslate = agx::Vec3() 
)

Create a Trimesh shape from vertices and indices.

Parameters
vertices- The vertices from which we will create a trimesh
indices- The index array that defines the triangles of the triangle mesh
trimeshOptionsOptions set to the created Trimesh
vertexRotateAndScaleRotation/home/jakobsson/agx/include/agxUtil/TrimeshReaderWriter/TrimeshReaderWriter.h and scale of Trimesh
vertexTranslateTranslation of Trimesh
Returns
pointer to new Trimesh shape, nullptr if file could not be loaded

◆ createTrimesh() [3/3]

AGXPHYSICS_EXPORT agxCollide::Trimesh * agxUtil::TrimeshReaderWriter::createTrimesh ( const agxCollide::HeightField heightField)

Creates a trimesh from an agxCollide::HeightField.

Parameters
heightFieldHeightField to create Trimesh from
Returns
pointer to new Trimesh shape

◆ createTrimeshTerrain()

AGXPHYSICS_EXPORT agxCollide::Trimesh * agxUtil::TrimeshReaderWriter::createTrimeshTerrain ( const agx::String filename,
agx::Real  bottomMargin,
uint32_t  trimeshOptions = agxCollide::Trimesh::REMOVE_DUPLICATE_VERTICES,
const agx::Matrix3x3 vertexRotateAndScale = agx::Matrix3x3(),
const agx::Vec3 vertexTranslate = agx::Vec3() 
)

Create a Terrain shape from a supported mesh model file (See agxIO::MeshReader::FileType).

Note
The mesh model must be a non closed mesh with a typical direction of the normals. Meaning that normals should all have a well defined "up" direction. Closed mesh models (such as a sphere) will generate in invalid Terrain meshes.
Parameters
filenameFile to create Terrain from
bottomMarginBottom margin of the Terrain Trimesh
trimeshOptionsOptions set to the created Trimesh
vertexRotateAndScaleRotation and scale of Trimesh
vertexTranslateTranslation of Trimesh
Returns
pointer to new Terrain shape, nullptr if file could not be loaded

◆ exportTrimesh()

AGXPHYSICS_EXPORT bool agxUtil::TrimeshReaderWriter::exportTrimesh ( const agxCollide::Trimesh trimesh,
const agx::String filename 
)

Exports trimesh vertex and index data to a mesh file (currently only supporting wavefront obj).

This can be useful when creating trimeshes from other sources than 3D data files.

Parameters
trimesh- The trimesh to serialize.
filename- The desired file name
Returns
Was the write operation successful?