public class Model extends Object implements Disposable
MeshPart
and Material
. Mesh parts reference subsets of vertices in one of the meshes of the model.
Animations can be applied to nodes, to modify their transform (translation, rotation, scale) over time.
A model can be rendered by creating a ModelInstance
from it. That instance has an additional transform to position the
model in the world, and allows modification of materials and nodes without destroying the original model. The original model is
the owner of any meshes and textures, all instances created from the model share these resources. Disposing the model will
automatically make all instances invalid!
A model is created from ModelData
, which in turn is loaded by a ModelLoader
.Modifier and Type | Field and Description |
---|---|
Array<Animation> |
animations
animations of the model, modifying node transformations
|
Array<Material> |
materials
the materials of the model, used by nodes that have a graphical representation FIXME not sure if superfluous, allows
modification of materials without having to traverse the nodes
|
Array<Mesh> |
meshes
the meshes of the model
|
Array<MeshPart> |
meshParts
parts of meshes, used by nodes that have a graphical representation FIXME not sure if superfluous, stored in Nodes as well,
could be useful to create bullet meshes
|
Array<Node> |
nodes
root nodes of the model
|
Constructor and Description |
---|
Model()
Constructs an empty model.
|
Model(ModelData modelData)
Constructs a new Model based on the
ModelData . |
Model(ModelData modelData,
TextureProvider textureProvider)
Constructs a new Model based on the
ModelData . |
Modifier and Type | Method and Description |
---|---|
BoundingBox |
calculateBoundingBox(BoundingBox out)
Calculate the bounding box of this model instance.
|
void |
calculateTransforms()
Calculates the local and world transform of all
Node instances in this model, recursively. |
void |
dispose()
Releases all resources of this object.
|
BoundingBox |
extendBoundingBox(BoundingBox out)
Extends the bounding box with the bounds of this model instance.
|
Animation |
getAnimation(String id) |
Animation |
getAnimation(String id,
boolean ignoreCase) |
Iterable<Disposable> |
getManagedDisposables() |
Material |
getMaterial(String id) |
Material |
getMaterial(String id,
boolean ignoreCase) |
Node |
getNode(String id) |
Node |
getNode(String id,
boolean recursive) |
Node |
getNode(String id,
boolean recursive,
boolean ignoreCase) |
void |
manageDisposable(Disposable disposable)
Adds a
Disposable to be managed and disposed by this Model. |
public final Array<Material> materials
public final Array<Animation> animations
public Model()
manageDisposable(Disposable)
to add resources to be managed by this model.public Model(ModelData modelData)
ModelData
. Texture files will be loaded from the internal file storage via an
TextureProvider.FileTextureProvider
.modelData
- the ModelData
got from e.g. ModelLoader
public Model(ModelData modelData, TextureProvider textureProvider)
ModelData
.modelData
- the ModelData
got from e.g. ModelLoader
textureProvider
- the TextureProvider
to use for loading the texturespublic void manageDisposable(Disposable disposable)
Disposable
to be managed and disposed by this Model. Can be used to keep track of manually loaded textures
for ModelInstance
.disposable
- the Disposablepublic Iterable<Disposable> getManagedDisposables()
Disposable
objects that will be disposed when the dispose()
method is called.public void dispose()
Disposable
dispose
in interface Disposable
public void calculateTransforms()
Node
instances in this model, recursively. First each
Node.localTransform
transform is calculated based on the translation, rotation and scale of each Node. Then each
Node.calculateWorldTransform()
is calculated, based on the parent's world transform and the local transform of each
Node. Finally, the animation bone matrices are updated accordingly.
This method can be used to recalculate all transforms if any of the Node's local properties (translation, rotation, scale)
was modified.public BoundingBox calculateBoundingBox(BoundingBox out)
out
- the BoundingBox
that will be set with the bounds.public BoundingBox extendBoundingBox(BoundingBox out)
out
- the BoundingBox
that will be extended with the bounds.public Animation getAnimation(String id)
id
- The ID of the animation to fetch (case sensitive).Animation
with the specified id, or null if not available.public Animation getAnimation(String id, boolean ignoreCase)
id
- The ID of the animation to fetch.ignoreCase
- whether to use case sensitivity when comparing the animation id.Animation
with the specified id, or null if not available.public Material getMaterial(String id)
id
- The ID of the material to fetch.Material
with the specified id, or null if not available.public Material getMaterial(String id, boolean ignoreCase)
id
- The ID of the material to fetch.ignoreCase
- whether to use case sensitivity when comparing the material id.Material
with the specified id, or null if not available.public Node getNode(String id)
id
- The ID of the node to fetch.Node
with the specified id, or null if not found.public Node getNode(String id, boolean recursive)
id
- The ID of the node to fetch.recursive
- false to fetch a root node only, true to search the entire node tree for the specified node.Node
with the specified id, or null if not found.public Node getNode(String id, boolean recursive, boolean ignoreCase)
id
- The ID of the node to fetch.recursive
- false to fetch a root node only, true to search the entire node tree for the specified node.ignoreCase
- whether to use case sensitivity when comparing the node id.Node
with the specified id, or null if not found.Copyright © 2015. All rights reserved.