Skip to content

AnimatedModelInstance

ThomasWrobel edited this page Aug 21, 2017 · 10 revisions

An extension of ModelInstance. Aside from easily animating position,rotation and scale, this class also adds "lookAt" abilities, positioning objects relative to eachother, and showing/hiding them by automatically adding/removing them from the render list in model management. It also enables optional interaction on objects.

@author Tom on the excellent and helpful advice of Xoppa

All widgets in GWTish ultimately extend this, but its also a useful to use for any dynamic objects in your scene. You should probably also look at the PosRotScale class, which simply stores position,rotation and scale separately rather then using a Matrix.


Selective method details copied from javadoc:

void attachThis(IsAnimatableModelInstance objectToAttach, PosRotScale displacement)

Lets you stick one object to another. The object stuck will then inherit rotation/position automatically as if physically attached.

Set getAllAttachments()

gets all attachments and child attachments

Quaternion getAngleTo(IsAnimatableModelInstance target)

Method to find the axis-angle between this AnimatableModelInstances and another relative to the xAxis (1,0,0)

Quaternion getAngleTo(IsAnimatableModelInstance target, com.badlogic.gdx.math.Vector3 Axis)

Method to find the axis-angle between this AnimatableModelInstances and another relative to the xAxis.

Quaternion getAngleTo(com.badlogic.gdx.math.Vector3 target, com.badlogic.gdx.math.Vector3 Axis) java.util.Set getAttachments()

gets all the direct attachments

PosRotScale getAttachmentsPoint(AnimatableModelInstance object) PosRotScale getAttachmentsPoint(IsAnimatableModelInstance object)

Returns the displacement specification of the specified object from this one. (the posrotscale set during attach this)

Vector3 getCenterOfBoundingBox() Note; Gets the center position of the bounding box if it was unscaled, you need to multiply by the position to get the center on the stage

Vector3 getCenterOfBoundingBoxScaled() Note; Gets the center position of the bounding box if it was scaled but not positioned, you need to multiply by the position to get the center on the stage

getName() To help debugging you can optionally give objects a name

IsAnimatableModelInstance getParentObject() If this object has a parent, what is it?

void hide() hides it by removing it from the render lists

void hide(boolean setlocalVisibility) There should be a internal boolean to determine if this object "should be" visible. If there is no parent object, this object reflects if this object is visible or not. If there is a parent object, and "inherit visibility" is turned on, then both this localvisibility AND the parents actual visibility have to be true in order for this object to display.

Thus normally when deliberately hiding/showing a object you also want to set the local visiblity variable.

boolean isVisible() Determains if this object is visible or not.

void lookAt(IsAnimatableModelInstance target) Sets this model to "lookat" the target models vector3 location by aligning this models xAxis(1,0,0) to point at the target

void lookAt(IsAnimatableModelInstance target, com.badlogic.gdx.math.Vector3 Axis) Sets this model to lookat the target models vector3 location

void lookAt(Vector3 target, Vector3 Axis) Sets this model to lookat the target vector3 location

Vector3 rayHits(com.badlogic.gdx.math.collision.Ray ray) Defaults to intersectRayBounds against bounding box, but you can override for more precision if needed.

void setAsHitable(boolean hitable) Adds it to the hitable list.

void setInheritedVisibility(boolean inheritVisibility) sets the visibility to be inherited from any parent object.

void setToPosition(com.badlogic.gdx.math.Vector3 vector3) Convince to quickly set the position.

void setToRotation(com.badlogic.gdx.math.Quaternion angle) Convince to quickly set the rotation.

void setToScale(com.badlogic.gdx.math.Vector3 scale) Sets the transform of this meshobject to a certain scale It will also scale all things attached to this, if they have been set to inherit the scale, as well as scaling their relative displacement so they remain attached to the same place

void setTransform(PosRotScale newState)
void show() Shows it by adding it to the render lists.

void show(boolean setlocalVisibility) There should be a internal boolean to determine if this object "should be" visible. If there is no parent object, this object reflects if this object is visible or not. If there is a parent object, and "inherit visibility" is turned on, then both this localvisibility AND the parents actual visibility have to be true in order for this object to display.

Thus normally when deliberately hiding/showing a object you also want to set the local visiblity variable.

void sycnTransform() should be called after ANY set of change to its transState before it will be reflected in the model visually

Clone this wiki locally