net.lenkaspace.creeper.model
Class CRBaseDynamicModel

java.lang.Object
  extended by net.lenkaspace.creeper.model.CRBaseModel
      extended by net.lenkaspace.creeper.model.CRBaseSituatedModel
          extended by net.lenkaspace.creeper.model.CRBaseDynamicModel

public class CRBaseDynamicModel
extends CRBaseSituatedModel

Represents a model that is situated in a CRWorld, can be rendered and moves / updates

Version:
2.0
Author:
Lenka Pitonakova contact@lenkaspace.net

Nested Class Summary
 
Nested classes/interfaces inherited from class net.lenkaspace.creeper.model.CRBaseSituatedModel
CRBaseSituatedModel.SHAPE
 
Field Summary
 
Fields inherited from class net.lenkaspace.creeper.model.CRBaseSituatedModel
binIndex
 
Fields inherited from class net.lenkaspace.creeper.model.CRBaseModel
childModels, id
 
Constructor Summary
CRBaseDynamicModel(int id_, CRVector3d position_, CRVector3d size_, double rotation_, CRBaseSituatedModel.SHAPE shape_, java.lang.String imageFileName_)
          Constructor
 
Method Summary
 void applyThrusters()
          Calculation of new x y position based on thrust forces
 CRVector3d getLookAtVector()
          Get vector that points in front of the situated model
 CRVector3d getOrientationVector()
          Get normalised steering force vector
 double getThrustForce()
           
 CRVector3d getVelocity()
          Get current velocity based on rotation and thrustforce.
 void onTrialStart(int trialNumber_, int runNumber_)
          Set variables according to their initial values
 void onUpdateLoopEnd()
          Called from CRWorld after update() of all objects is called.
 void onUpdateLoopStart()
          Called from CRWorld before update() of all objects is called.
 void setThrustForce(double value)
          Sets thrust force and makes sure it is within specified bounds.
 void turnByAngle(double angle_)
          Turn by a certain angle, i.e.
 void update()
          Main update function.
 
Methods inherited from class net.lenkaspace.creeper.model.CRBaseSituatedModel
adjustPositionInBorderlessWorld, getAlpha, getCorners, getImageFileName, getPosition, getPreviousPosition, getRelativeVectorTo, getRelativeVectorTo, getRotation, getShape, getSize, getToolTip, getWorld, isAt, isCollidingWith, isCollidingWith, isVisible, rotateVectorInLocalCoordinates, setAlpha, setImageFileName, setIsRemoved, setIsVisible, setPosition, setPositionX, setPositionY, setRotation, setSize, setToolTop, setWorld
 
Methods inherited from class net.lenkaspace.creeper.model.CRBaseModel
addChildModel, clearChildren, getId, getIsRemoved, onRunEnd, onRunStart, onTrialEnd, removeChildModel, setId
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CRBaseDynamicModel

public CRBaseDynamicModel(int id_,
                          CRVector3d position_,
                          CRVector3d size_,
                          double rotation_,
                          CRBaseSituatedModel.SHAPE shape_,
                          java.lang.String imageFileName_)
Constructor

Parameters:
id_ - Id of the model
position_ - CRVector3d position [x,y,z]
size_ - CRVector3d size [width, height, depth]
rotation_ - Double rotation in degrees where 0 is pointing towards top
shape_ - SHAPE shape
imageFileName_ - String image name that is used for rendering. If empty or null, the instance doesn't render. Use your own image or one of CRRenderer constants
Method Detail

onTrialStart

public void onTrialStart(int trialNumber_,
                         int runNumber_)
Set variables according to their initial values

Overrides:
onTrialStart in class CRBaseSituatedModel
Parameters:
trialNumber_ - int new trial number
runNumber_ - int new run number

onUpdateLoopStart

public void onUpdateLoopStart()
Called from CRWorld before update() of all objects is called. Use this to reset any temporary variables.


onUpdateLoopEnd

public void onUpdateLoopEnd()
Called from CRWorld after update() of all objects is called. Use this to save any necessary data


update

public void update()
Main update function.


applyThrusters

public void applyThrusters()
Calculation of new x y position based on thrust forces


turnByAngle

public void turnByAngle(double angle_)
Turn by a certain angle, i.e. add to the current rotation

Parameters:
angle_ - value to add to the current rotation

getVelocity

public CRVector3d getVelocity()
Get current velocity based on rotation and thrustforce.

Returns:
CRVector3d velocity that is always between <0;1>, i.e. does not take maxSpeed into account

getOrientationVector

public CRVector3d getOrientationVector()
Get normalised steering force vector


getLookAtVector

public CRVector3d getLookAtVector()
Get vector that points in front of the situated model


getThrustForce

public double getThrustForce()

setThrustForce

public void setThrustForce(double value)
Sets thrust force and makes sure it is within specified bounds.

Parameters:
value - thrust force