Support Forum       G3D Web Page     
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
G3D::ArticulatedModel Class Reference


A 3D object composed of multiple rigid triangle meshes connected by joints. More...

Inherits G3D::Model.

Classes

class  Animation
 A keyframe-based animation. More...
 
class  BoundsCallback
 Computes the world-space bounds of this model. More...
 
class  CleanGeometrySettings
 Parameters for cleanGeometry(). More...
 
class  Geometry
 Vertex information without an index array connecting them into triangles. More...
 
class  GeometryCallback
 
class  Instruction
 Preprocessing instruction. More...
 
class  Mesh
 A set of primitives (e.g., triangles) that share a material. More...
 
class  MeshCallback
 
class  MeshMergeCallback
 Merges meshes within the part based on their Materials. More...
 
class  Part
 
The reference frame for a Mesh or Bone. More...
 
class  PartCallback
 Base class for defining operations to perform on each part, in hierarchy order. More...
 
class  Pose
 Specifies the transformation that occurs at each node in the heirarchy. More...
 
class  PoseSpline
 
class  RemoveMeshCallback
 
class  ReverseWindingCallback
 
class  ScaleAndOffsetTexCoordCallback
 
class  ScaleGeometryTransformCallback
 Rescales each geometry by a constant factor. More...
 
class  ScalePartTransformCallback
 Rescales each part (and the position of its cframe) by a constant factor. More...
 
class  SetTwoSidedCallback
 
class  Specification
 Parameters for constructing a new ArticulatedModel from a file on disk. More...
 

Public Member Functions

 ~ArticulatedModel ()
 
GeometryaddGeometry (const String &name)
 
MeshaddMesh (const String &name, Part *part, Geometry *geom)
 
PartaddPart (const String &name, Part *parent=nullptr)
 
virtual const StringclassName () const override
 Name of the G3D::Model subclass. More...
 
void cleanGeometry (const CleanGeometrySettings &settings=CleanGeometrySettings())
 
Invokes Geometry::cleanGeometry on all meshes. More...
 
void clearGPUArrays ()
 Call this if you change the underlying CPU data and have not manually invoked the corresponding clear calls on the exact meshes and geometry affected. More...
 
void computeBounds ()
 Update the bounds on all meshes (without cleaning them) More...
 
void computePartTransforms (Table< Part *, CFrame > &partTransforms, Table< Part *, CFrame > &prevPartTransforms, const CoordinateFrame &cframe, const Pose &pose, const CoordinateFrame &prevCFrame, const Pose &prevPose)
 Fills partTransforms with full joint-to-world transforms. More...
 
void countTrianglesAndVertices (int &tri, int &vert) const
 
void forEachGeometry (GeometryCallback &c, const Any &source=Any())
 Applies the callback to all meshes in the model. More...
 
void forEachMesh (MeshCallback &c, const Any &source=Any())
 Applies the callback to all meshes in the model. More...
 
void forEachPart (PartCallback &c, const CoordinateFrame &cframe=CoordinateFrame(), const Pose &pose=defaultPose())
 Walks the hierarchy and invokes PartCallback c on each Part, where each model is in pose and the entire model is relative to cframe. More...
 
Geometrygeometry (const String &partName)
 Get a Geometry by name. More...
 
const Array< Geometry * > & geometryArray () const
 
void getAnimation (const String &name, Animation &animation)
 
void getAnimationNames (Array< String > &animationNames)
 
void getBoundingBox (AABox &box)
 Finds the bounding box of this articulated model. More...
 
void getSkeletonLines (const Pose &pose, const CFrame &cframe, Array< Point3 > &skeleton)
 Appends pairs of points to skeleton representing each bone in this model in the given Pose relative to the cframe. More...
 
void getSkeletonLines (const CFrame &cframe, Array< Point3 > &skeleton)
 Uses the previous pose. More...
 
virtual bool intersect (const Ray &ray, const CoordinateFrame &cframe, float &maxDistance, Model::HitInfo &info=Model::HitInfo::ignore, const Entity *entity=nullptr, const Model::Pose *pose=nullptr) const override
 Per-triangle ray-model intersection. More...
 
void maybeCompactArrays ()
 If this model's memory footprint is large, trim all of the internal CPU arrays to size. More...
 
Meshmesh (const String &meshName)
 Get a Mesh by name. More...
 
Meshmesh (int ID)
 
const Array< Mesh * > & meshArray () const
 
virtual const Stringname () const override
 Name of the instance (usually based on the filename it is loaded from) More...
 
Partpart (const String &partName)
 Get a Part by name. More...
 
void pose (Array< shared_ptr< Surface > > &surfaceArray, const CFrame &rootFrame, const CFrame &prevFrame, const shared_ptr< Entity > &entity, const Model::Pose *pose, const Model::Pose *prevPose, const Surface::ExpressiveLightScatteringProperties &e) override
 This will be replaced soon with a version that takes a shared_ptr<Pose>. More...
 
const Array< Part * > & rootArray () const
 Root parts. More...
 
void saveGeometryAsCode (const String &filename, bool compress=false)
 Saves C++ code for generating the geometry of mesh[0]. More...
 
void saveOBJ (const String &filename)
 Saves an OBJ with the given filename of this ArticulatedModel materials currently only work if loaded from an OBJ. More...
 
void scaleWholeModel (float scaleFactor)
 Scales all the underlying geometry for the whole model, and all of the part transforms (including animations if they exist. More...
 
const SpecificationsourceSpecification () const
 
bool usesAnimation () const
 
bool usesSkeletalAnimation () const
 

Static Public Member Functions

static float anyToMeshMergeRadius (const Any &a)
 AUTO is returned as -finf() More...
 
static void clearCache ()
 
static shared_ptr< ArticulatedModelcreate (const Specification &s, const String &name="")
 
static shared_ptr< ArticulatedModelcreateEmpty (const String &name)
 Creates an empty ArticulatedModel that you can then programmatically construct Parts and Meshes within. More...
 
static const PosedefaultPose ()
 The rest pose. More...
 
static shared_ptr< ArticulatedModelfromFile (const String &filename)
 From a model filename (e.g., .obj, .fbx) More...
 
static lazy_ptr< ModellazyCreate (const Specification &s, const String &name="")
 
More...
 
static lazy_ptr< ModellazyCreate (const String &name, const Any &any)
 
static Any meshMergeRadiusToAny (const float r)
 
static String resolveRelativeFilename (const String &filename, const String &basePath)
 Leaves empty filenames alone and resolves others. More...
 
static void setUseOptimizedIntersect (bool b)
 If true, complex models should use TriTree to accelerate intersect() calls where possible. More...
 
static bool useOptimizedIntersect ()
 

Protected Member Functions

 ArticulatedModel ()
 
void addVoxels (const ParseSchematic::ColorVoxels &voxels, Point3int32 minBound, Point3int32 maxBound, const Specification &specification)
 
void forEachGeometry (Instruction::Identifier geomId, GeometryCallback &c, const Any &source=Any())
 Invoked by preprocess instructions to apply the callback to each geometry matching the specified identifiers. More...
 
void forEachMesh (Instruction::Identifier meshId, MeshCallback &c, const Any &source=Any())
 Invoked by preprocess instructions to apply the callback to each mesh matching the specified identifiers. More...
 
void forEachPart (PartCallback &c, Part *part, const CFrame &parentFrame, const Pose &pose, const int treeDepth)
 Executes c for each part in the hierarchy. More...
 
Geometrygeometry (const Instruction::Identifier &geomIdent)
 
int getID ()
 
void getIdentifiedGeometry (const Instruction::Identifier &identifier, Array< Geometry *> &identifiedGeometry)
 Appends all geometry specified by identifier to. More...
 
void getIdentifiedMeshes (const Instruction::Identifier &identifier, Array< Mesh *> &identifiedMeshes)
 Appends all meshes specified by identifier to. More...
 
void load (const Specification &specification)
 
void load3DS (const Specification &specification)
 
void loadASSIMP (const Specification &specification)
 
void loadBSP (const Specification &specification)
 
void loadHAIR (const Specification &specification)
 The HAIR model format http://www.cemyuksel.com/research/hairmodels/. More...
 
void loadHeightfield (const Specification &specification)
 
void loadIFS (const Specification &specification)
 
void loadOBJ (const Specification &specification)
 After load, undefined normals have value NaN. More...
 
void loadOFF (const Specification &specification)
 
void loadPLY (const Specification &specification)
 
void loadPLY2 (const Specification &specification)
 
void loadSchematic (const Specification &specification)
 
void loadSTL (const Specification &specification)
 
void loadVOX (const Specification &specification)
 
Meshmesh (const Instruction::Identifier &mesh)
 
void moveToOrigin (bool centerY)
 Called from preprocess. More...
 
Partpart (const Instruction::Identifier &partIdent)
 
void preprocess (const Array< Instruction > &program)
 Execute the program. More...
 
void scaleAnimations (float scaleFactor)
 
void setMaterial (Instruction::Identifier meshId, const UniversalMaterial::Specification &spec, const bool keepLightMaps, const Any &source)
 Called from preprocess. More...
 

Static Protected Member Functions

template<class T , class ... ArgTypes>
static shared_ptr< T > createShared (ArgTypes &&... args)
 Like std::make_shared, but works for protected constructors. More...
 
static shared_ptr< ArticulatedModelloadArticulatedModel (const Specification &specification, const String &n)
 

Protected Attributes

Table< String, Animationm_animationTable
 
Array< Part * > m_boneArray
 
Array< Geometry * > m_geometryArray
 
shared_ptr< Posem_lastPose
 
Array< Mesh * > m_meshArray
 
Array< Stringm_mtlArray
 keeps track of the MTL files loaded from an OBJ only noneempty when loaded from an OBJ More...
 
String m_name
 
int m_nextID
 m_nextID is the ID of the next part or mesh to be added. More...
 
Array< Part * > m_partArray
 
Table< Part *, CFramem_partTransformTable
 A temporary cache for use on the main OpenGL thread when posing to avoid allocation. More...
 
Table< Part *, CFramem_prevPartTransformTable
 A temporary cache for use on the main OpenGL thread when posing to avoid allocation. More...
 
Array< Part * > m_rootArray
 
Specification m_sourceSpecification
 

Friends

class _internal::AssimpNodesToArticulatedModelParts
 
class AMIntersector
 

Detailed Description


A 3D object composed of multiple rigid triangle meshes connected by joints.

Supports the following file formats:

See G3D::ArticulatedModel::Specification for a complete description of the G3D::Any format that can be used with data files for modifying models on load.

If you manually modify an index array or CPUVertexArray within an ArticulatedModel (including by calling preprocess transforms like ArticulatedModel::scale()) then invoke either ArticulatedModel::clearGPUArrays() (which invalidates all GPU arrays associated with the model) or the particular Geometry::clearAttributeArrays and Mesh::clearIndexStream calls associated with the Geometry and Mesh your change touched.

ArticulatedModel::pose() checks each AttributeArray before creating a Surface. If any needed AttributeArray is not AttributeArray::valid(), then the interleaved AttributeArray for that ArticulatedModel::Geometry and the IndexStream for the ArticulatedModel::Meshs that reference that geometry are automatically updated from the corresponding CPUVertexArray and CPU index array.

ArticulatedModel::Geometry stores a G3D::CPUVertexArray and corresponding GPU G3D::AttributeArrays. Does not store the index array And multiple ArticulatedModel::Meshs may reference a single ArticulatedModel::Geometry.

ArticulatedModel::Mesh is a group of primitives that share a G3D::Material. It stores the index array and a pointer to the vertex data in an ArticulatedModel::Geometry .

ArticulatedModel::Part is a node in a reference frame hierarchy. It is used in two independent ways by ArticualtedModel. Meshes that do not use bone animation (G3D::ArticulatedModel::GPUGeom::hasBones() == false), the concatenation of the Mesh::Parts from the Mesh::logicalPart up to the root is the reference frame for that Mesh in default pose. This can be further modified by an G3D::Enitity at pose time by setting the elements ArticulatedModel::Pose::frameTable.

For Meshes that use bone animation ((G3D::ArticulatedModel::GPUGeom::hasBones() == true) the Mesh::logicalPart contains organizing, but not positioning information from the original model file. The positional information in that case is given by the referenced Geometry's bone weight vertex array and the Mesh contains a Mesh::contributingJoints array that is the union of all Parts referenced by that bone weight vertex array for this Mesh.

Constructor & Destructor Documentation

◆ ArticulatedModel()

G3D::ArticulatedModel::ArticulatedModel ( )
inlineprotected

◆ ~ArticulatedModel()

G3D::ArticulatedModel::~ArticulatedModel ( )

Member Function Documentation

◆ addGeometry()

Geometry* G3D::ArticulatedModel::addGeometry ( const String name)

◆ addMesh()

Mesh* G3D::ArticulatedModel::addMesh ( const String name,
Part part,
Geometry geom 
)
Parameters
partis set as both the logical part and the only part in the contributingJoint array.
See also
addPart, addGeometry, createEmpty. Does not support boned meshes directly, but other bones can be added to mesh after creating it.

◆ addPart()

Part* G3D::ArticulatedModel::addPart ( const String name,
Part parent = nullptr 
)

◆ addVoxels()

void G3D::ArticulatedModel::addVoxels ( const ParseSchematic::ColorVoxels voxels,
Point3int32  minBound,
Point3int32  maxBound,
const Specification specification 
)
protected

◆ anyToMeshMergeRadius()

static float G3D::ArticulatedModel::anyToMeshMergeRadius ( const Any a)
static

AUTO is returned as -finf()

◆ className()

virtual const String& G3D::ArticulatedModel::className ( ) const
overridevirtual

Name of the G3D::Model subclass.

Implements G3D::Model.

◆ cleanGeometry()

void G3D::ArticulatedModel::cleanGeometry ( const CleanGeometrySettings settings = CleanGeometrySettings())


Invokes Geometry::cleanGeometry on all meshes.

◆ clearCache()

static void G3D::ArticulatedModel::clearCache ( )
static

◆ clearGPUArrays()

void G3D::ArticulatedModel::clearGPUArrays ( )

Call this if you change the underlying CPU data and have not manually invoked the corresponding clear calls on the exact meshes and geometry affected.

Invokes Mesh::clearIndexStream and Geometry::clearAttributeArrays on all meshes and geometry and erases any CPU TriTrees for optimized intersections.

◆ computeBounds()

void G3D::ArticulatedModel::computeBounds ( )

Update the bounds on all meshes (without cleaning them)

◆ computePartTransforms()

void G3D::ArticulatedModel::computePartTransforms ( Table< Part *, CFrame > &  partTransforms,
Table< Part *, CFrame > &  prevPartTransforms,
const CoordinateFrame cframe,
const Pose pose,
const CoordinateFrame prevCFrame,
const Pose prevPose 
)

Fills partTransforms with full joint-to-world transforms.

◆ countTrianglesAndVertices()

void G3D::ArticulatedModel::countTrianglesAndVertices ( int &  tri,
int &  vert 
) const

◆ create()

static shared_ptr<ArticulatedModel> G3D::ArticulatedModel::create ( const Specification s,
const String name = "" 
)
static
See also
createEmpty, fromFile If the name is not the empty string, sets the name.

◆ createEmpty()

static shared_ptr<ArticulatedModel> G3D::ArticulatedModel::createEmpty ( const String name)
static

Creates an empty ArticulatedModel that you can then programmatically construct Parts and Meshes within.

Consider calling cleanGeometry() and maybeCompactArrays() after setting geometry during a preprocessing step. If modifying geometry after the first call to pose(), invoke Part::clearVertexRanges() to wipe the out of date GPU data.

Example of a procedurally generated model (run on load; too slow to execute in an animation loop):

shared_ptr<ArticulatedModel> model = ArticulatedModel::createEmpty("spiral");
ArticulatedModel::Part* part = model->addPart("root");
ArticulatedModel::Geometry* geometry = model->addGeometry("geom");
ArticulatedModel::Mesh* mesh = model->addMesh("mesh", part, geometry);
// Create the vertices
for (int i = 0; i < 100; ++i) {
CPUVertexArray::Vertex& v = geometry->cpuVertexArray.vertex.next();
v.position = Point3( ... );
}
// Create the indices
for (int i = 0; i < 50; ++i) {
}
// Tell Articulated model to generate normals automatically
model->cleanGeometry();

Example of updating geometry on the CPU for vertex animation (consider using a custom Shader to perform this work on the GPU if possible):

Array<CPUVertexArray::Vertex>& vertex = model->part(partID);
for (int i = 0; i < 50; ++i) {
vertex[i].position = ... ;
vertex[i].normal = ... ;
}
part->clearVertexArrays();

Note that you can obtain the partID when a part is originally created, by explicitly iterating through the hierarchy from rootArray(), or by iterating with forEachPart().

Consider creating a UniversalSurface, your own Surface subclass, or using VertexBuffer directly if you need extensive dynamic geometry that doesn't fit the design of ArticulatedModel well. G3D does not require the use of ArticulatedModel at all– it is just a helper class to jumpstart your projects.

See also
create, fromFile, addMesh, addPart

◆ createShared()

template<class T , class ... ArgTypes>
static shared_ptr<T> G3D::ReferenceCountedObject::createShared ( ArgTypes &&...  args)
inlinestaticprotectedinherited

Like std::make_shared, but works for protected constructors.

Call as createShared<myclass>.

◆ defaultPose()

static const Pose& G3D::ArticulatedModel::defaultPose ( )
static

The rest pose.

◆ forEachGeometry() [1/2]

void G3D::ArticulatedModel::forEachGeometry ( Instruction::Identifier  geomId,
GeometryCallback c,
const Any source = Any() 
)
protected

Invoked by preprocess instructions to apply the callback to each geometry matching the specified identifiers.

Parameters
sourceFor error reporting

◆ forEachGeometry() [2/2]

void G3D::ArticulatedModel::forEachGeometry ( GeometryCallback c,
const Any source = Any() 
)
inline

Applies the callback to all meshes in the model.

◆ forEachMesh() [1/2]

void G3D::ArticulatedModel::forEachMesh ( Instruction::Identifier  meshId,
MeshCallback c,
const Any source = Any() 
)
protected

Invoked by preprocess instructions to apply the callback to each mesh matching the specified identifiers.

Parameters
sourceFor error reporting

◆ forEachMesh() [2/2]

void G3D::ArticulatedModel::forEachMesh ( MeshCallback c,
const Any source = Any() 
)
inline

Applies the callback to all meshes in the model.

◆ forEachPart() [1/2]

void G3D::ArticulatedModel::forEachPart ( PartCallback c,
Part part,
const CFrame parentFrame,
const Pose pose,
const int  treeDepth 
)
protected

Executes c for each part in the hierarchy.

◆ forEachPart() [2/2]

void G3D::ArticulatedModel::forEachPart ( PartCallback c,
const CoordinateFrame cframe = CoordinateFrame(),
const Pose pose = defaultPose() 
)

Walks the hierarchy and invokes PartCallback c on each Part, where each model is in pose and the entire model is relative to cframe.

Remember to call cleanGeometry() if you change the geometry. This computes normals, welds vertices and throws away the GPU data structure. A later process then uploads the new data to the GPU.

Remember to set any normals and tangents you want recomputed to NaN.

◆ fromFile()

static shared_ptr<ArticulatedModel> G3D::ArticulatedModel::fromFile ( const String filename)
inlinestatic

From a model filename (e.g., .obj, .fbx)

◆ geometry() [1/2]

Geometry* G3D::ArticulatedModel::geometry ( const Instruction::Identifier &  geomIdent)
protected

◆ geometry() [2/2]

Geometry* G3D::ArticulatedModel::geometry ( const String partName)

Get a Geometry by name.

Returns nullptr if there is no such geometry.

◆ geometryArray()

const Array<Geometry*>& G3D::ArticulatedModel::geometryArray ( ) const
inline

◆ getAnimation()

void G3D::ArticulatedModel::getAnimation ( const String name,
Animation animation 
)
inline

◆ getAnimationNames()

void G3D::ArticulatedModel::getAnimationNames ( Array< String > &  animationNames)
inline

◆ getBoundingBox()

void G3D::ArticulatedModel::getBoundingBox ( AABox box)

Finds the bounding box of this articulated model.

◆ getID()

int G3D::ArticulatedModel::getID ( )
inlineprotected

◆ getIdentifiedGeometry()

void G3D::ArticulatedModel::getIdentifiedGeometry ( const Instruction::Identifier &  identifier,
Array< Geometry *> &  identifiedGeometry 
)
protected

Appends all geometry specified by identifier to.

Parameters
identifiedGeometry

◆ getIdentifiedMeshes()

void G3D::ArticulatedModel::getIdentifiedMeshes ( const Instruction::Identifier &  identifier,
Array< Mesh *> &  identifiedMeshes 
)
protected

Appends all meshes specified by identifier to.

Parameters
identifiedMeshes

◆ getSkeletonLines() [1/2]

void G3D::ArticulatedModel::getSkeletonLines ( const Pose pose,
const CFrame cframe,
Array< Point3 > &  skeleton 
)

Appends pairs of points to skeleton representing each bone in this model in the given Pose relative to the cframe.

◆ getSkeletonLines() [2/2]

void G3D::ArticulatedModel::getSkeletonLines ( const CFrame cframe,
Array< Point3 > &  skeleton 
)
inline

Uses the previous pose.

◆ intersect()

virtual bool G3D::ArticulatedModel::intersect ( const Ray ray,
const CoordinateFrame cframe,
float &  maxDistance,
Model::HitInfo info = Model::HitInfo::ignore,
const Entity entity = nullptr,
const Model::Pose pose = nullptr 
) const
overridevirtual

Per-triangle ray-model intersection.

Returns true if ray R intersects this model, when it has cframe and pose, at a distance less than maxDistance. If so, sets maxDistance to the intersection distance and sets the pointers to the Part and Mesh, and the index in Mesh::cpuIndexArray of the start of that triangle's indices. u and v are the barycentric coordinates of vertices triStartIndex and triStartIndex + 1, The barycentric coordinate of vertex triStartIndex + 2 is 1 - u - v.

This is primarily intended for mouse selection. For ray tracing or physics, consider G3D::TriTree instead.

Does not overwrite the arguments unless there is a hit closer than maxDistance.

Reimplemented from G3D::Model.

◆ lazyCreate() [1/2]

static lazy_ptr<Model> G3D::ArticulatedModel::lazyCreate ( const Specification s,
const String name = "" 
)
static


See also
createEmpty, fromFile If the name is not the empty string, sets the name.

◆ lazyCreate() [2/2]

static lazy_ptr<Model> G3D::ArticulatedModel::lazyCreate ( const String name,
const Any any 
)
static

◆ load()

void G3D::ArticulatedModel::load ( const Specification specification)
protected

◆ load3DS()

void G3D::ArticulatedModel::load3DS ( const Specification specification)
protected

◆ loadArticulatedModel()

static shared_ptr<ArticulatedModel> G3D::ArticulatedModel::loadArticulatedModel ( const Specification specification,
const String n 
)
staticprotected

◆ loadASSIMP()

void G3D::ArticulatedModel::loadASSIMP ( const Specification specification)
protected

◆ loadBSP()

void G3D::ArticulatedModel::loadBSP ( const Specification specification)
protected

◆ loadHAIR()

void G3D::ArticulatedModel::loadHAIR ( const Specification specification)
protected

◆ loadHeightfield()

void G3D::ArticulatedModel::loadHeightfield ( const Specification specification)
protected

◆ loadIFS()

void G3D::ArticulatedModel::loadIFS ( const Specification specification)
protected

◆ loadOBJ()

void G3D::ArticulatedModel::loadOBJ ( const Specification specification)
protected

After load, undefined normals have value NaN.

Undefined texcoords become (0,0). There are no tangents, the gpu arrays are empty, and the bounding spheres are undefined.

◆ loadOFF()

void G3D::ArticulatedModel::loadOFF ( const Specification specification)
protected

◆ loadPLY()

void G3D::ArticulatedModel::loadPLY ( const Specification specification)
protected

◆ loadPLY2()

void G3D::ArticulatedModel::loadPLY2 ( const Specification specification)
protected

◆ loadSchematic()

void G3D::ArticulatedModel::loadSchematic ( const Specification specification)
protected

◆ loadSTL()

void G3D::ArticulatedModel::loadSTL ( const Specification specification)
protected

◆ loadVOX()

void G3D::ArticulatedModel::loadVOX ( const Specification specification)
protected

◆ maybeCompactArrays()

void G3D::ArticulatedModel::maybeCompactArrays ( )

If this model's memory footprint is large, trim all of the internal CPU arrays to size.

◆ mesh() [1/3]

Mesh* G3D::ArticulatedModel::mesh ( const Instruction::Identifier &  mesh)
protected

◆ mesh() [2/3]

Mesh* G3D::ArticulatedModel::mesh ( const String meshName)

Get a Mesh by name.

Returns nullptr if there is no such mesh. will not neccesarily return the correct mesh if two meshes have the same name

◆ mesh() [3/3]

Mesh* G3D::ArticulatedModel::mesh ( int  ID)

◆ meshArray()

const Array<Mesh*>& G3D::ArticulatedModel::meshArray ( ) const
inline

◆ meshMergeRadiusToAny()

static Any G3D::ArticulatedModel::meshMergeRadiusToAny ( const float  r)
static

◆ moveToOrigin()

void G3D::ArticulatedModel::moveToOrigin ( bool  centerY)
protected

Called from preprocess.

Parameters
centerYIf false, move the base to the origin instead of the center in the vertical direction.

◆ name()

virtual const String& G3D::ArticulatedModel::name ( ) const
inlineoverridevirtual

Name of the instance (usually based on the filename it is loaded from)

Implements G3D::Model.

Referenced by getAnimation().

◆ part() [1/2]

Part* G3D::ArticulatedModel::part ( const Instruction::Identifier &  partIdent)
protected

◆ part() [2/2]

Part* G3D::ArticulatedModel::part ( const String partName)

Get a Part by name.

Returns nullptr if there is no such part.

◆ pose()

void G3D::ArticulatedModel::pose ( Array< shared_ptr< Surface > > &  surfaceArray,
const CFrame rootFrame,
const CFrame prevFrame,
const shared_ptr< Entity > &  entity,
const Model::Pose pose,
const Model::Pose prevPose,
const Surface::ExpressiveLightScatteringProperties e 
)
overridevirtual

This will be replaced soon with a version that takes a shared_ptr<Pose>.

Parameters
poseMust have the subclass of Model::Pose appropriate to the Model subclass.

Implements G3D::Model.

◆ preprocess()

void G3D::ArticulatedModel::preprocess ( const Array< Instruction > &  program)
protected

Execute the program.

Called from load()

◆ resolveRelativeFilename()

static String G3D::ArticulatedModel::resolveRelativeFilename ( const String filename,
const String basePath 
)
static

Leaves empty filenames alone and resolves others.

◆ rootArray()

const Array<Part*>& G3D::ArticulatedModel::rootArray ( ) const
inline

Root parts.

There may be more than one.

◆ saveGeometryAsCode()

void G3D::ArticulatedModel::saveGeometryAsCode ( const String filename,
bool  compress = false 
)

Saves C++ code for generating the geometry of mesh[0].

◆ saveOBJ()

void G3D::ArticulatedModel::saveOBJ ( const String filename)

Saves an OBJ with the given filename of this ArticulatedModel materials currently only work if loaded from an OBJ.

◆ scaleAnimations()

void G3D::ArticulatedModel::scaleAnimations ( float  scaleFactor)
protected

◆ scaleWholeModel()

void G3D::ArticulatedModel::scaleWholeModel ( float  scaleFactor)

Scales all the underlying geometry for the whole model, and all of the part transforms (including animations if they exist.

◆ setMaterial()

void G3D::ArticulatedModel::setMaterial ( Instruction::Identifier  meshId,
const UniversalMaterial::Specification spec,
const bool  keepLightMaps,
const Any source 
)
protected

Called from preprocess.

◆ setUseOptimizedIntersect()

static void G3D::Model::setUseOptimizedIntersect ( bool  b)
inlinestaticinherited

If true, complex models should use TriTree to accelerate intersect() calls where possible.

This can make the first intersect() call very slow for the tree build and can make loading slow. It may not affect performance of skinned or articulated models that animate.

This value should be set before the models are loaded. If it is changed after a model is loaded, the Model is not required to respond to it.

Default: false

◆ sourceSpecification()

const Specification& G3D::ArticulatedModel::sourceSpecification ( ) const
inline

◆ useOptimizedIntersect()

static bool G3D::Model::useOptimizedIntersect ( )
inlinestaticinherited

◆ usesAnimation()

bool G3D::ArticulatedModel::usesAnimation ( ) const
inline

◆ usesSkeletalAnimation()

bool G3D::ArticulatedModel::usesSkeletalAnimation ( ) const
inline

Friends And Related Function Documentation

◆ _internal::AssimpNodesToArticulatedModelParts

friend class _internal::AssimpNodesToArticulatedModelParts
friend

◆ AMIntersector

friend class AMIntersector
friend

Member Data Documentation

◆ m_animationTable

Table<String, Animation> G3D::ArticulatedModel::m_animationTable
protected

◆ m_boneArray

Array<Part*> G3D::ArticulatedModel::m_boneArray
protected

Referenced by usesSkeletalAnimation().

◆ m_geometryArray

Array<Geometry*> G3D::ArticulatedModel::m_geometryArray
protected

Referenced by geometryArray().

◆ m_lastPose

shared_ptr<Pose> G3D::ArticulatedModel::m_lastPose
protected

◆ m_meshArray

Array<Mesh*> G3D::ArticulatedModel::m_meshArray
protected

Referenced by meshArray().

◆ m_mtlArray

Array<String> G3D::ArticulatedModel::m_mtlArray
protected

keeps track of the MTL files loaded from an OBJ only noneempty when loaded from an OBJ

◆ m_name

String G3D::ArticulatedModel::m_name
protected

Referenced by name().

◆ m_nextID

int G3D::ArticulatedModel::m_nextID
protected

m_nextID is the ID of the next part or mesh to be added.

Each mesh or part when added is assigned a unique int id. Inorder to make sure that it is unique every time a mesh or part is added it is given m_nextID value and m_nextID is incremented by one.

Referenced by getID().

◆ m_partArray

Array<Part*> G3D::ArticulatedModel::m_partArray
protected

◆ m_partTransformTable

Table<Part*, CFrame> G3D::ArticulatedModel::m_partTransformTable
protected

A temporary cache for use on the main OpenGL thread when posing to avoid allocation.

◆ m_prevPartTransformTable

Table<Part*, CFrame> G3D::ArticulatedModel::m_prevPartTransformTable
protected

A temporary cache for use on the main OpenGL thread when posing to avoid allocation.

◆ m_rootArray

Array<Part*> G3D::ArticulatedModel::m_rootArray
protected

◆ m_sourceSpecification

Specification G3D::ArticulatedModel::m_sourceSpecification
protected

Referenced by sourceSpecification().


documentation generated on Wed Nov 24 2021 08:01:53 using doxygen 1.8.15