AnnGameObject.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include "systemMacro.h"
10 #include <string>
11 #include <BtOgrePG.h>
12 
13 //Annwvyn
14 #include "AnnTypes.h"
15 #include "AnnAbstractMovable.hpp"
16 #pragma warning(default : 4996)
17 
18 namespace Annwvyn
19 {
21  class AnnBehaviorScript;
22  class AnnAudioSource;
23 
26  {
27  public:
29  AnnGameObject();
30 
32  AnnGameObject(const AnnGameObject&) = delete;
33 
35  virtual ~AnnGameObject();
36 
41  void setPosition(float x, float y, float z);
42 
45  void setPosition(AnnVect3 pos) override;
46 
49  void setWorldPosition(AnnVect3 pos) const;
50 
55  void setWorldPosition(float x, float y, float z) const;
56 
61  void translate(float x, float y, float z) const;
62 
68  void setOrientation(float w, float x, float y, float z);
69 
72  void setOrientation(AnnQuaternion orient) override;
73 
76  void setWorldOrientation(AnnQuaternion orient) const;
77 
83  void setWorldOrientation(float w, float x, float y, float z) const;
84 
90  void setScale(float x, float y, float z, bool scaleMass = true) const;
91 
95  void setScale(AnnVect3 scale, bool scaleMass = true) const;
96 
98  AnnVect3 getPosition() override;
99 
101  AnnVect3 getWorldPosition() const;
102 
104  AnnQuaternion getOrientation() override;
105 
107  AnnQuaternion getWorldOrientation() const;
108 
110  AnnVect3 getScale() const;
111 
113  Ogre::SceneNode* getNode() const;
114 
116  Ogre::Item* getItem() const;
117 
119  btRigidBody* getBody() const;
120 
123  float getDistance(AnnGameObject* otherObject) const;
124 
129  void playSound(const std::string& name, bool loop = false, float volume = 1.0f) const;
130 
133  void setAnimation(const std::string& name);
134 
137  void playAnimation(bool play = true) const;
138 
141  void loopAnimation(bool loop = true) const;
142 
145  void applyForce(AnnVect3 force) const;
146 
149  void applyImpulse(AnnVect3 impulse) const;
150 
153  void setLinearSpeed(AnnVect3 v) const;
154 
158  void setFrictionCoef(float coef) const;
159 
164  void setupPhysics(float mass = 0, phyShapeType type = staticShape, bool hasPlayerCollision = true);
165 
167  void setVisible() const;
168 
170  void setInvisible() const;
171 
173  std::string getName() const;
174 
177  void attachScript(const std::string& scriptName);
178 
180  bool hasParent() const;
181 
183  std::shared_ptr<AnnGameObject> getParent() const;
184 
187  void attachChildObject(std::shared_ptr<AnnGameObject> child) const;
188 
190  void detachFromParent() const;
191 
193  bool checkForBodyInParent();
194 
196  bool checkForBodyInChild();
197 
198  private:
200  friend class AnnEngine;
201  friend class AnnGameObjectManager;
202 
203  //------------------ local utility
206  bool parentsHaveBody(AnnGameObject* obj) const;
207 
210  static bool childrenHaveBody(AnnGameObject* obj);
211 
212  //----------------- engine utility
215  void setNode(Ogre::SceneNode* node);
216 
219  void setItem(Ogre::Item* item);
220 
223  void addAnimationTime(double offsetTime) const;
224 
226  void updateOpenAlPos() const;
227 
229  Ogre::SceneNode* sceneNode;
230 
232  Ogre::Item* model3D;
233 
235  Ogre::SkeletonAnimation* currentAnimation;
236 
238  btCollisionShape* collisionShape;
239 
241  btRigidBody* rigidBody;
242 
244  float bodyMass;
245 
248 
251 
253  BtOgre::RigidBodyState* state;
254 
257 
258  public:
260  virtual void postInit() {}
261 
263  virtual void update() {}
264 
266  void callUpdateOnScripts();
267  };
268 
270 }
file for defining macros used for symbol export regarding the way the OS does things.
BtOgre::RigidBodyState * state
RigidBodyState of this object.
Main engine class. Creating an instance of this class make the engine start.
Definition: AnnEngine.hpp:70
float bodyMass
Mass of the rigid body.
A 3D Vector.
Definition: AnnVect3.hpp:16
btRigidBody * rigidBody
Bullet rigid body.
std::vector< std::shared_ptr< AnnBehaviorScript > > scripts
list of script objects
Namespace containing the totality of Annwvyn components.
Definition: AnnGetter.cpp:8
Ogre::SceneNode * sceneNode
SceneNode. This also holds the position/orientation/scale of the object.
An object that exist in the game. Graphically and Potentially Physically.
phyShapeType
Definition: AnnTypes.h:43
Object that reprenset a script defining an object "behavior".
btCollisionShape * collisionShape
Bullet shape.
Ogre::SkeletonAnimation * currentAnimation
Currently selected animation.
std::shared_ptr< AnnAudioSource > audioSource
AnnAudioEngine audioSource;.
virtual void update()
Executed at refresh time (each frames)
virtual void postInit()
Executed after object initialization.
Represent a Quaternion.
std::string name
Name of the object.
Abstract Class that represent an bobject that you can set the orientation.
Represent an audio source in the engine.
Game object manager. Create, destroy and keep track of objects, lights and other movable stuff...
Data types definition for Annwvyn.
#define AnnDllExport
Definition: systemMacro.h:24
Ogre::Item * model3D
Entity.