Skip to content

AnimatedModelInstance

ThomasWrobel edited this page Aug 21, 2017 · 10 revisions

AnimatedModelInstance

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. @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.

Selective details copied from jardoc:

void attachThis(IsAnimatableModelInstance objectToAttach, PosRotScale displacement) Lets you stick one object to another.

void fireClick() fired after the touchup event provided the object was previously toucheddown on

void fireDragStart()
void fireTouchDown()
void fireTouchUp()
java.util.Set getAllAttachments() gets all attachments and child attachments

com.badlogic.gdx.math.Quaternion getAngleTo(IsAnimatableModelInstance target) Method to find the axis-angle between this AnimatableModelInstances and another relative to the xAxis (1,0,0)

com.badlogic.gdx.math.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.

com.badlogic.gdx.math.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) Note; returns the displacement specification of the specified object from this one.

com.badlogic.gdx.math.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

com.badlogic.gdx.math.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

com.badlogic.gdx.math.Vector3 getCenterOnStage() = getCenterOfBoundingBox() * position matrix

float getHeight() returns unscaled total height, based on a bounding box

objectInteractionType getInteractionType() does this object block whats behind it?

float getLastHitsRange()
com.badlogic.gdx.math.collision.BoundingBox getLocalBoundingBox()
com.badlogic.gdx.math.collision.BoundingBox getLocalCollisionBox()
com.badlogic.gdx.math.collision.BoundingBox getLocalCollisionBox(boolean onceOnly)
com.badlogic.gdx.math.Matrix4 getMatrixTransform() try to avoid using this, use the transState to update/change things then sync to reflect them in the instance.

java.lang.String getName() To help debugging you can optionally give objects a name

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

com.badlogic.gdx.math.Vector3 getPivotsDisplacementFromCenterOfBoundingBox() the position of the pivot relative to the bounding box center

float getScaledHeight() returns scaled height

float getScaledWidth() returns scaled width

PosRotScale getTransform()
float getWidth() returns unscaled total width, based on a bounding box

boolean hasAttachment(AnimatableModelInstance object)
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.

void inheritTransform(PosRotScale newState)
boolean isInheriteingVisibility()
boolean isOverlay() If this is set to render in the overlay list

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(com.badlogic.gdx.math.Vector3 target, com.badlogic.gdx.math.Vector3 Axis) Sets this model to lookat the target vector3 location

com.badlogic.gdx.math.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 removeAttachment(IsAnimatableModelInstance objectToRemove)
void setAsHitable(boolean hitable) Adds it to the hitable list.

void setAsOverlay(boolean status)
void setInheritedPosition(boolean inheritedPosition)
void setInheritedRotation(boolean inheritedRotation)
void setInheritedScale(boolean inheritedScale)
void setInheritedVisibility(boolean inheritVisibility) sets the visibility to be inherited from any parent object.

void setLastHitsRange(float range)
void setParentObject(IsAnimatableModelInstance parentObject) Sets the parent object removing it from any existing parent first.

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

void updateAtachment(IsAnimatableModelInstance object, PosRotScale displacement)
void wasResized() should not really need to be public only temp while testing things to ensure it isn't the bounding box being inaccurate

Clone this wiki locally