Neo  0.5.0
Developer Documentation
OEntity.h
Go to the documentation of this file.
1 //========================================================================
2 // Copyright (c) 2003-2011 Anael Seghezzi <www.maratis3d.com>
3 // Copyright (c) 2014-2015 Yannick Pflanzer <www.neo-engine.de>
4 //
5 // This software is provided 'as-is', without any express or implied
6 // warranty. In no event will the authors be held liable for any damages
7 // arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it
11 // freely, subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented; you must not
14 // claim that you wrote the original software. If you use this software
15 // in a product, an acknowledgment in the product documentation would
16 // be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such, and must not
19 // be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source
22 // distribution.
23 //
24 //========================================================================
25 
26 
27 #ifndef __OENTITY_H
28 #define __OENTITY_H
29 
30 namespace Neo
31 {
32 
37 {
52 };
53 
54 struct NEO_ENGINE_EXPORT PhysicsConstraint
55 {
56  PhysicsConstraint(void);
57  PhysicsConstraint(const PhysicsConstraint & constraint);
58 
59  unsigned int constraintId;
60  unsigned int parentObjectId;
61 
69 };
70 
74 class NEO_ENGINE_EXPORT PhysicsProperties
75 {
76 public:
77 
78  PhysicsProperties(void);
79  PhysicsProperties(const PhysicsProperties & physicsProperties);
80  ~PhysicsProperties(void);
81 
82 private:
83 
84  PhysicsConstraint * m_constraint;
85 
86  unsigned int m_shapeId;
87  unsigned int m_collisionObjectId;
88  COLLISION_SHAPE_TYPE m_collisionShape;
89 
90  bool m_ghost;
91  float m_mass;
92  float m_friction;
93  float m_restitution;
94  float m_linearDamping;
95  float m_angularDamping;
96  float m_angularFactor;
97  Vector3 m_linearFactor;
98 
99 public:
100 
104  void deleteConstraint(void);
105  PhysicsConstraint * createConstraint(void);
106 
111  inline PhysicsConstraint * getConstraint(void){ return m_constraint; }
112 
117  inline void setShapeId(unsigned int shapeId){ m_shapeId = shapeId; }
118 
123  inline unsigned int getShapeId(void){ return m_shapeId; }
124 
129  inline void setCollisionObjectId(unsigned int collisionObjectId){ m_collisionObjectId = collisionObjectId; }
130 
135  inline unsigned int getCollisionObjectId(void){ return m_collisionObjectId; }
136 
141  inline void setCollisionShape(COLLISION_SHAPE_TYPE collisionShape){ m_collisionShape = collisionShape; }
142 
147  inline COLLISION_SHAPE_TYPE getCollisionShape(void){ return m_collisionShape; }
148 
154  inline void setGhost(bool ghost){ m_ghost = ghost; }
155 
166  inline bool isGhost(void){ return m_ghost; }
167 
177  inline void setMass(float mass){ m_mass = mass; }
178 
184  inline float getMass(void){ return m_mass; }
185 
190  inline void setFriction(float friction){ m_friction = friction; }
191 
196  inline float getFriction(void){ return m_friction; }
197 
202  inline void setRestitution(float restitution){ m_restitution = restitution; }
203 
208  inline float getRestitution(void){ return m_restitution; }
209 
214  inline void setLinearDamping(float linearDamping){ m_linearDamping = linearDamping; }
215 
220  inline float getLinearDamping(void){ return m_linearDamping; }
221 
226  inline void setAngularDamping(float angularDamping){ m_angularDamping = angularDamping; }
227 
232  inline float getAngularDamping(void){ return m_angularDamping; }
233 
238  inline void setAngularFactor(float angularFactor){ m_angularFactor = angularFactor; }
239 
244  inline float getAngularFactor(void){ return m_angularFactor; }
245 
250  inline void setLinearFactor(const Vector3 & linearFactor){ m_linearFactor = linearFactor; }
251 
256  inline Vector3 * getLinearFactor(void){ return &m_linearFactor; }
257 };
258 
270 class NEO_ENGINE_EXPORT OEntity : public Object3d
271 {
272 public:
273  // constructor / destructor
274  OEntity(MeshRef *meshRef);
275  ~OEntity(void);
276 
277  // copy constructor
278  OEntity(const OEntity &entity);
279 
280 private:
281  // mesh
282  MeshRef *m_meshRef;
283 
284  // invisible
285  bool m_isInvisible;
286  bool m_hasShadow;
287 
288  // animation
289  unsigned int m_animationId;
290  int m_currentLoop;
291  float m_animationSpeed;
292  float m_currentFrame;
293 
294  // collision
295  PhysicsProperties *m_physicsProperties;
296 
297  // bounding box
298  Box3d m_boundingBox;
299  bool m_isOccluder;
300 
301  bool m_hasTransparency;
302  bool m_wireframe;
303 
304  Material* m_materials;
305  unsigned int m_numMaterials;
306 
307 public:
308 
313  Material* getMaterial(size_t idx = 0) { return &m_materials[idx]; }
314 
319  size_t getMaterialsNumber() { return m_numMaterials; }
320 
325  bool hasWireframe() { return m_wireframe; }
326 
331  void enableWireframe(bool v) { m_wireframe = v; }
332 
337  bool hasTransparency() { return m_hasTransparency; }
338 
346  PhysicsProperties* enablePhysics(Scene *scene);
347 
354  PhysicsProperties* enablePhysics();
355 
363  bool isColliding(OEntity* entity);
364 
370  bool isColliding();
371 
378  inline void enableOccluder(bool value) { m_isOccluder = value; }
379 
384  inline bool isOccluder() { return m_isOccluder; }
385 
386  virtual int getType(void) { return OBJECT3D_ENTITY; }
387  virtual void setActive(bool active);
388 
396  void setInvisible(bool invisible) { m_isInvisible = invisible; }
397 
402  bool isInvisible(void) { return m_isInvisible; }
403 
408  Mesh *getMesh(void);
409 
415  void setMeshRef(MeshRef *meshRef);
416 
422  inline MeshRef *getMeshRef(void) { return m_meshRef; }
423 
429  void changeAnimation(unsigned int animationId);
430 
435  bool isAnimationOver(void);
436 
441  inline void setAnimationSpeed(float animationSpeed)
442  {
443  m_animationSpeed = animationSpeed;
444  }
445 
450  inline void setCurrentFrame(float currentFrame)
451  {
452  m_currentFrame = currentFrame;
453  }
454 
459  inline unsigned int getAnimationId(void) { return m_animationId; }
460 
465  inline float getAnimationSpeed(void) { return m_animationSpeed; }
466 
472  inline float getCurrentFrame(void) { return m_currentFrame; }
473 
477  void deletePhysicsProperties(void);
478 
483  PhysicsProperties *createPhysicsProperties(void);
484 
490  {
491  return m_physicsProperties;
492  }
493 
499  inline Box3d *getBoundingBox(void) { return &m_boundingBox; }
500 
505  inline bool hasShadow() { return m_hasShadow; }
506 
511  inline void enableShadow(bool shadow) { m_hasShadow = shadow; }
512 
513  virtual void update(void);
514  virtual void updateVisibility(OCamera *camera);
515 };
516 }
517 #endif
float getCurrentFrame(void)
Returns the animation current frame in the currently running animation.
Definition: OEntity.h:472
void setCollisionShape(COLLISION_SHAPE_TYPE collisionShape)
Changes the collision shape used for collision detection.
Definition: OEntity.h:141
bool hasWireframe()
Checks if the entity has the wireframe mode enabled.
Definition: OEntity.h:325
The Scene class represents a scene in a Maratis level.
Definition: Scene.h:48
float getRestitution(void)
Retrieves the current restitution value.
Definition: OEntity.h:208
COLLISION_SHAPE_TYPE getCollisionShape(void)
Retrieves the current collision shape that is used for collision detection.
Definition: OEntity.h:147
Vector3 lowerAngularLimit
Definition: OEntity.h:66
float getAngularDamping(void)
Retrieves the current angular damping value.
Definition: OEntity.h:232
Vector3 upperLinearLimit
Definition: OEntity.h:65
bool hasTransparency()
Checks if the entity has any transparent material.
Definition: OEntity.h:337
bool hasShadow()
Checks if the OEntity has a shadow.
Definition: OEntity.h:505
Definition: OEntity.h:54
void setFriction(float friction)
Changes the friction coefficient used for calculations.
Definition: OEntity.h:190
void setInvisible(bool invisible)
Changes if the OEntity is invisible or not.
Definition: OEntity.h:396
bool disableParentCollision
Definition: OEntity.h:68
Uses the bounding sphere for collision detection.
Definition: OEntity.h:41
Definition: MeshRef.h:32
Generate a capsule around the object and uses that for collision detection.
Definition: OEntity.h:45
float getMass(void)
Retrieves the mass of the object.
Definition: OEntity.h:184
Generates a convex hull around the object for collision detection.
Definition: OEntity.h:49
Vector3 lowerLinearLimit
Definition: OEntity.h:64
bool isInvisible(void)
Checks if the OEntity is invisible.
Definition: OEntity.h:402
float getFriction(void)
Retrieves the current friction value.
Definition: OEntity.h:196
Definition: Vector3.h:31
unsigned int getShapeId(void)
Retrieves the current physics ID.
Definition: OEntity.h:123
void setCurrentFrame(float currentFrame)
Changes the current frame in the current animation.
Definition: OEntity.h:450
The Material class contains the implementation of a material used by 3D meshes for rendering differen...
Definition: Material.h:118
Implements a framework for string manipulation that operates directly on C strings.
Definition: NeoString.h:35
MeshRef * getMeshRef(void)
Returns the MeshRef of the OEntity.
Definition: OEntity.h:422
float getAngularFactor(void)
Retrieves the current angular factor value.
Definition: OEntity.h:244
Box3d * getBoundingBox(void)
Returns the bounding box.
Definition: OEntity.h:499
Definition: Box3d.h:31
void setLinearFactor(const Vector3 &linearFactor)
Changes the linear factor coefficient used for calculations.
Definition: OEntity.h:250
bool isGhost(void)
Checks if the given object is a physical "ghost".
Definition: OEntity.h:166
void enableWireframe(bool v)
Enables/Disable the wireframe of the entity.
Definition: OEntity.h:331
virtual int getType(void)
Returns the type of the object.
Definition: OEntity.h:386
float getLinearDamping(void)
Retrieves the current linear damping value.
Definition: OEntity.h:220
unsigned int getCollisionObjectId(void)
Retrieves the current collision object ID that is used by the physics context.
Definition: OEntity.h:135
The PhysicsProperties class contains all physical properties an object can possibly possess...
Definition: OEntity.h:74
unsigned int parentObjectId
Definition: OEntity.h:60
bool isOccluder()
Checks if the OEntity is an occluder.
Definition: OEntity.h:384
Uses the bounding box for collision detection.
Definition: OEntity.h:39
Uses a cylinder that surrounds the object for collision detection.
Definition: OEntity.h:47
The Object3d class represents a general object in a 3D scene.
Definition: Object3d.h:43
void setShapeId(unsigned int shapeId)
Changes the physics shape ID that is given out by the physics context.
Definition: OEntity.h:117
Vector3 * getLinearFactor(void)
Retrieves the current linear factor value.
Definition: OEntity.h:256
PhysicsProperties * getPhysicsProperties(void)
Returns the physics properties object.
Definition: OEntity.h:489
Represents a 3D mesh in the scene.
Definition: OEntity.h:270
Uses a cone that completely surrounds the object for collision detection.
Definition: OEntity.h:43
void setGhost(bool ghost)
Sets the ghost property to the given value.
Definition: OEntity.h:154
void setAngularFactor(float angularFactor)
Changes the angular factor coefficient used for calculations.
Definition: OEntity.h:238
void enableOccluder(bool value)
Sets if this object is a occluder or not.
Definition: OEntity.h:378
PhysicsConstraint * getConstraint(void)
Retrieves a pointer to the physics constraint object.
Definition: OEntity.h:111
size_t getMaterialsNumber()
Returns the number of materials attached to this entity.
Definition: OEntity.h:319
String parentName
Definition: OEntity.h:62
void setRestitution(float restitution)
Changes the restitution coefficient used for calculations.
Definition: OEntity.h:202
unsigned int constraintId
Definition: OEntity.h:59
The Mesh class contains the implementation of a generic (i.e. file format agnostic) 3D mesh with supp...
Definition: Mesh.h:241
Definition: OCamera.h:30
void setMass(float mass)
Changes the mass.
Definition: OEntity.h:177
void enableShadow(bool shadow)
Enables or disables shadows for the OEntity.
Definition: OEntity.h:511
void setAngularDamping(float angularDamping)
Changes the angular damping coefficient used for calculations.
Definition: OEntity.h:226
void setLinearDamping(float linearDamping)
Changes the linear damping coefficient used for calculations.
Definition: OEntity.h:214
Definition: Color.h:29
float getAnimationSpeed(void)
Returns the animation speed of the currently running animation.
Definition: OEntity.h:465
void setCollisionObjectId(unsigned int collisionObjectId)
Changes the collision object ID used by the physics context.
Definition: OEntity.h:129
void setAnimationSpeed(float animationSpeed)
Changes the animation speed.
Definition: OEntity.h:441
Material * getMaterial(size_t idx=0)
Retrieves the material with the given index.
Definition: OEntity.h:313
unsigned int getAnimationId(void)
Returns the animation ID of the currently running animation.
Definition: OEntity.h:459
COLLISION_SHAPE_TYPE
Defines various types of collision shapes used for collision detection.
Definition: OEntity.h:36
Vector3 upperAngularLimit
Definition: OEntity.h:67
Definition: NeoEngine.h:48
Vector3 pivot
Definition: OEntity.h:63
Uses the triangle mesh directly for collision detection.
Definition: OEntity.h:51