Package gaiasky.util.gdx.model
Class IntModel
java.lang.Object
gaiasky.util.gdx.model.IntModel
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
-
Field Summary
Modifier and TypeFieldDescriptionfinal com.badlogic.gdx.utils.Array
<IntAnimation> Animations of the model, modifying node transformations.protected final com.badlogic.gdx.utils.Array
<com.badlogic.gdx.utils.Disposable> Array of disposable resources like textures or meshes the Model is responsible for disposing.final com.badlogic.gdx.utils.Array
<Material> The materials of the model, used by nodes that have a graphical representation.final com.badlogic.gdx.utils.Array
<IntMesh> The meshes of the model.final com.badlogic.gdx.utils.Array
<IntMeshPart> Parts of meshes, used by nodes that have a graphical representation.final com.badlogic.gdx.utils.Array
<IntNode> Root nodes of the model.double
Length of the furthest vertex from the origin. -
Constructor Summary
ConstructorDescriptionIntModel()
Constructs an empty model.IntModel
(IntModelData modelData) Constructs a new Model based on theIntModelData
.IntModel
(IntModelData modelData, com.badlogic.gdx.graphics.g3d.utils.TextureProvider textureProvider) Constructs a new Model based on theIntModelData
. -
Method Summary
Modifier and TypeMethodDescriptioncom.badlogic.gdx.math.collision.BoundingBox
calculateBoundingBox
(com.badlogic.gdx.math.collision.BoundingBox out) Calculate the bounding box of this model instance.void
Calculates the local and world transform of allNode
instances in this model, recursively.void
Once the model is fully loaded, this method computes its span, which is the length of the furthest vertex from the origin in this model.protected Material
convertMaterial
(OwnModelMaterial mtl, com.badlogic.gdx.graphics.g3d.utils.TextureProvider textureProvider) protected void
convertMesh
(IntModelMesh modelMesh) void
dispose()
com.badlogic.gdx.math.collision.BoundingBox
extendBoundingBox
(com.badlogic.gdx.math.collision.BoundingBox out) Extends the bounding box with the bounds of this model instance.getAnimation
(String id) getAnimation
(String id, boolean ignoreCase) Iterable
<com.badlogic.gdx.utils.Disposable> getMaterial
(String id) getMaterial
(String id, boolean ignoreCase) protected void
load
(IntModelData modelData, com.badlogic.gdx.graphics.g3d.utils.TextureProvider textureProvider) protected void
loadAnimations
(Iterable<com.badlogic.gdx.graphics.g3d.model.data.ModelAnimation> modelAnimations) protected void
loadMaterials
(Iterable<OwnModelMaterial> modelMaterials, com.badlogic.gdx.graphics.g3d.utils.TextureProvider textureProvider) protected void
loadMeshes
(Iterable<IntModelMesh> meshes) protected IntNode
loadNode
(IntModelNode modelNode) protected void
loadNodes
(Iterable<IntModelNode> modelNodes) void
manageDisposable
(com.badlogic.gdx.utils.Disposable disposable) Adds aDisposable
to be managed and disposed by this Model.
-
Field Details
-
materials
The materials of the model, used by nodes that have a graphical representation. -
nodes
Root nodes of the model. -
animations
Animations of the model, modifying node transformations. -
meshes
The meshes of the model. -
meshParts
Parts of meshes, used by nodes that have a graphical representation. -
span
public double spanLength of the furthest vertex from the origin. -
disposables
protected final com.badlogic.gdx.utils.Array<com.badlogic.gdx.utils.Disposable> disposablesArray of disposable resources like textures or meshes the Model is responsible for disposing.
-
-
Constructor Details
-
IntModel
public IntModel()Constructs an empty model. Manual created models do not manage their resources by default. UsemanageDisposable(Disposable)
to add resources to be managed by this model. -
IntModel
Constructs a new Model based on theIntModelData
. Texture files will be loaded from the internal file storage via anTextureProvider.FileTextureProvider
.- Parameters:
modelData
- theIntModelData
got from e.g.ModelLoader
-
IntModel
public IntModel(IntModelData modelData, com.badlogic.gdx.graphics.g3d.utils.TextureProvider textureProvider) Constructs a new Model based on theIntModelData
.- Parameters:
modelData
- theIntModelData
got from e.g.ModelLoader
textureProvider
- theTextureProvider
to use for loading the textures
-
-
Method Details
-
load
protected void load(IntModelData modelData, com.badlogic.gdx.graphics.g3d.utils.TextureProvider textureProvider) -
loadAnimations
protected void loadAnimations(Iterable<com.badlogic.gdx.graphics.g3d.model.data.ModelAnimation> modelAnimations) -
loadNodes
-
loadNode
-
loadMeshes
-
convertMesh
-
loadMaterials
protected void loadMaterials(Iterable<OwnModelMaterial> modelMaterials, com.badlogic.gdx.graphics.g3d.utils.TextureProvider textureProvider) -
convertMaterial
protected Material convertMaterial(OwnModelMaterial mtl, com.badlogic.gdx.graphics.g3d.utils.TextureProvider textureProvider) -
manageDisposable
public void manageDisposable(com.badlogic.gdx.utils.Disposable disposable) Adds aDisposable
to be managed and disposed by this Model. Can be used to keep track of manually loaded textures forIntModelInstance
.- Parameters:
disposable
- the Disposable
-
getManagedDisposables
- Returns:
- the
Disposable
objects that will be disposed when thedispose()
method is called.
-
dispose
public void dispose()- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
-
calculateTransforms
public void calculateTransforms()Calculates the local and world transform of all
Node
instances in this model, recursively. First eachNode.localTransform
transform is calculated based on the translation, rotation and scale of each Node. Then eachNode.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.
-
calculateBoundingBox
public com.badlogic.gdx.math.collision.BoundingBox calculateBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out) Calculate the bounding box of this model instance. This is a potential slow operation, it is advised to cache the result.- Parameters:
out
- theBoundingBox
that will be set with the bounds.- Returns:
- the out parameter for chaining
-
extendBoundingBox
public com.badlogic.gdx.math.collision.BoundingBox extendBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out) Extends the bounding box with the bounds of this model instance. This is a potential slow operation, it is advised to cache the result.- Parameters:
out
- theBoundingBox
that will be extended with the bounds.- Returns:
- the out parameter for chaining
-
getAnimation
- Parameters:
id
- The ID of the animation to fetch (case sensitive).- Returns:
- The
Animation
with the specified id, or null if not available.
-
getAnimation
- Parameters:
id
- The ID of the animation to fetch.ignoreCase
- whether to use case sensitivity when comparing the animation id.- Returns:
- The
Animation
with the specified id, or null if not available.
-
getMaterial
- Parameters:
id
- The ID of the material to fetch.- Returns:
- The
Material
with the specified id, or null if not available.
-
getMaterial
- Parameters:
id
- The ID of the material to fetch.ignoreCase
- whether to use case sensitivity when comparing the material id.- Returns:
- The
Material
with the specified id, or null if not available.
-
getNode
- Parameters:
id
- The ID of the node to fetch.- Returns:
- The
IntNode
with the specified id, or null if not found.
-
getNode
- Parameters:
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.- Returns:
- The
IntNode
with the specified id, or null if not found.
-
getNode
- Parameters:
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.- Returns:
- The
IntNode
with the specified id, or null if not found.
-
computeSpan
public void computeSpan()Once the model is fully loaded, this method computes its span, which is the length of the furthest vertex from the origin in this model.
-