Polycode::Entity Class Reference

Base class for both 2D and 3D objects in Polycode. More...

Inherited by Polycode::SceneEntity, and Polycode::ScreenEntity.

List of all members.

Public Member Functions

virtual void Render ()
 Main render method.
virtual void Update ()
 Main update method.
void setUserData (void *userData)
 If this flag is set to true, this entity's transformations will not take into account its parent, making its transforms always relative to 0.
void * getUserData ()
 Returns the user data pointer.
Matrix operations.

These methods operate directly on the entity's matrix.

void dirtyMatrix (bool val)
 Sets the state of the dirty matrix flag.
void rebuildTransformMatrix ()
 Forces the transformation matrix to be rebuilt.
void updateEntityMatrix ()
 Forces the matrix to be rebuilt if the matrix flag is dirty.
const Matrix4getTransformMatrix () const
 Returns the entity's transform matrix.
Matrix4 getConcatenatedMatrix () const
 Returns the entity's matrix multiplied by its parent's concatenated matrix.
Matrix4 getConcatenatedRollMatrix () const
 Returns Same as getConcatenatedMatrix(), but contains only roll information for rotation.
void setTransformByMatrix (const Matrix4 &matrix)
 Sets all of the individual transform properties from the matrix and rebuilds the transform matrix.
void setTransformByMatrixPure (const Matrix4 &matrix)
 Sets the transform matrix directly, without setting all of the individual transfrom properties of the entity.
Matrix4 getLookAtMatrix (const Vector3 &loc, const Vector3 &upVector=Vector3(0, 1, 0))
 Returns the matrix for the entity looking at a location based on a location and an up vector.
Transform operations.

These methods apply various transformations to the entity.

Vector3 getPosition () const
 Returns the entity's position.
Vector3 getCombinedPosition () const
 Returns the entity's position added to the combined position of its parent.
void setPosition (Number x, Number y, Number z)
 Sets the entity's position.
void setPosition (const Vector3 &posVec)
 Sets the entity's position with a vector.
void setPositionX (Number x)
 Returns the entity's position on the X axis.
void setPositionY (Number y)
 Returns the entity's position on the Y axis.
void Translate (Number x, Number y, Number z)
 Translates the entity relative to its current position.
void Translate (const Vector3 &tVec)
 Translates the entity relative to its current position with a vector.
void setPositionZ (Number z)
 Returns the entity's position on the Z axis.
void setScaleX (Number x)
 Returns the entity's scale on the X axis.
void setScaleY (Number y)
 Returns the entity's scale on the Y axis.
void setScaleZ (Number z)
 Returns the entity's scale on the Z axis.
void Scale (Number x, Number y, Number z)
 Scales the entity relative to its current scale.
void setScale (Number x, Number y, Number z)
 Sets the entity's scale.
void setScale (const Vector3 &v)
 Sets the entity's scale.
Vector3 getCompoundScale () const
 Returns the entity's scale multiplied by its parent's compound scale.
Vector3 getScale () const
 Returns the entity's scale.
Number getCombinedPitch () const
 Returns the entity's pitch combined with the combined pitch of its parent.
Number getCombinedYaw () const
 Returns the entity's yaw combined with the combined yaw of its parent.
Number getCombinedRoll () const
 Returns the entity's roll combined with the combined roll of its parent.
void rebuildRotation ()
 Forces the rotation quaternion to be rebuilt.
void setPitch (Number pitch)
 Sets the pitch rotation of the entity.
void setYaw (Number yaw)
 Sets the yaw rotation of the entity.
void setRoll (Number roll)
 Sets the roll rotation of the entity.
void Roll (Number roll)
 Rolls the entity relative to its current roll.
void Yaw (Number yaw)
 Yaws the entity relative to its current yaw.
void Pitch (Number pitch)
 Pitches the entity relative to its current pitch.
Number getPitch () const
 Returns the current pitch of the entity.
Number getYaw () const
 Returns the current yaw of the entity.
Number getRoll () const
 Returns the current roll of the entity.
void setRotationQuat (Number w, Number x, Number y, Number z)
 Sets the rotation with quaternion value.
Quaternion getRotationQuat () const
 Returns the current rotation as a quaternion.
void lookAt (const Vector3 &loc, const Vector3 &upVector=Vector3(0, 1, 0))
 Orients the entity towards the specified location with the provided up vector.
void lookAtEntity (Entity *entity, const Vector3 &upVector=Vector3(0, 1, 0))
 Orients the entity towards another entity with the provided up vector.
Color getCombinedColor () const
 Returns the entity's color multiplied by its parent entity's combined color.
void setColor (Number r, Number g, Number b, Number a)
 Sets the color of the entity as normalized floating point values.
void setColorInt (int r, int g, int b, int a)
 Sets the color of the entity as 0-255 integers.
void setColor (Color color)
 Sets the color of the entity as 0-255 integers.
Bounding box operations.

These methods modify the bounding box of the entity.

The bounding box is used for culling and collision detection.

void recalculateBBox ()
 Recalculates the bounding box of the entity based on its size.
Number getBBoxRadius () const
 Returns the bounding box radius.
Number getCompoundBBoxRadius () const
 Returns the entity's bounding box radius compounded from its children's bounding box radii.
void setBBoxRadius (Number rad)
 Sets the bounding box radius.

Hierarchy operations.

These methods add and remove entities to and from each other.



bool ownsChildren
 If set to true, will automatically delete children upon destruction.
void addEntity (Entity *newChild)
void addChild (Entity *newChild)
 Adds another entity as a child.
void removeChild (Entity *entityToRemove)
 Removes an entity from the entity's children.
void setParentEntity (Entity *entity)
 Manually sets the entity's parent.
EntitygetParentEntity () const
 Returns the parent entity of the entity.
unsigned int getNumChildren ()
 Returns the number of child entities belonging to this entity.
EntitygetChildAtIndex (unsigned int index)
 Returns the child entity at specified index.

Rendering properties

Methods and properties affecting the way the entity is rendered.



String custEntityType
 You can set a custom string identifier for user purposes.
bool billboardMode
 If this flag is true, the entity will always face the camera.
bool billboardRoll
 Normally, if billboardMode is on, no rotation is allowed at all.
bool alphaTest
 Normally, translucent textures do not affect the depth buffer, but if this flag is set to true, this entity's alpha channel is written to the depth buffer at a preset threshold.
bool backfaceCulled
 If this flag is set to false, backface culling is disabled when rendering this entity, rendering both sides of each face.
bool renderWireframe
 If this flag is set to true, the entity will render in wireframe.
Color color
 The entity's color.
bool enabled
 If this flag is set to false, this entity will not be rendered or updated.
bool visible
 If this flag is set to false, this entity will not be rendered.
bool depthWrite
 If this flag is set to false, this entity will not write to the depth buffer when it's rendered.
bool depthTest
 If this flag is set to false, this entity will not check the depth buffer when it's rendering.
int blendingMode
 Blending mode for rendering this entity.
bool colorAffectsChildren
 If set to false, the children of this entity will not multiply by this entity's color.
bool visibilityAffectsChildren
 If set to false, the children will be rendered even if the entity is invisible.
bool depthOnly
 If this flag is set to true, this entity will render only into the depth buffer.
void setMask (Entity *mask)
 Sets another entity as a mask for this entity (This is not really working properly right now).
void clearMask ()
 Removes the entity's mask.

Detailed Description

Base class for both 2D and 3D objects in Polycode.

It provides position and color transformations as well as hierarchy for all Polycode objects.


Member Function Documentation

void Entity::addChild ( Entity newChild  ) 

Adds another entity as a child.

The children inherit the parent's transforms.

Parameters:
newChild The entity to be added.
void Entity::addEntity ( Entity newChild  ) 
See also:
addChild()
void Entity::dirtyMatrix ( bool  val  ) 

Sets the state of the dirty matrix flag.

The dirty matrix flag gets set automatically when a transformation is applied to the entity and the transfrom matrix needs to be rebuilt. This method is provided to manually override that flag.

Parameters:
val New value of the dirty matrix flag.
Number Entity::getBBoxRadius (  )  const

Returns the bounding box radius.

Returns:
The bounding box radius.
Entity * Entity::getChildAtIndex ( unsigned int  index  ) 

Returns the child entity at specified index.

Parameters:
index Index to return entity at.
Returns:
Child entity at specified index or NULL of index out of range.
Color Entity::getCombinedColor (  )  const

Returns the entity's color multiplied by its parent entity's combined color.

Returns:
Entity's combined color.
Number Entity::getCombinedPitch (  )  const

Returns the entity's pitch combined with the combined pitch of its parent.

Returns:
Entity's combined pitch.
Vector3 Entity::getCombinedPosition (  )  const

Returns the entity's position added to the combined position of its parent.

This method is here only for convenience of calculating certain properties and should not be used to get an entity's actual position in the world. To get the actual world position of the entity, use the entity's concatendated matrix.

See also:
getConcatenatedMatrix()
Returns:
Entity's position as a vector.
Number Entity::getCombinedRoll (  )  const

Returns the entity's roll combined with the combined roll of its parent.

Returns:
Entity's combined roll.
Number Entity::getCombinedYaw (  )  const

Returns the entity's yaw combined with the combined yaw of its parent.

Returns:
Entity's combined yaw.
Number Entity::getCompoundBBoxRadius (  )  const

Returns the entity's bounding box radius compounded from its children's bounding box radii.

Returns:
The compound bounding box radius.
Vector3 Entity::getCompoundScale (  )  const

Returns the entity's scale multiplied by its parent's compound scale.

Returns:
Compound scale as vector.
Matrix4 Entity::getConcatenatedMatrix (  )  const

Returns the entity's matrix multiplied by its parent's concatenated matrix.

This, in effect, returns the entity's actual world transformation.

Returns:
Entity's concatenated matrix.
Matrix4 Entity::getConcatenatedRollMatrix (  )  const

Returns Same as getConcatenatedMatrix(), but contains only roll information for rotation.

Used internally for billboards.

Returns:
Entity's concatenated roll matrix.
See also:
getConcatenatedMatrix()
Matrix4 Entity::getLookAtMatrix ( const Vector3 loc,
const Vector3 upVector = Vector3(0,1,0) 
)

Returns the matrix for the entity looking at a location based on a location and an up vector.

Parameters:
loc Location to look at.
upVector Up vector.
Returns:
The resulting lookAt matrix.
unsigned int Entity::getNumChildren (  ) 

Returns the number of child entities belonging to this entity.

Returns:
Number of child entities.
Entity * Entity::getParentEntity (  )  const

Returns the parent entity of the entity.

Returns:
Parent entity of this entity.
Number Entity::getPitch (  )  const

Returns the current pitch of the entity.

Returns:
Current pitch value.
Vector3 Entity::getPosition (  )  const

Returns the entity's position.

Returns:
Entity's position as a vector.
Number Entity::getRoll (  )  const

Returns the current roll of the entity.

Returns:
Current roll value.
Quaternion Entity::getRotationQuat (  )  const

Returns the current rotation as a quaternion.

Returns:
Current rotation value.
Vector3 Entity::getScale (  )  const

Returns the entity's scale.

Returns:
Entity's scale as a vector.
const Matrix4 & Entity::getTransformMatrix (  )  const

Returns the entity's transform matrix.

Returns:
Transform matrix.
void * Entity::getUserData (  ) 

Returns the user data pointer.

Returns:
User data pointer
Number Entity::getYaw (  )  const

Returns the current yaw of the entity.

Returns:
Current yaw value.
void Entity::lookAt ( const Vector3 loc,
const Vector3 upVector = Vector3(0,1,0) 
)

Orients the entity towards the specified location with the provided up vector.

The up vector determines which side of the entity will be pointing in that direction.

Parameters:
loc Location to look at.
upVector The up vector.
void Entity::lookAtEntity ( Entity entity,
const Vector3 upVector = Vector3(0,1,0) 
)

Orients the entity towards another entity with the provided up vector.

The up vector determines which side of the entity will be pointing in that direction.

Parameters:
loc Location to look at.
upVector The up vector.
See also:
lookAt()
void Entity::Pitch ( Number  pitch  ) 

Pitches the entity relative to its current pitch.

Parameters:
pitch Pitch value in degrees.
void Entity::removeChild ( Entity entityToRemove  ) 

Removes an entity from the entity's children.

Parameters:
entityToRemove Entity to be removed.
virtual void Polycode::Entity::Render (  )  [inline, virtual]

Main render method.

Override this to do your own drawing.

Reimplemented in Polycode::Bone, Polycode::SceneLight, Polycode::SceneLine, Polycode::SceneMesh, Polycode::ScreenLine, Polycode::ScreenMesh, and Polycode::ScreenShape.

void Entity::Roll ( Number  roll  ) 

Rolls the entity relative to its current roll.

Parameters:
roll Roll value in degrees.
void Entity::Scale ( Number  x,
Number  y,
Number  z 
)

Scales the entity relative to its current scale.

Parameters:
x X-axis value.
y Y-axis value.
z Z-axis value.
void Entity::setBBoxRadius ( Number  rad  ) 

Sets the bounding box radius.

Parameters:
rad New bounding box radius.
void Entity::setColor ( Color  color  ) 

Sets the color of the entity as 0-255 integers.

Parameters:
r Red value as a 0-255 integer.
g Green value as a 0-255 integer.
b Blue value as a 0-255 integer.
a Alpha value as a 0-255 integer.
void Entity::setColor ( Number  r,
Number  g,
Number  b,
Number  a 
)

Sets the color of the entity as normalized floating point values.

Parameters:
r Red value as a 0-1 floating point number.
g Green value as a 0-1 floating point number.
b Blue value as a 0-1 floating point number.
a Alpha value as a 0-1 floating point number.
void Entity::setColorInt ( int  r,
int  g,
int  b,
int  a 
)

Sets the color of the entity as 0-255 integers.

Parameters:
r Red value as a 0-255 integer.
g Green value as a 0-255 integer.
b Blue value as a 0-255 integer.
a Alpha value as a 0-255 integer.
void Entity::setParentEntity ( Entity entity  ) 

Manually sets the entity's parent.

This method does not add the entity to the parent and should not be called manually.

Parameters:
entity Parent entity.
void Entity::setPitch ( Number  pitch  ) 

Sets the pitch rotation of the entity.

Parameters:
pitch New pitch value in degrees.
void Entity::setPosition ( const Vector3 posVec  ) 

Sets the entity's position with a vector.

Parameters:
posVec New position as a vector.
void Entity::setPosition ( Number  x,
Number  y,
Number  z 
)

Sets the entity's position.

Parameters:
x X-axis value.
y Y-axis value.
z Z-axis value.
void Entity::setPositionX ( Number  x  ) 

Returns the entity's position on the X axis.

Parameters:
x X-axis value.
void Entity::setPositionY ( Number  y  ) 

Returns the entity's position on the Y axis.

Parameters:
y Y-axis value.
void Entity::setPositionZ ( Number  z  ) 

Returns the entity's position on the Z axis.

Parameters:
z Z-axis value.
void Entity::setRoll ( Number  roll  ) 

Sets the roll rotation of the entity.

Parameters:
roll New roll value in degrees.
void Entity::setRotationQuat ( Number  w,
Number  x,
Number  y,
Number  z 
)

Sets the rotation with quaternion value.

Parameters:
Current yaw value.
void Entity::setScale ( const Vector3 v  ) 

Sets the entity's scale.

Parameters:
v New scale vector.
void Entity::setScale ( Number  x,
Number  y,
Number  z 
)

Sets the entity's scale.

Parameters:
x X-axis value.
y Y-axis value.
z Z-axis value.
void Entity::setScaleX ( Number  x  ) 

Returns the entity's scale on the X axis.

Parameters:
x X-axis scale value.
void Entity::setScaleY ( Number  y  ) 

Returns the entity's scale on the Y axis.

Parameters:
y Y-axis scale value.
void Entity::setScaleZ ( Number  z  ) 

Returns the entity's scale on the Z axis.

Parameters:
z Z-axis scale value.
void Entity::setTransformByMatrix ( const Matrix4 matrix  ) 

Sets all of the individual transform properties from the matrix and rebuilds the transform matrix.

Parameters:
matrix 4x4 transform matrix to apply.

setPitch(atan2(-matrix.m[0][1], matrix.m[0][0]) * TODEGREES);

void Entity::setTransformByMatrixPure ( const Matrix4 matrix  ) 

Sets the transform matrix directly, without setting all of the individual transfrom properties of the entity.

Parameters:
matrix 4x4 transform matrix to apply.
void Entity::setUserData ( void *  userData  ) 

If this flag is set to true, this entity's transformations will not take into account its parent, making its transforms always relative to 0.

Sets user data pointer.

Parameters:
userData User data pointer
void Entity::setYaw ( Number  yaw  ) 

Sets the yaw rotation of the entity.

Parameters:
yaw New yaw value in degrees.
void Entity::Translate ( const Vector3 tVec  ) 

Translates the entity relative to its current position with a vector.

Parameters:
tVec New position as a vector.
void Entity::Translate ( Number  x,
Number  y,
Number  z 
)

Translates the entity relative to its current position.

Parameters:
x X-axis value.
y Y-axis value.
z Z-axis value.
virtual void Polycode::Entity::Update (  )  [inline, virtual]
void Entity::updateEntityMatrix (  ) 

Forces the matrix to be rebuilt if the matrix flag is dirty.

This is also called on all of the entity's children.

void Entity::Yaw ( Number  yaw  ) 

Yaws the entity relative to its current yaw.

Parameters:
yaw Yaw value in degrees.

Member Data Documentation

Normally, translucent textures do not affect the depth buffer, but if this flag is set to true, this entity's alpha channel is written to the depth buffer at a preset threshold.

This flag is set to false by default.

If this flag is set to false, backface culling is disabled when rendering this entity, rendering both sides of each face.

Set to true by default.

If this flag is true, the entity will always face the camera.

False by default.

Normally, if billboardMode is on, no rotation is allowed at all.

If this flag is also true, you can rotate the entity around the axis pointing to the camera.

Blending mode for rendering this entity.

Possible blending modes are: Renderer::BLEND_MODE_NORMAL - Draw entity normally Renderer::BLEND_MODE_LIGHTEN - Add the entity's color on top of the background color. Renderer::BLEND_MODE_COLOR - Only change the color of the background.

If set to false, the children of this entity will not multiply by this entity's color.

Set to true by default.

If this flag is set to true, this entity will render only into the depth buffer.

This, effectively, means that it will be invisible, but still obscuring other entities.

If set to true, will automatically delete children upon destruction.

(defaults to false).

Generated on Sat Aug 11 18:04:11 2012 for Polycode by  doxygen 1.6.3