ScummVM API documentation
NewtonClass.h
1 /* Copyright (c) <2003-2011> <Julio Jerez, Newton Game Dynamics>
2 *
3 * This software is provided 'as-is', without any express or implied
4 * warranty. In no event will the authors be held liable for any damages
5 * arising from the use of this software.
6 *
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 *
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 *
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 *
19 * 3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 #ifndef __NewotnClass_3HL6356GYL459020__
23 #define __NewotnClass_3HL6356GYL459020__
24 
25 #include "NewtonStdAfx.h"
26 #include "Newton.h"
27 
28 
29 
30 #define MAX_TIMESTEP (1.0f / 60.0f)
31 #define MIN_TIMESTEP (1.0f / 1000.0f)
32 
33 class Newton;
34 
35 
36 class NewtonDeadBodies: public dgTree<dgBody *, void * > {
37 public:
38  NewtonDeadBodies(dgMemoryAllocator *const allocator);
39  void DestroyBodies(Newton &world);
40 };
41 
42 
43 class NewtonDeadJoints: public dgTree<dgConstraint *, void *> {
44 public:
45  NewtonDeadJoints(dgMemoryAllocator *const allocator);
46  void DestroyJoints(Newton &world);
47 };
48 
49 
50 class Newton:
51  public dgWorld,
52  public NewtonDeadBodies,
53  public NewtonDeadJoints {
54 public:
55  DG_CLASS_ALLOCATOR(allocator)
56 
57  Newton(dgFloat32 scale, dgMemoryAllocator *const allocator);
58  ~Newton();
59 
60  void DestroyBody(dgBody *body);
61  void DestroyJoint(dgConstraint *joint);
62 
63  void UpdatePhysics(dgFloat32 timestep);
64  static void *DefaultAllocMemory(dgInt32 size);
65  static void DefaultFreeMemory(void *ptr, dgInt32 size);
66 
67  dgFloat32 g_maxTimeStep;
68  bool m_updating;
69 
70  NewtonDestroyWorld m_destructor;
71 
72 };
73 
74 
75 
77 public:
78  NewtonUserJoint(dgWorld *world, dgInt32 maxDof,
79  NewtonUserBilateralCallBack callback, NewtonUserBilateralGetInfoCallBack getInfo,
80  dgBody *dyn0, dgBody *dyn1);
81  ~NewtonUserJoint();
82 
83  dgUnsigned32 JacobianDerivative(dgContraintDescritor &params);
84 
85  void AddAngularRowJacobian(const dgVector &dir, dgFloat32 relAngle);
86  void AddGeneralRowJacobian(const dgFloat32 *jacobian0, const dgFloat32 *jacobian1);
87  void AddLinearRowJacobian(const dgVector &pivot0, const dgVector &pivot1, const dgVector &dir);
88 
89  dgFloat32 GetRowForce(dgInt32 row) const;
90  void SetHighFriction(dgFloat32 friction);
91  void SetLowerFriction(dgFloat32 friction);
92  void SetRowStiffness(dgFloat32 stiffness);
93  void SetAcceleration(dgFloat32 acceleration);
94  void SetSpringDamperAcceleration(dgFloat32 springK, dgFloat32 springD);
95  void GetInfo(dgConstraintInfo *const info) const;
96 
97  void SetUpdateFeedbackFunction(NewtonUserBilateralCallBack getFeedback);
98 
99 
100 
101 private:
102  NewtonUserBilateralCallBack m_jacobianFnt;
103  NewtonUserBilateralGetInfoCallBack m_getInfoCallback;
104 
105  dgInt32 m_rows;
106  dgFloat32 *m_forceArray;
107  dgContraintDescritor *m_param;
108 
109  dgFloat32 m_lastJointAngle;
110  dgVector m_lastPosit0;
111  dgVector m_lastPosit1;
112 };
113 
114 
115 
116 #endif
Definition: NewtonClass.h:43
Definition: dgBody.h:85
Definition: NewtonClass.h:50
Definition: dgVector.h:86
Definition: NewtonClass.h:36
Definition: dgConstraint.h:137
Definition: dgConstraint.h:48
Definition: dgUserConstraint.h:30
Definition: dgTree.h:88
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: NewtonClass.h:76
Definition: dgMemory.h:80
Definition: dgConstraint.h:169
Definition: dgWorld.h:118