TDME2  1.9.200
BoundingVolume.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <reactphysics3d/collision/shapes/AABB.h>
4 #include <reactphysics3d/collision/shapes/CollisionShape.h>
5 #include <reactphysics3d/mathematics/Transform.h>
6 
7 #include <tdme/tdme.h>
8 #include <tdme/engine/fwd-tdme.h>
12 #include <tdme/math/fwd-tdme.h>
13 #include <tdme/math/Vector3.h>
15 
20 
21 /**
22  * Bounding volume interface
23  * @author Andreas Drewke
24  */
26 {
27  friend class Capsule;
28  friend class ConvexMesh;
29  friend class OrientedBoundingBox;
30  friend class Sphere;
35 
36 protected:
37  World* world { nullptr };
41  reactphysics3d::CollisionShape* collisionShape { nullptr };
42  reactphysics3d::Transform collisionShapeLocalTransform;
43  reactphysics3d::Transform collisionShapeTransform;
44 
45  /**
46  * Destroy collision shape
47  */
48  virtual void destroyCollisionShape() = 0;
49 
50  /**
51  * Create collision shap
52  */
53  virtual void createCollisionShape(World* world) = 0;
54 
55  /**
56  * @return is attached to world
57  */
58  inline bool isAttachedToWorld() {
59  return world != nullptr;
60  }
61 
62 public:
63  /**
64  * Destructor
65  */
66  virtual ~BoundingVolume();
67 
68  /**
69  * Transform bounding volume from given transform
70  * @param transform transform
71  */
72  virtual void setTransform(const Transform& transform);
73 
74  /**
75  * Get local scale
76  * @return scale
77  */
78  const Vector3& getScale();
79 
80  /**
81  * Set local scale
82  * @return if collision shape had been recreated
83  */
84  virtual void setScale(const Vector3& scale) = 0;
85 
86  /**
87  * @return center
88  */
89  const Vector3& getCenter() const;
90 
91  /**
92  * Clones this bounding volume
93  * @return cloned bounding volume
94  */
95  virtual BoundingVolume* clone() const = 0;
96 
97 };
Transform which contain scale, rotations and translation.
Definition: Transform.h:29
Rigid body class.
Definition: Body.h:41
Dynamic physics world class.
Definition: World.h:38
Axis aligned bounding box used for frustum, this is not directly connectable with physics engine.
Definition: BoundingBox.h:26
virtual void setTransform(const Transform &transform)
Transform bounding volume from given transform.
virtual void setScale(const Vector3 &scale)=0
Set local scale.
reactphysics3d::Transform collisionShapeLocalTransform
virtual void destroyCollisionShape()=0
Destroy collision shape.
reactphysics3d::Transform collisionShapeTransform
virtual void createCollisionShape(World *world)=0
Create collision shap.
reactphysics3d::CollisionShape * collisionShape
virtual BoundingVolume * clone() const =0
Clones this bounding volume.
const Vector3 & getScale()
Get local scale.
Capsule physics primitive.
Definition: Capsule.h:19
Convex mesh physics primitive.
Definition: ConvexMesh.h:37
Oriented bounding box physics primitive.
Sphere physics primitive.
Definition: Sphere.h:19
Vector3 class representing vector3 mathematical structure and operations with x, y,...
Definition: Vector3.h:20
Helper class to create models from physics primitive bounding volumes.
Definition: Primitives.h:33