Neo
0.5.0
Developer Documentation
|
The Object3d class represents a general object in a 3D scene. More...
#include <Object3d.h>
Classes | |
class | AdditionalData |
Public Member Functions | |
Object3d (void) | |
virtual | ~Object3d (void) |
Object3d (const Object3d &object) | |
AdditionalData * | getAdditionalData () |
void | setAdditionalData (AdditionalData *d) |
void | updateMatrix (void) |
Recalculates the internal matrix relative to the parent object. More... | |
void | computeLocalMatrix (void) |
Calculates the local matrix without respecting the parent. More... | |
Matrix4x4 * | getMatrix (void) |
Returns the current matrix. More... | |
void | unlinkChildren (void) |
Unlinks all children from this object and sets their parent to NULL. More... | |
void | computeChildrenMatrices (void) |
Calculates the matrix of every child object. More... | |
void | setAttribute (const char *name, NeoVariable variable) |
Sets the value of the attribute with the given name. More... | |
NeoVariable | getAttribute (const char *name) |
Returns the value of the attribute variable with the given name. More... | |
Vector3 | getUniformRotatedVector (const Vector3 &vector) |
Rotates the given vector while preserving its length and returns the result. More... | |
Vector3 | getInverseRotatedVector (const Vector3 &vector) const |
Calculates the inverse rotated vector. More... | |
Vector3 | getRotatedVector (const Vector3 &vector) const |
Rotates the given vector and returns the result. More... | |
Vector3 | getInversePosition (const Vector3 &position) const |
Multiplies the inverse matrix with the given vector and return the result. More... | |
Vector3 | getTransformedVector (const Vector3 &vector) const |
Transforms the given vector using the internal matrix. More... | |
void | setPosition (const Vector3 &position) |
Changes the position. More... | |
void | translate (const Vector3 &vec, bool local=false) |
Translates the object. More... | |
void | rotate (const Vector3 &axis, float angle, bool local=false) |
Rotates the object. More... | |
Vector3 | getTransformedPosition (void) const |
Returns the transformed position directly from the internal matrix. More... | |
Vector3 | getPosition (void) const |
Returns the position as a Vector3. More... | |
void | setEulerRotation (const Vector3 &euler) |
Changes the Euler rotation. More... | |
void | setAxisAngleRotation (const Vector3 &axis, float angle) |
Changes the angle of the specified axis. More... | |
void | addAxisAngleRotation (const Vector3 &axis, float angle) |
Changes the angle of the specified axis by adding the given value. More... | |
void | setRotation (const Quaternion &rotation) |
Sets the rotation or the object. More... | |
Vector3 | getTransformedRotation (void) const |
Returns the transformed rotation. More... | |
Vector3 | getEulerRotation (void) const |
Returns the Euler rotation in a Vector3 in degrees. More... | |
Quaternion | getRotation (void) const |
Returns the rotation of the object. More... | |
void | setScale (const Vector3 &scale) |
Changes the scale of the object. More... | |
Vector3 | getTransformedScale (void) const |
Returns the transformed scale of the object. More... | |
Vector3 | getScale (void) const |
Returns the scale of the object. More... | |
void | linkTo (Object3d *parent) |
Links the object to another object. More... | |
void | unLink (void) |
Removing the link to the parent object. More... | |
void | setParent (Object3d *object) |
Sets the parent object. More... | |
void | addChild (Object3d *child) |
Adds an Object3d to the list of children. More... | |
bool | hasParent (void) |
Checks if the object has a parent. More... | |
unsigned int | getChildrenNumber (void) |
Returns the number of children. More... | |
Object3d * | getParent (void) |
Returns the parent object. More... | |
Object3d * | getChild (unsigned int id) |
Returns the child with the given ID. More... | |
unsigned long | getId () |
Returns the ID of the object. More... | |
void | setId (unsigned long id) |
Changes the ID of the object. More... | |
void | updateBehaviors (void) |
Updates all behaviors. More... | |
void | drawBehaviors (void) |
Draws all behaviors. More... | |
void | deleteBehavior (unsigned int id) |
Deletes the Behavior with the given ID. More... | |
void | invertBehavior (unsigned int idA, unsigned int idB) |
Switches the IDs of the given behavior IDs. More... | |
void | changeBehavior (unsigned int id, Behavior *behavior) |
Replaces the behavior with the given ID with the given Behavior. More... | |
void | addBehavior (Behavior *behavior) |
Adds a new behavior to the list of behaviors. More... | |
unsigned int | getBehaviorsNumber (void) |
Returns the number of registered Behaviors. More... | |
Behavior * | getBehavior (unsigned int id) |
Returns the Behavior with the given ID. More... | |
bool | needToUpdate (void) |
Checks if the object needs to be updated. More... | |
virtual void | setActive (bool active) |
Changes if the object is being active or inactive. More... | |
bool | isActive (void) |
Checks if the object is active. More... | |
void | setVisible (bool visible) |
Changes if the object is visible or not. More... | |
bool | isVisible (void) |
Checks if the object is visible. More... | |
virtual void | updateVisibility (OCamera *camera) |
Recalculates visibility for the given camera. More... | |
void | setName (const char *name) |
Change the object name. More... | |
const char * | getName (void) |
Returns the object name. More... | |
virtual int | getType (void) |
Returns the type of the object. More... | |
virtual void | update (void) |
Updates the object. More... | |
Protected Types | |
typedef unordered_map< string, NeoVariable >::iterator | AttributeIterator |
typedef map< string, NeoVariable >::iterator | AttributeIterator |
Protected Member Functions | |
void | clearObject3d (void) |
Protected Attributes | |
String | m_name |
The name of the object. More... | |
Vector3 | m_position |
The positopm. More... | |
Vector3 | m_scale |
The scale. More... | |
Quaternion | m_rotation |
The rotation. More... | |
Matrix4x4 | m_matrix |
The matrix. More... | |
vector< Object3d * > | m_children |
List of children. More... | |
unordered_map< string, NeoVariable > | m_attributes |
map< string, NeoVariable > | m_attributes |
bool | m_isActive |
bool | m_isVisible |
bool | m_needToUpdate |
unsigned long | m_id |
Object3d * | m_parent |
vector< Behavior * > | m_behaviors |
List of behaviors. More... | |
The Object3d class represents a general object in a 3D scene.
You can add new types of objects by creating sub-classes that extend this class.
|
protected |
|
protected |
Neo::Object3d::Object3d | ( | void | ) |
|
virtual |
Neo::Object3d::Object3d | ( | const Object3d & | object | ) |
void Neo::Object3d::addAxisAngleRotation | ( | const Vector3 & | axis, |
float | angle | ||
) |
Changes the angle of the specified axis by adding the given value.
axis | The axis to change. Only one axis should be 1.0f at a time! |
angle | The angle in degrees. |
|
inline |
Adds a new behavior to the list of behaviors.
The ID can be retrieved by calling getBehaviorsNumber.
behavior | The new behavior. |
|
inline |
Adds an Object3d to the list of children.
child | The new child object. |
void Neo::Object3d::changeBehavior | ( | unsigned int | id, |
Behavior * | behavior | ||
) |
Replaces the behavior with the given ID with the given Behavior.
id | The ID of the behavior to replace. |
behavior | The replacement. |
|
protected |
void Neo::Object3d::computeChildrenMatrices | ( | void | ) |
Calculates the matrix of every child object.
void Neo::Object3d::computeLocalMatrix | ( | void | ) |
Calculates the local matrix without respecting the parent.
void Neo::Object3d::deleteBehavior | ( | unsigned int | id | ) |
Deletes the Behavior with the given ID.
id | The ID to delete. |
void Neo::Object3d::drawBehaviors | ( | void | ) |
Draws all behaviors.
|
inline |
|
inline |
Returns the value of the attribute variable with the given name.
name | The name of the variable to fetch. |
|
inline |
|
inline |
Returns the number of registered Behaviors.
|
inline |
Returns the child with the given ID.
Attention: The ID might change if children are deleted!
id | The ID of the child. |
|
inline |
Returns the number of children.
|
inline |
Returns the Euler rotation in a Vector3 in degrees.
|
inline |
Returns the ID of the object.
Multiplies the inverse matrix with the given vector and return the result.
Pi = inv(M) * P
position | The vector to multiply. |
Calculates the inverse rotated vector.
vector | The vector to rotate. |
|
inline |
|
inline |
Returns the object name.
|
inline |
Returns the parent object.
|
inline |
Returns the position as a Vector3.
Rotates the given vector and returns the result.
vector | The vector to rotate. |
|
inline |
|
inline |
Returns the scale of the object.
|
inline |
Returns the transformed position directly from the internal matrix.
|
inline |
Returns the transformed rotation.
|
inline |
Returns the transformed scale of the object.
Transforms the given vector using the internal matrix.
Vt = M * V
The | vector to transform. |
|
inlinevirtual |
Returns the type of the object.
Reimplemented in Neo::OEntity, Neo::OLight, Neo::OText, Neo::OCamera, Neo::OSound, and Neo::OBone.
Rotates the given vector while preserving its length and returns the result.
vector | The vector to rotate. |
|
inline |
Checks if the object has a parent.
void Neo::Object3d::invertBehavior | ( | unsigned int | idA, |
unsigned int | idB | ||
) |
Switches the IDs of the given behavior IDs.
idA | The ID of the first object. |
idB | The ID of the second object. |
|
inline |
Checks if the object is active.
|
inline |
void Neo::Object3d::linkTo | ( | Object3d * | parent | ) |
Links the object to another object.
Linking means recalculating positon, rotation and scale of the object to become relative to the given parent object.
parent | The parent object. |
|
inline |
Checks if the object needs to be updated.
|
inline |
Rotates the object.
If local is set to true the rotation will happen relative to the objects current rotation.
axis | The axis to rotate around. |
angle | The amount to rotate. |
local | Sets the rotation to local if true. |
|
inlinevirtual |
Changes if the object is being active or inactive.
active | The new activity value. |
Reimplemented in Neo::OEntity.
|
inline |
|
inline |
Sets the value of the attribute with the given name.
name | The name of the variable to set. |
variable | The variable containing the data. |
void Neo::Object3d::setAxisAngleRotation | ( | const Vector3 & | axis, |
float | angle | ||
) |
Changes the angle of the specified axis.
axis | The axis to change. Only one axis should be 1.0f at a time! |
angle | The angle in degrees. |
void Neo::Object3d::setEulerRotation | ( | const Vector3 & | euler | ) |
Changes the Euler rotation.
The unit is degrees.
euler | The vector containing the new value in deggrees for each axis. |
|
inline |
Changes the ID of the object.
id | The new ID. |
void Neo::Object3d::setName | ( | const char * | name | ) |
Change the object name.
Attention: Names must be unique!
name | The new name. |
|
inline |
Sets the parent object.
Attention: Does not link to the parent!
object | The new parent. |
void Neo::Object3d::setPosition | ( | const Vector3 & | position | ) |
Changes the position.
position | The new position. |
void Neo::Object3d::setRotation | ( | const Quaternion & | rotation | ) |
void Neo::Object3d::setScale | ( | const Vector3 & | scale | ) |
Changes the scale of the object.
scale | The new scale. |
|
inline |
Changes if the object is visible or not.
This value is used for culling and will be updated on every frame. This makes setting it manually useless. For OEntity objects you can use OEntity::setInvisible to overwrite the visibility.
visible | The new visibility value. |
|
inline |
Translates the object.
If local is set to true the translation will happen relative to the objects rotation.
vec | The direction to translate with. |
local | Sets the translation to local if true. |
void Neo::Object3d::unLink | ( | void | ) |
Removing the link to the parent object.
void Neo::Object3d::unlinkChildren | ( | void | ) |
Unlinks all children from this object and sets their parent to NULL.
|
virtual |
Updates the object.
Reimplemented in Neo::OEntity, and Neo::OSound.
void Neo::Object3d::updateBehaviors | ( | void | ) |
Updates all behaviors.
void Neo::Object3d::updateMatrix | ( | void | ) |
Recalculates the internal matrix relative to the parent object.
|
inlinevirtual |
Recalculates visibility for the given camera.
Used for culling.
camera | The camera to check visibility for. |
Reimplemented in Neo::OEntity, Neo::OLight, and Neo::OText.
|
protected |
|
protected |
|
protected |
List of behaviors.
|
protected |
List of children.
|
protected |
|
protected |
|
protected |
|
protected |
The matrix.
|
protected |
The name of the object.
|
protected |
|
protected |
|
protected |
The positopm.
|
protected |
The rotation.
|
protected |
The scale.