net.lenkaspace.creeper.model
Class CRBaseSituatedModel

java.lang.Object
  extended by net.lenkaspace.creeper.model.CRBaseModel
      extended by net.lenkaspace.creeper.model.CRBaseSituatedModel
Direct Known Subclasses:
CRBaseDynamicModel

public class CRBaseSituatedModel
extends CRBaseModel

Represents a model that is situated in a CRWorld and can optionally be rendered but doesn't update

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

Nested Class Summary
static class CRBaseSituatedModel.SHAPE
           
 
Field Summary
 int binIndex
           
 
Fields inherited from class net.lenkaspace.creeper.model.CRBaseModel
childModels, id
 
Constructor Summary
CRBaseSituatedModel(int id_, CRVector3d position_, CRVector3d size_, double rotation_, CRBaseSituatedModel.SHAPE shape_, java.lang.String imageFileName_)
          Constructor
 
Method Summary
 void adjustPositionInBorderlessWorld()
          Sends agent to the left side when went away through right, etc.
 double getAlpha()
           
 CRVector3d[] getCorners()
          Get coordinates of corners, based on shape and current rotation
 java.lang.String getImageFileName()
           
 CRVector3d getPosition()
           
 CRVector3d getPreviousPosition()
           
 CRVector3d getRelativeVectorTo(CRVector3d vector_)
          Get vector to an object translated into local coordinates, based on middle of own body as pivot
 CRVector3d getRelativeVectorTo(CRVector3d vector_, CRVector3d pivot_)
          Get vector to an object translated into local coordinates
 double getRotation()
           
 CRBaseSituatedModel.SHAPE getShape()
           
 CRVector3d getSize()
           
 java.lang.String getToolTip()
           
 CRWorld getWorld()
           
 boolean isAt(CRVector3d coords_, int extraSpace_)
          Find out whether specific coordinates have been reached by any part of the body
 boolean isCollidingWith(CRBaseSituatedModel anotherObject_)
          Find out if colliding with another object
 boolean isCollidingWith(CRBaseSituatedModel anotherObject_, int extraSpace_)
          Find out if colliding with another object
 boolean isVisible()
           
 void onTrialStart(int trialNumber_, int runNumber_)
          Set variables according to their initial values
 void rotateVectorInLocalCoordinates(CRVector3d vector_)
          Rotate a vector around own middle
 void setAlpha(double alpha_)
           
 void setImageFileName(java.lang.String imageFileName_)
           
 void setIsRemoved(boolean is_)
           
 void setIsVisible(boolean value_)
           
 void setPosition(CRVector3d position_)
           
 void setPositionX(double value_)
           
 void setPositionY(double value_)
           
 void setRotation(double rotation_)
           
 void setSize(CRVector3d size_)
           
 void setToolTop(java.lang.String toolTip_)
           
 void setWorld(CRWorld world_)
           
 
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
 

Field Detail

binIndex

public int binIndex
Constructor Detail

CRBaseSituatedModel

public CRBaseSituatedModel(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 CRBaseModel
Parameters:
trialNumber_ - int new trial number
runNumber_ - int new run number

isCollidingWith

public boolean isCollidingWith(CRBaseSituatedModel anotherObject_)
Find out if colliding with another object

Parameters:
anotherObject_ - CRBaseSituatedModel another object
Returns:
boolean true if collision detected

isCollidingWith

public boolean isCollidingWith(CRBaseSituatedModel anotherObject_,
                               int extraSpace_)
Find out if colliding with another object

Parameters:
anotherObject_ - CRBaseSituatedModel another object
extraSpace_ - int extra space around this object that will also count as collision. Not implemented for RECRANGLEs
Returns:
boolean true if collision detected

isAt

public boolean isAt(CRVector3d coords_,
                    int extraSpace_)
Find out whether specific coordinates have been reached by any part of the body

Parameters:
coords_ - CRVector3d coordinates to hit test with
extraSpace_ - int extra space around the object that should be included in the hit test !TODO: not implemented for Rectangles
Returns:
boolean true if at coordinates

getCorners

public CRVector3d[] getCorners()
Get coordinates of corners, based on shape and current rotation

Returns:
CRVector3d[4] corners if shape is RECTANGLE, otherwise return NULL

rotateVectorInLocalCoordinates

public void rotateVectorInLocalCoordinates(CRVector3d vector_)
Rotate a vector around own middle

Parameters:
vector_ - CRVector3d vector to rotate

getRelativeVectorTo

public CRVector3d getRelativeVectorTo(CRVector3d vector_)
Get vector to an object translated into local coordinates, based on middle of own body as pivot

Parameters:
vector_ - CRVector3d vector to point towards
Returns:
CRVector3d vector where X component represents angle towards the object and y component distance

getRelativeVectorTo

public CRVector3d getRelativeVectorTo(CRVector3d vector_,
                                      CRVector3d pivot_)
Get vector to an object translated into local coordinates

Parameters:
vector_ - CRVector3d vector to point towards
pivot_ - CRVector3d vector (within own body) to measure from.
Returns:
CRVector3d vector where X component represents angle towards the object and y component distance

adjustPositionInBorderlessWorld

public void adjustPositionInBorderlessWorld()
Sends agent to the left side when went away through right, etc.


getRotation

public double getRotation()

setRotation

public void setRotation(double rotation_)

getPosition

public CRVector3d getPosition()

setPosition

public void setPosition(CRVector3d position_)

setPositionX

public void setPositionX(double value_)

setPositionY

public void setPositionY(double value_)

getPreviousPosition

public CRVector3d getPreviousPosition()

getSize

public CRVector3d getSize()

setSize

public void setSize(CRVector3d size_)

getWorld

public CRWorld getWorld()

setWorld

public void setWorld(CRWorld world_)

getImageFileName

public java.lang.String getImageFileName()

setImageFileName

public void setImageFileName(java.lang.String imageFileName_)

isVisible

public boolean isVisible()

setIsVisible

public void setIsVisible(boolean value_)

getShape

public CRBaseSituatedModel.SHAPE getShape()

setIsRemoved

public void setIsRemoved(boolean is_)
Overrides:
setIsRemoved in class CRBaseModel

setToolTop

public void setToolTop(java.lang.String toolTip_)

getToolTip

public java.lang.String getToolTip()

setAlpha

public void setAlpha(double alpha_)

getAlpha

public double getAlpha()