Neo  0.5.0
Developer Documentation
Neo::Object3d Class Reference

The Object3d class represents a general object in a 3D scene. More...

#include <Object3d.h>

+ Inheritance diagram for Neo::Object3d:

Classes

class  AdditionalData
 

Public Member Functions

 Object3d (void)
 
virtual ~Object3d (void)
 
 Object3d (const Object3d &object)
 
AdditionalDatagetAdditionalData ()
 
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...
 
Matrix4x4getMatrix (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...
 
Object3dgetParent (void)
 Returns the parent object. More...
 
Object3dgetChild (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...
 
BehaviorgetBehavior (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, NeoVariablem_attributes
 
map< string, NeoVariablem_attributes
 
bool m_isActive
 
bool m_isVisible
 
bool m_needToUpdate
 
unsigned long m_id
 
Object3dm_parent
 
vector< Behavior * > m_behaviors
 List of behaviors. More...
 

Detailed Description

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.

See also
OEntity
OSound
OText
OLight

Member Typedef Documentation

typedef unordered_map<string, NeoVariable>::iterator Neo::Object3d::AttributeIterator
protected
typedef map<string, NeoVariable>::iterator Neo::Object3d::AttributeIterator
protected

Constructor & Destructor Documentation

Neo::Object3d::Object3d ( void  )
virtual Neo::Object3d::~Object3d ( void  )
virtual
Neo::Object3d::Object3d ( const Object3d object)

Member Function Documentation

void Neo::Object3d::addAxisAngleRotation ( const Vector3 axis,
float  angle 
)

Changes the angle of the specified axis by adding the given value.

object->addAxisAngleRotation(Vector3(1.0f,0.0f,0.0f), 15.0f);
Parameters
axisThe axis to change. Only one axis should be 1.0f at a time!
angleThe angle in degrees.
void Neo::Object3d::addBehavior ( Behavior behavior)
inline

Adds a new behavior to the list of behaviors.

The ID can be retrieved by calling getBehaviorsNumber.

Parameters
behaviorThe new behavior.
See also
getBehaviorsNumber
void Neo::Object3d::addChild ( Object3d child)
inline

Adds an Object3d to the list of children.

Parameters
childThe new child object.
void Neo::Object3d::changeBehavior ( unsigned int  id,
Behavior behavior 
)

Replaces the behavior with the given ID with the given Behavior.

Parameters
idThe ID of the behavior to replace.
behaviorThe replacement.
void Neo::Object3d::clearObject3d ( void  )
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.

Parameters
idThe ID to delete.
void Neo::Object3d::drawBehaviors ( void  )

Draws all behaviors.

AdditionalData* Neo::Object3d::getAdditionalData ( )
inline
NeoVariable Neo::Object3d::getAttribute ( const char *  name)
inline

Returns the value of the attribute variable with the given name.

Parameters
nameThe name of the variable to fetch.
Returns
The variable containing the data.
Behavior* Neo::Object3d::getBehavior ( unsigned int  id)
inline

Returns the Behavior with the given ID.

Parameters
idThe ID of the Behavior.
Returns
The Behavior.
unsigned int Neo::Object3d::getBehaviorsNumber ( void  )
inline

Returns the number of registered Behaviors.

Returns
The number of registered Behaviors.
Object3d* Neo::Object3d::getChild ( unsigned int  id)
inline

Returns the child with the given ID.

Attention: The ID might change if children are deleted!

Parameters
idThe ID of the child.
unsigned int Neo::Object3d::getChildrenNumber ( void  )
inline

Returns the number of children.

Returns
The number of children.
Vector3 Neo::Object3d::getEulerRotation ( void  ) const
inline

Returns the Euler rotation in a Vector3 in degrees.

Returns
The Euler rotation.
unsigned long Neo::Object3d::getId ( )
inline

Returns the ID of the object.

Returns
The ID.
Vector3 Neo::Object3d::getInversePosition ( const Vector3 position) const
inline

Multiplies the inverse matrix with the given vector and return the result.

Pi = inv(M) * P

Parameters
positionThe vector to multiply.
Returns
The result.
Vector3 Neo::Object3d::getInverseRotatedVector ( const Vector3 vector) const
inline

Calculates the inverse rotated vector.

Parameters
vectorThe vector to rotate.
Returns
The rotated vector.
Matrix4x4* Neo::Object3d::getMatrix ( void  )
inline

Returns the current matrix.

Returns
The pointer to the internal matrix.
See also
Matrix4x4
const char* Neo::Object3d::getName ( void  )
inline

Returns the object name.

Returns
The name of the object.
Object3d* Neo::Object3d::getParent ( void  )
inline

Returns the parent object.

Returns
The parent object.
Vector3 Neo::Object3d::getPosition ( void  ) const
inline

Returns the position as a Vector3.

Returns
The current position.
Vector3 Neo::Object3d::getRotatedVector ( const Vector3 vector) const
inline

Rotates the given vector and returns the result.

Parameters
vectorThe vector to rotate.
Returns
The rotated vector.
Quaternion Neo::Object3d::getRotation ( void  ) const
inline

Returns the rotation of the object.

Returns
The rotation.
See also
Quaternion
Vector3 Neo::Object3d::getScale ( void  ) const
inline

Returns the scale of the object.

Returns
The scale of the object.
Vector3 Neo::Object3d::getTransformedPosition ( void  ) const
inline

Returns the transformed position directly from the internal matrix.

Returns
The transformed position.
Vector3 Neo::Object3d::getTransformedRotation ( void  ) const
inline

Returns the transformed rotation.

Returns
The Transformed rotation.
Vector3 Neo::Object3d::getTransformedScale ( void  ) const
inline

Returns the transformed scale of the object.

Returns
The transformed scale.
Vector3 Neo::Object3d::getTransformedVector ( const Vector3 vector) const
inline

Transforms the given vector using the internal matrix.

Vt = M * V

Parameters
Thevector to transform.
Returns
The result.
virtual int Neo::Object3d::getType ( void  )
inlinevirtual

Returns the type of the object.

Returns
The type.

Reimplemented in Neo::OEntity, Neo::OLight, Neo::OText, Neo::OCamera, Neo::OSound, and Neo::OBone.

Vector3 Neo::Object3d::getUniformRotatedVector ( const Vector3 vector)

Rotates the given vector while preserving its length and returns the result.

Parameters
vectorThe vector to rotate.
Returns
The uniform rotated vector.
bool Neo::Object3d::hasParent ( void  )
inline

Checks if the object has a parent.

Returns
A boolean value.
void Neo::Object3d::invertBehavior ( unsigned int  idA,
unsigned int  idB 
)

Switches the IDs of the given behavior IDs.

Parameters
idAThe ID of the first object.
idBThe ID of the second object.
bool Neo::Object3d::isActive ( void  )
inline

Checks if the object is active.

Returns
A boolean value.
bool Neo::Object3d::isVisible ( void  )
inline

Checks if the object is visible.

Returns
A boolean value.
See also
setVisible
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.

Parameters
parentThe parent object.
See also
unLink
bool Neo::Object3d::needToUpdate ( void  )
inline

Checks if the object needs to be updated.

See also
update
void Neo::Object3d::rotate ( const Vector3 axis,
float  angle,
bool  local = false 
)
inline

Rotates the object.

If local is set to true the rotation will happen relative to the objects current rotation.

Parameters
axisThe axis to rotate around.
angleThe amount to rotate.
localSets the rotation to local if true.
virtual void Neo::Object3d::setActive ( bool  active)
inlinevirtual

Changes if the object is being active or inactive.

Parameters
activeThe new activity value.

Reimplemented in Neo::OEntity.

void Neo::Object3d::setAdditionalData ( AdditionalData d)
inline
void Neo::Object3d::setAttribute ( const char *  name,
NeoVariable  variable 
)
inline

Sets the value of the attribute with the given name.

Parameters
nameThe name of the variable to set.
variableThe variable containing the data.
void Neo::Object3d::setAxisAngleRotation ( const Vector3 axis,
float  angle 
)

Changes the angle of the specified axis.

object->setAxisAngleRotation(Vector3(1.0f,0.0f,0.0f), 15.0f);
Parameters
axisThe axis to change. Only one axis should be 1.0f at a time!
angleThe angle in degrees.
void Neo::Object3d::setEulerRotation ( const Vector3 euler)

Changes the Euler rotation.

The unit is degrees.

Parameters
eulerThe vector containing the new value in deggrees for each axis.
void Neo::Object3d::setId ( unsigned long  id)
inline

Changes the ID of the object.

Parameters
idThe new ID.
void Neo::Object3d::setName ( const char *  name)

Change the object name.

Attention: Names must be unique!

Parameters
nameThe new name.
void Neo::Object3d::setParent ( Object3d object)
inline

Sets the parent object.

Attention: Does not link to the parent!

Parameters
objectThe new parent.
See also
linkTo
void Neo::Object3d::setPosition ( const Vector3 position)

Changes the position.

Parameters
positionThe new position.
void Neo::Object3d::setRotation ( const Quaternion rotation)

Sets the rotation or the object.

Parameters
rotationThe new rotation.
See also
Quaternion
void Neo::Object3d::setScale ( const Vector3 scale)

Changes the scale of the object.

Parameters
scaleThe new scale.
void Neo::Object3d::setVisible ( bool  visible)
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.

Parameters
visibleThe new visibility value.
void Neo::Object3d::translate ( const Vector3 vec,
bool  local = false 
)
inline

Translates the object.

If local is set to true the translation will happen relative to the objects rotation.

Parameters
vecThe direction to translate with.
localSets the translation to local if true.
void Neo::Object3d::unLink ( void  )

Removing the link to the parent object.

See also
linkTo
void Neo::Object3d::unlinkChildren ( void  )

Unlinks all children from this object and sets their parent to NULL.

virtual void Neo::Object3d::update ( void  )
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.

virtual void Neo::Object3d::updateVisibility ( OCamera camera)
inlinevirtual

Recalculates visibility for the given camera.

Used for culling.

Parameters
cameraThe camera to check visibility for.

Reimplemented in Neo::OEntity, Neo::OLight, and Neo::OText.

Member Data Documentation

unordered_map<string, NeoVariable> Neo::Object3d::m_attributes
protected
map<string, NeoVariable> Neo::Object3d::m_attributes
protected
vector<Behavior *> Neo::Object3d::m_behaviors
protected

List of behaviors.

vector<Object3d*> Neo::Object3d::m_children
protected

List of children.

unsigned long Neo::Object3d::m_id
protected
bool Neo::Object3d::m_isActive
protected
bool Neo::Object3d::m_isVisible
protected
Matrix4x4 Neo::Object3d::m_matrix
protected

The matrix.

String Neo::Object3d::m_name
protected

The name of the object.

bool Neo::Object3d::m_needToUpdate
protected
Object3d* Neo::Object3d::m_parent
protected
Vector3 Neo::Object3d::m_position
protected

The positopm.

Quaternion Neo::Object3d::m_rotation
protected

The rotation.

Vector3 Neo::Object3d::m_scale
protected

The scale.


The documentation for this class was generated from the following file: