|
| ~ArticulatedModel () |
|
Geometry * | addGeometry (const String &name) |
|
Mesh * | addMesh (const String &name, Part *part, Geometry *geom) |
|
Part * | addPart (const String &name, Part *parent=nullptr) |
|
virtual const String & | className () 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...
|
|
Geometry * | geometry (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...
|
|
Mesh * | mesh (const String &meshName) |
| Get a Mesh by name. More...
|
|
Mesh * | mesh (int ID) |
|
const Array< Mesh * > & | meshArray () const |
|
virtual const String & | name () const override |
| Name of the instance (usually based on the filename it is loaded from) More...
|
|
Part * | part (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 Specification & | sourceSpecification () const |
|
bool | usesAnimation () const |
|
bool | usesSkeletalAnimation () const |
|
|
| 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...
|
|
Geometry * | geometry (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) |
|
Mesh * | mesh (const Instruction::Identifier &mesh) |
|
void | moveToOrigin (bool centerY) |
| Called from preprocess. More...
|
|
Part * | part (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...
|
|
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.
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):
ArticulatedModel::Part*
part = model->addPart(
"root");
ArticulatedModel::Geometry*
geometry = model->addGeometry(
"geom");
for (int i = 0; i < 100; ++i) {
}
for (int i = 0; i < 50; ++i) {
}
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
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.