Neo  0.5.0
Developer Documentation
PhysicsContext.h
Go to the documentation of this file.
1 //========================================================================
2 // Copyright (c) 2003-2011 Anael Seghezzi <www.maratis3d.com>
3 //
4 // This software is provided 'as-is', without any express or implied
5 // warranty. In no event will the authors be held liable for any damages
6 // arising from the use of this software.
7 //
8 // Permission is granted to anyone to use this software for any purpose,
9 // including commercial applications, and to alter it and redistribute it
10 // freely, subject to the following restrictions:
11 //
12 // 1. The origin of this software must not be misrepresented; you must not
13 // claim that you wrote the original software. If you use this software
14 // in a product, an acknowledgment in the product documentation would
15 // be appreciated but is not required.
16 //
17 // 2. Altered source versions must be plainly marked as such, and must not
18 // be misrepresented as being the original software.
19 //
20 // 3. This notice may not be removed or altered from any source
21 // distribution.
22 //
23 //========================================================================
24 
25 
26 #ifndef __PHYSICS_CONTEXT_H
27 #define __PHYSICS_CONTEXT_H
28 
29 namespace Neo
30 {
34 class NEO_CORE_EXPORT PhysicsContext
35 {
36 public:
37 
38  // destructor
39  virtual ~PhysicsContext(void){}
40 
41  // init
42  virtual void init(const Vector3 & worldMin, const Vector3 & worldMax) = 0;
43 
44  // destroy
45  virtual void clear(void) = 0;
46 
47  // update simulation
48 
58  virtual void setSimulationQuality(unsigned int quality) = 0;
59  virtual void updateSimulation(void) = 0;
60 
61  // world
66  virtual void setWorldGravity(const Vector3 & gravity) = 0;
67 
68  // create object
69  virtual void createGhost(unsigned int * objectId, unsigned int shapeId, const Vector3 & position, const Quaternion & rotation) = 0;
70  virtual void createRigidBody(unsigned int * objectId, unsigned int shapeId, const Vector3 & position, const Quaternion & rotation, float mass) = 0;
71 
72  // activate / deactivate
73  virtual void activateObject(unsigned int objectId) = 0;
74  virtual void deactivateObject(unsigned int objectId) = 0;
75 
76  // delete object
77  virtual void deleteObject(unsigned int * objectId) = 0;
78 
79  // object properties
80  virtual void enableObjectKinematic(unsigned int objectId) = 0;
81  virtual void disableObjectKinematic(unsigned int objectId) = 0;
82 
83  virtual void setObjectShape(unsigned int objectId, unsigned int shapeId) = 0;
84  virtual void setObjectMass(unsigned int objectId, float mass) = 0;
85  virtual void setObjectRestitution(unsigned int objectId, float restitution) = 0;
86  virtual void setObjectFriction(unsigned int objectId, float friction) = 0;
87  virtual void setObjectLinearFactor(unsigned int objectId, const Vector3 & linearFactor) = 0;
88  virtual void setObjectAngularFactor(unsigned int objectId, float angularFactor) = 0;
89  virtual void setObjectDamping(unsigned int objectId, float linearDamping, float angularDamping) = 0;
90  virtual void setObjectTransform(unsigned int objectId, const Vector3 & position, const Quaternion & rotation) = 0;
91  virtual void getObjectTransform(unsigned int objectId, Vector3 * position, Quaternion * rotation) = 0;
92 
93  virtual void setObjectUserPointer(unsigned int objectId, void * userPointer) = 0;
94  virtual void * getObjectUserPointer(unsigned int objectId) = 0;
95 
96  // affectors
97  virtual void addCentralForce(unsigned int objectId, const Vector3 & force) = 0;
98  virtual void getCentralForce(unsigned int objectId, Vector3 * force) = 0;
99  virtual void addTorque(unsigned int objectId, const Vector3 & torque) = 0;
100  virtual void getTorque(unsigned int objectId, Vector3 * torque) = 0;
101  virtual void clearForces(unsigned int objectId) = 0;
102 
103  // objects collision
104  virtual int isObjectInCollision(unsigned int objectId, unsigned int * collisionList = NULL, unsigned int size = 0) = 0;
105  virtual bool isObjectsCollision(unsigned int object1Id, unsigned int object2Id) = 0;
106  virtual bool isRayHit(const Vector3 & start, const Vector3 & end, unsigned int * objectId = NULL, Vector3 * point = NULL, Vector3 * normal = NULL) = 0;
107 
108  // create shape
109  virtual void createMultiShape(unsigned int * shapeId) = 0;
110 
111  virtual void createBoxShape(unsigned int * shapeId, const Vector3 & scale) = 0;
112  virtual void createSphereShape(unsigned int * shapeId, float radius) = 0;
113  virtual void createConeShape(unsigned int * shapeId, float radius, float height) = 0;
114  virtual void createCapsuleShape(unsigned int * shapeId, float radius, float height) = 0;
115  virtual void createCylinderShape(unsigned int * shapeId, float radius, float height) = 0;
116 
117  virtual void createConvexHullShape(unsigned int * shapeId, const Vector3 * vertices, unsigned int verticesNumber, const Vector3 scale = Vector3(1)) = 0;
118  virtual void createTriangleMeshShape(unsigned int * shapeId, const Vector3 * vertices, unsigned int verticesNumber, const void * indices, unsigned int indicesNumber, VAR_TYPES indicesType, const Vector3 scale = Vector3(1)) = 0;
119 
120  // delete shape
121  virtual void deleteShape(unsigned int * shapeId) = 0;
122 
123  // add child shape to multishape
124  virtual void addChildShape(unsigned int multiShapeId, unsigned int shapeId, const Vector3 & position, const Quaternion & rotation) = 0;
125 
126  // create constraint
127  virtual void createConstraint(unsigned int * constraintId, unsigned int parentObjectId, unsigned int objectId, const Vector3 & pivot, bool disableParentCollision) = 0;
128  virtual void setLinearLimit(unsigned int constraintId, const Vector3 & lower, const Vector3 & upper) = 0;
129  virtual void setAngularLimit(unsigned int constraintId, const Vector3 & lower, const Vector3 & upper) = 0;
130 
131  // delete constraint
132  virtual void deleteConstraint(unsigned int * constraintId) = 0;
133 };
134 }
135 
136 #endif
Definition: Vector3.h:31
virtual ~PhysicsContext(void)
Definition: PhysicsContext.h:39
The PhysicsContext class contains abstraction to 3D physics functionality.
Definition: PhysicsContext.h:34
Definition: Color.h:29
Definition: Quaternion.h:31
VAR_TYPES
Definition: RenderingContext.h:140