Annwvyn::AnnGameObject Class Reference

An object that exist in the game. Graphically and Potentially Physically. More...

#include <AnnGameObject.hpp>

Inheritance diagram for Annwvyn::AnnGameObject:
Collaboration diagram for Annwvyn::AnnGameObject:

Public Member Functions

 AnnGameObject ()
 Class constructor. More...
 
 AnnGameObject (const AnnGameObject &)=delete
 Deleted AnnGameObject Copy Constructor. More...
 
virtual ~AnnGameObject ()
 Class Destructor. Virtual. More...
 
void setPosition (float x, float y, float z)
 
void setPosition (AnnVect3 pos) override
 
void setWorldPosition (AnnVect3 pos) const
 
void setWorldPosition (float x, float y, float z) const
 
void translate (float x, float y, float z) const
 
void setOrientation (float w, float x, float y, float z)
 
void setOrientation (AnnQuaternion orient) override
 
void setWorldOrientation (AnnQuaternion orient) const
 
void setWorldOrientation (float w, float x, float y, float z) const
 
void setScale (float x, float y, float z, bool scaleMass=true) const
 
void setScale (AnnVect3 scale, bool scaleMass=true) const
 
AnnVect3 getPosition () override
 Get Position. More...
 
AnnVect3 getWorldPosition () const
 Get the position in world. More...
 
AnnQuaternion getOrientation () override
 Get Orientation. More...
 
AnnQuaternion getWorldOrientation () const
 Get the world orientation. More...
 
AnnVect3 getScale () const
 Get scale. More...
 
Ogre::SceneNode * getNode () const
 Get Ogre Node. More...
 
Ogre::Item * getItem () const
 Get the item of this object. More...
 
btRigidBody * getBody () const
 Get Rigid rigidBody. More...
 
float getDistance (AnnGameObject *otherObject) const
 
void playSound (const std::string &name, bool loop=false, float volume=1.0f) const
 
void setAnimation (const std::string &name)
 
void playAnimation (bool play=true) const
 
void loopAnimation (bool loop=true) const
 
void applyForce (AnnVect3 force) const
 
void applyImpulse (AnnVect3 impulse) const
 
void setLinearSpeed (AnnVect3 v) const
 
void setFrictionCoef (float coef) const
 
void setupPhysics (float mass=0, phyShapeType type=staticShape, bool hasPlayerCollision=true)
 
void setVisible () const
 Make the object visible. More...
 
void setInvisible () const
 Make the object invisible. More...
 
std::string getName () const
 Return the name of the object. More...
 
void attachScript (const std::string &scriptName)
 
bool hasParent () const
 Return true if node is attached to the node owned by another AnnGameObject. More...
 
std::shared_ptr< AnnGameObjectgetParent () const
 Get the parent Game Object. More...
 
void attachChildObject (std::shared_ptr< AnnGameObject > child) const
 
void detachFromParent () const
 Make the node independent to any GameObject. More...
 
bool checkForBodyInParent ()
 Recursively check if any parent has a body, if one is found, returns true. More...
 
bool checkForBodyInChild ()
 Recursively check if any child has a body, if one is found, returns true. More...
 
virtual void postInit ()
 Executed after object initialization. More...
 
virtual void update ()
 Executed at refresh time (each frames) More...
 
void callUpdateOnScripts ()
 Call the update methods of all the script present in the scripts container. More...
 
- Public Member Functions inherited from Annwvyn::AnnAbstractMovable
virtual ~AnnAbstractMovable ()=default
 
- Public Member Functions inherited from Annwvyn::AnnAbstractTranslatable
virtual ~AnnAbstractTranslatable ()=default
 

Private Member Functions

bool parentsHaveBody (AnnGameObject *obj) const
 
void setNode (Ogre::SceneNode *node)
 
void setItem (Ogre::Item *item)
 
void addAnimationTime (double offsetTime) const
 
void updateOpenAlPos () const
 For engine : update OpenAL source position. More...
 

Static Private Member Functions

static bool childrenHaveBody (AnnGameObject *obj)
 

Private Attributes

Ogre::SceneNode * sceneNode
 SceneNode. This also holds the position/orientation/scale of the object. More...
 
Ogre::Item * model3D
 Entity. More...
 
Ogre::SkeletonAnimation * currentAnimation
 Currently selected animation. More...
 
btCollisionShape * collisionShape
 Bullet shape. More...
 
btRigidBody * rigidBody
 Bullet rigid body. More...
 
float bodyMass
 Mass of the rigid body. More...
 
std::shared_ptr< AnnAudioSourceaudioSource
 AnnAudioEngine audioSource;. More...
 
std::string name
 Name of the object. More...
 
BtOgre::RigidBodyState * state
 RigidBodyState of this object. More...
 
std::vector< std::shared_ptr< AnnBehaviorScript > > scripts
 list of script objects More...
 

Friends

class AnnEngine
 The GameObjectManager populate the content of this object when it goes through it's initialization. More...
 
class AnnGameObjectManager
 

Additional Inherited Members

Detailed Description

An object that exist in the game. Graphically and Potentially Physically.

Definition at line 25 of file AnnGameObject.hpp.

Constructor & Destructor Documentation

◆ AnnGameObject() [1/2]

AnnGameObject::AnnGameObject ( )

Class constructor.

Definition at line 11 of file AnnGameObject.cpp.

◆ AnnGameObject() [2/2]

Annwvyn::AnnGameObject::AnnGameObject ( const AnnGameObject )
delete

Deleted AnnGameObject Copy Constructor.

◆ ~AnnGameObject()

AnnGameObject::~AnnGameObject ( )
virtual

Class Destructor. Virtual.

Definition at line 23 of file AnnGameObject.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ addAnimationTime()

void AnnGameObject::addAnimationTime ( double  offsetTime) const
private

For engine : get elapsed time

Parameters
offsetTimetime to add to the animation

Definition at line 294 of file AnnGameObject.cpp.

◆ applyForce()

void AnnGameObject::applyForce ( AnnVect3  force) const

Apply a physical force

Parameters
forceForce vector that will be applied to the center of mass of the object

Definition at line 304 of file AnnGameObject.cpp.

Here is the call graph for this function:

◆ applyImpulse()

void AnnGameObject::applyImpulse ( AnnVect3  impulse) const

Apply a physical impulsion

Parameters
impulsethe impulsion force

Definition at line 299 of file AnnGameObject.cpp.

Here is the call graph for this function:

◆ attachChildObject()

void AnnGameObject::attachChildObject ( std::shared_ptr< AnnGameObject child) const

Attach an object to this object.

Parameters
childThe object you want to attach

Definition at line 365 of file AnnGameObject.cpp.

◆ attachScript()

void AnnGameObject::attachScript ( const std::string scriptName)

Attach a script to this object

Parameters
scriptNamename of a script

Definition at line 336 of file AnnGameObject.cpp.

Here is the call graph for this function:

◆ callUpdateOnScripts()

void AnnGameObject::callUpdateOnScripts ( )

Call the update methods of all the script present in the scripts container.

Definition at line 74 of file AnnGameObject.cpp.

◆ checkForBodyInChild()

bool AnnGameObject::checkForBodyInChild ( )

Recursively check if any child has a body, if one is found, returns true.

Definition at line 418 of file AnnGameObject.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkForBodyInParent()

bool AnnGameObject::checkForBodyInParent ( )

Recursively check if any parent has a body, if one is found, returns true.

Definition at line 380 of file AnnGameObject.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ childrenHaveBody()

bool AnnGameObject::childrenHaveBody ( AnnGameObject obj)
staticprivate

Do the actual recursion of checkForBodyInChild

Parameters
objobject to check (for recursion)

Definition at line 423 of file AnnGameObject.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ detachFromParent()

void AnnGameObject::detachFromParent ( ) const

Make the node independent to any GameObject.

Definition at line 374 of file AnnGameObject.cpp.

Here is the call graph for this function:

◆ getBody()

btRigidBody * AnnGameObject::getBody ( ) const

Get Rigid rigidBody.

Definition at line 252 of file AnnGameObject.cpp.

◆ getDistance()

float AnnGameObject::getDistance ( AnnGameObject otherObject) const

Get distance from another object

Parameters
otherObjectThe object we're counting the distance from

Definition at line 247 of file AnnGameObject.cpp.

Here is the call graph for this function:

◆ getItem()

Ogre::Item * AnnGameObject::getItem ( ) const

Get the item of this object.

Definition at line 459 of file AnnGameObject.cpp.

Here is the caller graph for this function:

◆ getName()

std::string AnnGameObject::getName ( ) const

Return the name of the object.

Definition at line 331 of file AnnGameObject.cpp.

Here is the caller graph for this function:

◆ getNode()

Ogre::SceneNode * AnnGameObject::getNode ( ) const

Get Ogre Node.

Definition at line 242 of file AnnGameObject.cpp.

Here is the caller graph for this function:

◆ getOrientation()

AnnQuaternion AnnGameObject::getOrientation ( )
overridevirtual

Get Orientation.

Implements Annwvyn::AnnAbstractMovable.

Definition at line 191 of file AnnGameObject.cpp.

◆ getParent()

std::shared_ptr< AnnGameObject > AnnGameObject::getParent ( ) const

Get the parent Game Object.

Definition at line 360 of file AnnGameObject.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPosition()

AnnVect3 AnnGameObject::getPosition ( )
overridevirtual

Get Position.

Implements Annwvyn::AnnAbstractTranslatable.

Definition at line 186 of file AnnGameObject.cpp.

◆ getScale()

AnnVect3 AnnGameObject::getScale ( ) const

Get scale.

Definition at line 196 of file AnnGameObject.cpp.

◆ getWorldOrientation()

AnnQuaternion AnnGameObject::getWorldOrientation ( ) const

Get the world orientation.

Definition at line 397 of file AnnGameObject.cpp.

◆ getWorldPosition()

AnnVect3 AnnGameObject::getWorldPosition ( ) const

Get the position in world.

Definition at line 385 of file AnnGameObject.cpp.

Here is the caller graph for this function:

◆ hasParent()

bool AnnGameObject::hasParent ( ) const

Return true if node is attached to the node owned by another AnnGameObject.

Definition at line 344 of file AnnGameObject.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loopAnimation()

void AnnGameObject::loopAnimation ( bool  loop = true) const

Loop the animation ?

Parameters
loopthe looping state of the animation

Definition at line 289 of file AnnGameObject.cpp.

◆ parentsHaveBody()

bool AnnGameObject::parentsHaveBody ( AnnGameObject obj) const
private

Do the actual recursion of checkForBodyInParent

Parameters
objobject to check (for recursion)

Definition at line 409 of file AnnGameObject.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ playAnimation()

void AnnGameObject::playAnimation ( bool  play = true) const

Set if we want to play the animation

Parameters
playthe playing state we want to apply

Definition at line 284 of file AnnGameObject.cpp.

◆ playSound()

void AnnGameObject::playSound ( const std::string name,
bool  loop = false,
float  volume = 1.0f 
) const

Play a sound file

Parameters
nameName of the audio file in a resource location
loopIf set to true, will play the sound in loop
volumeFloating point number between 0 and 1 to set the loudness of the sound

Definition at line 60 of file AnnGameObject.cpp.

Here is the call graph for this function:

◆ postInit()

virtual void Annwvyn::AnnGameObject::postInit ( )
inlinevirtual

Executed after object initialization.

Definition at line 260 of file AnnGameObject.hpp.

◆ setAnimation()

void AnnGameObject::setAnimation ( const std::string name)

Set currently playing animation

Parameters
nameName of the animation as defined by the 3D entity

Definition at line 257 of file AnnGameObject.cpp.

Here is the call graph for this function:

◆ setFrictionCoef()

void AnnGameObject::setFrictionCoef ( float  coef) const

Set the friction coefficient See the "Results" table from this page : https://www.thoughtspike.com/friction-coefficients-for-bullet-physics/

Parameters
coeffriction coef applied to this object's body

Definition at line 315 of file AnnGameObject.cpp.

◆ setInvisible()

void AnnGameObject::setInvisible ( ) const

Make the object invisible.

Definition at line 326 of file AnnGameObject.cpp.

Here is the call graph for this function:

◆ setItem()

void AnnGameObject::setItem ( Ogre::Item *  item)
private

For engine : set item

Parameters
itemOgre::Item

Definition at line 454 of file AnnGameObject.cpp.

◆ setLinearSpeed()

void AnnGameObject::setLinearSpeed ( AnnVect3  v) const

Set the linear speed of the object

Parameters
vThe linear speed

Definition at line 309 of file AnnGameObject.cpp.

◆ setNode()

void AnnGameObject::setNode ( Ogre::SceneNode *  node)
private

For engine : set node

Parameters
nodeogre SceneNode

Definition at line 201 of file AnnGameObject.cpp.

◆ setOrientation() [1/2]

void AnnGameObject::setOrientation ( float  w,
float  x,
float  y,
float  z 
)

Set orientation from Quaternion components

Parameters
wW component of the quaternion
xX component of the quaternion
yY component of the quaternion
zZ component of the quaternion

Definition at line 123 of file AnnGameObject.cpp.

◆ setOrientation() [2/2]

void AnnGameObject::setOrientation ( AnnQuaternion  orient)
overridevirtual

Set Orientation from Quaternion

Parameters
orientQuaternion for absolute orientation

Implements Annwvyn::AnnAbstractMovable.

Definition at line 128 of file AnnGameObject.cpp.

Here is the call graph for this function:

◆ setPosition() [1/2]

void AnnGameObject::setPosition ( float  x,
float  y,
float  z 
)

Set position from spatial variables

Parameters
xX component of the position vector
yY component of the position vector
zZ component of the position vector

Definition at line 79 of file AnnGameObject.cpp.

◆ setPosition() [2/2]

void AnnGameObject::setPosition ( AnnVect3  pos)
overridevirtual

Set position from Vector 3D

Parameters
pos3D position vector. Relative to scene root position

Implements Annwvyn::AnnAbstractTranslatable.

Definition at line 98 of file AnnGameObject.cpp.

Here is the call graph for this function:

◆ setScale() [1/2]

void AnnGameObject::setScale ( float  x,
float  y,
float  z,
bool  scaleMass = true 
) const

Set scale

Parameters
xX component of the scale vector
yY component of the scale vector
zZ component of the scale vector
scaleMassIf set to true (by default) will update the mass of the rigid body to reflect the change in size (constant density)

Definition at line 181 of file AnnGameObject.cpp.

◆ setScale() [2/2]

void AnnGameObject::setScale ( AnnVect3  scale,
bool  scaleMass = true 
) const

Set scale from Vector 3D

Parameters
scaleRelative scaling factor
scaleMasswill adjust the mass accoring to the scaling vector. true by default

Definition at line 150 of file AnnGameObject.cpp.

Here is the call graph for this function:

◆ setupPhysics()

void AnnGameObject::setupPhysics ( float  mass = 0,
phyShapeType  type = staticShape,
bool  hasPlayerCollision = true 
)

Set up Physics

Parameters
massThe mass of the object
typeThe type of shape you want to define for the object hasPlayerCollision if set to true (by default) object can colide with the player body representation

Definition at line 206 of file AnnGameObject.cpp.

Here is the call graph for this function:

◆ setVisible()

void AnnGameObject::setVisible ( ) const

Make the object visible.

Definition at line 321 of file AnnGameObject.cpp.

Here is the call graph for this function:

◆ setWorldOrientation() [1/2]

void AnnGameObject::setWorldOrientation ( AnnQuaternion  orient) const

Set the world orientation as a quaternion

Parameters
orientQuaternion for absolute orientation

Definition at line 145 of file AnnGameObject.cpp.

Here is the caller graph for this function:

◆ setWorldOrientation() [2/2]

void AnnGameObject::setWorldOrientation ( float  w,
float  x,
float  y,
float  z 
) const

Set the world orientation as some floats

Parameters
wW component of the quaternion
xX component of the quaternion
yY component of the quaternion
zZ component of the quaternion

Definition at line 176 of file AnnGameObject.cpp.

Here is the call graph for this function:

◆ setWorldPosition() [1/2]

void AnnGameObject::setWorldPosition ( AnnVect3  pos) const

Set the world position from a vector

Parameters
pos3D position vector. Relative to scene root position

Definition at line 117 of file AnnGameObject.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setWorldPosition() [2/2]

void AnnGameObject::setWorldPosition ( float  x,
float  y,
float  z 
) const

Set the world position from a few floats

Parameters
xX component of the position vector
yY component of the position vector
zZ component of the position vector

Definition at line 449 of file AnnGameObject.cpp.

Here is the call graph for this function:

◆ translate()

void AnnGameObject::translate ( float  x,
float  y,
float  z 
) const

Translate

Parameters
xX component of the translation vector
yY component of the translation vector
zZ component of the translation vector

Definition at line 84 of file AnnGameObject.cpp.

Here is the call graph for this function:

◆ update()

virtual void Annwvyn::AnnGameObject::update ( )
inlinevirtual

Executed at refresh time (each frames)

Definition at line 263 of file AnnGameObject.hpp.

◆ updateOpenAlPos()

void AnnGameObject::updateOpenAlPos ( ) const
private

For engine : update OpenAL source position.

Definition at line 69 of file AnnGameObject.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ AnnEngine

friend class AnnEngine
friend

The GameObjectManager populate the content of this object when it goes through it's initialization.

Definition at line 200 of file AnnGameObject.hpp.

◆ AnnGameObjectManager

friend class AnnGameObjectManager
friend

Definition at line 201 of file AnnGameObject.hpp.

Member Data Documentation

◆ audioSource

std::shared_ptr<AnnAudioSource> Annwvyn::AnnGameObject::audioSource
private

AnnAudioEngine audioSource;.

Definition at line 247 of file AnnGameObject.hpp.

◆ bodyMass

float Annwvyn::AnnGameObject::bodyMass
private

Mass of the rigid body.

Definition at line 244 of file AnnGameObject.hpp.

◆ collisionShape

btCollisionShape* Annwvyn::AnnGameObject::collisionShape
private

Bullet shape.

Definition at line 238 of file AnnGameObject.hpp.

◆ currentAnimation

Ogre::SkeletonAnimation* Annwvyn::AnnGameObject::currentAnimation
private

Currently selected animation.

Definition at line 235 of file AnnGameObject.hpp.

◆ model3D

Ogre::Item* Annwvyn::AnnGameObject::model3D
private

Entity.

Definition at line 232 of file AnnGameObject.hpp.

◆ name

std::string Annwvyn::AnnGameObject::name
private

Name of the object.

Definition at line 250 of file AnnGameObject.hpp.

◆ rigidBody

btRigidBody* Annwvyn::AnnGameObject::rigidBody
private

Bullet rigid body.

Definition at line 241 of file AnnGameObject.hpp.

◆ sceneNode

Ogre::SceneNode* Annwvyn::AnnGameObject::sceneNode
private

SceneNode. This also holds the position/orientation/scale of the object.

Definition at line 229 of file AnnGameObject.hpp.

◆ scripts

std::vector<std::shared_ptr<AnnBehaviorScript> > Annwvyn::AnnGameObject::scripts
private

list of script objects

Definition at line 256 of file AnnGameObject.hpp.

◆ state

BtOgre::RigidBodyState* Annwvyn::AnnGameObject::state
private

RigidBodyState of this object.

Definition at line 253 of file AnnGameObject.hpp.


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