ScummVM API documentation
PhysicsBodyNewton.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of HPL1 Engine.
26  */
27 
28 #ifndef HPL_PHYSICS_BODY_NEWTON_H
29 #define HPL_PHYSICS_BODY_NEWTON_H
30 
31 #include "hpl1/engine/libraries/newton/Newton.h"
32 
33 #include "hpl1/engine/physics/PhysicsBody.h"
34 
35 namespace hpl {
36 
38  void OnTransformUpdate(iEntity3D *apEntity);
39 };
40 
42  friend class cPhysicsBodyNewtonCallback;
43 
44 public:
45  cPhysicsBodyNewton(const tString &asName, iPhysicsWorld *apWorld, iCollideShape *apShape);
47 
48  void SetMaterial(iPhysicsMaterial *apMaterial);
49 
50  void SetLinearVelocity(const cVector3f &avVel);
51  cVector3f GetLinearVelocity() const;
52  void SetAngularVelocity(const cVector3f &avVel);
53  cVector3f GetAngularVelocity() const;
54  void SetLinearDamping(float afDamping);
55  float GetLinearDamping() const;
56  void SetAngularDamping(float afDamping);
57  float GetAngularDamping() const;
58  void SetMaxLinearSpeed(float afSpeed);
59  float GetMaxLinearSpeed() const;
60  void SetMaxAngularSpeed(float afDamping);
61  float GetMaxAngularSpeed() const;
62  cMatrixf GetInertiaMatrix();
63 
64  void SetMass(float afMass);
65  float GetMass() const;
66  void SetMassCentre(const cVector3f &avCentre);
67  cVector3f GetMassCentre() const;
68 
69  void AddForce(const cVector3f &avForce);
70  void AddForceAtPosition(const cVector3f &avForce, const cVector3f &avPos);
71  void AddTorque(const cVector3f &avTorque);
72  void AddImpulse(const cVector3f &avImpulse);
73  void AddImpulseAtPosition(const cVector3f &avImpulse, const cVector3f &avPos);
74 
75  void SetEnabled(bool abEnabled);
76  bool GetEnabled() const;
77  void SetAutoDisable(bool abEnabled);
78  bool GetAutoDisable() const;
79 #if 0
80  void SetAutoDisableLinearThreshold(float afThresold);
81  float GetAutoDisableLinearThreshold() const;
82  void SetAutoDisableAngularThreshold(float afThresold);
83  float GetAutoDisableAngularThreshold() const;
84  void SetAutoDisableNumSteps(int alNum);
85  int GetAutoDisableNumSteps() const;
86 #endif
87  void SetContinuousCollision(bool abOn);
88  bool GetContinuousCollision();
89 
90  void SetGravity(bool abEnabled);
91  bool GetGravity() const;
92 
93  void RenderDebugGeometry(iLowLevelGraphics *apLowLevel, const cColor &aColor);
94 
95  NewtonBody *GetNewtonBody() { return mpNewtonBody; }
96 
97  void ClearForces();
98 
99  void DeleteLowLevel();
100 
101  static void SetUseCallback(bool abX) { mbUseCallback = abX; }
102 
103 private:
104  static int BuoyancyPlaneCallback(const int32 alCollisionID, void *apContext,
105  const float *afGlobalSpaceMatrix, float *afGlobalSpacePlane);
106  static void OnTransformCallback(const NewtonBody *apBody, const dFloat *apMatrix, int32);
107  static void OnUpdateCallback(NewtonBody *apBody, float, int32);
108 
109  NewtonBody *mpNewtonBody;
110  NewtonWorld *mpNewtonWorld;
111 
112  cPhysicsBodyNewtonCallback *mpCallback;
113 
114  static bool mbUseCallback;
115 
116  // Properties
117  bool mbGravity;
118 
119  float mfMaxLinearSpeed;
120  float mfMaxAngularSpeed;
121  float mfMass;
122 
123  float mfAutoDisableLinearThreshold;
124  float mfAutoDisableAngularThreshold;
125  int mlAutoDisableNumSteps;
126 
127  // Forces that will be set and clear on update callback
128  cVector3f mvTotalForce;
129  cVector3f mvTotalTorque;
130 };
131 
132 } // namespace hpl
133 
134 #endif // HPL_PHYSICS_BODY_NEWTON_H
Definition: AI.h:36
Definition: str.h:59
Definition: PhysicsWorld.h:115
Definition: CollideShape.h:50
Definition: PhysicsBody.h:117
Definition: PhysicsMaterial.h:77
Definition: Color.h:37
Definition: Entity3D.h:81
Definition: PhysicsBodyNewton.h:37
Definition: Entity3D.h:44
Definition: PhysicsBodyNewton.h:41
Definition: LowLevelGraphics.h:200