ScummVM API documentation
Newton.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 __NEWTON_H_INCLUDED__
23 #define __NEWTON_H_INCLUDED__
24 
25 #include "common/scummsys.h"
26 
27 #define NEWTON_MAJOR_VERSION 2
28 #define NEWTON_MINOR_VERSION 36
29 
30 #define NEWTON_API
31 
32 #ifdef __USE_DOUBLE_PRECISION__
33 #define dFloat double
34 #else
35 #define dFloat float
36 #endif
37 
38 #define dFloat64 double
39 
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 #define NEWTON_PROFILER_WORLD_UPDATE 0
46 
47 #define NEWTON_PROFILER_COLLISION_UPDATE 1
48 #define NEWTON_PROFILER_COLLISION_UPDATE_BROAD_PHASE 2
49 #define NEWTON_PROFILER_COLLISION_UPDATE_NARROW_PHASE 3
50 
51 #define NEWTON_PROFILER_DYNAMICS_UPDATE 4
52 #define NEWTON_PROFILER_DYNAMICS_CONSTRAINT_GRAPH 5
53 #define NEWTON_PROFILER_DYNAMICS_SOLVE_CONSTRAINT_GRAPH 6
54 
55 #define NEWTON_PROFILER_FORCE_CALLBACK_UPDATE 7
56 
57 
58 class NewtonMesh;
59 class NewtonBody;
60 class NewtonWorld;
61 class NewtonJoint;
62 class NewtonMaterial;
63 class NewtonCollision;
64 class NewtonSceneProxy;
65 class NewtonbreakableComponentMesh;
66 
67 // typedef struct NewtonRagDoll{} NewtonRagDoll;
68 // typedef struct NewtonRagDollBone{} NewtonRagDollBone;
69 
70 #define SERIALIZE_ID_BOX 0
71 #define SERIALIZE_ID_CONE 1
72 #define SERIALIZE_ID_SPHERE 2
73 #define SERIALIZE_ID_CAPSULE 3
74 #define SERIALIZE_ID_CYLINDER 4
75 #define SERIALIZE_ID_COMPOUND 5
76 #define SERIALIZE_ID_CONVEXHULL 6
77 #define SERIALIZE_ID_CONVEXMODIFIER 7
78 #define SERIALIZE_ID_CHAMFERCYLINDER 8
79 #define SERIALIZE_ID_TREE 9
80 #define SERIALIZE_ID_NULL 10
81 #define SERIALIZE_ID_HEIGHTFIELD 11
82 #define SERIALIZE_ID_USERMESH 12
83 #define SERIALIZE_ID_SCENE 13
84 #define SERIALIZE_ID_COMPOUND_BREAKABLE 14
85 
86 typedef struct NewtonBoxParam NewtonBoxParam;
87 typedef struct NewtonConeParam NewtonConeParam;
98 
100 
102  dFloat m_x;
103  dFloat m_y;
104  dFloat m_z;
105 };
106 
108  dFloat m_r0;
109  dFloat m_r1;
110  dFloat m_r2;
111 };
112 
114  dFloat m_r0;
115  dFloat m_r1;
116  dFloat m_height;
117 };
118 
120  dFloat m_r0;
121  dFloat m_r1;
122  dFloat m_height;
123 };
124 
126  dFloat m_r;
127  dFloat m_height;
128 };
129 
131  dFloat m_r;
132  dFloat m_height;
133 };
134 
136  int m_vertexCount;
137  int m_vertexStrideInBytes;
138  int m_faceCount;
139  dFloat *m_vertex;
140 };
141 
143  NewtonCollision *m_chidren;
144 };
145 
146 
148  int m_chidrenCount;
149  NewtonCollision **m_chidren;
150 };
151 
153  int m_vertexCount;
154  int m_indexCount;
155 };
156 
158  int m_width;
159  int m_height;
160  int m_gridsDiagonals;
161  dFloat m_horizonalScale;
162  dFloat m_verticalScale;
163  unsigned short *m_elevation;
164  char *m_atributes;
165 };
166 
168  int m_childrenProxyCount;
169 };
170 
172  dFloat m_offsetMatrix[4][4];
173  int m_collisionType; // tag id to identify the collision primitive
174  int m_referenceCount; // the current reference count for this collision
175  int m_collisionUserID;
176 
177  union {
178  NewtonBoxParam m_box;
179  NewtonConeParam m_cone;
180  NewtonSphereParam m_sphere;
181  NewtonCapsuleParam m_capsule;
182  NewtonCylinderParam m_cylinder;
183  NewtonChamferCylinderParam m_chamferCylinder;
184  NewtonConvexHullParam m_convexHull;
185  NewtonCompoundCollisionParam m_compoundCollision;
186  NewtonConvexHullModifierParam m_convexHullModifier;
187  NewtonCollisionTreeParam m_collisionTree;
188  NewtonHeightFieldCollisionParam m_heightField;
189  NewtonSceneCollisionParam m_sceneCollision;
190  dFloat m_paramArray[64]; // user define collision can use this to store information
191  };
192 };
193 
194 
195 typedef struct NewtonJointRecord NewtonJointRecord;
196 typedef struct NewtonHingeSliderUpdateDesc NewtonHingeSliderUpdateDesc;
197 typedef struct NewtonUserMeshCollisionRayHitDesc NewtonUserMeshCollisionRayHitDesc;
198 typedef struct NewtonUserMeshCollisionCollideDesc NewtonUserMeshCollisionCollideDesc;
199 typedef struct NewtonWorldConvexCastReturnInfo NewtonWorldConvexCastReturnInfo;
200 
201 
202 struct NewtonJointRecord {
203  dFloat m_attachmenMatrix_0[4][4];
204  dFloat m_attachmenMatrix_1[4][4];
205  dFloat m_minLinearDof[3];
206  dFloat m_maxLinearDof[3];
207  dFloat m_minAngularDof[3];
208  dFloat m_maxAngularDof[3];
209  const NewtonBody *m_attachBody_0;
210  const NewtonBody *m_attachBody_1;
211  dFloat m_extraParameters[16];
212  int m_bodiesCollisionOn;
213  char m_descriptionType[32];
214 } ;
215 
216 
217 
218 struct NewtonUserMeshCollisionCollideDesc {
219  dFloat m_boxP0[4]; // lower bounding box of intersection query in local space
220  dFloat m_boxP1[4]; // upper bounding box of intersection query in local space
221  int m_threadNumber; // current thread executing this query
222  int m_faceCount; // the application should set here how many polygons intersect the query box
223  int m_vertexStrideInBytes; // the application should set here the size of each vertex
224  void *m_userData; // user data passed to the collision geometry at creation time
225  dFloat *m_vertex; // the application should the pointer to the vertex array.
226  int *m_userAttribute; // the application should set here the pointer to the user data, one for each face
227  int *m_faceIndexCount; // the application should set here the pointer to the vertex count of each face.
228  int *m_faceVertexIndex; // the application should set here the pointer index array for each vertex on a face.
229  NewtonBody *m_objBody; // pointer to the colliding body
230  NewtonBody *m_polySoupBody; // pointer to the rigid body owner of this collision tree
231 };
232 
233 struct NewtonWorldConvexCastReturnInfo {
234  dFloat m_point[4]; // collision point in global space
235  dFloat m_normal[4]; // surface normal at collision point in global space
236  dFloat m_normalOnHitPoint[4]; // surface normal at the surface of the hit body,
237  // is the same as the normal calculated by a ray cast hitting the body at the hit point
238  dFloat m_penetration; // contact penetration at collision point
239  int m_contactID; // collision ID at contact point
240  const NewtonBody *m_hitBody; // body hit at contact point
241 };
242 
243 struct NewtonUserMeshCollisionRayHitDesc {
244  dFloat m_p0[4]; // ray origin in collision local space
245  dFloat m_p1[4]; // ray destination in collision local space
246  dFloat m_normalOut[4]; // copy here the normal at the ray intersection
247  int m_userIdOut; // copy here a user defined id for further feedback
248  void *m_userData; // user data passed to the collision geometry at creation time
249 };
250 
251 struct NewtonHingeSliderUpdateDesc {
252  dFloat m_accel;
253  dFloat m_minFriction;
254  dFloat m_maxFriction;
255  dFloat m_timestep;
256 } ;
257 
258 
259 // Newton callback functions
260 typedef void *(*NewtonAllocMemory)(int sizeInBytes);
261 typedef void (*NewtonFreeMemory)(void *const ptr, int sizeInBytes);
262 typedef void (*NewtonDestroyWorld)(const NewtonWorld *const newtonWorld);
263 
264 typedef unsigned(*NewtonGetTicksCountCallback)();
265 
266 typedef void (*NewtonSerialize)(void *const serializeHandle, const void *buffer, size_t size);
267 typedef void (*NewtonDeserialize)(void *const serializeHandle, void *buffer, size_t size);
268 
269 // user collision callbacks
270 typedef void (*NewtonUserMeshCollisionDestroyCallback)(void *const userData);
271 typedef void (*NewtonUserMeshCollisionCollideCallback)(NewtonUserMeshCollisionCollideDesc *const collideDescData);
272 typedef dFloat(*NewtonUserMeshCollisionRayHitCallback)(NewtonUserMeshCollisionRayHitDesc *const lineDescData);
273 typedef void (*NewtonUserMeshCollisionGetCollisionInfo)(void *const userData, NewtonCollisionInfoRecord *const infoRecord);
274 typedef void (*NewtonUserMeshCollisionGetFacesInAABB)(void *const userData, const dFloat *const p0, const dFloat *const p1,
275  const dFloat *const *const vertexArray, int32 *const vertexCount, int32 *const vertexStrideInBytes,
276  const int32 *const indexList, int32 maxIndexCount, const int32 *const userDataList);
277 
278 typedef dFloat(*NewtonCollisionTreeRayCastCallback)(const NewtonBody *const body, const NewtonCollision *const treeCollision, dFloat interception, dFloat *normal, int faceId, void *usedData);
279 typedef dFloat(*NewtonHeightFieldRayCastCallback)(const NewtonBody *const body, const NewtonCollision *const heightFieldCollision, dFloat interception, int row, int col, dFloat *normal, int faceId, void *usedData);
280 
281 
282 // collision tree call back (obsoleted no recommended)
283 typedef void (*NewtonTreeCollisionCallback)(const NewtonBody *const bodyWithTreeCollision, const NewtonBody *const body, int faceID,
284  int vertexCount, const dFloat *const vertex, int vertexStrideInBytes);
285 
286 typedef void (*NewtonBodyDestructor)(const NewtonBody *const body);
287 typedef void (*NewtonApplyForceAndTorque)(NewtonBody *const body, dFloat timestep, int32 threadIndex);
288 typedef void (*NewtonSetTransform)(const NewtonBody *const body, const dFloat *const matrix, int32 threadIndex);
289 
290 typedef int (*NewtonIslandUpdate)(const NewtonWorld *const newtonWorld, const void *islandHandle, int bodyCount);
291 typedef void (*NewtonBodyLeaveWorld)(const NewtonBody *const body, int threadIndex);
292 typedef void (*NewtonDestroyBodyByExeciveForce)(const NewtonBody *const body, const NewtonJoint *const contact);
293 typedef void (*NewtonCollisionDestructor)(const NewtonWorld *const newtonWorld, const NewtonCollision *const collision);
294 
295 typedef int (*NewtonCollisionCompoundBreakableCallback)(NewtonMesh *const mesh, void *const userData, dFloat *const planeMatrixOut);
296 
297 typedef int (*NewtonGetBuoyancyPlane)(const int32 collisionID, void *const context, const dFloat *const globalSpaceMatrix, dFloat *const globalSpacePlane);
298 typedef unsigned(*NewtonWorldRayPrefilterCallback)(const NewtonBody *const body, const NewtonCollision *const collision, void *const userData);
299 typedef dFloat(*NewtonWorldRayFilterCallback)(const NewtonBody *const body, const dFloat *const hitNormal, int collisionID, void *const userData, dFloat intersectParam);
300 
301 
302 typedef int (*NewtonOnAABBOverlap)(const NewtonMaterial *const material, const NewtonBody *const body0, const NewtonBody *const body1, int32 threadIndex);
303 typedef void (*NewtonContactsProcess)(const NewtonJoint *const contact, dFloat timestep, int32 threadIndex);
304 
305 typedef void (*NewtonBodyIterator)(const NewtonBody *const body, void *const userData);
306 typedef void (*NewtonJointIterator)(const NewtonJoint *const joint, void *const userData);
307 typedef void (*NewtonCollisionIterator)(void *const userData, int vertexCount, const dFloat *const faceArray, int faceId);
308 
309 typedef void (*NewtonBallCallBack)(const NewtonJoint *const ball, dFloat timestep);
310 typedef unsigned(*NewtonHingeCallBack)(const NewtonJoint *const hinge, NewtonHingeSliderUpdateDesc *const desc);
311 typedef unsigned(*NewtonSliderCallBack)(const NewtonJoint *const slider, NewtonHingeSliderUpdateDesc *const desc);
312 typedef unsigned(*NewtonUniversalCallBack)(const NewtonJoint *const universal, NewtonHingeSliderUpdateDesc *const desc);
313 typedef unsigned(*NewtonCorkscrewCallBack)(const NewtonJoint *const corkscrew, NewtonHingeSliderUpdateDesc *const desc);
314 
315 typedef void (*NewtonUserBilateralCallBack)(const NewtonJoint *const userJoint, dFloat timestep, int threadIndex);
316 typedef void (*NewtonUserBilateralGetInfoCallBack)(const NewtonJoint *const userJoint, NewtonJointRecord *const info);
317 
318 typedef void (*NewtonConstraintDestructor)(const NewtonJoint *const me);
319 
320 // typedef void (*NewtonSetRagDollTransform) (const NewtonRagDollBone* const bone);
321 // typedef void (*NewtonBodyActivationState) (const NewtonBody* const body, unsigned state);
322 // typedef void (*NewtonVehicleTireUpdate) (const NewtonJoint* const vehicle, dFloat timestep);
323 
324 
325 void NewtonInitGlobals();
326 
327 void NewtonDestroyGlobals();
328 
329 // **********************************************************************************************
330 //
331 // world control functions
332 //
333 // **********************************************************************************************
334 NEWTON_API int NewtonWorldGetVersion();
335 NEWTON_API int NewtonWorldFloatSize();
336 
337 NEWTON_API int NewtonGetMemoryUsed();
338 NEWTON_API void NewtonSetMemorySystem(NewtonAllocMemory malloc, NewtonFreeMemory mfree);
339 
340 NEWTON_API NewtonWorld *NewtonCreate();
341 NEWTON_API void NewtonDestroy(const NewtonWorld *const newtonWorld);
342 NEWTON_API void NewtonDestroyAllBodies(const NewtonWorld *const newtonWorld);
343 
344 NEWTON_API void NewtonUpdate(NewtonWorld *const newtonWorld, dFloat timestep);
345 NEWTON_API void NewtonInvalidateCache(NewtonWorld *const newtonWorld);
346 NEWTON_API void NewtonCollisionUpdate(NewtonWorld *const newtonWorld);
347 
348 NEWTON_API void NewtonSetSolverModel(NewtonWorld *const newtonWorld, int model);
349 NEWTON_API void NewtonSetPlatformArchitecture(NewtonWorld *const newtonWorld, int mode);
350 NEWTON_API int NewtonGetPlatformArchitecture(const NewtonWorld *const newtonWorld, char *description);
351 NEWTON_API void NewtonSetMultiThreadSolverOnSingleIsland(NewtonWorld *const newtonWorld, int mode);
352 NEWTON_API int NewtonGetMultiThreadSolverOnSingleIsland(const NewtonWorld *const newtonWorld);
353 
354 NEWTON_API void NewtonSetPerformanceClock(NewtonWorld *const newtonWorld, NewtonGetTicksCountCallback callback);
355 NEWTON_API unsigned NewtonReadPerformanceTicks(const NewtonWorld *const newtonWorld, unsigned performanceEntry);
356 NEWTON_API unsigned NewtonReadThreadPerformanceTicks(const NewtonWorld *newtonWorld, unsigned threadIndex);
357 
358 NEWTON_API void NewtonWorldCriticalSectionLock(NewtonWorld *const newtonWorld);
359 NEWTON_API void NewtonWorldCriticalSectionUnlock(NewtonWorld *const newtonWorld);
360 NEWTON_API void NewtonSetThreadsCount(NewtonWorld *const newtonWorld, int threads);
361 NEWTON_API int NewtonGetThreadsCount(const NewtonWorld *const newtonWorld);
362 NEWTON_API int NewtonGetMaxThreadsCount(const NewtonWorld *const newtonWorld);
363 
364 NEWTON_API void NewtonSetFrictionModel(NewtonWorld *const newtonWorld, int model);
365 NEWTON_API void NewtonSetMinimumFrameRate(NewtonWorld *const newtonWorld, dFloat frameRate);
366 NEWTON_API void NewtonSetBodyLeaveWorldEvent(NewtonWorld *const newtonWorld, NewtonBodyLeaveWorld callback);
367 NEWTON_API void NewtonSetWorldSize(NewtonWorld *const newtonWorld, const dFloat *const minPoint, const dFloat *const maxPoint);
368 NEWTON_API void NewtonSetIslandUpdateEvent(NewtonWorld *const newtonWorld, NewtonIslandUpdate islandUpdate);
369 NEWTON_API void NewtonSetCollisionDestructor(NewtonWorld *const newtonWorld, NewtonCollisionDestructor callback);
370 NEWTON_API void NewtonSetDestroyBodyByExeciveForce(NewtonWorld *const newtonWorld, NewtonDestroyBodyByExeciveForce callback);
371 
372 
373 // NEWTON_API void NewtonWorldForEachBodyDo (const NewtonWorld* const newtonWorld, NewtonBodyIterator callback);
374 NEWTON_API void NewtonWorldForEachJointDo(const NewtonWorld *const newtonWorld, NewtonJointIterator callback, void *const userData);
375 NEWTON_API void NewtonWorldForEachBodyInAABBDo(const NewtonWorld *const newtonWorld, const dFloat *const p0, const dFloat *const p1, NewtonBodyIterator callback, void *const userData);
376 
377 
378 NEWTON_API void NewtonWorldSetUserData(NewtonWorld *const newtonWorld, void *const userData);
379 NEWTON_API void *NewtonWorldGetUserData(const NewtonWorld *const newtonWorld);
380 NEWTON_API void NewtonWorldSetDestructorCallBack(NewtonWorld *const newtonWorld, NewtonDestroyWorld destructor);
381 NEWTON_API NewtonDestroyWorld NewtonWorldGetDestructorCallBack(const NewtonWorld *const newtonWorld);
382 
383 NEWTON_API void NewtonWorldRayCast(NewtonWorld *const newtonWorld, const dFloat *const p0, const dFloat *const p1, NewtonWorldRayFilterCallback filter, void *const userData,
384  NewtonWorldRayPrefilterCallback prefilter);
385 NEWTON_API int NewtonWorldConvexCast(NewtonWorld *const newtonWorld, const dFloat *const matrix, const dFloat *const target, NewtonCollision *shape, dFloat *const hitParam, void *const userData,
386  NewtonWorldRayPrefilterCallback prefilter, NewtonWorldConvexCastReturnInfo *info, int maxContactsCount, int threadIndex);
387 
388 
389 // world utility functions
390 NEWTON_API int NewtonWorldGetBodyCount(const NewtonWorld *const newtonWorld);
391 NEWTON_API int NewtonWorldGetConstraintCount(const NewtonWorld *const newtonWorld);
392 
393 // NEWTON_API int NewtonGetActiveBodiesCount();
394 // NEWTON_API int NewtonGetActiveConstraintsCount();
395 // NEWTON_API dFloat NewtonGetGlobalScale (const NewtonWorld* const newtonWorld);
396 
397 
398 
399 // **********************************************************************************************
400 //
401 // Simulation islands
402 //
403 // **********************************************************************************************
404 NEWTON_API NewtonBody *NewtonIslandGetBody(const void *const island, int bodyIndex);
405 NEWTON_API void NewtonIslandGetBodyAABB(const void *const island, int bodyIndex, dFloat *const p0, dFloat *const p1);
406 
407 // **********************************************************************************************
408 //
409 // Physics Material Section
410 //
411 // **********************************************************************************************
412 NEWTON_API int NewtonMaterialCreateGroupID(NewtonWorld *const newtonWorld);
413 NEWTON_API int NewtonMaterialGetDefaultGroupID(const NewtonWorld *const newtonWorld);
414 NEWTON_API void NewtonMaterialDestroyAllGroupID(NewtonWorld *const newtonWorld);
415 
416 // material definitions that can not be overwritten in function callback
417 NEWTON_API void *NewtonMaterialGetUserData(const NewtonWorld *const newtonWorld, int id0, int id1);
418 NEWTON_API void NewtonMaterialSetSurfaceThickness(const NewtonWorld *const newtonWorld, int id0, int id1, dFloat thickness);
419 NEWTON_API void NewtonMaterialSetContinuousCollisionMode(const NewtonWorld *const newtonWorld, int id0, int id1, int state);
420 NEWTON_API void NewtonMaterialSetCollisionCallback(const NewtonWorld *const newtonWorld, int id0, int id1, void *const userData,
421  NewtonOnAABBOverlap aabbOverlap, NewtonContactsProcess process);
422 
423 NEWTON_API void NewtonMaterialSetDefaultSoftness(const NewtonWorld *const newtonWorld, int id0, int id1, dFloat value);
424 NEWTON_API void NewtonMaterialSetDefaultElasticity(const NewtonWorld *const newtonWorld, int id0, int id1, dFloat elasticCoef);
425 NEWTON_API void NewtonMaterialSetDefaultCollidable(const NewtonWorld *const newtonWorld, int id0, int id1, int state);
426 NEWTON_API void NewtonMaterialSetDefaultFriction(const NewtonWorld *const newtonWorld, int id0, int id1, dFloat staticFriction, dFloat kineticFriction);
427 
428 NEWTON_API NewtonMaterial *NewtonWorldGetFirstMaterial(const NewtonWorld *const newtonWorld);
429 NEWTON_API NewtonMaterial *NewtonWorldGetNextMaterial(const NewtonWorld *const newtonWorld, NewtonMaterial *const material);
430 
431 NEWTON_API NewtonBody *NewtonWorldGetFirstBody(const NewtonWorld *const newtonWorld);
432 NEWTON_API NewtonBody *NewtonWorldGetNextBody(const NewtonWorld *const newtonWorld, const NewtonBody *const curBody);
433 
434 
435 // **********************************************************************************************
436 //
437 // Physics Contact control functions
438 //
439 // **********************************************************************************************
440 NEWTON_API void *NewtonMaterialGetMaterialPairUserData(const NewtonMaterial *const material);
441 NEWTON_API unsigned NewtonMaterialGetContactFaceAttribute(const NewtonMaterial *const material);
442 NEWTON_API NewtonCollision *NewtonMaterialGetBodyCollidingShape(const NewtonMaterial *const material, const NewtonBody *const body);
443 //NEWTON_API unsigned NewtonMaterialGetBodyCollisionID (const NewtonMaterial* const material, const NewtonBody* const body);
444 NEWTON_API dFloat NewtonMaterialGetContactNormalSpeed(const NewtonMaterial *const material);
445 NEWTON_API void NewtonMaterialGetContactForce(const NewtonMaterial *const material, NewtonBody *const body, dFloat *const force);
446 NEWTON_API void NewtonMaterialGetContactPositionAndNormal(const NewtonMaterial *const material, NewtonBody *const body, dFloat *const posit, dFloat *const normal);
447 NEWTON_API void NewtonMaterialGetContactTangentDirections(const NewtonMaterial *const material, NewtonBody *const body, dFloat *const dir0, dFloat *const dir1);
448 NEWTON_API dFloat NewtonMaterialGetContactTangentSpeed(const NewtonMaterial *const material, int index);
449 
450 NEWTON_API void NewtonMaterialSetContactSoftness(NewtonMaterial *const material, dFloat softness);
451 NEWTON_API void NewtonMaterialSetContactElasticity(NewtonMaterial *const material, dFloat restitution);
452 NEWTON_API void NewtonMaterialSetContactFrictionState(NewtonMaterial *const material, int state, int index);
453 NEWTON_API void NewtonMaterialSetContactFrictionCoef(NewtonMaterial *const material, dFloat staticFrictionCoef, dFloat kineticFrictionCoef, int index);
454 
455 NEWTON_API void NewtonMaterialSetContactNormalAcceleration(NewtonMaterial *const material, dFloat accel);
456 NEWTON_API void NewtonMaterialSetContactNormalDirection(NewtonMaterial *const material, const dFloat *const directionVector);
457 
458 NEWTON_API void NewtonMaterialSetContactTangentAcceleration(NewtonMaterial *const material, dFloat accel, int index);
459 NEWTON_API void NewtonMaterialContactRotateTangentDirections(NewtonMaterial *const material, const dFloat *const directionVector);
460 
461 
462 
463 // **********************************************************************************************
464 //
465 // convex collision primitives creation functions
466 //
467 // **********************************************************************************************
468 NEWTON_API NewtonCollision *NewtonCreateNull(NewtonWorld *const newtonWorld);
469 NEWTON_API NewtonCollision *NewtonCreateSphere(NewtonWorld *const newtonWorld, dFloat radiusX, dFloat radiusY, dFloat radiusZ, int shapeID, const dFloat *const offsetMatrix);
470 NEWTON_API NewtonCollision *NewtonCreateBox(NewtonWorld *const newtonWorld, dFloat dx, dFloat dy, dFloat dz, int shapeID, const dFloat *const offsetMatrix);
471 NEWTON_API NewtonCollision *NewtonCreateCone(NewtonWorld *const newtonWorld, dFloat radius, dFloat height, int shapeID, const dFloat *const offsetMatrix);
472 NEWTON_API NewtonCollision *NewtonCreateCapsule(NewtonWorld *const newtonWorld, dFloat radius, dFloat height, int shapeID, const dFloat *const offsetMatrix);
473 NEWTON_API NewtonCollision *NewtonCreateCylinder(NewtonWorld *const newtonWorld, dFloat radius, dFloat height, int shapeID, const dFloat *const offsetMatrix);
474 NEWTON_API NewtonCollision *NewtonCreateChamferCylinder(NewtonWorld *const newtonWorld, dFloat radius, dFloat height, int shapeID, const dFloat *const offsetMatrix);
475 NEWTON_API NewtonCollision *NewtonCreateConvexHull(NewtonWorld *const newtonWorld, int count, const dFloat *const vertexCloud, int strideInBytes, dFloat tolerance, int shapeID, const dFloat *const offsetMatrix);
476 NEWTON_API NewtonCollision *NewtonCreateConvexHullFromMesh(const NewtonWorld *const newtonWorld, const NewtonMesh *const mesh, dFloat tolerance, int shapeID);
477 
478 NEWTON_API NewtonCollision *NewtonCreateConvexHullModifier(NewtonWorld *const newtonWorld, NewtonCollision *const convexHullCollision, int shapeID);
479 NEWTON_API void NewtonConvexHullModifierGetMatrix(const NewtonCollision *const convexHullCollision, dFloat *const matrix);
480 NEWTON_API void NewtonConvexHullModifierSetMatrix(NewtonCollision *const convexHullCollision, const dFloat *const matrix);
481 
482 NEWTON_API int NewtonCollisionIsTriggerVolume(const NewtonCollision *const convexCollision);
483 NEWTON_API void NewtonCollisionSetAsTriggerVolume(NewtonCollision *convexCollision, int trigger);
484 
485 NEWTON_API void NewtonCollisionSetMaxBreakImpactImpulse(NewtonCollision *const convexHullCollision, dFloat maxImpactImpulse);
486 NEWTON_API dFloat NewtonCollisionGetMaxBreakImpactImpulse(const NewtonCollision *const convexHullCollision);
487 
488 NEWTON_API void NewtonCollisionSetUserID(NewtonCollision *convexCollision, unsigned id);
489 NEWTON_API unsigned NewtonCollisionGetUserID(NewtonCollision *const convexCollision);
490 
491 NEWTON_API int NewtonConvexHullGetFaceIndices(const NewtonCollision *const convexHullCollision, int face, int32 *const faceIndices);
492 NEWTON_API dFloat NewtonConvexCollisionCalculateVolume(const NewtonCollision *const convexCollision);
493 NEWTON_API void NewtonConvexCollisionCalculateInertialMatrix(const NewtonCollision *convexCollision, dFloat *const inertia, dFloat *const origin);
494 
495 
496 NEWTON_API void NewtonCollisionMakeUnique(NewtonWorld *const newtonWorld, NewtonCollision *const collision);
497 NEWTON_API void NewtonReleaseCollision(NewtonWorld *const newtonWorld, NewtonCollision *const collision);
498 NEWTON_API int NewtonAddCollisionReference(NewtonCollision *const collision);
499 
500 
501 // **********************************************************************************************
502 //
503 // mass/spring/damper collision shape
504 //
505 // **********************************************************************************************
506 // NEWTON_API NewtonCollision* NewtonCreateSoftShape (const NewtonWorld* const newtonWorld);
507 // NEWTON_API void NewtonSoftBodySetMassCount (const NewtonCollision* convexCollision, int count);
508 // NEWTON_API void NewtonSoftBodySetSpringCount (const NewtonCollision* convexCollision, int count);
509 
510 // NEWTON_API void NewtonSoftBodySetMass (const NewtonCollision* convexCollision, int index, dFloat mass, dFloat* position);
511 // NEWTON_API int NewtonSoftBodySetSpring (const NewtonCollision* convexCollision, int index, int mass0, int mass1, dFloat stiffness, dFloat damper);
512 // NEWTON_API int NewtonSoftBodyGetMassArray (const NewtonCollision* convexCollision, dFloat* masses, dFloat** positions);
513 
514 
515 // **********************************************************************************************
516 //
517 // complex collision primitives creation functions
518 //
519 // **********************************************************************************************
520 NEWTON_API NewtonCollision *NewtonCreateCompoundCollision(NewtonWorld *const newtonWorld, int count, NewtonCollision *const collisionPrimitiveArray[], int shapeID);
521 NEWTON_API NewtonCollision *NewtonCreateCompoundCollisionFromMesh(NewtonWorld *const newtonWorld, const NewtonMesh *const mesh, dFloat hullTolerance, int shapeID, int subShapeID);
522 //NEWTON_API NewtonCollision* NewtonCreateCompoundCollisionFromMesh(const NewtonWorld* const newtonWorld, const NewtonMesh* const mesh, int maxSubShapesCount, int shapeID, int subShapeID);
523 
524 // **********************************************************************************************
525 //
526 // complex breakable collision primitives interface
527 //
528 // **********************************************************************************************
529 // NEWTON_API NewtonCollision* NewtonCreateCompoundBreakable (const NewtonWorld* const newtonWorld, int meshCount,
530 // NewtonMesh* const solids[], NewtonMesh* const splitePlanes[],
531 // dFloat* const matrixPallete, int32* const shapeIDArray, dFloat* const densities,
532 // int shapeID, int debriID, NewtonCollisionCompoundBreakableCallback callback, void* buildUsedData);
533 
534 NEWTON_API NewtonCollision *NewtonCreateCompoundBreakable(NewtonWorld *const newtonWorld, int meshCount,
535  NewtonMesh **const solids, const int32 *const shapeIDArray,
536  const dFloat *const densities, const int32 *const internalFaceMaterial,
537  int shapeID, int debriID, dFloat debriSeparationGap);
538 
539 
540 NEWTON_API void NewtonCompoundBreakableResetAnchoredPieces(NewtonCollision *const compoundBreakable);
541 NEWTON_API void NewtonCompoundBreakableSetAnchoredPieces(NewtonCollision *const compoundBreakable, int fixShapesCount, dFloat *const matrixPallete, NewtonCollision **const fixedShapesArray);
542 
543 NEWTON_API int NewtonCompoundBreakableGetVertexCount(const NewtonCollision *const compoundBreakable);
544 NEWTON_API void NewtonCompoundBreakableGetVertexStreams(const NewtonCollision *const compoundBreakable, int vertexStrideInByte, dFloat *const vertex,
545  int normalStrideInByte, dFloat *const normal, int uvStrideInByte, dFloat *const uv);
546 
547 
548 NEWTON_API NewtonbreakableComponentMesh *NewtonBreakableGetMainMesh(const NewtonCollision *const compoundBreakable);
549 NEWTON_API NewtonbreakableComponentMesh *NewtonBreakableGetFirstComponent(const NewtonCollision *const compoundBreakable);
550 NEWTON_API const NewtonbreakableComponentMesh *NewtonBreakableGetNextComponent(const NewtonbreakableComponentMesh *const component);
551 
552 NEWTON_API void NewtonBreakableBeginDelete(NewtonCollision *const compoundBreakable);
553 NEWTON_API NewtonBody *NewtonBreakableCreateDebrieBody(NewtonCollision *const compoundBreakable, NewtonbreakableComponentMesh *const component);
554 NEWTON_API void NewtonBreakableDeleteComponent(NewtonCollision *const compoundBreakable, NewtonbreakableComponentMesh *const component);
555 NEWTON_API void NewtonBreakableEndDelete(NewtonCollision *const compoundBreakable);
556 
557 
558 NEWTON_API int NewtonBreakableGetComponentsInRadius(const NewtonCollision *const compoundBreakable, const dFloat *position, dFloat radius, NewtonbreakableComponentMesh **const segments, int maxCount);
559 
560 NEWTON_API void *NewtonBreakableGetFirstSegment(NewtonbreakableComponentMesh *const breakableComponent);
561 NEWTON_API void *NewtonBreakableGetNextSegment(const void *const segment);
562 
563 NEWTON_API int NewtonBreakableSegmentGetMaterial(void *const segment);
564 NEWTON_API int NewtonBreakableSegmentGetIndexCount(void *const segment);
565 NEWTON_API int NewtonBreakableSegmentGetIndexStream(const NewtonCollision *const compoundBreakable, NewtonbreakableComponentMesh *const meshOwner, void *const segment, int32 *const index);
566 NEWTON_API int NewtonBreakableSegmentGetIndexStreamShort(const NewtonCollision *const compoundBreakable, const NewtonbreakableComponentMesh *const meshOwner, void *const segment, short int *const index);
567 
568 
569 NEWTON_API NewtonCollision *NewtonCreateUserMeshCollision(NewtonWorld *const newtonWorld, const dFloat *const minBox,
570  const dFloat *const maxBox, void *const userData, NewtonUserMeshCollisionCollideCallback collideCallback,
571  NewtonUserMeshCollisionRayHitCallback rayHitCallback, NewtonUserMeshCollisionDestroyCallback destroyCallback,
572  NewtonUserMeshCollisionGetCollisionInfo getInfoCallback, NewtonUserMeshCollisionGetFacesInAABB facesInAABBCallback, int shapeID);
573 
574 
575 NEWTON_API NewtonCollision *NewtonCreateSceneCollision(NewtonWorld *const newtonWorld, int shapeID);
576 NEWTON_API NewtonSceneProxy *NewtonSceneCollisionCreateProxy(NewtonCollision *const scene, NewtonCollision *const collision, dFloat *const matrix);
577 
578 NEWTON_API void NewtonSceneCollisionDestroyProxy(NewtonCollision *const scene, NewtonSceneProxy *Proxy);
579 NEWTON_API void NewtonSceneProxySetMatrix(NewtonSceneProxy *const proxy, const dFloat *matrix);
580 NEWTON_API void NewtonSceneProxyGetMatrix(NewtonSceneProxy *const proxy, dFloat *matrix);
581 NEWTON_API void NewtonSceneSetProxyUserData(NewtonSceneProxy *const proxy, void *userData);
582 NEWTON_API void *NewtonSceneGetProxyUserData(NewtonSceneProxy *const proxy);
583 
584 NEWTON_API NewtonSceneProxy *NewtonSceneGetFirstProxy(NewtonCollision *const scene);
585 NEWTON_API NewtonSceneProxy *NewtonSceneGetNextProxy(NewtonCollision *const scene, NewtonSceneProxy *const proxy);
586 
587 NEWTON_API void NewtonSceneCollisionOptimize(NewtonCollision *scene);
588 
589 // ***********************************************************************************************************
590 //
591 // Collision serialization functions
592 //
593 // ***********************************************************************************************************
594 NEWTON_API NewtonCollision *NewtonCreateCollisionFromSerialization(NewtonWorld *const newtonWorld, NewtonDeserialize deserializeFunction, void *const serializeHandle);
595 NEWTON_API void NewtonCollisionSerialize(const NewtonWorld *const newtonWorld, const NewtonCollision *const collision, NewtonSerialize serializeFunction, void *const serializeHandle);
596 NEWTON_API void NewtonCollisionGetInfo(const NewtonCollision *const collision, NewtonCollisionInfoRecord *const collisionInfo);
597 
598 // **********************************************************************************************
599 //
600 // Static collision shapes functions
601 //
602 // **********************************************************************************************
603 NEWTON_API NewtonCollision *NewtonCreateHeightFieldCollision(NewtonWorld *const newtonWorld, int width, int height, int gridsDiagonals,
604  const unsigned short *const elevationMap, const int8 *const attributeMap,
605  dFloat horizontalScale, dFloat verticalScale, int shapeID);
606 NEWTON_API void NewtonHeightFieldSetUserRayCastCallback(NewtonCollision *const treeCollision, NewtonHeightFieldRayCastCallback rayHitCallback);
607 
608 
609 NEWTON_API NewtonCollision *NewtonCreateTreeCollision(NewtonWorld *const newtonWorld, int shapeID);
610 NEWTON_API NewtonCollision *NewtonCreateTreeCollisionFromMesh(const NewtonWorld *const newtonWorld, const NewtonMesh *const mesh, int shapeID);
611 
612 NEWTON_API void NewtonTreeCollisionSetUserRayCastCallback(const NewtonCollision *const treeCollision, NewtonCollisionTreeRayCastCallback rayHitCallback);
613 
614 NEWTON_API void NewtonTreeCollisionBeginBuild(NewtonCollision *treeCollision);
615 NEWTON_API void NewtonTreeCollisionAddFace(NewtonCollision *const treeCollision, int vertexCount, const dFloat *const vertexPtr, int strideInBytes, int faceAttribute);
616 NEWTON_API void NewtonTreeCollisionEndBuild(NewtonCollision *const treeCollision, int optimize);
617 
618 NEWTON_API int NewtonTreeCollisionGetFaceAtribute(const NewtonCollision *const treeCollision, const int32 *const faceIndexArray);
619 NEWTON_API void NewtonTreeCollisionSetFaceAtribute(NewtonCollision *const treeCollision, const int32 *const faceIndexArray, int attribute);
620 NEWTON_API int NewtonTreeCollisionGetVertexListIndexListInAABB(const NewtonCollision *const treeCollision, const dFloat *const p0, const dFloat *const p1, const dFloat **const vertexArray, int32 *const vertexCount, int32 *const vertexStrideInBytes, int32 *const indexList, int maxIndexCount, int32 *const faceAttribute);
621 
622 
623 NEWTON_API void NewtonStaticCollisionSetDebugCallback(NewtonCollision *const staticCollision, NewtonTreeCollisionCallback userCallback);
624 
625 // **********************************************************************************************
626 //
627 // General purpose collision library functions
628 //
629 // **********************************************************************************************
630 NEWTON_API int NewtonCollisionPointDistance(NewtonWorld *const newtonWorld, const dFloat *const point,
631  NewtonCollision *const collision, const dFloat *const matrix, dFloat *const contact, dFloat *const normal, int threadIndex);
632 
633 NEWTON_API int NewtonCollisionClosestPoint(NewtonWorld *const newtonWorld,
634  NewtonCollision *const collisionA, const dFloat *const matrixA, NewtonCollision *const collisionB, const dFloat *const matrixB,
635  dFloat *const contactA, dFloat *const contactB, dFloat *const normalAB, int threadIndex);
636 
637 NEWTON_API int NewtonCollisionCollide(NewtonWorld *const newtonWorld, int maxSize,
638  NewtonCollision *const collisionA, const dFloat *const matrixA,
639  NewtonCollision *const collisionB, const dFloat *const matrixB,
640  dFloat *const contacts, dFloat *const normals, dFloat *const penetration, int threadIndex);
641 
642 NEWTON_API int NewtonCollisionCollideContinue(NewtonWorld *const newtonWorld, int maxSize, const dFloat timestep,
643  NewtonCollision *const collisionA, const dFloat *const matrixA, const dFloat *const velocA, const dFloat *omegaA,
644  NewtonCollision *const collisionB, const dFloat *const matrixB, const dFloat *const velocB, const dFloat *const omegaB,
645  dFloat *const timeOfImpact, dFloat *const contacts, dFloat *const normals, dFloat *const penetration, int threadIndex);
646 
647 NEWTON_API void NewtonCollisionSupportVertex(const NewtonCollision *const collision, const dFloat *const dir, dFloat *const vertex);
648 NEWTON_API dFloat NewtonCollisionRayCast(const NewtonCollision *const collision, const dFloat *const p0, const dFloat *const p1, dFloat *const normal, int *const attribute);
649 NEWTON_API void NewtonCollisionCalculateAABB(const NewtonCollision *const collision, const dFloat *const matrix, dFloat *const p0, dFloat *const p1);
650 NEWTON_API void NewtonCollisionForEachPolygonDo(const NewtonCollision *const collision, const dFloat *const matrix, NewtonCollisionIterator callback, void *const userData);
651 
652 
653 // **********************************************************************************************
654 //
655 // transforms utility functions
656 //
657 // **********************************************************************************************
658 NEWTON_API void NewtonGetEulerAngle(const dFloat *const matrix, dFloat *const eulersAngles);
659 NEWTON_API void NewtonSetEulerAngle(const dFloat *const eulersAngles, dFloat *const matrix);
660 NEWTON_API dFloat NewtonCalculateSpringDamperAcceleration(dFloat dt, dFloat ks, dFloat x, dFloat kd, dFloat s);
661 
662 // **********************************************************************************************
663 //
664 // body manipulation functions
665 //
666 // **********************************************************************************************
667 NEWTON_API NewtonBody *NewtonCreateBody(NewtonWorld *const newtonWorld, NewtonCollision *const collision, const dFloat *const matrix);
668 NEWTON_API void NewtonDestroyBody(NewtonWorld *const newtonWorld, NewtonBody *const body);
669 
670 NEWTON_API void NewtonBodyAddForce(NewtonBody *const body, const dFloat *const force);
671 NEWTON_API void NewtonBodyAddTorque(NewtonBody *const body, const dFloat *const torque);
672 NEWTON_API void NewtonBodyCalculateInverseDynamicsForce(const NewtonBody *const body, dFloat timestep, const dFloat *const desiredVeloc, dFloat *const forceOut);
673 
674 NEWTON_API void NewtonBodySetMatrix(NewtonBody *const body, dFloat *const matrix);
675 NEWTON_API void NewtonBodySetMatrixRecursive(NewtonBody *const body, const dFloat *const matrix);
676 NEWTON_API void NewtonBodySetMassMatrix(NewtonBody *const body, dFloat mass, dFloat Ixx, dFloat Iyy, dFloat Izz);
677 NEWTON_API void NewtonBodySetMaterialGroupID(NewtonBody *body, int id);
678 NEWTON_API void NewtonBodySetContinuousCollisionMode(NewtonBody *body, unsigned state);
679 NEWTON_API void NewtonBodySetJointRecursiveCollision(NewtonBody *body, unsigned state);
680 NEWTON_API void NewtonBodySetOmega(NewtonBody *body, const dFloat *const omega);
681 NEWTON_API void NewtonBodySetVelocity(NewtonBody *body, const dFloat *const velocity);
682 NEWTON_API void NewtonBodySetForce(NewtonBody *const body, const dFloat *const force);
683 NEWTON_API void NewtonBodySetTorque(NewtonBody *body, const dFloat *const torque);
684 
685 NEWTON_API void NewtonBodySetCentreOfMass(NewtonBody *body, const dFloat *const com);
686 NEWTON_API void NewtonBodySetLinearDamping(NewtonBody *body, dFloat linearDamp);
687 NEWTON_API void NewtonBodySetAngularDamping(NewtonBody *body, const dFloat *const angularDamp);
688 NEWTON_API void NewtonBodySetUserData(NewtonBody *const body, void *const userData);
689 NEWTON_API void NewtonBodySetCollision(NewtonBody *body, NewtonCollision *collision);
690 
691 
692 
693 NEWTON_API int NewtonBodyGetSleepState(const NewtonBody *const body);
694 NEWTON_API int NewtonBodyGetAutoSleep(const NewtonBody *const body);
695 NEWTON_API void NewtonBodySetAutoSleep(NewtonBody *body, int state);
696 
697 NEWTON_API int NewtonBodyGetFreezeState(const NewtonBody *const body);
698 NEWTON_API void NewtonBodySetFreezeState(NewtonBody *body, int state);
699 
700 
701 // NEWTON_API void NewtonBodySetAutoFreeze(const NewtonBody* const body, int state);
702 // NEWTON_API void NewtonBodyCoriolisForcesMode (const NewtonBody* const body, int mode);
703 // NEWTON_API void NewtonBodySetGyroscopicForcesMode (const NewtonBody* const body, int mode);
704 // NEWTON_API int NewtonBodyGetGyroscopicForcesMode (const NewtonBody* const body);
705 // NEWTON_API int NewtonBodyGetFreezeState (const NewtonBody* const body);
706 // NEWTON_API void NewtonBodySetFreezeState (const NewtonBody* const body, int state);
707 // NEWTON_API void NewtonBodyGetFreezeTreshold (const NewtonBody* const body, dFloat* freezeSpeed2, dFloat* freezeOmega2);
708 // NEWTON_API void NewtonBodySetFreezeTreshold (const NewtonBody* const body, dFloat freezeSpeed2, dFloat freezeOmega2, int framesCount);
709 // NEWTON_API void NewtonBodySetAutoactiveCallback (const NewtonBody* const body, NewtonBodyActivationState callback);
710 
711 
712 NEWTON_API void NewtonBodySetDestructorCallback(NewtonBody *const body, NewtonBodyDestructor callback);
713 
714 NEWTON_API void NewtonBodySetTransformCallback(NewtonBody *const body, NewtonSetTransform callback);
715 NEWTON_API NewtonSetTransform NewtonBodyGetTransformCallback(const NewtonBody *const body);
716 
717 NEWTON_API void NewtonBodySetForceAndTorqueCallback(NewtonBody *const body, NewtonApplyForceAndTorque callback);
718 NEWTON_API NewtonApplyForceAndTorque NewtonBodyGetForceAndTorqueCallback(const NewtonBody *const body);
719 NEWTON_API void *NewtonBodyGetUserData(const NewtonBody *const body);
720 NEWTON_API NewtonWorld *NewtonBodyGetWorld(const NewtonBody *const body);
721 NEWTON_API NewtonCollision *NewtonBodyGetCollision(const NewtonBody *const body);
722 NEWTON_API int NewtonBodyGetMaterialGroupID(const NewtonBody *const body);
723 
724 NEWTON_API int NewtonBodyGetContinuousCollisionMode(const NewtonBody *const body);
725 NEWTON_API int NewtonBodyGetJointRecursiveCollision(const NewtonBody *const body);
726 
727 NEWTON_API void NewtonBodyGetMatrix(const NewtonBody *const body, dFloat *const matrix);
728 NEWTON_API void NewtonBodyGetRotation(const NewtonBody *const body, dFloat *const rotation);
729 NEWTON_API void NewtonBodyGetMassMatrix(const NewtonBody *const body, dFloat *mass, dFloat *const Ixx, dFloat *const Iyy, dFloat *const Izz);
730 NEWTON_API void NewtonBodyGetInvMass(const NewtonBody *const body, dFloat *const invMass, dFloat *const invIxx, dFloat *const invIyy, dFloat *const invIzz);
731 NEWTON_API void NewtonBodyGetOmega(const NewtonBody *const body, dFloat *const vector);
732 NEWTON_API void NewtonBodyGetVelocity(const NewtonBody *const body, dFloat *const vector);
733 NEWTON_API void NewtonBodyGetForce(const NewtonBody *const body, dFloat *const vector);
734 NEWTON_API void NewtonBodyGetTorque(const NewtonBody *const body, dFloat *const vector);
735 NEWTON_API void NewtonBodyGetForceAcc(const NewtonBody *const body, dFloat *const vector);
736 NEWTON_API void NewtonBodyGetTorqueAcc(const NewtonBody *const body, dFloat *const vector);
737 NEWTON_API void NewtonBodyGetCentreOfMass(const NewtonBody *const body, dFloat *const com);
738 
739 NEWTON_API dFloat NewtonBodyGetLinearDamping(const NewtonBody *const body);
740 NEWTON_API void NewtonBodyGetAngularDamping(const NewtonBody *const body, dFloat *const vector);
741 NEWTON_API void NewtonBodyGetAABB(const NewtonBody *const body, dFloat *const p0, dFloat *const p1);
742 NEWTON_API NewtonJoint *NewtonBodyGetFirstJoint(const NewtonBody *const body);
743 NEWTON_API NewtonJoint *NewtonBodyGetNextJoint(const NewtonBody *const body, const NewtonJoint *const joint);
744 NEWTON_API NewtonJoint *NewtonBodyGetFirstContactJoint(const NewtonBody *const body);
745 NEWTON_API NewtonJoint *NewtonBodyGetNextContactJoint(const NewtonBody *const body, const NewtonJoint *const contactJoint);
746 
747 NEWTON_API void *NewtonContactJointGetFirstContact(const NewtonJoint *const contactJoint);
748 NEWTON_API void *NewtonContactJointGetNextContact(const NewtonJoint *const contactJoint, void *const contact);
749 
750 NEWTON_API int NewtonContactJointGetContactCount(const NewtonJoint *const contactJoint);
751 NEWTON_API void NewtonContactJointRemoveContact(NewtonJoint *contactJoint, void *const contact);
752 
753 NEWTON_API NewtonMaterial *NewtonContactGetMaterial(void *const contact);
754 
755 
756 NEWTON_API void NewtonBodyAddBuoyancyForce(NewtonBody *const body, dFloat fluidDensity,
757  dFloat fluidLinearViscosity, dFloat fluidAngularViscosity,
758  const dFloat *const gravityVector, NewtonGetBuoyancyPlane buoyancyPlane, void *const context);
759 
760 // NEWTON_API void NewtonBodyForEachPolygonDo (const NewtonBody* const body, NewtonCollisionIterator callback);
761 NEWTON_API void NewtonBodyAddImpulse(NewtonBody *body, const dFloat *const pointDeltaVeloc, const dFloat *const pointPosit);
762 
763 
764 NEWTON_API void NewtonBodyApplyImpulseArray(NewtonBody *body, int impuleCount, int strideInByte, const dFloat *const impulseArray, const dFloat *const pointArray);
765 
766 
767 // **********************************************************************************************
768 //
769 // Common joint functions
770 //
771 // **********************************************************************************************
772 NEWTON_API void *NewtonJointGetUserData(const NewtonJoint *const joint);
773 NEWTON_API void NewtonJointSetUserData(NewtonJoint *joint, void *const userData);
774 
775 NEWTON_API NewtonBody *NewtonJointGetBody0(const NewtonJoint *const joint);
776 NEWTON_API NewtonBody *NewtonJointGetBody1(const NewtonJoint *const joint);
777 
778 NEWTON_API void NewtonJointGetInfo(const NewtonJoint *const joint, NewtonJointRecord *const info);
779 NEWTON_API int NewtonJointGetCollisionState(const NewtonJoint *const joint);
780 NEWTON_API void NewtonJointSetCollisionState(NewtonJoint *joint, int state);
781 
782 NEWTON_API dFloat NewtonJointGetStiffness(const NewtonJoint *const joint);
783 NEWTON_API void NewtonJointSetStiffness(NewtonJoint *joint, dFloat state);
784 
785 NEWTON_API void NewtonDestroyJoint(NewtonWorld *newtonWorld, NewtonJoint *joint);
786 NEWTON_API void NewtonJointSetDestructor(const NewtonJoint *const joint, NewtonConstraintDestructor destructor);
787 
788 
789 
790 
791 // **********************************************************************************************
792 //
793 // Ball and Socket joint functions
794 //
795 // **********************************************************************************************
796 NEWTON_API NewtonJoint *NewtonConstraintCreateBall(NewtonWorld *newtonWorld, const dFloat *pivotPoint,
797  NewtonBody *childBody, NewtonBody *parentBody);
798 NEWTON_API void NewtonBallSetUserCallback(NewtonJoint *ball, NewtonBallCallBack callback);
799 NEWTON_API void NewtonBallGetJointAngle(const NewtonJoint *const ball, dFloat *angle);
800 NEWTON_API void NewtonBallGetJointOmega(const NewtonJoint *const ball, dFloat *omega);
801 NEWTON_API void NewtonBallGetJointForce(const NewtonJoint *const ball, dFloat *const force);
802 NEWTON_API void NewtonBallSetConeLimits(NewtonJoint *ball, const dFloat *pin, dFloat maxConeAngle, dFloat maxTwistAngle);
803 
804 // **********************************************************************************************
805 //
806 // Hinge joint functions
807 //
808 // **********************************************************************************************
809 NEWTON_API NewtonJoint *NewtonConstraintCreateHinge(NewtonWorld *newtonWorld,
810  const dFloat *pivotPoint, const dFloat *pinDir,
811  NewtonBody *childBody, NewtonBody *parentBody);
812 
813 NEWTON_API void NewtonHingeSetUserCallback(NewtonJoint *hinge, NewtonHingeCallBack callback);
814 NEWTON_API dFloat NewtonHingeGetJointAngle(const NewtonJoint *const hinge);
815 NEWTON_API dFloat NewtonHingeGetJointOmega(const NewtonJoint *const hinge);
816 NEWTON_API void NewtonHingeGetJointForce(const NewtonJoint *const hinge, dFloat *const force);
817 NEWTON_API dFloat NewtonHingeCalculateStopAlpha(const NewtonJoint *const hinge, const NewtonHingeSliderUpdateDesc *const desc, dFloat angle);
818 
819 // **********************************************************************************************
820 //
821 // Slider joint functions
822 //
823 // **********************************************************************************************
824 NEWTON_API NewtonJoint *NewtonConstraintCreateSlider(NewtonWorld *newtonWorld,
825  const dFloat *pivotPoint, const dFloat *pinDir,
826  NewtonBody *childBody, NewtonBody *parentBody);
827 NEWTON_API void NewtonSliderSetUserCallback(NewtonJoint *slider, NewtonSliderCallBack callback);
828 NEWTON_API dFloat NewtonSliderGetJointPosit(const NewtonJoint *slider);
829 NEWTON_API dFloat NewtonSliderGetJointVeloc(const NewtonJoint *slider);
830 NEWTON_API void NewtonSliderGetJointForce(const NewtonJoint *const slider, dFloat *const force);
831 NEWTON_API dFloat NewtonSliderCalculateStopAccel(const NewtonJoint *const slider, const NewtonHingeSliderUpdateDesc *const desc, dFloat position);
832 
833 
834 // **********************************************************************************************
835 //
836 // Corkscrew joint functions
837 //
838 // **********************************************************************************************
839 NEWTON_API NewtonJoint *NewtonConstraintCreateCorkscrew(NewtonWorld *newtonWorld,
840  const dFloat *pivotPoint, const dFloat *pinDir,
841  NewtonBody *childBody, NewtonBody *parentBody);
842 NEWTON_API void NewtonCorkscrewSetUserCallback(NewtonJoint *corkscrew, NewtonCorkscrewCallBack callback);
843 NEWTON_API dFloat NewtonCorkscrewGetJointPosit(const NewtonJoint *const corkscrew);
844 NEWTON_API dFloat NewtonCorkscrewGetJointAngle(const NewtonJoint *const corkscrew);
845 NEWTON_API dFloat NewtonCorkscrewGetJointVeloc(const NewtonJoint *const corkscrew);
846 NEWTON_API dFloat NewtonCorkscrewGetJointOmega(const NewtonJoint *const corkscrew);
847 NEWTON_API void NewtonCorkscrewGetJointForce(const NewtonJoint *const corkscrew, dFloat *const force);
848 NEWTON_API dFloat NewtonCorkscrewCalculateStopAlpha(const NewtonJoint *const corkscrew, const NewtonHingeSliderUpdateDesc *const desc, dFloat angle);
849 NEWTON_API dFloat NewtonCorkscrewCalculateStopAccel(const NewtonJoint *const corkscrew, const NewtonHingeSliderUpdateDesc *const desc, dFloat position);
850 
851 
852 // **********************************************************************************************
853 //
854 // Universal joint functions
855 //
856 // **********************************************************************************************
857 NEWTON_API NewtonJoint *NewtonConstraintCreateUniversal(const NewtonWorld *const newtonWorld,
858  const dFloat *pivotPoint, const dFloat *pinDir0, const dFloat *pinDir1,
859  const NewtonBody *const childBody, const NewtonBody *const parentBody);
860 NEWTON_API void NewtonUniversalSetUserCallback(const NewtonJoint *const universal, NewtonUniversalCallBack callback);
861 NEWTON_API dFloat NewtonUniversalGetJointAngle0(const NewtonJoint *const universal);
862 NEWTON_API dFloat NewtonUniversalGetJointAngle1(const NewtonJoint *const universal);
863 NEWTON_API dFloat NewtonUniversalGetJointOmega0(const NewtonJoint *const universal);
864 NEWTON_API dFloat NewtonUniversalGetJointOmega1(const NewtonJoint *const universal);
865 NEWTON_API void NewtonUniversalGetJointForce(const NewtonJoint *const universal, dFloat *const force);
866 NEWTON_API dFloat NewtonUniversalCalculateStopAlpha0(const NewtonJoint *const universal, const NewtonHingeSliderUpdateDesc *const desc, dFloat angle);
867 NEWTON_API dFloat NewtonUniversalCalculateStopAlpha1(const NewtonJoint *const universal, const NewtonHingeSliderUpdateDesc *const desc, dFloat angle);
868 
869 
870 // **********************************************************************************************
871 //
872 // Up vector joint functions
873 //
874 // **********************************************************************************************
875 NEWTON_API NewtonJoint *NewtonConstraintCreateUpVector(const NewtonWorld *const newtonWorld, const dFloat *pinDir, const NewtonBody *const body);
876 NEWTON_API void NewtonUpVectorGetPin(const NewtonJoint *const upVector, dFloat *pin);
877 NEWTON_API void NewtonUpVectorSetPin(const NewtonJoint *const upVector, const dFloat *pin);
878 
879 
880 // **********************************************************************************************
881 //
882 // User defined bilateral Joint
883 //
884 // **********************************************************************************************
885 NEWTON_API NewtonJoint *NewtonConstraintCreateUserJoint(const NewtonWorld *const newtonWorld, int maxDOF,
886  NewtonUserBilateralCallBack callback,
887  NewtonUserBilateralGetInfoCallBack getInfo,
888  const NewtonBody *const childBody, const NewtonBody *const parentBody) ;
889 NEWTON_API void NewtonUserJointSetFeedbackCollectorCallback(const NewtonJoint *const joint, NewtonUserBilateralCallBack getFeedback);
890 NEWTON_API void NewtonUserJointAddLinearRow(const NewtonJoint *const joint, const dFloat *const pivot0, const dFloat *const pivot1, const dFloat *const dir);
891 NEWTON_API void NewtonUserJointAddAngularRow(const NewtonJoint *const joint, dFloat relativeAngle, const dFloat *const dir);
892 NEWTON_API void NewtonUserJointAddGeneralRow(const NewtonJoint *const joint, const dFloat *const jacobian0, const dFloat *const jacobian1);
893 NEWTON_API void NewtonUserJointSetRowMinimumFriction(const NewtonJoint *const joint, dFloat friction);
894 NEWTON_API void NewtonUserJointSetRowMaximumFriction(const NewtonJoint *const joint, dFloat friction);
895 NEWTON_API void NewtonUserJointSetRowAcceleration(const NewtonJoint *const joint, dFloat acceleration);
896 NEWTON_API void NewtonUserJointSetRowSpringDamperAcceleration(const NewtonJoint *const joint, dFloat springK, dFloat springD);
897 NEWTON_API void NewtonUserJointSetRowStiffness(const NewtonJoint *const joint, dFloat stiffness);
898 NEWTON_API dFloat NewtonUserJointGetRowForce(const NewtonJoint *const joint, int row);
899 
900 
901 // **********************************************************************************************
902 //
903 // Mesh joint functions
904 //
905 // **********************************************************************************************
906 NEWTON_API NewtonMesh *NewtonMeshCreate(const NewtonWorld *const newtonWorld);
907 NEWTON_API NewtonMesh *NewtonMeshCreateFromMesh(const NewtonMesh *const mesh);
908 NEWTON_API NewtonMesh *NewtonMeshCreateFromCollision(const NewtonCollision *const collision);
909 NEWTON_API NewtonMesh *NewtonMeshConvexHull(const NewtonWorld *const newtonWorld, int count, const dFloat *const vertexCloud, int strideInBytes, dFloat tolerance);
910 NEWTON_API NewtonMesh *NewtonMeshCreatePlane(const NewtonWorld *const newtonWorld, const dFloat *const locationMatrix, dFloat witdth, dFloat breadth, int material, const dFloat *const textureMatrix0, const dFloat *const textureMatrix1);
911 
912 NEWTON_API void NewtonMeshDestroy(const NewtonMesh *const mesh);
913 
914 NEWTON_API void NewtonMesApplyTransform(const NewtonMesh *const mesh, const dFloat *const matrix);
915 NEWTON_API void NewtonMeshCalculateOOBB(const NewtonMesh *const mesh, dFloat *const matrix, dFloat *const x, dFloat *const y, dFloat *const z);
916 
917 NEWTON_API void NewtonMeshCalculateVertexNormals(const NewtonMesh *const mesh, dFloat angleInRadians);
918 NEWTON_API void NewtonMeshApplySphericalMapping(const NewtonMesh *const mesh, int material);
919 NEWTON_API void NewtonMeshApplyBoxMapping(const NewtonMesh *const mesh, int front, int side, int top);
920 NEWTON_API void NewtonMeshApplyCylindricalMapping(const NewtonMesh *const mesh, int cylinderMaterial, int capMaterial);
921 
922 NEWTON_API int NewtonMeshIsOpenMesh(const NewtonMesh *const mesh);
923 NEWTON_API void NewtonMeshFixTJoints(const NewtonMesh *const mesh);
924 
925 
926 NEWTON_API void NewtonMeshPolygonize(const NewtonMesh *const mesh);
927 NEWTON_API void NewtonMeshTriangulate(const NewtonMesh *const mesh);
928 NEWTON_API NewtonMesh *NewtonMeshUnion(const NewtonMesh *const mesh, const NewtonMesh *const clipper, const dFloat *const clipperMatrix);
929 NEWTON_API NewtonMesh *NewtonMeshDifference(const NewtonMesh *const mesh, const NewtonMesh *const clipper, const dFloat *const clipperMatrix);
930 NEWTON_API NewtonMesh *NewtonMeshIntersection(const NewtonMesh *const mesh, const NewtonMesh *const clipper, const dFloat *const clipperMatrix);
931 NEWTON_API void NewtonMeshClip(const NewtonMesh *const mesh, const NewtonMesh *const clipper, const dFloat *const clipperMatrix, NewtonMesh **const topMesh, NewtonMesh **const bottomMesh);
932 NEWTON_API void NewtonMeshPlaneClip(const NewtonMesh *const mesh, dFloat *const planeMatrix, const dFloat *const planeTextureMatrix, int planeMaterial, NewtonMesh **const topMesh, NewtonMesh **const bottomMesh);
933 
934 NEWTON_API NewtonMesh *NewtonMeshApproximateConvexDecomposition(const NewtonMesh *const mesh, dFloat maxConcavity, int maxCount);
935 NEWTON_API NewtonMesh *NewtonMeshTetrahedralization(const NewtonMesh *const mesh, int internalMaterial, const dFloat *const textureMatrix);
936 NEWTON_API NewtonMesh *NewtonMeshVoronoiDecomposition(const NewtonMesh *const mesh, int pointCount, int pointStrideInBytes, const dFloat *const pointCloud, int internalMaterial, const dFloat *const textureMatrix);
937 
938 
939 NEWTON_API void NewtonRemoveUnusedVertices(const NewtonMesh *const mesh, int32 *const vertexRemapTable);
940 
941 NEWTON_API void NewtonMeshBeginFace(const NewtonMesh *const mesh);
942 NEWTON_API void NewtonMeshAddFace(const NewtonMesh *const mesh, int vertexCount, const dFloat *const vertex, int strideInBytes, int materialIndex);
943 NEWTON_API void NewtonMeshEndFace(const NewtonMesh *const mesh);
944 
945 NEWTON_API void NewtonMeshBuildFromVertexListIndexList(const NewtonMesh *const mesh,
946  int faceCount, const int32 *const faceIndexCount, const int32 *const faceMaterialIndex,
947  const dFloat *const vertex, int vertexStrideInBytes, const int32 *const vertexIndex,
948  const dFloat *const normal, int normalStrideInBytes, const int32 *const normalIndex,
949  const dFloat *const uv0, int uv0StrideInBytes, const int32 *const uv0Index,
950  const dFloat *const uv1, int uv1StrideInBytes, const int32 *const uv1Index);
951 
952 
953 
954 NEWTON_API void NewtonMeshGetVertexStreams(const NewtonMesh *const mesh,
955  int vertexStrideInByte, dFloat *const vertex,
956  int normalStrideInByte, dFloat *const normal,
957  int uvStrideInByte0, dFloat *const uv0,
958  int uvStrideInByte1, dFloat *const uv1);
959 NEWTON_API void NewtonMeshGetIndirectVertexStreams(const NewtonMesh *const mesh,
960  int vertexStrideInByte, dFloat *const vertex, int *const vertexIndices, int *const vertexCount,
961  int normalStrideInByte, dFloat *const normal, int *const normalIndices, int *const normalCount,
962  int uvStrideInByte0, dFloat *const uv0, int *const uvIndices0, int *const uvCount0,
963  int uvStrideInByte1, dFloat *const uv1, int *const uvIndices1, int *const uvCount1);
964 NEWTON_API void *NewtonMeshBeginHandle(const NewtonMesh *const mesh);
965 NEWTON_API void NewtonMeshEndHandle(const NewtonMesh *const mesh, void *const handle);
966 NEWTON_API int NewtonMeshFirstMaterial(const NewtonMesh *const mesh, void *const handle);
967 NEWTON_API int NewtonMeshNextMaterial(const NewtonMesh *const mesh, void *const handle, int materialId);
968 NEWTON_API int NewtonMeshMaterialGetMaterial(const NewtonMesh *const mesh, void *const handle, int materialId);
969 NEWTON_API int NewtonMeshMaterialGetIndexCount(const NewtonMesh *const mesh, void *const handle, int materialId);
970 NEWTON_API void NewtonMeshMaterialGetIndexStream(const NewtonMesh *const mesh, void *const handle, int materialId, int32 *const index);
971 NEWTON_API void NewtonMeshMaterialGetIndexStreamShort(const NewtonMesh *const mesh, void *const handle, int materialId, short int *const index);
972 
973 NEWTON_API NewtonMesh *NewtonMeshCreateFirstSingleSegment(const NewtonMesh *const mesh);
974 NEWTON_API NewtonMesh *NewtonMeshCreateNextSingleSegment(const NewtonMesh *const mesh, const NewtonMesh *const segment);
975 
976 NEWTON_API NewtonMesh *NewtonMeshCreateFirstLayer(const NewtonMesh *const mesh);
977 NEWTON_API NewtonMesh *NewtonMeshCreateNextLayer(const NewtonMesh *const mesh, const NewtonMesh *const segment);
978 
979 
980 NEWTON_API int NewtonMeshGetTotalFaceCount(const NewtonMesh *const mesh);
981 NEWTON_API int NewtonMeshGetTotalIndexCount(const NewtonMesh *const mesh);
982 NEWTON_API void NewtonMeshGetFaces(const NewtonMesh *const mesh, int32 *const faceIndexCount, int32 *const faceMaterial, void **const faceIndices);
983 
984 
985 NEWTON_API int NewtonMeshGetPointCount(const NewtonMesh *const mesh);
986 NEWTON_API int NewtonMeshGetPointStrideInByte(const NewtonMesh *const mesh);
987 NEWTON_API dFloat64 *NewtonMeshGetPointArray(const NewtonMesh *const mesh);
988 NEWTON_API dFloat64 *NewtonMeshGetNormalArray(const NewtonMesh *const mesh);
989 NEWTON_API dFloat64 *NewtonMeshGetUV0Array(const NewtonMesh *const mesh);
990 NEWTON_API dFloat64 *NewtonMeshGetUV1Array(const NewtonMesh *const mesh);
991 
992 NEWTON_API int NewtonMeshGetVertexCount(const NewtonMesh *const mesh);
993 NEWTON_API int NewtonMeshGetVertexStrideInByte(const NewtonMesh *const mesh);
994 NEWTON_API dFloat64 *NewtonMeshGetVertexArray(const NewtonMesh *const mesh);
995 
996 
997 NEWTON_API void *NewtonMeshGetFirstVertex(const NewtonMesh *const mesh);
998 NEWTON_API void *NewtonMeshGetNextVertex(const NewtonMesh *const mesh, void *const vertex);
999 NEWTON_API int NewtonMeshGetVertexIndex(const NewtonMesh *const mesh, void *const vertex);
1000 
1001 NEWTON_API void *NewtonMeshGetFirstPoint(const NewtonMesh *const mesh);
1002 NEWTON_API void *NewtonMeshGetNextPoint(const NewtonMesh *const mesh, void *const point);
1003 NEWTON_API int NewtonMeshGetPointIndex(const NewtonMesh *const mesh, const void *const point);
1004 NEWTON_API int NewtonMeshGetVertexIndexFromPoint(const NewtonMesh *const mesh, void *const point);
1005 
1006 
1007 NEWTON_API void *NewtonMeshGetFirstEdge(const NewtonMesh *const mesh);
1008 NEWTON_API void *NewtonMeshGetNextEdge(const NewtonMesh *const mesh, void *const edge);
1009 NEWTON_API void NewtonMeshGetEdgeIndices(const NewtonMesh *const mesh, const void *const edge, int32 *const v0, int32 *const v1);
1010 //NEWTON_API void NewtonMeshGetEdgePointIndices (const NewtonMesh* const mesh, const void* const edge, int* const v0, int* const v1);
1011 
1012 NEWTON_API void *NewtonMeshGetFirstFace(const NewtonMesh *const mesh);
1013 NEWTON_API void *NewtonMeshGetNextFace(const NewtonMesh *const mesh, void *const face);
1014 NEWTON_API int NewtonMeshIsFaceOpen(const NewtonMesh *const mesh, const void *const face);
1015 NEWTON_API int NewtonMeshGetFaceMaterial(const NewtonMesh *const mesh, const void *const face);
1016 NEWTON_API int NewtonMeshGetFaceIndexCount(const NewtonMesh *const mesh, const void *const face);
1017 NEWTON_API void NewtonMeshGetFaceIndices(const NewtonMesh *const mesh, const void *const face, int *const indices);
1018 NEWTON_API void NewtonMeshGetFacePointIndices(const NewtonMesh *const mesh, const void *const face, int *const indices);
1019 
1020 
1021 #ifdef __cplusplus
1022 }
1023 #endif
1024 
1025 #endif
Definition: Newton.h:152
Definition: Newton.h:135
Definition: Newton.h:107
Definition: Newton.h:125
Definition: Newton.h:157
Definition: Newton.h:113
Definition: Newton.h:171
Definition: Newton.h:130
Definition: Newton.h:142
Definition: Newton.h:147
Definition: Newton.h:218
Definition: Newton.h:119
Definition: Newton.h:101
Definition: Newton.h:243
Definition: Newton.h:251
Definition: Newton.h:233
Definition: Newton.h:202
Definition: Newton.h:167