public final class Model extends java.lang.Object implements IDestroyable, java.lang.Cloneable, java.lang.Comparable<Model>, ITransformable, ILod, ITree<Model>, ICullableNode, IUpdatable
| Modifier and Type | Field and Description |
|---|---|
AssetManager |
assets
Dependency to external assets (textures)
|
boolean |
md3
Flag to indicate the model hierarchy is in MD3 format
|
java.lang.String |
name
Model name
|
HwData |
rendererData
Managed internally.
|
Skeleton |
skeleton
Skeleton for skinning animation.
|
Mat4x4[] |
skeletonAbsoluteMatrices
Managed internally.
|
Mat4x4[] |
skinMatrices
Managed internally.
|
| Constructor and Description |
|---|
Model(AssetManager assetManager) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAnimation(Animation animation) |
void |
addAnimation(Animation animation,
JointMotion jointMotion)
|
void |
addAnimationBindPose()
|
void |
addChild(Model model) |
void |
addMaterial(MaterialStandard material) |
void |
addMesh(int lod,
Mesh mesh) |
void |
addMorphMotion(MorphMotion morphMotion) |
int |
compareTo(Model o) |
void |
destroy(IGLApi glApi) |
Model |
duplicate(boolean duplicateHierarchy,
boolean duplicateAnimation,
boolean duplicateAnimationList,
boolean duplicateMaterialKey) |
Animation |
getAnimation(int index) |
Animation |
getAnimation(java.lang.String animationName) |
AnimationContext |
getAnimationContext() |
int |
getAnimationIndex(Animation anim) |
void |
getAnimationKeys(java.util.Set<java.lang.Float> times,
Animation anim) |
Model |
getChild(int index) |
java.lang.Iterable<? extends ICullableNode> |
getCullableNodes() |
RenderState.Cull |
getCullFace() |
MaterialStandard |
getMaterial(int materialIndex) |
IMaterial |
getMaterial(java.lang.Object materialKey) |
MaterialStandard |
getMaterial(java.lang.String materialName) |
Mat4x4 |
getMatrix() |
Mat4x4 |
getMatrix(Mat4x4 dst) |
Array<Mesh> |
getMeshes() |
Array<Mesh> |
getMeshes(int meshLod) |
MorphMotion |
getMorphMotion(int index) |
MorphMotion |
getMorphMotion(java.lang.String motionName) |
int |
getNumAnimations() |
int |
getNumAnimationsRec() |
int |
getNumChilds() |
int |
getNumLodLevels() |
int |
getNumMaterials() |
int |
getNumMorphMotions() |
Transform |
getTransform() |
Transform |
getTransform(Transform dst) |
IVolume<?> |
getVolume(int bvOptions)
Model Bounding Box
================== By default the bounding box is axis aligned, to get a bounding box oriented relativly to the model use : VolumeOptions.BV_ORIENTED By default, all model/meshes are included in the bounding box even invisible object. |
int |
indexOfMaterial(MaterialStandard material) |
void |
initialize()
Internal use.
|
boolean |
isAnimated() |
boolean |
isCullBackFace() |
boolean |
isCulled() |
boolean |
isCullFrontFace() |
boolean |
isDrawBoundingVolume() |
boolean |
isVisible() |
boolean |
isVisibleAndNotCulled() |
void |
onAnimationChanged()
This method must be called when
transforms has been manually modified (add, remove, clear, null, ...). |
void |
onContextLost()
Deprecated.
Use
AssetManager.onContextLost(Model) instead |
void |
onHierarchyChanged()
This method must be called when
childs or #meshes has been manually modified (add, remove, clear, ...). |
void |
onMaterialChanged()
This method must be called when a {Material#name} has been modified.
|
static Model |
read(IByteInputStream in,
Model model) |
static boolean |
readBoolean(IByteInputStream in) |
static java.lang.String |
readString(IByteInputStream in,
java.lang.String[] strings,
boolean indexed) |
boolean |
removeAnimation(Animation animation) |
Animation |
removeAnimation(int index) |
boolean |
removeChild(Model model) |
boolean |
removeMaterial(MaterialStandard material) |
boolean |
removeMesh(int lod,
Mesh mesh) |
MorphMotion |
removeMorphMotion(int index) |
void |
removeMorphMotion(MorphMotion morphMotion) |
void |
restartAnimations()
Restart the animation of this model and all its links.
|
Array<Model> |
setChilds(Array<Model> childs) |
void |
setCullBackFace(boolean cullBackFace,
boolean propagate) |
void |
setCulled(boolean culled) |
void |
setCullFrontFace(boolean cullFrontFace,
boolean propagate) |
void |
setDrawBoundingVolume(boolean drawBoundingVolume) |
void |
setMaterials(Array<MaterialStandard> materials) |
Array<Mesh> |
setMeshes(int lod,
Array<Mesh> meshes) |
void |
setTransform(Transform src) |
void |
setTransforms(KeyFrame<Transform> transforms) |
void |
setVisible(boolean visible) |
java.lang.String |
toString() |
void |
transform(Transform transform)
Post multiplication by the specified transform
|
void |
unreferenceAssets() |
boolean |
update(long timePassedMS)
Must be called each frame for the root model to synchronize animation, bounding volumes, etc ...
|
void |
write(IByteOutputStream out) |
static void |
writeBoolean(IByteOutputStream out,
boolean b) |
static void |
writeString(IByteOutputStream out,
java.lang.String s) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetLodDistance, getLodLevel, setLodLevelpublic java.lang.String name
public boolean md3
public Skeleton skeleton
public AssetManager assets
public Mat4x4[] skeletonAbsoluteMatrices
public Mat4x4[] skinMatrices
public HwData rendererData
public Model(AssetManager assetManager)
assetManager - AssetManager for external resource, can be shared with multiple Modelpublic final java.lang.String toString()
toString in class java.lang.Objectpublic final int compareTo(Model o)
compareTo in interface java.lang.Comparable<Model>public static final Model read(IByteInputStream in, Model model) throws java.io.IOException
java.io.IOExceptionpublic final void write(IByteOutputStream out) throws java.io.IOException
java.io.IOExceptionpublic static final java.lang.String readString(IByteInputStream in, java.lang.String[] strings, boolean indexed) throws java.io.IOException
java.io.IOExceptionpublic static final void writeString(IByteOutputStream out, java.lang.String s) throws java.io.IOException
java.io.IOExceptionpublic static final boolean readBoolean(IByteInputStream in) throws java.io.IOException
java.io.IOExceptionpublic static final void writeBoolean(IByteOutputStream out, boolean b) throws java.io.IOException
java.io.IOExceptionpublic final void initialize()
public final Model duplicate(boolean duplicateHierarchy, boolean duplicateAnimation, boolean duplicateAnimationList, boolean duplicateMaterialKey)
public final void unreferenceAssets()
public final void destroy(IGLApi glApi)
destroy in interface IDestroyable@Deprecated public final void onContextLost()
AssetManager.onContextLost(Model) insteadAssetManager.onContextLost(Model)public final IMaterial getMaterial(java.lang.Object materialKey) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
materialKey - java.lang.IllegalStateException - when materialKey is an AssetKey and assets's materialLibrary is nulljava.lang.IllegalArgumentException - when materialKey type is not int (Integer), String or AssetKeypublic final void setMaterials(Array<MaterialStandard> materials)
materials - list of MaterialStandard set on this Modelpublic final void addMaterial(MaterialStandard material)
material - a MaterialStandard to add to this Modelpublic final boolean removeMaterial(MaterialStandard material)
material - a MaterialStandard to remove from this Modelpublic final int getNumMaterials()
MaterialStandard in this Modelpublic final MaterialStandard getMaterial(int materialIndex)
materialIndex - index of the MaterialStandard to getgetNumMaterials()public final MaterialStandard getMaterial(java.lang.String materialName)
materialName - a MaterialStandard namepublic final int indexOfMaterial(MaterialStandard material)
material - a MaterialStandard to get its indexModelpublic final int getNumChilds()
getNumChilds in interface ITree<Model>this model.public final void addChild(Model model)
public final boolean removeChild(Model model)
public final Model getChild(int index)
getChild in interface ITree<Model>index - in the range [0; ITree.getNumChilds()[public final Array<Model> setChilds(Array<Model> childs)
childs - public final Array<Mesh> getMeshes()
getMeshes(int)public final int getNumLodLevels()
getNumLodLevels in interface ILodgetMeshes(int)public final Array<Mesh> getMeshes(int meshLod)
meshLod - getNumLodLevels()public final void addMesh(int lod,
Mesh mesh)
public final boolean removeMesh(int lod,
Mesh mesh)
public final AnimationContext getAnimationContext()
public final int getNumAnimations()
Modelpublic final int getNumAnimationsRec()
public final Animation getAnimation(int index)
Animation at the specified indexpublic final Animation getAnimation(java.lang.String animationName)
public final int getAnimationIndex(Animation anim)
Animationpublic final void addAnimation(Animation animation)
animation - animation to addremoveAnimation(Animation),
removeAnimation(int),
addAnimation(Animation, JointMotion)public final Animation removeAnimation(int index)
index - index of the Animation to remove.Utils.removeAnimations(Model, Animation[])public final boolean removeAnimation(Animation animation)
public final void addAnimation(Animation animation, JointMotion jointMotion)
Animation to this Model and it's associated JointMotion
to this skeleton.Animation.skeletonMotion is set to use the specified JointMotion,
and if the Animation.name is null then it set it using JointMotion name.
if (animation.name == null) {
animation.name = jointMotion.getName();
}
animation.skeletonMotion = jointMotion.getName();
addAnimation(animation)
skeleton.addMotion(jointMotion);
animation - an Animation to addjointMotion - the JointMotion to associated to the specified Animationjava.lang.IllegalStateException - if skeleton is nullpublic final void addAnimationBindPose()
java.lang.IllegalStateException - if skeleton is nullpublic void restartAnimations()
getAnimationContext().getTimeline().setTime(0)
for this Model and recursively to all of it childs Model#getChilds()public void getAnimationKeys(java.util.Set<java.lang.Float> times,
Animation anim)
times - storage for animation key timespublic final int getNumMorphMotions()
public final MorphMotion getMorphMotion(int index)
index - index of the MorphMotion to getpublic final MorphMotion getMorphMotion(java.lang.String motionName)
motionName - name of the motion to getpublic final void addMorphMotion(MorphMotion morphMotion)
morphMotion - MorphMotion to addpublic final void removeMorphMotion(MorphMotion morphMotion)
morphMotion - MorphMotion to removepublic final MorphMotion removeMorphMotion(int index)
index - index of the MorphMotion to removeMorphMotion removedpublic final java.lang.Iterable<? extends ICullableNode> getCullableNodes()
getCullableNodes in interface ICullableNodepublic final Mat4x4 getMatrix(Mat4x4 dst)
getMatrix in interface ICullableNodedst - destination Mat4x4 to store local matrixpublic final Transform getTransform(Transform dst)
getTransform in interface ITransformabledst - destination Transform to store local transformpublic final void setTransform(Transform src)
setTransform in interface ITransformablepublic final Transform getTransform()
Model, or null if identitypublic final void transform(Transform transform)
transform in interface ITransformableTransform.multiply(Transform, Transform),
#getTransforms()public boolean isAnimated()
public IVolume<?> getVolume(int bvOptions)
getVolume in interface IBoundablebvOptions - bounding volume options.BoundingBox or BoundingSphere depending on options.VolumeOptions,
Box,
Sphere,
Cylinder,
Capsulepublic boolean update(long timePassedMS)
update in interface IUpdatabletimePassedMS - time passed from last frame in millisecondspublic final void onAnimationChanged()
transforms has been manually modified (add, remove, clear, null, ...).public final void onHierarchyChanged()
childs or #meshes has been manually modified (add, remove, clear, ...).public final void onMaterialChanged()
public final boolean isVisibleAndNotCulled()
public final boolean isVisible()
isVisible in interface ICullableGeometryData is visiblepublic final void setVisible(boolean visible)
visible - set new visibility state of this GeometryDatapublic final boolean isCulled()
isCulled in interface ICullableGeometryData is culled (by visibility algorithm, ...)public final void setCulled(boolean culled)
setCulled in interface ICullableculled - new culled state for this GeometryDatapublic final boolean isDrawBoundingVolume()
GeometryDatapublic final void setDrawBoundingVolume(boolean drawBoundingVolume)
public RenderState.Cull getCullFace()
public final boolean isCullBackFace()
Mesh and GeometryData have their back face culledpublic final void setCullBackFace(boolean cullBackFace,
boolean propagate)
public final boolean isCullFrontFace()
Mesh and GeometryData have their front face culledpublic final void setCullFrontFace(boolean cullFrontFace,
boolean propagate)
Bonzai Engine 1.4.1-20200831 - A Java OpenGL engine and tools for Windows/Mac/Linux/Android
Copyright © 2007-2019 Jérôme Jouvie bonzaiengine.com contact@bonzaiengine.com