Polycode
|
Base class for both 2D and 3D objects in Polycode. More...
Inherited by Polycode::SceneEntity, and Polycode::ScreenEntity.
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 Matrix4 & | getTransformMatrix () 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. | |
Entity * | getParentEntity () const |
Returns the parent entity of the entity. | |
unsigned int | getNumChildren () |
Returns the number of child entities belonging to this entity. | |
Entity * | getChildAtIndex (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. |
Base class for both 2D and 3D objects in Polycode.
It provides position and color transformations as well as hierarchy for all Polycode objects.
void Entity::addChild | ( | Entity * | newChild | ) |
Adds another entity as a child.
The children inherit the parent's transforms.
newChild | The entity to be added. |
void Entity::addEntity | ( | Entity * | newChild | ) |
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.
val | New value of the dirty matrix flag. |
Number Entity::getBBoxRadius | ( | ) | const |
Returns the bounding box radius.
Entity * Entity::getChildAtIndex | ( | unsigned int | index | ) |
Returns the child entity at specified index.
index | Index to return entity at. |
Color Entity::getCombinedColor | ( | ) | const |
Returns the entity's color multiplied by its parent entity's combined color.
Number Entity::getCombinedPitch | ( | ) | const |
Returns the entity's pitch combined with the combined pitch of its parent.
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.
Number Entity::getCombinedRoll | ( | ) | const |
Returns the entity's roll combined with the combined roll of its parent.
Number Entity::getCombinedYaw | ( | ) | const |
Returns the entity's yaw combined with the combined yaw of its parent.
Number Entity::getCompoundBBoxRadius | ( | ) | const |
Returns the entity's bounding box radius compounded from its children's bounding box radii.
Vector3 Entity::getCompoundScale | ( | ) | const |
Returns the entity's scale multiplied by its parent's compound scale.
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.
Matrix4 Entity::getConcatenatedRollMatrix | ( | ) | const |
Returns Same as getConcatenatedMatrix(), but contains only roll information for rotation.
Used internally for billboards.
Returns the matrix for the entity looking at a location based on a location and an up vector.
loc | Location to look at. |
upVector | Up vector. |
unsigned int Entity::getNumChildren | ( | ) |
Returns the number of child entities belonging to this entity.
Entity * Entity::getParentEntity | ( | ) | const |
Returns the parent entity of the entity.
Number Entity::getPitch | ( | ) | const |
Returns the current pitch of the entity.
Vector3 Entity::getPosition | ( | ) | const |
Returns the entity's position.
Number Entity::getRoll | ( | ) | const |
Returns the current roll of the entity.
Quaternion Entity::getRotationQuat | ( | ) | const |
Returns the current rotation as a quaternion.
Vector3 Entity::getScale | ( | ) | const |
Returns the entity's scale.
const Matrix4 & Entity::getTransformMatrix | ( | ) | const |
Returns the entity's transform matrix.
void * Entity::getUserData | ( | ) |
Returns the user data pointer.
Number Entity::getYaw | ( | ) | const |
Returns the current yaw of the entity.
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.
loc | Location to look at. |
upVector | The up vector. |
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.
loc | Location to look at. |
upVector | The up vector. |
void Entity::Pitch | ( | Number | pitch | ) |
Pitches the entity relative to its current pitch.
pitch | Pitch value in degrees. |
void Entity::removeChild | ( | Entity * | entityToRemove | ) |
Removes an entity from the entity's children.
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::SceneLight, Polycode::SceneMesh, Polycode::ScreenMesh, Polycode::Bone, Polycode::ScreenLine, Polycode::SceneLine, and Polycode::ScreenShape.
void Entity::Roll | ( | Number | roll | ) |
Rolls the entity relative to its current roll.
roll | Roll value in degrees. |
void Entity::Scale | ( | Number | x, |
Number | y, | ||
Number | z | ||
) |
Scales the entity relative to its current scale.
x | X-axis value. |
y | Y-axis value. |
z | Z-axis value. |
void Entity::setBBoxRadius | ( | Number | rad | ) |
Sets the bounding box radius.
rad | New bounding box radius. |
void Entity::setColor | ( | Number | r, |
Number | g, | ||
Number | b, | ||
Number | a | ||
) |
Sets the color of the entity as normalized floating point values.
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::setColor | ( | Color | color | ) |
Sets the color of the entity as 0-255 integers.
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::setColorInt | ( | int | r, |
int | g, | ||
int | b, | ||
int | a | ||
) |
Sets the color of the entity as 0-255 integers.
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.
entity | Parent entity. |
void Entity::setPitch | ( | Number | pitch | ) |
Sets the pitch rotation of the entity.
pitch | New pitch value in degrees. |
void Entity::setPosition | ( | Number | x, |
Number | y, | ||
Number | z | ||
) |
Sets the entity's position.
x | X-axis value. |
y | Y-axis value. |
z | Z-axis value. |
void Entity::setPosition | ( | const Vector3 & | posVec | ) |
Sets the entity's position with a vector.
posVec | New position as a vector. |
void Entity::setPositionX | ( | Number | x | ) |
Returns the entity's position on the X axis.
x | X-axis value. |
void Entity::setPositionY | ( | Number | y | ) |
Returns the entity's position on the Y axis.
y | Y-axis value. |
void Entity::setPositionZ | ( | Number | z | ) |
Returns the entity's position on the Z axis.
z | Z-axis value. |
void Entity::setRoll | ( | Number | roll | ) |
Sets the roll rotation of the entity.
roll | New roll value in degrees. |
void Entity::setRotationQuat | ( | Number | w, |
Number | x, | ||
Number | y, | ||
Number | z | ||
) |
Sets the rotation with quaternion value.
Current | yaw value. |
void Entity::setScale | ( | Number | x, |
Number | y, | ||
Number | z | ||
) |
Sets the entity's scale.
x | X-axis value. |
y | Y-axis value. |
z | Z-axis value. |
void Entity::setScale | ( | const Vector3 & | v | ) |
Sets the entity's scale.
v | New scale vector. |
void Entity::setScaleX | ( | Number | x | ) |
Returns the entity's scale on the X axis.
x | X-axis scale value. |
void Entity::setScaleY | ( | Number | y | ) |
Returns the entity's scale on the Y axis.
y | Y-axis scale value. |
void Entity::setScaleZ | ( | Number | z | ) |
Returns the entity's scale on the Z axis.
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.
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.
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.
userData | User data pointer |
void Entity::setYaw | ( | Number | yaw | ) |
Sets the yaw rotation of the entity.
yaw | New yaw value in degrees. |
void Entity::Translate | ( | Number | x, |
Number | y, | ||
Number | z | ||
) |
Translates the entity relative to its current position.
x | X-axis value. |
y | Y-axis value. |
z | Z-axis value. |
void Entity::Translate | ( | const Vector3 & | tVec | ) |
Translates the entity relative to its current position with a vector.
tVec | New position as a vector. |
virtual void Polycode::Entity::Update | ( | ) | [inline, virtual] |
Main update method.
Override this to do your updates before the render cycle.
Reimplemented in Polycode::ScreenParticleEmitter, Polycode::SceneParticleEmitter, Polycode::Skeleton, Polycode::ScreenSprite, Polycode::ScreenLine, Polycode::SceneSound, Polycode::ScreenSound, Polycode::SceneSoundListener, and Polycode::ScreenSoundListener.
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.
yaw | Yaw value in degrees. |
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).