//Newton header Delphi translation v2.24
//Includes:
//  Newton.h
//  JointLibrary.h
//dll:
//  Newton.dll
//  JointLibrary.dll
//Translation by Dan
unit Newton;

interface

  const NEWTON_MAJOR_VERSION = 2;
  const NEWTON_MINOR_VERSION = 24;

  const NEWTON_API = 'Newton.dll';
  const JOINTLIBRARY_API = 'JointLibrary.dll';

  //No double precision. Who needs it anyway.
  type dFloat = Single;
  type PdFloat = ^dFloat;

  const NEWTON_PROFILER_WORLD_UPDATE = 0;

  const NEWTON_PROFILER_COLLISION_UPDATE = 1;
  const NEWTON_PROFILER_FORCE_CALLBACK_UPDATE = 2;
  const NEWTON_PROFILER_COLLISION_UPDATE_BROAD_PHASE = 3;
  const NEWTON_PROFILER_COLLISION_UPDATE_NARROW_PHASE =	4;

  const NEWTON_PROFILER_DYNAMICS_UPDATE = 5;
  const NEWTON_PROFILER_DYNAMICS_CONSTRAINT_GRAPH = 6;
  const NEWTON_PROFILER_DYNAMICS_SOLVE_CONSTRAINT_GRAPH = 7;


  type TNewtonMesh = Pointer;
  type TNewtonBody = Pointer;
  type TNewtonWorld = Pointer;
  type TNewtonJoint = Pointer;
  type TNewtonMaterial = Pointer;
  type TNewtonCollision = Pointer;
  type TNewtonSceneProxy = Pointer;
  type TNewtonbreakableComponentMesh = Pointer;


  const SERIALIZE_ID_BOX = 0;
  const SERIALIZE_ID_CONE = 1;
  const SERIALIZE_ID_SPHERE = 2;
  const SERIALIZE_ID_CAPSULE = 3;
  const SERIALIZE_ID_CYLINDER = 4;
  const SERIALIZE_ID_COMPOUND = 5;
  const SERIALIZE_ID_CONVEXHULL = 6;
  const SERIALIZE_ID_CONVEXMODIFIER = 7;
  const SERIALIZE_ID_CHAMFERCYLINDER = 8;
  const SERIALIZE_ID_TREE = 9;
  const SERIALIZE_ID_NULL = 10;
  const SERIALIZE_ID_HEIGHTFIELD = 11;
  const SERIALIZE_ID_USERMESH = 12;
  const SERIALIZE_ID_SCENE = 13;
  const SERIALIZE_ID_COMPOUND_BREAKABLE = 14;

  type TNewtonMatrix = array[0..3]of array[0..3] of dFloat;

  type TNewtonCollisionInfoRecord = record
  public
    var OffsetMatrix: TNewtonMatrix;
    var CollisionType: Integer;				// tag id to identify the collision primitive
    var ReferenceCount: Integer;				// the current reference count for this collision
    var CollisionUserID: Integer;

    type TNewtonBoxParam = record
    public
      var x: dFloat;
      var y: dFloat;
      var z: dFloat;
    end;

    type TNewtonSphereParam = record
    public
      var r0: dFloat;
      var r1: dFloat;
      var r2: dFloat;
    end;

    type TNewtonCylinderParam = record
    public
      var r0: dFloat;
      var r1: dFloat;
      var Height: dFloat;
    end;

    type TNewtonCapsuleParam = record
    public
      var r0: dFloat;
      var r1: dFloat;
      var Height: dFloat;
    end;

    type TNewtonConeParam = record
    public
      var r: dFloat;
      var Height: dFloat;
    end;

    type TNewtonChamferCylinderParam = record
    public
      var r: dFloat;
      var Height: dFloat;
    end;

    type TNewtonConvexHullParam = record
    public
      var VertexCount: Integer;
      var VertexStrideInBytes: Integer;
      var FaceCount: Integer;
      var Vertex: PdFloat;
    end;

    type TNewtonConvexHullModifierParam = record
    public
      var Chidren: TNewtonCollision;
    end;

    type TNewtonCompoundCollisionParam = record
    public
      var ChidrenCount: Integer;
      var Chidren: Pointer;
    end;

    type TNewtonCollisionTreeParam = record
    public
      var VertexCount: Integer;
      var IndexCount: Integer;
    end;

    type TNewtonHeightFieldCollisionParam = record
    public
      var Width: Integer;
      var Height: Integer;
      var GridsDiagonals: Integer;
      var HorizonalScale: dFloat;
      var VerticalScale: dFloat;
      var Elevation: PByte;
      var Atributes: PByte;
    end;

    type TNewtonSceneCollisionParam = record
    public
      var ChildrenProxyCount: Integer;
    end;

    case Integer of
    SERIALIZE_ID_BOX: (Box: TNewtonBoxParam);
    SERIALIZE_ID_CONE: (Cone: TNewtonConeParam);
    SERIALIZE_ID_SPHERE: (Sphere: TNewtonSphereParam);
    SERIALIZE_ID_CAPSULE: (Capsule: TNewtonCapsuleParam);
    SERIALIZE_ID_CYLINDER: (Cylinder: TNewtonCylinderParam);
    SERIALIZE_ID_COMPOUND: (CompoundCollision: TNewtonCompoundCollisionParam);
    SERIALIZE_ID_CONVEXHULL: (ConvexHull: TNewtonConvexHullParam);
    SERIALIZE_ID_CONVEXMODIFIER: (ConvexHullModifier: TNewtonConvexHullModifierParam);
    SERIALIZE_ID_CHAMFERCYLINDER: (ChamferCylinder: TNewtonChamferCylinderParam);
    SERIALIZE_ID_TREE: (CollisionTree: TNewtonCollisionTreeParam);
    SERIALIZE_ID_NULL: ();
    SERIALIZE_ID_HEIGHTFIELD: (HeightField: TNewtonHeightFieldCollisionParam);
    SERIALIZE_ID_USERMESH: (ParamArray: array[0..63] of dFloat);
    SERIALIZE_ID_SCENE: (SceneCollision: TNewtonSceneCollisionParam);
    SERIALIZE_ID_COMPOUND_BREAKABLE: ();
  end;

  type TNewtonJointRecord = record
  public
    var AttachmenMatrix_0: TNewtonMatrix;
    var AttachmenMatrix_1: TNewtonMatrix;
    var MinLinearDof: array[0..2] of dFloat;
    var MaxLinearDof: array[0..2] of dFloat;
    var MinAngularDof: array[0..2] of dFloat;
    var MaxAngularDof: array[0..2] of dFloat;
    var AttachBody_0: ^TNewtonBody;
    var AttachBody_1: ^TNewtonBody;
    var ExtraParameters: array[0..15] of dFloat;
    var BodiesCollisionOn: Integer;
    var DescriptionType: array[0..31] of AnsiChar;
  end;

  type TNewtonUserMeshCollisionCollideDesc = record
  public
    var BoxP0: array[0..3] of dFloat;						// lower bounding box of intersection query in local space
    var BoxP1: array[0..3] of dFloat;						// upper bounding box of intersection query in local space
    var ThreadNumber: Integer;						// current thread executing this query
    var FaceCount: Integer;                        // the application should set here how many polygons intersect the query box
    var VertexStrideInBytes: Integer;              // the application should set here the size of each vertex
    var UserData: Pointer;                       // user data passed to the collision geometry at creation time
    var Vertex: PdFloat;                       // the application should the pointer to the vertex array.
    var UserAttribute: PInteger;                   // the application should set here the pointer to the user data, one for each face
    var FaceIndexCount: PInteger;                  // the application should set here the pointer to the vertex count of each face.
    var FaceVertexIndex: PInteger;                 // the application should set here the pointer index array for each vertex on a face.
    var ObjBody: ^TNewtonBody;                  // pointer to the colliding body
    var PolySoupBody: ^TNewtonBody;             // pointer to the rigid body owner of this collision tree
  end;

  type TNewtonWorldConvexCastReturnInfo = record
  public
    var Point: array[0..3] of dFloat;						// collision point in global space
    var Normal: array[0..3] of dFloat;						// surface normal at collision point in global space
    var NormalOnHitPoint: array[0..3] of dFloat;           // surface normal at the surface of the hit body,
                          // is the same as the normal calculated by a ray cast hitting the body at the hit point
    var Penetration: dFloat;                   // contact penetration at collision point
    var ContactID: Integer;	                    // collision ID at contact point
    var HitBody: ^TNewtonBody;			// body hit at contact point
  end;

  type TNewtonUserMeshCollisionRayHitDesc = record
  public
    var p0: array[0..3] of dFloat;							// ray origin in collision local space
    var p1: array[0..3] of dFloat;                         // ray destination in collision local space
    var NormalOut: array[0..3] of dFloat;					// copy here the normal at the ray intersection
    var UserIdOut: Integer;                        // copy here a user defined id for further feedback
    var UserData: Pointer;                       // user data passed to the collision geometry at creation time
  end;

  type TNewtonHingeSliderUpdateDesc = record
  public
    var Accel: dFloat;
    var MinFriction: dFloat;
    var MaxFriction: dFloat;
    var Timestep: dFloat;
  end;

    // Newton callback functions

  //typedef void* (*NewtonAllocMemory) (int sizeInBytes);
  type TNewtonAllocMemory = function(sizeInBytes: Integer): Pointer; cdecl;

  //typedef void (*NewtonFreeMemory) (void *ptr, int sizeInBytes);
  type TNewtonFreeMemory = procedure(Ptr: Pointer; sizeInBytes: Integer); cdecl;

  //typedef void (*NewtonDestroyWorld) (const NewtonWorld* newtonWorld);
  type TNewtonDestroyWorld = procedure(const NewtonWorld: TNewtonWorld); cdecl;


  //typedef unsigned (*NewtonGetTicksCountCallback) ();
  type TNewtonGetTicksCountCallback = function(): Cardinal; cdecl;


  //typedef void (*NewtonSerialize) (void* serializeHandle, const void* buffer, int size);
  type TNewtonSerialize = procedure(serializeHandle: Pointer; const buffer: Pointer; size: Integer); cdecl;

  //typedef void (*NewtonDeserialize) (void* serializeHandle, void* buffer, int size);
  type TNewtonDeserialize = procedure(serializeHandle: Pointer; buffer: Pointer; size: Integer); cdecl;


    // user collision callbacks

  //typedef void (*NewtonUserMeshCollisionDestroyCallback) (void* userData);
  type TNewtonUserMeshCollisionDestroyCallback = procedure(userData: Pointer); cdecl;

  //typedef void (*NewtonUserMeshCollisionCollideCallback) (NewtonUserMeshCollisionCollideDesc* collideDescData);
  type TNewtonUserMeshCollisionCollideCallback = procedure(collideDescData: TNewtonUserMeshCollisionCollideDesc); cdecl;

  //typedef dFloat (*NewtonUserMeshCollisionRayHitCallback) (NewtonUserMeshCollisionRayHitDesc* lineDescData);
  type TNewtonUserMeshCollisionRayHitCallback = function(lineDescData: TNewtonUserMeshCollisionRayHitDesc): dFloat; cdecl;

  //typedef void (*NewtonUserMeshCollisionGetCollisionInfo) (void* userData, NewtonCollisionInfoRecord* infoRecord);
  type TNewtonUserMeshCollisionGetCollisionInfo = procedure(userData: Pointer; infoRecord: TNewtonCollisionInfoRecord); cdecl;

  //typedef int (*NewtonUserMeshCollisionGetFacesInAABB) (
  //void* userData, const dFloat* p0, const dFloat* p1,
  //const dFloat** vertexArray, int* vertexCount, int* vertexStrideInBytes,
  //const int* indexList, int maxIndexCount, const int* userDataList);
  type TNewtonUserMeshCollisionGetFacesInAABB = function(
    userData: Pointer; const p0, p1: PdFloat;
    const vertexArray: Pointer; vertexCount: PInteger; vertexStrideInBytes: PInteger;
    const indexList: PInteger; maxIndexCount: Integer; const userDataList: PInteger
  ): Integer; cdecl;


  //typedef dFloat (*NewtonCollisionTreeRayCastCallback) (dFloat interception, dFloat* normal, int faceId, void* usedData);
  type TNewtonCollisionTreeRayCastCallback = function(interception: dFloat; normal: PdFloat; faceId: Integer; userData: Pointer): dFloat; cdecl;


    // collision tree call back (obsoleted no recommended)
  //typedef void (*NewtonTreeCollisionCallback) (
  //const NewtonBody* bodyWithTreeCollision, const NewtonBody* body, int faceID,
  //int vertexCount, const dFloat* vertex, int vertexStrideInBytes);
  type TNewtonTreeCollisionCallback = procedure (
    const bodyWithTreeCollision: TNewtonBody; const body: TNewtonBody; faceID: Integer;
    vertexCount: Integer; const vertex: PdFloat; vertexStrideInBytes: Integer
  ); cdecl;


  //typedef void (*NewtonBodyDestructor) (const NewtonBody* body);
  type TNewtonBodyDestructor = procedure(const NewtonBody: TNewtonBody); cdecl;

  //typedef void (*NewtonApplyForceAndTorque) (const NewtonBody* body, dFloat timestep, int threadIndex);
  type TNewtonApplyForceAndTorque = procedure(const body: TNewtonBody; timestep: dFloat; threadIndex: Integer); cdecl;

  //typedef void (*NewtonSetTransform) (const NewtonBody* body, const dFloat* matrix, int threadIndex);
  type TNewtonSetTransform = procedure(const body: TNewtonBody; const matrix: PdFloat; threadIndex: Integer); cdecl;


  //typedef int (*NewtonIslandUpdate) (const NewtonWorld* world, const void* islandHandle, int bodyCount);
  type TNewtonIslandUpdate = function(const world: TNewtonWorld; const islandHandle: Pointer; bodyCount: Integer): Integer; cdecl;

  //typedef void (*NewtonBodyLeaveWorld) (const NewtonBody* body, int threadIndex);
  type TNewtonBodyLeaveWorld = procedure(const body: TNewtonBody; threadIndex: Integer); cdecl;

  //typedef void (*NewtonDestroyBodyByExeciveForce) (const NewtonBody* body, const NewtonJoint* contact);
  type TNewtonDestroyBodyByExeciveForce = procedure(const body: TNewtonBody; const contact: TNewtonJoint); cdecl;

  //typedef void (*NewtonCollisionDestructor) (const NewtonWorld* world, const NewtonCollision* collision);
  type TNewtonCollisionDestructor = procedure(const world: TNewtonWorld; const collision: TNewtonCollision); cdecl;


  //typedef int (*NewtonCollisionCompoundBreakableCallback) (NewtonMesh* const mesh, void* userData, dFloat* planeMatrixOut);
  type TNewtonCollisionCompoundBreakableCallback = function(const mesh: TNewtonMesh; userData: Pointer; planeMatrixOut: PdFloat): Integer; cdecl;


  //typedef int (*NewtonGetBuoyancyPlane) (const int collisionID, void *context, const dFloat* globalSpaceMatrix, dFloat* globalSpacePlane);
  type TNewtonGetBuoyancyPlane = function(const collisionID: Integer; context: Pointer; const globalSpaceMatrix: PdFloat; globalSpacePlane: PdFloat): Integer; cdecl;

  //typedef unsigned (*NewtonWorldRayPrefilterCallback)(const NewtonBody* body, const NewtonCollision* collision, void* userData);
  type TNewtonWorldRayPrefilterCallback = function(const body: TNewtonBody; const collision: TNewtonCollision; userData: Pointer): Cardinal; cdecl;

  //typedef dFloat (*NewtonWorldRayFilterCallback)(const NewtonBody* body, const dFloat* hitNormal, int collisionID, void* userData, dFloat intersectParam);
  type TNewtonWorldRayFilterCallback = function(const body: TNewtonBody; const hitNormal: PdFloat; collisionID: Integer; userData: Pointer; intersectParam: dFloat): dFloat; cdecl;


  //typedef int  (*NewtonOnAABBOverlap) (const NewtonMaterial* material, const NewtonBody* body0, const NewtonBody* body1, int threadIndex);
  type TNewtonOnAABBOverlap = function(const material: TNewtonMaterial; const body0, body1: TNewtonBody; threadIndex: Integer): Integer; cdecl;

  //typedef void (*NewtonContactsProcess) (const NewtonJoint* contact, dFloat timestep, int threadIndex);
  type TNewtonContactsProcess = procedure(const constact: TNewtonJoint; timestep: dFloat; threadIndex: Integer); cdecl;


  //typedef void (*NewtonBodyIterator) (const NewtonBody* body, void* userData);
  type TNewtonBodyIterator = procedure(const body: TNewtonBody; userData: Pointer); cdecl;

  //typedef void (*NewtonJointIterator) (const NewtonJoint* joint, void* userData);
  type TNewtonJointIterator = procedure(const joint: TNewtonJoint; userData: Pointer); cdecl;

  //typedef void (*NewtonCollisionIterator) (void* userData, int vertexCount, const dFloat* faceArray, int faceId);
  type TNewtonCollisionIterator = procedure(userData: Pointer; vertexCount: Integer; const faceArray: PdFloat; faceID: Integer); cdecl;


  //typedef void (*NewtonBallCallBack) (const NewtonJoint* ball, dFloat timestep);
  type TNewtonBallCallBack = procedure(const ball: TNewtonJoint; timestep: dFloat); cdecl;

  //typedef unsigned (*NewtonHingeCallBack) (const NewtonJoint* hinge, NewtonHingeSliderUpdateDesc* desc);
  type TNewtonHingeCallback = function(const hinge: TNewtonJoint; desc: TNewtonHingeSliderUpdateDesc): Cardinal; cdecl;

  //typedef unsigned (*NewtonSliderCallBack) (const NewtonJoint* slider, NewtonHingeSliderUpdateDesc* desc);
  type TNewtonSliderCallback = function(const slider: TNewtonJoint; desc: TNewtonHingeSliderUpdateDesc): Cardinal; cdecl;

  //typedef unsigned (*NewtonUniversalCallBack) (const NewtonJoint* universal, NewtonHingeSliderUpdateDesc* desc);
  type TNewtonUniversalCallback = function(const universal: TNewtonJoint; desc: TNewtonHingeSliderUpdateDesc): Cardinal; cdecl;

  //typedef unsigned (*NewtonCorkscrewCallBack) (const NewtonJoint* corkscrew, NewtonHingeSliderUpdateDesc* desc);
  type TNewtonCorkscrewCallback = function(const corkscrew: TNewtonJoint; desc: TNewtonHingeSliderUpdateDesc): Cardinal; cdecl;


  //typedef void (*NewtonUserBilateralCallBack) (const NewtonJoint* userJoint, dFloat timestep, int threadIndex);
  type TNewtonUserBilateralCallback = procedure(const userJoint: TNewtonJoint; timestep: dFloat; threadIndex: Integer); cdecl;

  //typedef void (*NewtonUserBilateralGetInfoCallBack) (const NewtonJoint* userJoint, NewtonJointRecord* info);
  type TNewtonUserBilateralGetInfoCallback = procedure(const userJoint: TNewtonJoint; info: TNewtonJointRecord); cdecl;


  //typedef void (*NewtonConstraintDestructor) (const NewtonJoint* me);
  type TNewtonConstraintDestructor = procedure(const me: TNewtonJoint); cdecl;

//	typedef void (*NewtonSetRagDollTransform) (const NewtonRagDollBone* bone);
//	typedef void (*NewtonBodyActivationState) (const NewtonBody* body, unsigned state);
//	typedef void (*NewtonVehicleTireUpdate) (const NewtonJoint* vehicle, dFloat timestep);

  // **********************************************************************************************
  //
  // world control functions
  //
  // **********************************************************************************************

	//NEWTON_API int NewtonGetMemoryUsed ();
  function NewtonGetMemoryUsed(): Integer; cdecl; external NEWTON_API name 'NewtonGetMemoryUsed';

	//NEWTON_API void NewtonSetMemorySystem (
  //NewtonAllocMemory malloc,
  //NewtonFreeMemory mfree);
  procedure NewtonSetMemorySystem(
    malloc: TNewtonAllocMemory;
    mfree: TNewtonFreeMemory
  ); cdecl; external NEWTON_API name 'NewtonSetMemorySystem';


	//NEWTON_API NewtonWorld* NewtonCreate ();
  function NewtonCreate(): TNewtonWorld; cdecl; external NEWTON_API name 'NewtonCreate';

	//NEWTON_API void NewtonDestroy (
  //const NewtonWorld* newtonWorld);
  procedure NewtonDestroy(
    const newtonWorld: TNewtonWorld
  ); cdecl; external NEWTON_API name 'NewtonDestroy';

	//NEWTON_API void NewtonDestroyAllBodies (
  //const NewtonWorld* newtonWorld);
  procedure NewtonDestroyAllBodies(
    const newtonWorld: TNewtonWorld
  ); cdecl; external NEWTON_API name 'NewtonDestroyAllBodies';


	//NEWTON_API void NewtonUpdate (
  //const NewtonWorld* newtonWorld,
  //dFloat timestep);
  procedure NewtonUpdate(
    const newtonWorld: TNewtonWorld;
    timestep: dFloat
  ); cdecl; external NEWTON_API name 'NewtonUpdate';

	//NEWTON_API void NewtonInvalidateCache (
  //const NewtonWorld* newtonWorld);
  procedure NewtonInvalidateCache(
    const newtonWorld: TNewtonWorld
  ); cdecl; external NEWTON_API name 'NewtonInvalidateCache';

	//NEWTON_API void NewtonCollisionUpdate (
  //const NewtonWorld* newtonWorld);
  procedure NewtonCollisionUpdate(
    const newtonWorld: TNewtonWorld
  ); cdecl; external NEWTON_API name 'NewtonCollisionUpdate';


	//NEWTON_API void NewtonSetSolverModel (
  //const NewtonWorld* newtonWorld,
  //int model);
  procedure NewtonSetSolverModel(
    const newtonWorld: TNewtonWorld;
    model: Integer
  ); cdecl; external NEWTON_API name 'NewtonSetSolverModel';

	//NEWTON_API void NewtonSetPlatformArchitecture (
  //const NewtonWorld* newtonWorld,
  //int mode);
  procedure NewtonSetPlatformArchitecture(
    const newtonWorld: TNewtonWorld;
    mode: Integer
  ); cdecl; external NEWTON_API name 'NewtonSetPlatformArchitecture';

	//NEWTON_API int NewtonGetPlatformArchitecture(
  //const NewtonWorld* newtonWorld,
  //char* description);
  function NewtonGetPlatformArchitecture(
    const newtonWorld: TNewtonWorld;
    description: PByte
  ): Integer; cdecl; external NEWTON_API name 'NewtonGetPlatformArchitecture';

	//NEWTON_API void NewtonSetMultiThreadSolverOnSingleIsland (
  //const NewtonWorld* newtonWorld,
  //int mode);
  procedure NewtonSetMultiThreadSolverOnSingleIsland(
    const newtonWorld: TNewtonWorld;
    mode: Integer
  ); cdecl; external NEWTON_API name 'NewtonSetMultiThreadSolverOnSingleIsland';

	//NEWTON_API int NewtonGetMultiThreadSolverOnSingleIsland (
  //const NewtonWorld* newtonWorld);
  function NewtonGetMultiThreadSolverOnSingleIsland(
    const newtonWorld: TNewtonWorld
  ): Integer; cdecl; external NEWTON_API name 'NewtonGetMultiThreadSolverOnSingleIsland';


	//NEWTON_API void NewtonSetPerformanceClock (
  //const NewtonWorld* newtonWorld,
  //NewtonGetTicksCountCallback callback);
  procedure NewtonSetPerformanceClock(
    const newtonWorld: TNewtonWorld;
    callback: TNewtonGetTicksCountCallback
  ); cdecl; external NEWTON_API name 'NewtonSetPerformanceClock';

	//NEWTON_API unsigned NewtonReadPerformanceTicks (
  //const NewtonWorld* newtonWorld,
  //unsigned performanceEntry);
  function NewtonReadPerformanceTicks(
    const newtonWorld: TNewtonWorld;
    performanceEntry: Cardinal
  ): Cardinal; cdecl; external NEWTON_API name 'NewtonReadPerformanceTicks';


	//NEWTON_API void NewtonWorldCriticalSectionLock (
  //const NewtonWorld* newtonWorld);
  procedure NewtonWorldCriticalSectionLock(
    const newtonWorld: TNewtonWorld
  ); cdecl; external NEWTON_API name 'NewtonWorldCriticalSectionLock';

	//NEWTON_API void NewtonWorldCriticalSectionUnlock (
  //const NewtonWorld* newtonWorld);
  procedure NewtonWorldCriticalSectionUnlock(
    const newtonWorld: TNewtonWorld
  ); cdecl; external NEWTON_API name 'NewtonWorldCriticalSectionUnlock';

	//NEWTON_API void NewtonSetThreadsCount (
  //const NewtonWorld* newtonWorld,
  //int threads);
  procedure NewtonSetThreadsCount(
    const newtonWorld: TNewtonWorld;
    threads: Integer
  ); cdecl; external NEWTON_API name 'NewtonSetThreadsCount';

	//NEWTON_API int NewtonGetThreadsCount(
  //const NewtonWorld* newtonWorld);
  function NewtonGetThreadsCount(
    const newtonWorld: TNewtonWorld
  ): Integer; cdecl; external NEWTON_API name 'NewtonGetThreadsCount';


	//NEWTON_API void NewtonSetFrictionModel (
  //const NewtonWorld* newtonWorld,
  //int model);
  procedure NewtonSetFrictionModel(
    const newtonWorld: TNewtonWorld;
    model: Integer
  ); cdecl; external NEWTON_API name 'NewtonSetFrictionModel';

	//NEWTON_API void NewtonSetMinimumFrameRate (
  //const NewtonWorld* newtonWorld,
  //dFloat frameRate);
  procedure NewtonSetMinimumFrameRate(
    const newtonWorld: TNewtonWorld;
    frameRate: dFloat
  ); cdecl; external NEWTON_API name 'NewtonSetMinimumFrameRate';

	//NEWTON_API void NewtonSetBodyLeaveWorldEvent (
  //const NewtonWorld* newtonWorld,
  //NewtonBodyLeaveWorld callback);
  procedure NewtonSetBodyLeaveWorldEvent(
    const newtonWorld: TNewtonWorld;
    callback: TNewtonBodyLeaveWorld
  ); cdecl; external NEWTON_API name 'NewtonSetBodyLeaveWorldEvent';

	//NEWTON_API void NewtonSetWorldSize (
  //const NewtonWorld* newtonWorld,
  //const dFloat* minPoint,
  //const dFloat* maxPoint);
  procedure NewtonSetWorldSize(
    const newtonWorld: TNewtonWorld;
    const minPoint,
    maxPoint: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonSetWorldSize';

	//NEWTON_API void NewtonSetIslandUpdateEvent (
  //const NewtonWorld* newtonWorld,
  //NewtonIslandUpdate islandUpdate);
  procedure NewtonSetIslandUpdateEvent(
    const newtonWorld: TNewtonWorld;
    islandUpdate: TNewtonIslandUpdate
  ); cdecl; external NEWTON_API name 'NewtonSetIslandUpdateEvent';

	//NEWTON_API void NewtonSetCollisionDestructor (
  //const NewtonWorld* newtonWorld,
  //NewtonCollisionDestructor callback);
  procedure NewtonSetCollisionDestructor(
    const newtonWorld: TNewtonWorld;
    callback: TNewtonCollisionDestructor
  ); cdecl; external NEWTON_API name 'NewtonSetCollisionDestructor';

	//NEWTON_API void NewtonSetDestroyBodyByExeciveForce (
  //const NewtonWorld* newtonWorld,
  //NewtonDestroyBodyByExeciveForce callback);
  procedure NewtonSetDestroyBodyByExeciveForce(
    const newtonWorld: TNewtonWorld;
    callback: TNewtonDestroyBodyByExeciveForce
  ); cdecl; external NEWTON_API name 'NewtonSetDestroyBodyByExeciveForce';


//	NEWTON_API void NewtonWorldForEachBodyDo (const NewtonWorld* newtonWorld, NewtonBodyIterator callback);
	//NEWTON_API void NewtonWorldForEachJointDo (
  //const NewtonWorld* newtonWorld,
  //NewtonJointIterator callback,
  //void* userData);
  procedure NewtonWorldForEachJointDo(
    const newtonWorld: TNewtonWorld;
    callback: TNewtonJointIterator;
    userData: Pointer
  ); cdecl; external NEWTON_API name 'NewtonWorldForEachJointDo';

	//NEWTON_API void NewtonWorldForEachBodyInAABBDo (
  //const NewtonWorld* newtonWorld,
  //const dFloat* p0,
  //const dFloat* p1,
  //NewtonBodyIterator callback,
  //void* userData);
  procedure NewtonWorldForEachBodyInAABBDo(
    const newtonWorld: TNewtonWorld;
    const p0, p1: PdFloat;
    const callback: TNewtonBodyIterator;
    userData: Pointer
  ); cdecl; external NEWTON_API name 'NewtonWorldForEachBodyInAABBDo';


	//NEWTON_API int NewtonWorldGetVersion (
  //const NewtonWorld* newtonWorld);
  function NewtonWorldGetVersion(
    const newtonWorld: TNewtonWorld
  ): Integer; cdecl; external NEWTON_API name 'NewtonWorldGetVersion';

	//NEWTON_API void NewtonWorldSetUserData (
  //const NewtonWorld* newtonWorld,
  //void* userData);
  procedure NewtonWorldSetUserData(
    const newtonWorld: Pointer;
    userData: Pointer
  ); cdecl; external NEWTON_API name 'NewtonWorldSetUserData';

	//NEWTON_API void* NewtonWorldGetUserData (
  //const NewtonWorld* newtonWorld);
  function NewtonWorldGetUserData(
    const newtonWorld
  ): Pointer; cdecl; external NEWTON_API name 'NewtonWorldGetUserData';

	//NEWTON_API void NewtonWorldSetDestructorCallBack (
  //const NewtonWorld* newtonWorld,
  //NewtonDestroyWorld destructor);
  procedure NewtonWorldSetDestructorCallback(
    const newtonWorld: TNewtonWorld;
    callback: TNewtonDestroyWorld
  ); cdecl; external NEWTON_API name 'NewtonWorldSetDestructorCallBack';

	//NEWTON_API NewtonDestroyWorld NewtonWorldGetDestructorCallBack (
  //const NewtonWorld* newtonWorld);
  function NewtonWorldGetDestructorCallback(
    const newtonWorld
  ): TNewtonDestroyWorld; cdecl; external NEWTON_API name 'NewtonWorldGetDestructorCallBack';


	//NEWTON_API void NewtonWorldRayCast (
  //const NewtonWorld* newtonWorld,
  //const dFloat* p0,
  //const dFloat* p1,
  //NewtonWorldRayFilterCallback filter,
  //void* userData,
  //NewtonWorldRayPrefilterCallback prefilter);
  procedure NewtonWorldRayCast(
    const newtonWorld: TNewtonWorld;
    const p0, p1: PdFloat;
    filter: TNewtonWorldRayFilterCallback;
    userData: Pointer;
    prefilter: TNewtonWorldRayPrefilterCallback
  ); cdecl; external NEWTON_API name 'NewtonWorldRayCast';

	//NEWTON_API int NewtonWorldConvexCast (
  //const NewtonWorld* newtonWorld,
  //const dFloat* matrix,
  //const dFloat* target,
  //const NewtonCollision* shape,
  //dFloat* hitParam,
  //void* userData,
  //NewtonWorldRayPrefilterCallback prefilter,
  //NewtonWorldConvexCastReturnInfo* info,
  //int maxContactsCount,
  //int threadIndex);
  function NewtonWorldConvexCast(
    const newtonWorld: TNewtonWorld;
    const matrix: PdFloat;
    const target: PdFloat;
    const shape: TNewtonCollision;
    hitPatam: PdFloat;
    userData: Pointer;
    prefilter: TNewtonWorldRayPrefilterCallback;
    info: TNewtonWorldConvexCastReturnInfo;
    maxContactsCount: Integer;
    threadIndex: Integer
  ): Integer; cdecl; external NEWTON_API name 'NewtonWorldConvexCast';


	// world utility functions
	//NEWTON_API int NewtonWorldGetBodyCount(
  //const NewtonWorld* newtonWorld);
  function NewtonWorldGetBodyCount(
    const newtonWorld: TNewtonWorld
  ): Integer; cdecl; external NEWTON_API name 'NewtonWorldGetBodyCount';

	//NEWTON_API int NewtonWorldGetConstraintCount(
  //const NewtonWorld* newtonWorld);
  function NewtonWorldGetConstraintCount(
    const newtonWorld: TNewtonWorld
  ): Integer; cdecl; external NEWTON_API name 'NewtonWorldGetConstraintCount';


	// NEWTON_API int NewtonGetActiveBodiesCount();
	// NEWTON_API int NewtonGetActiveConstraintsCount();
	// NEWTON_API dFloat NewtonGetGlobalScale (const NewtonWorld* newtonWorld);


	// **********************************************************************************************
	//
	// Simulation islands
	//
	// **********************************************************************************************

	//NEWTON_API NewtonBody* NewtonIslandGetBody (
  //const void* island,
  //int bodyIndex);
  function NewtonIslandGetBody(
    const island: Pointer;
    bodyIndex: Integer
  ): TNEwtonBody; cdecl; external NEWTON_API name 'NewtonIslandGetBody';

	//NEWTON_API void NewtonIslandGetBodyAABB (
  //const void* island,
  //int bodyIndex,
  //const dFloat* p0,
  //const dFloat* p1);
  procedure NewtonIslandGetBodyAABB(
    const island: Pointer;
    bodyIndex: Integer;
    const p0, p1: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonIslandGetBodyAABB';


	// **********************************************************************************************
	//
	// Physics Material Section
	//
	// **********************************************************************************************

	//NEWTON_API int NewtonMaterialCreateGroupID(
  //const NewtonWorld* newtonWorld);
  function NewtonMaterialCreateGroupID(
    const newtonWorld: TNewtonWorld
  ): Integer; cdecl; external NEWTON_API name 'NewtonMaterialCreateGroupID';

	//NEWTON_API int NewtonMaterialGetDefaultGroupID(
  //const NewtonWorld* newtonWorld);
  function NewtonMaterialGetDefaultGroupID(
    const newtonWorld: TNewtonWorld
  ): Integer; cdecl; external NEWTON_API name 'NewtonMaterialGetDefaultGroupID';

	//NEWTON_API void NewtonMaterialDestroyAllGroupID(
  //const NewtonWorld* newtonWorld);
  procedure NewtonMaterialDestroyAllGroupID(
    const newtonWorld: TNewtonWorld
  ); cdecl; external NEWTON_API name 'NewtonMaterialDestroyAllGroupID';


	// material definitions that can not be overwritten in function callback
	//NEWTON_API void* NewtonMaterialGetUserData (
  //const NewtonWorld* newtonWorld,
  //int id0, int id1);
  function NewtonMaterialGetUserData(
    const newtonWorld: TNewtonWorld;
    id0, id1: Integer
  ): Pointer; cdecl; external NEWTON_API name 'NewtonMaterialGetUserData';

	//NEWTON_API void NewtonMaterialSetSurfaceThickness (
  //const NewtonWorld* newtonWorld,
  //int id0, int id1,
  //dFloat thickness);
  procedure NewtonMaterialSetSurfaceThickness(
    const newtonWorld: TNewtonWorld;
    id0, id1: Integer;
    thickness: dFloat
  ); cdecl; external NEWTON_API name 'NewtonMaterialSetSurfaceThickness';

	//NEWTON_API void NewtonMaterialSetContinuousCollisionMode (
  //const NewtonWorld* newtonWorld,
  //int id0, int id1,
  //int state);
  procedure NewtonMaterialSetContiniousCollisionMode(
    const newtonWorld: TNewtonWorld;
    id0, id1: Integer;
    state: Integer
  ); cdecl; external NEWTON_API name 'NewtonMaterialSetContinuousCollisionMode';

	//NEWTON_API void NewtonMaterialSetCollisionCallback (
  //const NewtonWorld* newtonWorld,
  //int id0, int id1,
  //void* userData,
	//NewtonOnAABBOverlap aabbOverlap,
  //NewtonContactsProcess process);
  procedure NewtonMaterialSetCollisionCallback(
    const newtonWorld: TNewtonWorld;
    id0, id1: Integer;
    userData: Pointer;
    aabbOverlap: TNewtonOnAABBOverlap;
    process: TNewtonContactsProcess
  ); cdecl; external NEWTON_API name 'NewtonMaterialSetCollisionCallback';


	//NEWTON_API void NewtonMaterialSetDefaultSoftness (
  //const NewtonWorld* newtonWorld,
  //int id0, int id1, dFloat value);
  procedure NewtonMaterialSetDefaultSoftness(
    const newtonWorld: TNewtonWorld;
    id0, id1: Integer;
    value: dFloat
  ); cdecl; external NEWTON_API name 'NewtonMaterialSetDefaultSoftness';

	//NEWTON_API void NewtonMaterialSetDefaultElasticity (
  //const NewtonWorld* newtonWorld,
  //int id0, int id1,
  //dFloat elasticCoef);
  procedure NewtonMaterialSetDefaultElasticity(
    const newtonWorld: TNewtonWorld;
    id0, id1: Integer;
    elasticCoef: dFloat
  ); cdecl; external NEWTON_API name 'NewtonMaterialSetDefaultElasticity';

	//NEWTON_API void NewtonMaterialSetDefaultCollidable (
  //const NewtonWorld* newtonWorld,
  //int id0, int id1,
  //int state);
  procedure NewtonMaterialSetDefaultCollidable(
    const newtonWorld: TNewtonWorld;
    id0, id1: Integer;
    state: Integer
  ); cdecl; external NEWTON_API name 'NewtonMaterialSetDefaultCollidable';

	//NEWTON_API void NewtonMaterialSetDefaultFriction (
  //const NewtonWorld* newtonWorld,
  //int id0, int id1,
	//dFloat staticFriction,
  //dFloat kineticFriction);
  procedure NewtonMaterialSetDefaultFriction(
    const newtonWorld: TNewtonWorld;
    id0, id1: Integer;
    staticFriction,
    kineticFriction: dFloat
  ); cdecl; external NEWTON_API name 'NewtonMaterialSetDefaultFriction';


	//NEWTON_API NewtonMaterial* NewtonWorldGetFirstMaterial (
  //const NewtonWorld* world);
  function NewtonWorldGetFirstMaterial(
    const world: TNewtonWorld
  ): TNewtonMaterial; cdecl; external NEWTON_API name 'NewtonWorldGetFirstMaterial';

	//NEWTON_API NewtonMaterial* NewtonWorldGetNextMaterial (
  //const NewtonWorld* world,
  //const NewtonMaterial* material);
  function NewtonWorldGetNextMaterial(
    const world: TNewtonWorld;
    const material: TNewtonMaterial
  ): TNewtonMaterial; cdecl; external NEWTON_API name 'NewtonWorldGetNextMaterial';


	//NEWTON_API NewtonBody* NewtonWorldGetFirstBody (
  //const NewtonWorld* world);
  function NewtonWorldGetFirstBody(
    const world: TNewtonWorld
  ): TNewtonBody; cdecl; external NEWTON_API name 'NewtonWorldGetFirstBody';

	//NEWTON_API NewtonBody* NewtonWorldGetNextBody (
  //const NewtonWorld* world,
  //const NewtonBody* curBody);
  function NewtonWorldGetNextBody(
    const world: TNewtonWorld;
    const curBody: TNewtonBody
  ): TNewtonBody; cdecl; external NEWTON_API name 'NewtonWorldGetNextBody';


	// **********************************************************************************************
	//
	// Physics Contact control functions
	//
	// **********************************************************************************************

	//NEWTON_API void *NewtonMaterialGetMaterialPairUserData (
  //const NewtonMaterial* material);
  function NewtonMaterialGetMaterialPairUserData(
    const material: TNewtonMaterial
  ): Pointer; cdecl; external NEWTON_API name 'NewtonMaterialGetMaterialPairUserData';

	//NEWTON_API unsigned NewtonMaterialGetContactFaceAttribute (
  //const NewtonMaterial* material);
  function NewtonMaterialGetContactFaceAttribute(
    const material: TNewtonMaterial
  ): Cardinal; cdecl; external NEWTON_API name 'NewtonMaterialGetContactFaceAttribute';

	//NEWTON_API unsigned NewtonMaterialGetBodyCollisionID (
  //const NewtonMaterial* material,
  //const NewtonBody* body);
  function NewtonMaterialGetBodyCollisionID(
    const material: TNewtonMaterial;
    const body: TNewtonBody
  ): Cardinal; cdecl; external NEWTON_API name 'NewtonMaterialGetBodyCollisionID';

	//NEWTON_API dFloat NewtonMaterialGetContactNormalSpeed (
  //const NewtonMaterial* material);
  function NewtonMaterialGetContactNormalSpeed(
    const material: TNewtonMaterial
  ): dFloat; cdecl; external NEWTON_API name 'NewtonMaterialGetContactNormalSpeed';

	//NEWTON_API void NewtonMaterialGetContactForce (
  //const NewtonMaterial* material,
  //dFloat* force);
  procedure NewtonMaterialGetContactForce(
    const material: TNewtonMaterial;
    force: dFloat
  ); cdecl; external NEWTON_API name 'NewtonMaterialGetContactForce';

	//NEWTON_API void NewtonMaterialGetContactPositionAndNormal (
  //const NewtonMaterial* material,
  //dFloat* posit,
  //dFloat* normal);
  procedure NewtonMaterialGetContactPositionAndNormal(
    const material: TNewtonMaterial;
    position: PdFloat;
    normal: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonMaterialGetContactPositionAndNormal';

	//NEWTON_API void NewtonMaterialGetContactTangentDirections (
  //const NewtonMaterial* material,
  //dFloat* dir0,
  //dFloat* dir1);
  procedure NewtonMaterialGetContactTangentDirecions(
    const material: TNewtonMaterial;
    dir0, dir1: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonMaterialGetContactTangentDirections';

	//NEWTON_API dFloat NewtonMaterialGetContactTangentSpeed (
  //const NewtonMaterial* material,
  //int index);
  function NewtonMaterialGetContactTangentSpeed(
    const material: TNewtonMaterial;
    index: Integer
  ): dFloat; cdecl; external NEWTON_API name 'NewtonMaterialGetContactTangentSpeed';


	//NEWTON_API void NewtonMaterialSetContactSoftness (
  //const NewtonMaterial* material,
  //dFloat softness);
  procedure NewtonMaterialSetContactSoftness(
    const material: TNewtonMaterial;
    softness: dFloat
  ); cdecl; external NEWTON_API name 'NewtonMaterialSetContactSoftness';

	//NEWTON_API void NewtonMaterialSetContactElasticity (
  //const NewtonMaterial* material,
  //dFloat restitution);
  procedure NewtonMaterialSetContactElasticity(
    const material: TNewtonMaterial;
    restitution: dFloat
  ); cdecl; external NEWTON_API name 'NewtonMaterialSetContactElasticity';

	//NEWTON_API void NewtonMaterialSetContactFrictionState (
  //const NewtonMaterial* material,
  //int state,
  //int index);
  procedure NewtonMaterialSetContactFrictionState(
    const material: TNewtonMaterial;
    state: Integer;
    index: Integer
  ); cdecl; external NEWTON_API name 'NewtonMaterialSetContactFrictionState';

	//NEWTON_API void NewtonMaterialSetContactFrictionCoef (
  //const NewtonMaterial* material,
  //dFloat staticFrictionCoef,
  //dFloat kineticFrictionCoef,
  //int index);
  procedure NewtonMaterialSetContactFrictionCoef(
    const material: TNewtonMaterial;
    staticFrictionCoef, kineticFrictionCoef: dFloat;
    index: Integer
  ); cdecl; external NEWTON_API name 'NewtonMaterialSetContactFrictionCoef';


	//NEWTON_API void NewtonMaterialSetContactNormalAcceleration (
  //const NewtonMaterial* material,
  //dFloat accel);
  procedure NewtonMaterialSetContactNormalAcceleration(
    const material: TNewtonMaterial;
    accel: dFloat
  ); cdecl; external NEWTON_API name 'NewtonMaterialSetContactNormalAcceleration';

	//NEWTON_API void NewtonMaterialSetContactNormalDirection (
  //const NewtonMaterial* material,
  //const dFloat* directionVector);
  procedure NewtonMaterialSetContactNormalDirection(
    const material: TNewtonMaterial;
    const directionVector: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonMaterialSetContactNormalDirection';


	//NEWTON_API void NewtonMaterialSetContactTangentAcceleration (
  //const NewtonMaterial* material,
  //dFloat accel,
  //int index);
  procedure NewtonMaterialSetContactTangentAcceleration(
    const material: TNewtonMaterial;
    accel: dFloat;
    index: Integer
  ); cdecl; external NEWTON_API name 'NewtonMaterialSetContactTangentAcceleration';

	//NEWTON_API void NewtonMaterialContactRotateTangentDirections (
  //const NewtonMaterial* material,
  //const dFloat* directionVector);
  procedure NewtonMaterialContactRotateTangentDirections(
    const material: TNewtonMaterial;
    const directionVector: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonMaterialContactRotateTangentDirections';


	// **********************************************************************************************
	//
	// convex collision primitives creation functions
	//
	// **********************************************************************************************

	//NEWTON_API NewtonCollision* NewtonCreateNull (
  //const NewtonWorld* newtonWorld);
  function NewtonCreateNull(
    const newtonWorld: TNewtonWorld
  ): TNewtonCollision; cdecl; external NEWTON_API name 'NewtonCreateNull';

	//NEWTON_API NewtonCollision* NewtonCreateSphere (
  //const NewtonWorld* newtonWorld,
  //dFloat radiusX,
  //dFloat radiusY,
  //dFloat radiusZ,
  //int shapeID,
  //const dFloat *offsetMatrix);
  function NewtonCreateSphere(
    const newtonWorld: TNewtonWorld;
    radiusX, radiusY, radiusZ: dFloat;
    shapeID: Integer;
    const offsetMatrix: PdFloat
  ): TNewtonCollision; cdecl; external NEWTON_API name 'NewtonCreateSphere';

	//NEWTON_API NewtonCollision* NewtonCreateBox (
  //const NewtonWorld* newtonWorld,
  //dFloat dx,
  //dFloat dy,
  //dFloat dz,
  //int shapeID,
  //const dFloat *offsetMatrix);
  function NewtonCreateBox(
    const newtonWorld: TNewtonWorld;
    dx, dy, dz: dFloat;
    shapeID: Integer;
    const offsetMatrix: PdFloat
  ): TNewtonCollision; cdecl; external NEWTON_API name 'NewtonCreateBox';

	//NEWTON_API NewtonCollision* NewtonCreateCone (
  //const NewtonWorld* newtonWorld,
  //dFloat radius,
  //dFloat height,
  //int shapeID,
  //const dFloat *offsetMatrix);
  function NewtonCreateCone(
    const newtonWorld: TNewtonWorld;
    radius, height:
    dFloat; shapeID: Integer;
    const offsetMatrix: PdFloat
  ): TNewtonCollision; cdecl; external NEWTON_API name 'NewtonCreateCone';

	//NEWTON_API NewtonCollision* NewtonCreateCapsule (
  //const NewtonWorld* newtonWorld,
  //dFloat radius,
  //dFloat height,
  //int shapeID,
  //const dFloat *offsetMatrix);
  function NewtonCreateCapsule(
    const newtonWorld: TNewtonWorld;
    radius, height: dFloat;
    shapeID: Integer;
    const offsetMatrix: PdFloat
  ): TNewtonCollision; cdecl; external NEWTON_API name 'NewtonCreateCapsule';

	//NEWTON_API NewtonCollision* NewtonCreateCylinder (
  //const NewtonWorld* newtonWorld,
  //dFloat radius,
  //dFloat height,
  //int shapeID,
  //const dFloat *offsetMatrix);
  function NewtonCreateCylinder(
    const newtonWorld: TNewtonWorld;
    radius, height: dFloat;
    shapeID: Integer;
    const offsetMatrix: PdFloat
  ): TNewtonCollision; cdecl; external NEWTON_API name 'NewtonCreateCylinder';

	//NEWTON_API NewtonCollision* NewtonCreateChamferCylinder (
  //const NewtonWorld* newtonWorld,
  //dFloat radius,
  //dFloat height,
  //int shapeID,
  //const dFloat *offsetMatrix);
  function NewtonCreateChamferCylinder(
    const newtonWorld: TNewtonWorld;
    radius, height: dFloat;
    shapeID: Integer;
    offsetMatrix: PdFloat
  ): TNewtonCollision; cdecl; external NEWTON_API name 'NewtonCreateChamferCylinder';

	//NEWTON_API NewtonCollision* NewtonCreateConvexHull (
  //const NewtonWorld* newtonWorld,
  //int count,
  //const dFloat* vertexCloud,
  //int strideInBytes,
  //dFloat tolerance,
  //int shapeID,
  //const dFloat *offsetMatrix);
  function NewtonCreateConvexHull(
    const newtonWorld: TNewtonWorld;
    count: Integer;
    const vertexCloud: PdFloat;
    strideInBytes: Integer;
    tolerance: dFloat;
    shapeID: Integer;
    const offsetMatrix: PdFloat
  ): TNewtonCollision; cdecl; external NEWTON_API name 'NewtonCreateConvexHull';

	//NEWTON_API NewtonCollision* NewtonCreateConvexHullFromMesh (
  //const NewtonWorld* newtonWorld,
  //const NewtonMesh* mesh,
  //dFloat tolerance,
  //int shapeID);
  function NewtonCreateConvexHullFromMesh(
    const newtonWorld: TNewtonWorld;
    const mesh: TNewtonMesh;
    tolerance: dFloat;
    shapeID: Integer
  ): TNewtonCollision; cdecl; external NEWTON_API name 'NewtonCreateConvexHullFromMesh';


	//NEWTON_API NewtonCollision* NewtonCreateConvexHullModifier (
  //const NewtonWorld* newtonWorld,
  //const NewtonCollision* convexHullCollision,
  //int shapeID);
  function NewtonCreateConvexHullModifier(
    const newtonWorld: TNewtonWorld;
    const convexHullCollision: TNewtonCollision;
    shapeID: Integer
  ): TNewtonCollision; cdecl; external NEWTON_API name 'NewtonCreateConvexHullModifier';

	//NEWTON_API void NewtonConvexHullModifierGetMatrix (
  //const NewtonCollision* convexHullCollision,
  //dFloat* matrix);
  procedure NewtonConvexHullModifierGetMatrix(
    const convexHullCollision: TNewtonCollision;
    matrix: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonConvexHullModifierGetMatrix';

	//NEWTON_API void NewtonConvexHullModifierSetMatrix (
  //const NewtonCollision* convexHullCollision,
  //const dFloat* matrix);
  procedure NewtonConvexHullModifierSetMatrix(
    const convexHullCollision: TNewtonCollision;
    const matrix: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonConvexHullModifierSetMatrix';


	//NEWTON_API int NewtonCollisionIsTriggerVolume(
  //const NewtonCollision* convexCollision);
  function NewtonCollisioIsTriggerVolume(
    const convexCollision: TNewtonCollision
  ): Integer; cdecl; external NEWTON_API name 'NewtonCollisionIsTriggerVolume';

	//NEWTON_API void NewtonCollisionSetAsTriggerVolume(
  //const NewtonCollision* convexCollision,
  //int trigger);
  procedure NewtonCollisionSetAsTriggerVolume(
    const convexCollision: TNewtonCollision;
    trigger: Integer
  ); cdecl; external NEWTON_API name 'NewtonCollisionSetAsTriggerVolume';


	//NEWTON_API void NewtonCollisionSetMaxBreakImpactImpulse(
  //const NewtonCollision* convexHullCollision,
  //dFloat maxImpactImpulse);
  procedure NewtonCollisionSetMaxBreakImpactImpulse(
    const convexHullCollision: TNewtonCollision;
    maxImpactImpulse: dFloat
  ); cdecl; external NEWTON_API name 'NewtonCollisionSetMaxBreakImpactImpulse';

	//NEWTON_API dFloat NewtonCollisionGetMaxBreakImpactImpulse(
  //const NewtonCollision* convexHullCollision);
  function NewtonCollisionGetMaxBreakImpactImpulse(
    const convexHullCollision: TNewtonCollision
  ): dFloat; cdecl; external NEWTON_API name 'NewtonCollisionGetMaxBreakImpactImpulse';


	//NEWTON_API void NewtonCollisionSetUserID (
  //const NewtonCollision* convexCollision,
  //unsigned id);
  procedure NewtonCollisionSetUserID(
    const convexCollision: TNewtonCollision;
    id: Cardinal
  ); cdecl; external NEWTON_API name 'NewtonCollisionSetUserID';

	//NEWTON_API unsigned NewtonCollisionGetUserID (
  //const NewtonCollision* convexCollision);
  function NewtonCollisionGetUserID(
    const convexCollision: TNewtonCollision
  ): Cardinal; cdecl; external NEWTON_API name 'NewtonCollisionGetUserID';


	//NEWTON_API int NewtonConvexHullGetFaceIndices (
  //const NewtonCollision* convexHullCollision,
  //int face,
  //int* faceIndices);
  function NewtonConvexHullGetFaceIndices(
    const convexHullCollision: TNewtonCollision;
    face: Integer;
    faceIndices: PInteger
  ): Integer; cdecl; external NEWTON_API name 'NewtonConvexHullGetFaceIndices';

	//NEWTON_API dFloat NewtonConvexCollisionCalculateVolume (
  //const NewtonCollision* convexCollision);
  function NEwtonConvexCollisionCalculateVolume(
    const convexCollision: TNewtonCollision
  ): dFloat; cdecl; external NEWTON_API name 'NewtonConvexCollisionCalculateVolume';

	//NEWTON_API void NewtonConvexCollisionCalculateInertialMatrix (
  //const NewtonCollision* convexCollision,
  //dFloat* inertia,
  //dFloat* origin);
  procedure NewtonConvexCollisionCalculateInertialMatrix(
    const convexCollision: TNewtonCollision;
    inertia: PdFloat;
    origin: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonConvexCollisionCalculateInertialMatrix';


	//NEWTON_API void NewtonCollisionMakeUnique (
  //const NewtonWorld* newtonWorld,
  //const NewtonCollision* collision);
  procedure NewtonCollisionMakeUnique(
    const newtonWorld: TNewtonWorld;
    const collision: TNewtonCollision
  ); cdecl; external NEWTON_API name 'NewtonCollisionMakeUnique';

	//NEWTON_API void NewtonReleaseCollision (
  //const NewtonWorld* newtonWorld,
  //const NewtonCollision* collision);
  procedure NewtonReleaseCollision(
    const newtonWorld: TNewtonWorld;
    const collision: TNewtonCollision
  ); cdecl; external NEWTON_API name 'NewtonReleaseCollision';

	//NEWTON_API int NewtonAddCollisionReference (
  //const NewtonCollision* collision);
  function NewtonAddCollisionReference(
    const collision: TNewtonCollision
  ): Integer; cdecl; external NEWTON_API name 'NewtonAddCollisionReference';


	// **********************************************************************************************
	//
	// mass/spring/damper collision shape
	//
	// **********************************************************************************************

//	NEWTON_API NewtonCollision* NewtonCreateSoftShape (const NewtonWorld* newtonWorld);
//	NEWTON_API void NewtonSoftBodySetMassCount (const NewtonCollision* convexCollision, int count);
//	NEWTON_API void NewtonSoftBodySetSpringCount (const NewtonCollision* convexCollision, int count);

//	NEWTON_API void NewtonSoftBodySetMass (const NewtonCollision* convexCollision, int index, dFloat mass, dFloat* position);
//	NEWTON_API int NewtonSoftBodySetSpring (const NewtonCollision* convexCollision, int index, int mass0, int mass1, dFloat stiffness, dFloat damper);
//	NEWTON_API int NewtonSoftBodyGetMassArray (const NewtonCollision* convexCollision, dFloat* masses, dFloat** positions);


	// **********************************************************************************************
	//
	// complex collision primitives creation functions
	//
	// **********************************************************************************************

	//NEWTON_API NewtonCollision* NewtonCreateCompoundCollision (
  //const NewtonWorld* newtonWorld,
  //int count,
  //NewtonCollision* const collisionPrimitiveArray[],
  //int shapeID);
  function NewtonCreateCompoundCollision(
    const newtonWorld: TNewtonWorld;
    count: Integer;
    const collisionPrimitiveArray: TNewtonCollision;
    shapeID: Integer
  ): TNewtonCollision; cdecl; external NEWTON_API name 'NewtonCreateCompoundCollision';

	//NEWTON_API NewtonCollision* NewtonCreateCompoundCollisionFromMesh (
  //const NewtonWorld* newtonWorld,
  //const NewtonMesh* mesh,
  //dFloat concavity,
  //int maxShapeCount,
  //int shapeID);
  function NewtonCreateCompoundCollisionFromMesh(
    const newtonWorld: TNewtonWorld;
    const mesh: TNewtonMesh;
    concavity: dFloat;
    maxShapeCount: Integer;
    shapeID: Integer
  ): TNewtonCollision; cdecl; external NEWTON_API name 'NewtonCreateCompoundCollisionFromMesh';


	// **********************************************************************************************
	//
	// complex breakable collision primitives interface
	//
	// **********************************************************************************************

//	NEWTON_API NewtonCollision* NewtonCreateCompoundBreakable (const NewtonWorld* newtonWorld, int meshCount,
//															   NewtonMesh* const solids[], NewtonMesh* const splitePlanes[],
//															   dFloat* const matrixPallete, int* const shapeIDArray, dFloat* const densities,
//															   int shapeID, int debriID, NewtonCollisionCompoundBreakableCallback callback, void* buildUsedData);

	//NEWTON_API NewtonCollision* NewtonCreateCompoundBreakable (
  //const NewtonWorld* newtonWorld,
  //int meshCount,
	//const NewtonMesh* const solids[],
  //const int* const shapeIDArray,
	//const dFloat* const densities,
  //const int* const internalFaceMaterial,
	//int shapeID,
  //int debriID,
  //dFloat debrieSeapasationGap);
  function NewtonCreateCompoundBreakable(
    const newtonWorld: TNewtonWorld;
    meshCount: Integer;
    const solids: TNewtonMesh;
    const splitePlanes: TNewtonMesh;
    const matrixPallete: PdFloat;
    const shapeIDArray: PInteger;
    const densities: PdFloat;
    shapeID: Integer; debriID: Integer;
    callback: TNewtonCollisionCompoundBreakableCallback;
    buildUsedData: Pointer
  ): TNewtonCollision; cdecl; external NEWTON_API name 'NewtonCreateCompoundBreakable';


	//NEWTON_API void NewtonCompoundBreakableResetAnchoredPieces (
  //const NewtonCollision* compoundBreakable);
  procedure NewtonCompoundBreakableResetAnchoredPieces(
    const compoundBreakable: TNewtonCollision
  ); cdecl; external NEWTON_API name 'NewtonCompoundBreakableResetAnchoredPieces';

	//NEWTON_API void NewtonCompoundBreakableSetAnchoredPieces (
  //const NewtonCollision* compoundBreakable,
  //int fixShapesCount,
  //dFloat* const matrixPallete,
  //NewtonCollision** fixedShapesArray);
  procedure NewtonCompoundBreakableSetAnchoredPieces(
    const compoundBreakable: TNewtonCollision;
    fixShapesCount: Integer;
    const matrixPallete: PdFloat;
    fixedShapesArray: Pointer
  ); cdecl; external NEWTON_API name 'NewtonCompoundBreakableSetAnchoredPieces';


	//NEWTON_API int NewtonCompoundBreakableGetVertexCount (
  //const NewtonCollision* compoundBreakable);
  function NewtonCompoundBreakableGetVertexCount(
    const compoundBreakable: TNewtonCollision
  ): Integer; cdecl; external NEWTON_API name 'NewtonCompoundBreakableGetVertexCount';

	//NEWTON_API void NewtonCompoundBreakableGetVertexStreams (
  //const NewtonCollision* compoundBreakable,
  //int vertexStrideInByte,
  //dFloat* vertex,
  //int normalStrideInByte,
  //dFloat* normal,
  //int uvStrideInByte,
  //dFloat* uv);
  procedure NewtonCompoundBreakableGetVertexStreams(
    const compoundBreakable: TNewtonCollision;
    vertexStrideInBytes: Integer;
    vertex: PdFloat;
    normalStrideInBytes: Integer;
    normal: PdFloat;
    uvStrideInBytes: Integer;
    uv: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonCompoundBreakableGetVertexStreams';


	//NEWTON_API NewtonbreakableComponentMesh* NewtonBreakableGetMainMesh (
  //const NewtonCollision* compoundBreakable);
  function NewtonBreakableGetMainMesh(
    const compoundBreakable: TNewtonCollision
  ): TNewtonBreakableComponentMesh; cdecl; external NEWTON_API name 'NewtonBreakableGetMainMesh';

	//NEWTON_API NewtonbreakableComponentMesh* NewtonBreakableGetFirstComponent (
  //const NewtonCollision* compoundBreakable);
  function NewtonBreakableGetFirstComponent(
    const compoundBreakable: TNewtonCollision
  ): TNewtonBreakableComponentMesh; cdecl; external NEWTON_API name 'NewtonBreakableGetFirstComponent';

	//NEWTON_API NewtonbreakableComponentMesh* NewtonBreakableGetNextComponent (
  //const NewtonbreakableComponentMesh* component);
  function NewtonBreakableGetNextComponent(
    const component: TNewtonBreakableComponentMesh
  ): TNewtonBreakableComponentMesh; cdecl; external NEWTON_API name 'NewtonBreakableGetNextComponent';


	//NEWTON_API void NewtonBreakableBeginDelete (
  //const NewtonCollision* compoundBreakable);
  procedure NewtonBreakableBeginDelete(
    const compoundBreakable: TNewtonCollision
  ); cdecl; external NEWTON_API name 'NewtonBreakableBeginDelete';

	//NEWTON_API NewtonBody* NewtonBreakableCreateDebrieBody (
  //const NewtonCollision* compoundBreakable,
  //const NewtonbreakableComponentMesh* component);
  function NewtonBreakableCreateDebrieBody(
    const compoundBreakable: TNewtonCollision;
    const component: TNewtonBreakableComponentMesh
  ): TNewtonBody; cdecl; external NEWTON_API name 'NewtonBreakableCreateDebrieBody';

	//NEWTON_API void NewtonBreakableDeleteComponent (
  //const NewtonCollision* compoundBreakable,
  //const NewtonbreakableComponentMesh* component);
  procedure NewtonBreakableDeleteComponent(
    const compoundBreakable: TNewtonCollision;
    const component: TNewtonBreakableComponentMesh
  ); cdecl; external NEWTON_API name 'NewtonBreakableDeleteComponent';

	//NEWTON_API void NewtonBreakableEndDelete (
  //const NewtonCollision* compoundBreakable);
  procedure NewtonBreakableEndDelete(
    const compoundBreakable: TNewtonCollision
  ); cdecl; external NEWTON_API name 'NewtonBreakableEndDelete';


	//NEWTON_API int NewtonBreakableGetComponentsInRadius (
  //const NewtonCollision* compoundBreakable,
  //const dFloat* position,
  //dFloat radius,
  //NewtonbreakableComponentMesh** segments,
  //int maxCount);
  function NewtonBreakableGetComponentsInRadius(
    const compoundBreakable: TNewtonCollision;
    const position: PdFloat;
    radius: dFloat;
    segments: Pointer;
    maxCount: Integer
  ): Integer; cdecl; external NEWTON_API name 'NewtonBreakableGetComponentsInRadius';


	//NEWTON_API void* NewtonBreakableGetFirstSegment (
  //const NewtonbreakableComponentMesh* breakableComponent);
  function NewtonBreakableGetFirstSegment(
    const breakableComponent: TNewtonBreakableComponentMesh
  ): Pointer; cdecl; external NEWTON_API name 'NewtonBreakableGetFirstSegment';

	//NEWTON_API void* NewtonBreakableGetNextSegment (
  //const void* segment);
  function NewtonBreakableGetNextSegment(
    const segment: Pointer
  ): Pointer; cdecl; external NEWTON_API name 'NewtonBreakableGetNextSegment';


	//NEWTON_API int NewtonBreakableSegmentGetMaterial (
  //const void* segment);
  function NewtonBreakableSegmentGetMaterial(
    const segment: Pointer
  ): Integer; cdecl; external NEWTON_API name 'NewtonBreakableSegmentGetMaterial';

	//NEWTON_API int NewtonBreakableSegmentGetIndexCount (
  //const void* segment);
  function NewtonBreakableSegmentGetIndexCount(
    const segment: Pointer
  ): Integer; cdecl; external NEWTON_API name 'NewtonBreakableSegmentGetIndexCount';

	//NEWTON_API int NewtonBreakableSegmentGetIndexStream (
  //const NewtonCollision* compoundBreakable,
  //const NewtonbreakableComponentMesh* meshOwner,
  //const void* segment,
  //int* index);
  function NewtonBreakableSegmentGetIndexStream(
    const compoundBreakable: TNewtonCollision;
    const meshOwner: TNewtonBreakableComponentMesh;
    const segment: Pointer;
    index: PInteger
  ): Integer; cdecl; external NEWTON_API name 'NewtonBreakableSegmentGetIndexStream';

	//NEWTON_API int NewtonBreakableSegmentGetIndexStreamShort (
  //const NewtonCollision* compoundBreakable,
  //const NewtonbreakableComponentMesh* meshOwner,
  //const void* segment,
  //short int* index);
  function NewtonBreakableSegmentGetIndexStreamShort(
    const componentBreakable: TNewtonCollision;
    const meshOwner: TNewtonBreakableComponentMesh;
    const segment: Pointer;
    index: PSmallInt
  ): Integer; cdecl; external NEWTON_API name 'NewtonBreakableSegmentGetIndexStreamShort';


	//NEWTON_API NewtonCollision* NewtonCreateUserMeshCollision (
  //const NewtonWorld* newtonWorld,
  //const dFloat *minBox,
  //const dFloat *maxBox,
  //void *userData,
  //NewtonUserMeshCollisionCollideCallback collideCallback,
  //NewtonUserMeshCollisionRayHitCallback rayHitCallback,
  //NewtonUserMeshCollisionDestroyCallback destroyCallback,
  //NewtonUserMeshCollisionGetCollisionInfo getInfoCallback,
  //NewtonUserMeshCollisionGetFacesInAABB facesInAABBCallback,
  //int shapeID);
  function NewtonCreateUserMeshCollision(
    const newtonWorld: TNewtonWorld;
    const minBox, maxBox: PdFloat;
    userData: Pointer;
    collideCallback: TNewtonUserMeshCollisionCollideCallback;
    rayHitCallback: TNewtonUserMeshCollisionRayHitCallback;
    destroyCallback: TNewtonUserMeshCollisionDestroyCallback;
    getInfoCallback: TNewtonUserMeshCollisionGetCollisionInfo;
    facesInAABBCallback: TNewtonUserMeshCollisionGetFacesInAABB;
    shapeID: Integer
  ): TNewtonCollision; cdecl; external NEWTON_API name 'NewtonCreateUserMeshCollision';


	//NEWTON_API NewtonCollision* NewtonCreateSceneCollision (
  //const NewtonWorld* newtonWorld, int shapeID);
  function NewtonCreateSceneCollision(
    const newtonWorld: TNewtonWorld;
    shapeID: Integer
  ): TNewtonCollision; cdecl; external NEWTON_API name 'NewtonCreateSceneCollision';

	//NEWTON_API NewtonSceneProxy* NewtonSceneCollisionCreateProxy (
  //NewtonCollision* scene,
  //NewtonCollision* collision);
  function NewtonSceneCollisionCreateProxy(
    scene: TNewtonCollision;
    collision: TNewtonCollision
  ): TNewtonSceneProxy; cdecl; external NEWTON_API name 'NewtonSceneCollisionCreateProxy';

	//NEWTON_API void NewtonSceneCollisionDestroyProxy (
  //NewtonCollision* scene,
  //NewtonSceneProxy* Proxy);
  procedure NewtonSceneCollisionDestroyProxy(
    scene: TNewtonCollision;
    proxy: TNewtonSceneProxy
  ); cdecl; external NEWTON_API name 'NewtonSceneCollisionDestroyProxy';

	//NEWTON_API void NewtonSceneProxySetMatrix (
  //NewtonSceneProxy* proxy,
  //const dFloat* matrix);
  procedure NewtonSceneProxySetMatrix(
    proxy: TNewtonSceneProxy;
    const matrix: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonSceneProxySetMatrix';

	//NEWTON_API void NewtonSceneProxyGetMatrix (
  //NewtonSceneProxy* proxy,
  //dFloat* matrix);
  procedure NewtonSceneProxyGetMatrix(
    proxy: TNewtonSceneProxy;
    matrix: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonSceneProxyGetMatrix';


	//NEWTON_API void NewtonSceneCollisionOptimize (
  //NewtonCollision* scene);
  procedure NewtonSceneCollisionOptimize(
    scene: TNewtonCollision
  ); cdecl; external NEWTON_API name 'NewtonSceneCollisionOptimize';


	//  ***********************************************************************************************************
	//
	//	Collision serialization functions
	//
	// ***********************************************************************************************************

	//NEWTON_API NewtonCollision* NewtonCreateCollisionFromSerialization (
  //const NewtonWorld* newtonWorld,
  //NewtonDeserialize deserializeFunction,
  //void* serializeHandle);
  function NewtonCreateCollisionFromSerialization(
    const newtonWorld: TNewtonWorld;
    deserializeFunction: TNewtonDeserialize;
    serializeHandle: Pointer
  ): TNewtonCollision; cdecl; external NEWTON_API name 'NewtonCreateCollisionFromSerialization';

	//NEWTON_API void NewtonCollisionSerialize (
  //const NewtonWorld* newtonWorld,
  //const NewtonCollision* collision,
  //NewtonSerialize serializeFunction,
  //void* serializeHandle);
  procedure NewtonCollisionSerialize(
    const newtonWorld: TNewtonWorld;
    const collision: TNewtonCollision;
    serializeFunction: TNewtonSerialize;
    serializeHandle: Pointer
  ); cdecl; external NEWTON_API name 'NewtonCollisionSerialize';

	//NEWTON_API void NewtonCollisionGetInfo (
  //const NewtonCollision* collision,
  //NewtonCollisionInfoRecord* collisionInfo);
  procedure NewtonCollisionGetInfo(
    const collision: TNewtonCollision;
    collisionInfo: TNewtonCollisionInfoRecord
  ); cdecl; external NEWTON_API name 'NewtonCollisionGetInfo';


	// **********************************************************************************************
	//
	// Static collision shapes functions
	//
	// **********************************************************************************************

	//NEWTON_API NewtonCollision* NewtonCreateHeightFieldCollision (
  //const NewtonWorld* newtonWorld,
  //int width,
  //int height,
  //int gridsDiagonals,
	//unsigned short* elevationMap,
  //char* attributeMap,
	//dFloat horizontalScale,
  //dFloat verticalScale,
  //int shapeID);
  function NewtonCreateHeightFieldCollision(
    const newtonWorld: TNewtonWorld;
    width, height, gridsDiagonals: Integer;
    elevationMap: PWord;
    attributeMap: PByte;
    horizontalScale, verticalScale: dFloat;
    shapeID: Integer
  ): TNewtonCollision; cdecl; external NEWTON_API name 'NewtonCreateHeightFieldCollision';


	//NEWTON_API NewtonCollision* NewtonCreateTreeCollision (
  //const NewtonWorld* newtonWorld,
  //int shapeID);
  function NewtonCreateTreeCollision(
    const newtonWorld: TNewtonWorld;
    shapeID: Integer
  ): TNewtonCollision; cdecl; external NEWTON_API name 'NewtonCreateTreeCollision';

	//NEWTON_API void NewtonTreeCollisionSetUserRayCastCallback (
  //const NewtonCollision* treeCollision,
  //NewtonCollisionTreeRayCastCallback rayHitCallback);
  procedure NewtonTreeCollisionSetUserRayCastCallback(
    const treeCollision: TNewtonCollision;
    rayHitCallback: TNewtonCollisionTreeRayCastCallback
  ); cdecl; external NEWTON_API name 'NewtonTreeCollisionSetUserRayCastCallback';


	//NEWTON_API void NewtonTreeCollisionBeginBuild (
  //const NewtonCollision* treeCollision);
  procedure NewtonTreeCollisionBeginBuild(
    const treeCollision: TNewtonCollision
  ); cdecl; external NEWTON_API name 'NewtonTreeCollisionBeginBuild';

	//NEWTON_API void NewtonTreeCollisionAddFace (
  //const NewtonCollision* treeCollision,
  //int vertexCount,
  //const dFloat* vertexPtr,
  //int strideInBytes,
  //int faceAttribute);
  procedure NewtonTreeCollisionAddFace(
    const treeCollision: TNewtonCollision;
    vertexCount: Integer;
    const vertexPtr: PdFloat;
    strideInBytes: Integer;
    faceAttribute: Integer
  ); cdecl; external NEWTON_API name 'NewtonTreeCollisionAddFace';

	//NEWTON_API void NewtonTreeCollisionEndBuild (
  //const NewtonCollision* treeCollision,
  //int optimize);
  procedure NewtonTreeCollisionEndBuild(
    const treeCollision: TNewtonCollision;
    optimize: Integer
  ); cdecl; external NEWTON_API name 'NewtonTreeCollisionEndBuild';


	//NEWTON_API int NewtonTreeCollisionGetFaceAtribute (
  //const NewtonCollision* treeCollision,
  //const int* faceIndexArray);
  function NewtonTreeCollisionGetFaceAtribute(
    const treeCollision: TNewtonCollision;
    const faceIndexArray: PInteger
  ): Integer; cdecl; external NEWTON_API name 'NewtonTreeCollisionGetFaceAtribute';

	//NEWTON_API void NewtonTreeCollisionSetFaceAtribute (
  //const NewtonCollision* treeCollision,
  //const int* faceIndexArray,
  //int attribute);
  procedure NewtonTreeCollisionSetFaceAtribute(
    const treeCollision: TNewtonCollision;
    faceIndexArray: PInteger;
    attribute: Integer
  ); cdecl; external NEWTON_API name 'NewtonTreeCollisionSetFaceAtribute';

	//NEWTON_API int NewtonTreeCollisionGetVertexListIndexListInAABB (
  //const NewtonCollision* treeCollision,
  //const dFloat* p0,
  //const dFloat* p1,
  //const dFloat** vertexArray,
  //int* vertexCount,
  //int* vertexStrideInBytes,
  //const int* indexList,
  //int maxIndexCount,
  //const int* faceAttribute);
  function NewtonTreeCollisionGetVertexListIndexListInAABB(
    const treeCollision: TNewtonCollision;
    const p0, p1: PdFloat;
    const vertexArray: Pointer;
    vertexCount: PInteger;
    vertexStrideInBytes: PInteger;
    const indexList: PInteger;
    maxIndexCount: Integer;
    const faceAttribute: PInteger
  ): Integer; cdecl; external NEWTON_API name 'NewtonTreeCollisionGetVertexListIndexListInAABB';


	//NEWTON_API void NewtonStaticCollisionSetDebugCallback (
  //const NewtonCollision* staticCollision,
  //NewtonTreeCollisionCallback userCallback);
  procedure NewtonStaticCollisionSetDebugCallback(
    const staticCollision: TNewtonCollision;
    userCallback: TNewtonTreeCollisionCallback
  ); cdecl; external NEWTON_API name 'NewtonStaticCollisionSetDebugCallback';


	// **********************************************************************************************
	//
	// General purpose collision library functions
	//
	// **********************************************************************************************

	//NEWTON_API int NewtonCollisionPointDistance (
  //const NewtonWorld* newtonWorld,
  //const dFloat *point,
  //const NewtonCollision* collision,
  //const dFloat* matrix,
  //dFloat* contact,
  //dFloat* normal,
  //int threadIndex);
  function NewtonCollisionPointDistance(
    const newtonWorld: TNewtonWorld;
    const point: PdFloat;
    const collision: TNewtonCollision;
    const matrix: PdFloat;
    contact: PdFloat;
    normal: PdFloat;
    threadIndex: Integer
  ): Integer; cdecl; external NEWTON_API name 'NewtonCollisionPointDistance';


	//NEWTON_API int NewtonCollisionClosestPoint (
  //const NewtonWorld* newtonWorld,
  //const NewtonCollision* collisionA,
  //const dFloat* matrixA,
  //const NewtonCollision* collisionB,
  //const dFloat* matrixB,
  //dFloat* contactA,
  //dFloat* contactB,
  //dFloat* normalAB,
  //int threadIndex);
  function NewtonCollisionClosestPoint (
    const newtonWorld: TNewtonWorld;
    const collisionA: TNewtonCollision;
    const matrixA: PdFloat;
    const collisionB: TNewtonCollision;
    const matrixB: PdFloat;
    contactA: PdFloat;
    contactB: PdFloat;
    normalAB: PdFloat;
    threadIndex: Integer
  ): Integer; cdecl; external NEWTON_API name 'NewtonCollisionClosestPoint';


	//NEWTON_API int NewtonCollisionCollide (
  //const NewtonWorld* newtonWorld,
  //int maxSize,
  //const NewtonCollision* collisionA,
  //const dFloat* matrixA,
  //const NewtonCollision* collisionB,
  //const dFloat* matrixB,
  //dFloat* contacts,
  //dFloat* normals,
  //dFloat* penetration,
  //int threadIndex);
  function NewtonCollisionCollide(
    const newtonWorld: TNewtonWorld;
    maxSize: Integer;
    const collisionA: TNewtonCollision;
    const matrixA: PdFloat;
    const collisionB: TNewtonCollision;
    const matrixB: PdFloat;
    contacts: PdFloat;
    normals: PdFloat;
    penetration: PdFloat;
    threadIndex: Integer
  ): Integer; cdecl; external NEWTON_API name 'NewtonCollisionCollide';


	//NEWTON_API int NewtonCollisionCollideContinue (
  //const NewtonWorld* newtonWorld,
  //int maxSize,
  //const dFloat timestep,
  //const NewtonCollision* collisionA,
  //const dFloat* matrixA,
  //const dFloat* velocA,
  //const dFloat* omegaA,
  //const NewtonCollision* collisionB,
  //const dFloat* matrixB,
  //const dFloat* velocB,
  //const dFloat* omegaB,
  //dFloat* timeOfImpact,
  //dFloat* contacts,
  //dFloat* normals,
  //dFloat* penetration,
  //int threadIndex);
  function NewtonCollisionCollideContinue(
    const newtonWorld: TNewtonWorld;
    maxSize: Integer;
    const timestep: dFloat;
    const collisionA: TNewtonCollision;
    const matrixA: PdFloat;
    const velocityA: PdFloat;
    const omegaA: PdFloat;
    const collisionB: TNewtonCollision;
    const matrixB: PdFloat;
    const velocityB: PdFloat;
    const omegaB: PdFloat;
    timeOfImpact: PdFloat;
    contacts: PdFloat;
    normals: PdFloat;
    penetration: PdFloat;
    threadIndex: Integer
  ): Integer; cdecl; external NEWTON_API name 'NewtonCollisionCollideContinue';


	//NEWTON_API void NewtonCollisionSupportVertex (
  //const NewtonCollision* collision,
  //const dFloat* dir,
  //dFloat* vertex);
  procedure NewtonCollisionSupportVertex(
    const collision: TNewtonCollision;
    const dir: PdFloat;
    vertex: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonCollisionSupportVertex';

	//NEWTON_API dFloat NewtonCollisionRayCast (
  //const NewtonCollision* collision,
  //const dFloat* p0,
  //const dFloat* p1,
  //dFloat* normals,
  //int* attribute);
  function NewtonCollisionRayCast(
    const collision: TNewtonCollision;
    const p0, p1: PdFloat;
    normals: PdFloat;
    attribute: PInteger
  ): dFloat; cdecl; external NEWTON_API name 'NewtonCollisionRayCast';

	//NEWTON_API void NewtonCollisionCalculateAABB (
  //const NewtonCollision* collision,
  //const dFloat *matrix,
  //dFloat* p0,
  //dFloat* p1);
  procedure NewtonCollisionCalculateAABB(
    const collision: TNewtonCollision;
    const matrix: PdFloat;
    p0, p1: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonCollisionCalculateAABB';

	//NEWTON_API void NewtonCollisionForEachPolygonDo (
  //const NewtonCollision* collision,
  //const dFloat* matrix,
  //NewtonCollisionIterator callback,
  //void* userData);
  procedure NewtonCollisionForEachPolygonDo(
    const collision: TNewtonCollision;
    const matrix: PdFloat;
    callback: TNewtonCollisionIterator;
    userData: Pointer
  ); cdecl; external NEWTON_API name 'NewtonCollisionForEachPolygonDo';


	// **********************************************************************************************
	//
	// transforms utility functions
	//
	// **********************************************************************************************

	//NEWTON_API void NewtonGetEulerAngle (
  //const dFloat* matrix,
  //dFloat* eulersAngles);
  procedure NewtonGetEulerAngle(
    const matrix: PdFloat;
    eulersAngles: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonGetEulerAngle';

	//NEWTON_API void NewtonSetEulerAngle (
  //const dFloat* eulersAngles,
  //dFloat* matrix);
  procedure NewtonSetEulerAngle(
    const eulersAngles: PdFloat;
    matrix: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonSetEulerAngle';

	//NEWTON_API dFloat NewtonCalculateSpringDamperAcceleration (
  //dFloat dt,
  //dFloat ks,
  //dFloat x,
  //dFloat kd,
  //dFloat s);
  function NewtonCalculateSpringDamperAcceleration(
    dt, ks, x, kd, s: dFloat
  ): dFloat; cdecl; external NEWTON_API name 'NewtonCalculateSpringDamperAcceleration';


	// **********************************************************************************************
	//
	// body manipulation functions
	//
	// **********************************************************************************************

	//NEWTON_API NewtonBody* NewtonCreateBody (
  //const NewtonWorld* newtonWorld,
  //const NewtonCollision* collision);
  function NewtonCreateBody(
    const newtonWorld: TNewtonWorld;
    const collision: TNewtonCollision
  ): TNewtonBody; cdecl; external NEWTON_API name 'NewtonCreateBody';

	//NEWTON_API void  NewtonDestroyBody(
  //const NewtonWorld* newtonWorld,
  //const NewtonBody* body);
  procedure NewtonDestroyBody(
    const newtonWorld: TNewtonWorld;
    const body: TNewtonBody
  ); cdecl; external NEWTON_API name 'NewtonDestroyBody';


	//NEWTON_API void  NewtonBodyAddForce (
  //const NewtonBody* body,
  //const dFloat* force);
  procedure NewtonBodyAddForce(
    const body: TNewtonBody;
    const force: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodyAddForce';

	//NEWTON_API void  NewtonBodyAddTorque (
  //const NewtonBody* body,
  //const dFloat* torque);
  procedure NewtonBodyAddTorque(
    const body: TNewtonBody;
    const torque: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodyAddTorque';

	//NEWTON_API void  NewtonBodyCalculateInverseDynamicsForce (
  //const NewtonBody* body,
  //dFloat timestep,
  //const dFloat* desiredVeloc,
  //dFloat* forceOut);
  procedure NewtonBodyCalculateInverseDynamicsForce(
    const body: TNewtonBody;
    timestep: dFloat;
    const desiredVelocity: PdFloat;
    forceOut: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodyCalculateInverseDynamicsForce';


	//NEWTON_API void  NewtonBodySetMatrix (
  //const NewtonBody* body,
  //const dFloat* matrix);
  procedure NewtonBodySetMatrix(
    const body: TNewtonBody;
    const matrix: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodySetMatrix';

	//NEWTON_API void  NewtonBodySetMatrixRecursive (
  //const NewtonBody* body,
  //const dFloat* matrix);
  procedure NewtonBodySetMatrixRecursive(
    const body: TNewtonBody;
    const matrix: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodySetMatrixRecursive';

	//NEWTON_API void  NewtonBodySetMassMatrix (
  //const NewtonBody* body,
  //dFloat mass,
  //dFloat Ixx,
  //dFloat Iyy,
  //dFloat Izz);
  procedure NewtonBodySetMassMatrix(
    const body: TNewtonBody;
    mass, Ixx, Iyy, Izz: dFloat
  ); cdecl; external NEWTON_API name 'NewtonBodySetMassMatrix';

	//NEWTON_API void  NewtonBodySetMaterialGroupID (
  //const NewtonBody* body,
  //int id);
  procedure NewtonBodySetMaterialGroupId(
    const body: TNewtonBody;
    id: Integer
  ); cdecl; external NEWTON_API name 'NewtonBodySetMaterialGroupID';

	//NEWTON_API void  NewtonBodySetContinuousCollisionMode (
  //const NewtonBody* body,
  //unsigned state);
  procedure NewtonBodySetContiniousCollisionMode(
    const body: TNewtonBody;
    state: Cardinal
  ); cdecl; external NEWTON_API name 'NewtonBodySetContinuousCollisionMode';

	//NEWTON_API void  NewtonBodySetJointRecursiveCollision (
  //const NewtonBody* body,
  //unsigned state);
  procedure NewtonBodySetJointRecursiveCollision(
    const body: TNewtonBody;
    state: Cardinal
  ); cdecl; external NEWTON_API name 'NewtonBodySetJointRecursiveCollision';

	//NEWTON_API void  NewtonBodySetOmega (
  //const NewtonBody* body,
  //const dFloat* omega);
  procedure NewtonBodySetOmega(
    const body: TNewtonBody;
    const omega: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodySetOmega';

	//NEWTON_API void  NewtonBodySetVelocity (
  //const NewtonBody* body,
  //const dFloat* velocity);
  procedure NewtonBodySetVelocity(
    const body: TNewtonBody;
    const velocity: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodySetVelocity';

	//NEWTON_API void  NewtonBodySetForce (
  //const NewtonBody* body,
  //const dFloat* force);
  procedure NewtonBodySetForce(
    const body: TNewtonBody;
    const force: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodySetForce';

	//NEWTON_API void  NewtonBodySetTorque (
  //const NewtonBody* body,
  //const dFloat* torque);
  procedure NewtonBodySetTorque(
    const body: TNewtonBody;
    const torque: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodySetTorque';


	//NEWTON_API void  NewtonBodySetCentreOfMass  (
  //const NewtonBody* body,
  //const dFloat* com);
  procedure NewtonBodySetCenterOfMass(
    const body: TNewtonBody;
    const com: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodySetCentreOfMass';

	//NEWTON_API void  NewtonBodySetLinearDamping (
  //const NewtonBody* body,
  //dFloat linearDamp);
  procedure NewtonBodySetLinearDamping(
    const body: TNewtonBody;
    linearDamp: dFloat
  ); cdecl; external NEWTON_API name 'NewtonBodySetLinearDamping';

	//NEWTON_API void  NewtonBodySetAngularDamping (
  //const NewtonBody* body,
  //const dFloat* angularDamp);
  procedure NewtonBodySetAngularDamping(
    const body: TNewtonBody;
    const angularDamp: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodySetAngularDamping';

	//NEWTON_API void  NewtonBodySetUserData (
  //const NewtonBody* body,
  //void* userData);
  procedure NewtonBodySetUserData(
    const body: TNewtonBody;
    userData: Pointer
  ); cdecl; external NEWTON_API name 'NewtonBodySetUserData';

	//NEWTON_API void  NewtonBodySetCollision (
  //const NewtonBody* body,
  //const NewtonCollision* collision);
  procedure NewtonBodySetCollision(
    const body: TNewtonBody;
    const collision: TNewtonCollision
  ); cdecl; external NEWTON_API name 'NewtonBodySetCollision';


	//NEWTON_API int  NewtonBodyGetSleepState (
  //const NewtonBody* body);
  function NewtonBodyGetSleepState(
    const body: TNewtonBody
  ): Integer; cdecl; external NEWTON_API name 'NewtonBodyGetSleepState';

	//NEWTON_API int  NewtonBodyGetAutoSleep (
  //const NewtonBody* body);
  function NewtonBodyGetAutoSleep(
    const body: TNewtonBody
  ): Integer; cdecl; external NEWTON_API name 'NewtonBodyGetAutoSleep';

	//NEWTON_API void NewtonBodySetAutoSleep (
  //const NewtonBody* body,
  //int state);
  procedure NewtonBodySetAutoSleep(
    const body: TNewtonBody;
    state: Integer
  ); cdecl; external NEWTON_API name 'NewtonBodySetAutoSleep';


	//NEWTON_API int  NewtonBodyGetFreezeState(
  //const NewtonBody* body);
  function NewtonBodyGetFreezeState(
    const body: TNewtonBody
  ): Integer; cdecl; external NEWTON_API name 'NewtonBodyGetFreezeState';

	//NEWTON_API void NewtonBodySetFreezeState (
  //const NewtonBody* body,
  //int state);
  procedure NewtonBodySetFreezeState(
    const body: TNewtonBody;
    state: Integer
  ); cdecl; external NEWTON_API name 'NewtonBodySetFreezeState';


//	NEWTON_API void NewtonBodySetAutoFreeze(const NewtonBody* body, int state);
//	NEWTON_API void NewtonBodyCoriolisForcesMode (const NewtonBody* body, int mode);
//	NEWTON_API void NewtonBodySetGyroscopicForcesMode (const NewtonBody* body, int mode);
//	NEWTON_API int  NewtonBodyGetGyroscopicForcesMode (const NewtonBody* body);
//	NEWTON_API int  NewtonBodyGetFreezeState (const NewtonBody* body);
//	NEWTON_API void NewtonBodySetFreezeState  (const NewtonBody* body, int state);
//	NEWTON_API void NewtonBodyGetFreezeTreshold (const NewtonBody* body, dFloat* freezeSpeed2, dFloat* freezeOmega2);
//	NEWTON_API void NewtonBodySetFreezeTreshold (const NewtonBody* body, dFloat freezeSpeed2, dFloat freezeOmega2, int framesCount);
//	NEWTON_API void NewtonBodySetAutoactiveCallback (const NewtonBody* body, NewtonBodyActivationState callback);


	//NEWTON_API void  NewtonBodySetDestructorCallback (
  //const NewtonBody* body,
  //NewtonBodyDestructor callback);
  procedure NewtonBodySetDestructorCallback(
    const body: TNewtonBody;
    callback: TNewtonBodyDestructor
  ); cdecl; external NEWTON_API name 'NewtonBodySetDestructorCallback';


	//NEWTON_API void  NewtonBodySetTransformCallback (
  //const NewtonBody* body,
  //NewtonSetTransform callback);
  procedure NewtonBodySetTransformCallback(
    const body: TNewtonBody;
    callback: TNewtonSetTransform
  ); cdecl; external NEWTON_API name 'NewtonBodySetTransformCallback';

	//NEWTON_API NewtonSetTransform NewtonBodyGetTransformCallback (
  //const NewtonBody* body);
  function NewtonBodyGetTransformCallback(
    const body: TNewtonBody
  ): TNewtonSetTransform; cdecl; external NEWTON_API name 'NewtonBodyGetTransformCallback';


	//NEWTON_API void  NewtonBodySetForceAndTorqueCallback (
  //const NewtonBody* body,
  //NewtonApplyForceAndTorque callback);
  procedure NewtonBodySetForceAndTorqueCallback(
    const body: TNewtonBody;
    callback: TNewtonApplyForceAndTorque
  ); cdecl; external NEWTON_API name 'NewtonBodySetForceAndTorqueCallback';

	//NEWTON_API NewtonApplyForceAndTorque NewtonBodyGetForceAndTorqueCallback (
  //const NewtonBody* body);
  function NewotnBodyGetForceAndTorqueCallback(
    const body: TNewtonBody
  ): TNewtonApplyForceAndTorque; cdecl; external NEWTON_API name 'NewtonBodyGetForceAndTorqueCallback';

	//NEWTON_API void* NewtonBodyGetUserData (
  //const NewtonBody* body);
  function NewtonBodyGetUserData(
    const body: TNewtonBody
  ): Pointer; cdecl; external NEWTON_API name 'NewtonBodyGetUserData';

	//NEWTON_API NewtonWorld* NewtonBodyGetWorld (
  //const NewtonBody* body);
  function NewtonBodyGetWorld(
    const body: TNewtonWorld
  ): TNewtonWorld; cdecl; external NEWTON_API name 'NewtonBodyGetWorld';

	//NEWTON_API NewtonCollision* NewtonBodyGetCollision (
  //const NewtonBody* body);
  function NewtonBodyGetCollision(
    const body: TNewtonBody
  ): TNewtonCollision; cdecl; external NEWTON_API name 'NewtonBodyGetCollision';

	//NEWTON_API int   NewtonBodyGetMaterialGroupID (
  //const NewtonBody* body);
  function NewtonBodyGetMaterialGroupID(
    const body: TNewtonBody
  ): Integer; cdecl; external NEWTON_API name 'NewtonBodyGetMaterialGroupID';


	//NEWTON_API int   NewtonBodyGetContinuousCollisionMode (
  //const NewtonBody* body);
  function NewtonBodyGetContinuousCollisionMode(
    const body: TNewtonBody
  ): Integer; cdecl; external NEWTON_API name 'NewtonBodyGetContinuousCollisionMode';

	//NEWTON_API int   NewtonBodyGetJointRecursiveCollision (
  //const NewtonBody* body);
  function NewtonBodyGetJointRecursiveCollision(
    const body: TNewtonBody
  ): Integer; cdecl; external NEWTON_API name 'NewtonBodyGetJointRecursiveCollision';


	//NEWTON_API void  NewtonBodyGetMatrix(
  //const NewtonBody* body,
  //dFloat* matrix);
  procedure NewtonBodyGetMatrix(
    const body: TNewtonBody;
    matrix: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodyGetMatrix';

	//NEWTON_API void  NewtonBodyGetRotation(
  //const NewtonBody* body,
  //dFloat* rotation);
  procedure NewtonBodyGetRotation(
    const body: TNewtonBody;
    rotation: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodyGetRotation';

	//NEWTON_API void  NewtonBodyGetMassMatrix (
  //const NewtonBody* body,
  //dFloat* mass,
  //dFloat* Ixx,
  //dFloat* Iyy,
  //dFloat* Izz);
  procedure NewtonBodyGetMassMatrix(
    const body: TNewtonBody;
    mass, Ixx, Iyy, Izz: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodyGetMassMatrix';

	//NEWTON_API void  NewtonBodyGetInvMass(
  //const NewtonBody* body,
  //dFloat* invMass,
  //dFloat* invIxx,
  //dFloat* invIyy,
  //dFloat* invIzz);
  procedure NewtonBodyGetInvMass(
    const body: TNewtonBody;
    invMass, invIxx, invIyy, invIzz: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodyGetInvMass';

	//NEWTON_API void  NewtonBodyGetOmega(
  //const NewtonBody* body,
  //dFloat* vector);
  procedure NewtonBodyGetOmega(
    const body: TNewtonBody;
    vector: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodyGetOmega';

	//NEWTON_API void  NewtonBodyGetVelocity(
  //const NewtonBody* body,
  //dFloat* vector);
  procedure NewtonBodyGetVelocity(
    const body: TNewtonBody;
    vector: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodyGetVelocity';

	//NEWTON_API void  NewtonBodyGetForce(
  //const NewtonBody* body,
  //dFloat* vector);
  procedure NewtonBodyGetForce(
    const body: TNewtonBody;
    vector: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodyGetForce';

	//NEWTON_API void  NewtonBodyGetTorque(
  //const NewtonBody* body,
  //dFloat* vector);
  procedure NewtonBodyGetTorque(
    const body: TNewtonBody;
    vector: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodyGetTorque';

	//NEWTON_API void  NewtonBodyGetForceAcc(
  //const NewtonBody* body,
  //dFloat* vector);
  procedure NewotnBodyGetForceAcc(
    const body: TNewtonBody;
    vector: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodyGetForceAcc';

	//NEWTON_API void  NewtonBodyGetTorqueAcc(
  //const NewtonBody* body,
  //dFloat* vector);
  procedure NewtonBodyGetTorqueAcc(
    const body: TNewtonBody;
    vector: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodyGetTorqueAcc';

	//NEWTON_API void  NewtonBodyGetCentreOfMass (
  //const NewtonBody* body,
  //dFloat* com);
  procedure NewtonBodyGetCenterOfMass(
    const body: TNewtonBody;
    com: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodyGetCentreOfMass';


	//NEWTON_API dFloat NewtonBodyGetLinearDamping (
  //const NewtonBody* body);
  function NewtonBodyGetLinearDamping(
    const body: TNewtonBody
  ): dFloat; cdecl; external NEWTON_API name 'NewtonBodyGetLinearDamping';

	//NEWTON_API void  NewtonBodyGetAngularDamping (
  //const NewtonBody* body,
  //dFloat* vector);
  procedure NewtonBodyGetAngilarDamping(
    const body: TNewtonBody;
    vector: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodyGetAngularDamping';

	//NEWTON_API void  NewtonBodyGetAABB (
  //const NewtonBody* body,
  //dFloat* p0,
  //dFloat* p1);
  procedure NewtonBodyGetAABB(
    const body: TNewtonBody;
    p0, p1: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodyGetAABB';

	//NEWTON_API NewtonJoint* NewtonBodyGetFirstJoint (
  //const NewtonBody* body);
  function NewtonBodyGetFirstJoint(
    const body: TNewtonBody
  ): TNewtonJoint; cdecl; external NEWTON_API name 'NewtonBodyGetFirstJoint';

	//NEWTON_API NewtonJoint* NewtonBodyGetNextJoint (
  //const NewtonBody* body,
  //const NewtonJoint* joint);
  function NewtonBodyGetNextJoint(
    const body: TNewtonBody;
    const joint: TNewtonJoint
  ): TNewtonJoint; cdecl; external NEWTON_API name 'NewtonBodyGetNextJoint';

	//NEWTON_API NewtonJoint* NewtonBodyGetFirstContactJoint (
  //const NewtonBody* body);
  function NewtonBodyGetFirstContactJoint(
    const body: TNewtonBody
  ): TNewtonJoint; cdecl; external NEWTON_API name 'NewtonBodyGetFirstContactJoint';

	//NEWTON_API NewtonJoint* NewtonBodyGetNextContactJoint (
  //const NewtonBody* body,
  //const NewtonJoint* contactJoint);
  function NewtonBodyGetNextContactJoint(
    const body: TNewtonBody;
    const contactJoint: TNewtonJoint
  ): TNewtonJoint; cdecl; external NEWTON_API name 'NewtonBodyGetNextContactJoint';


	//NEWTON_API void* NewtonContactJointGetFirstContact (
  //const NewtonJoint* contactJoint);
  function NewtonContactJointGetFirstContact(
    const contactJoint: TNewtonJoint
  ): Pointer; cdecl; external NEWTON_API name 'NewtonContactJointGetFirstContact';

	//NEWTON_API void* NewtonContactJointGetNextContact (
  //const NewtonJoint* contactJoint,
  //void* contact);
  function NewtonContactJointGetNextContact(
    const contactJoint: TNewtonJoint;
    contact: Pointer
  ): Pointer; cdecl; external NEWTON_API name 'NewtonContactJointGetNextContact';


	//NEWTON_API int NewtonContactJointGetContactCount(
  //const NewtonJoint* contactJoint);
  function NewtonContactJointGetContactCount(
    const contactJoint: TNewtonJoint
  ): Integer; cdecl; external NEWTON_API name 'NewtonContactJointGetContactCount';

	//NEWTON_API void NewtonContactJointRemoveContact(
  //const NewtonJoint* contactJoint,
  //void* contact);
  procedure NewtonContactJointRemoveContact(
    const contactJoint: TNewtonJoint;
    contact: Pointer
  ); cdecl; external NEWTON_API name 'NewtonContactJointRemoveContact';


	//NEWTON_API NewtonMaterial* NewtonContactGetMaterial (
  //const void* contact);
  function NewtonContactGetMaterial(
    const contact: Pointer
  ): TNewtonMaterial; cdecl; external NEWTON_API name 'NewtonContactGetMaterial';


	//NEWTON_API void  NewtonBodyAddBuoyancyForce (
  //const NewtonBody* body,
  //dFloat fluidDensity,
  //dFloat fluidLinearViscosity,
  //dFloat fluidAngularViscosity,
  //const dFloat* gravityVector,
  //NewtonGetBuoyancyPlane buoyancyPlane,
  //void *context);
  procedure NewtonBodyAddBuoyancyForce(
    const body: TNewtonBody;
    fluidDensity: dFloat;
    fluidLinearViscosity: dFloat;
    fluidAngularViscosity: dFloat;
    const gravityVector: PdFloat;
    buoyancyPlane: TNewtonGetBuoyancyPlane;
    context: Pointer
  ); cdecl; external NEWTON_API name 'NewtonBodyAddBuoyancyForce';


//	NEWTON_API void NewtonBodyForEachPolygonDo (const NewtonBody* body, NewtonCollisionIterator callback);

	//NEWTON_API void NewtonBodyAddImpulse (
  //const NewtonBody* body,
  //const dFloat* pointDeltaVeloc,
  //const dFloat* pointPosit);
  procedure NewtonBodyAddImpulse(
    const body: TNewtonBody;
    const pointDeltaVelocity: PdFloat;
    const pointPosition: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBodyAddImpulse';


	// **********************************************************************************************
	//
	// Common joint functions
	//
	// **********************************************************************************************

	//NEWTON_API void* NewtonJointGetUserData (
  //const NewtonJoint* joint);
  function NewtonJointGetUserData(
    const joint: TNewtonJoint
  ): Pointer; cdecl; external NEWTON_API name 'NewtonJointGetUserData';

	//NEWTON_API void NewtonJointSetUserData (
  //const NewtonJoint* joint,
  //void* userData);
  procedure NewtonJointSetUserData(
    const joint: TNewtonJoint;
    userData: Pointer
  ); cdecl; external NEWTON_API name 'NewtonJointSetUserData';


	//NEWTON_API NewtonBody* NewtonJointGetBody0 (
  //const NewtonJoint* joint);
  function NewtonJointGetBody0(
    const joint: TNewtonJoint
  ): TNewtonBody; cdecl; external NEWTON_API name 'NewtonJointGetBody0';

	//NEWTON_API NewtonBody* NewtonJointGetBody1 (
  //const NewtonJoint* joint);
  function NewtonJointGetBody1(
    const joint: TNewtonJoint
  ): TNewtonBody; cdecl; external NEWTON_API name 'NewtonJointGetBody1';


	//NEWTON_API void NewtonJointGetInfo  (
  //const NewtonJoint* joint,
  //NewtonJointRecord* info);
  procedure NewtonJointGetInfo(
    const joint: TNewtonJoint;
    info: TNewtonJointRecord
  ); cdecl; external NEWTON_API name 'NewtonJointGetInfo';

	//NEWTON_API int NewtonJointGetCollisionState (
  //const NewtonJoint* joint);
  function NewtonJointGetCollisionState(
    const joint: TNewtonJoint
  ): Integer; cdecl; external NEWTON_API name 'NewtonJointGetCollisionState';

	//NEWTON_API void NewtonJointSetCollisionState (
  //const NewtonJoint* joint,
  //int state);
  procedure NewtonJointSetCollisionState(
    const joint: TNewtonJoint;
    state: Integer
  ); cdecl; external NEWTON_API name 'NewtonJointSetCollisionState';


	//NEWTON_API dFloat NewtonJointGetStiffness (
  //const NewtonJoint* joint);
  function NewtonJointGetStiffness(
    const joint: TNewtonJoint
  ): dFloat; cdecl; external NEWTON_API name 'NewtonJointGetStiffness';

	//NEWTON_API void NewtonJointSetStiffness (
  //const NewtonJoint* joint,
  //dFloat state);
  procedure NewtonJointSetStiffness(
    const joint: TNewtonJoint;
    state: dFloat
  ); cdecl; external NEWTON_API name 'NewtonJointSetStiffness';


	//NEWTON_API void NewtonDestroyJoint(
  //const NewtonWorld* newtonWorld,
  //const NewtonJoint* joint);
  procedure NewtonDestroyJoint(
    const newtonWorld: TNewtonWorld;
    const joint: TNewtonJoint
  ); cdecl; external NEWTON_API name 'NewtonDestroyJoint';

	//NEWTON_API void NewtonJointSetDestructor (
  //const NewtonJoint* joint,
  //NewtonConstraintDestructor destructor);
  procedure NewtonJointSetDestructor(
    const join: TNewtonJoint;
    destructorFunction: TNewtonConstraintDestructor
  ); cdecl; external NEWTON_API name 'NewtonJointSetDestructor';


	// **********************************************************************************************
	//
	// Ball and Socket joint functions
	//
	// **********************************************************************************************

	//NEWTON_API NewtonJoint* NewtonConstraintCreateBall (
  //const NewtonWorld* newtonWorld,
  //const dFloat* pivotPoint,
	//const NewtonBody* childBody,
  //const NewtonBody* parentBody);
  function NewtonConstraintCreateBall(
    const newtonWorld: TNewtonWorld;
    const pivotPoint: PdFloat;
    const childBody, parentBody: TNewtonBody
  ): TNewtonJoint; cdecl; external NEWTON_API name 'NewtonConstraintCreateBall';

	//NEWTON_API void NewtonBallSetUserCallback (
  //const NewtonJoint* ball,
  //NewtonBallCallBack callback);
  procedure NewtonBallSetUserCallback(
    const ball: TNewtonJoint;
    callback: TNewtonBallCallback
  ); cdecl; external NEWTON_API name 'NewtonBallSetUserCallback';

	//NEWTON_API void NewtonBallGetJointAngle (
  //const NewtonJoint* ball,
  //dFloat* angle);
  procedure NewtonBallGetJointAngle(
    const ball: TNewtonJoint;
    angle: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBallGetJointAngle';

	//NEWTON_API void NewtonBallGetJointOmega (
  //const NewtonJoint* ball,
  //dFloat* omega);
  procedure NewtonBallGetJointOmega(
    const ball: TNewtonJoint;
    omega: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBallGetJointOmega';

	//NEWTON_API void NewtonBallGetJointForce (
  //const NewtonJoint* ball,
  //dFloat* force);
  procedure NewtonBallGetJointForce(
    const ball: TNewtonJoint;
    force: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonBallGetJointForce';

	//NEWTON_API void NewtonBallSetConeLimits (
  //const NewtonJoint* ball,
  //const dFloat* pin,
  //dFloat maxConeAngle,
  //dFloat maxTwistAngle);
  procedure NewtonBallSetConeLimits(
    const ball: TNewtonJoint;
    const pin: PdFloat;
    maxConeAngle: dFloat;
    maxTwistAngle: dFloat
  ); cdecl; external NEWTON_API name 'NewtonBallSetConeLimits';


	// **********************************************************************************************
	//
	// Hinge joint functions
	//
	// **********************************************************************************************

	//NEWTON_API NewtonJoint* NewtonConstraintCreateHinge (
  //const NewtonWorld* newtonWorld,
  //const dFloat* pivotPoint,
  //const dFloat* pinDir,
  //const NewtonBody* childBody,
  //const NewtonBody* parentBody);
  function NewtonConstraintCreateHinge(
    const newtonWorld: TNewtonWorld;
    const pivotPoint: PdFloat;
    const pinDir: PdFloat;
    const childBody, parentBody: TNewtonBody
  ): TNewtonJoint; cdecl; external NEWTON_API name 'NewtonConstraintCreateHinge';

	//NEWTON_API void NewtonHingeSetUserCallback (
  //const NewtonJoint* hinge,
  //NewtonHingeCallBack callback);
  procedure NewtonHingeSetUserCallback(
    const hinge: TNewtonJoint;
    callback: TNewtonHingeCallback
  ); cdecl; external NEWTON_API name 'NewtonHingeSetUserCallback';

	//NEWTON_API dFloat NewtonHingeGetJointAngle (
  //const NewtonJoint* hinge);
  function NewtonHingeGetJointAngle(
    const hinge: TNewtonJoint
  ): dFloat; cdecl; external NEWTON_API name 'NewtonHingeGetJointAngle';

	//NEWTON_API dFloat NewtonHingeGetJointOmega (
  //const NewtonJoint* hinge);
  function NewtonHingeGetJointOmega(
    const hinge: TNewtonJoint
  ): dFloat; cdecl; external NEWTON_API name 'NewtonHingeGetJointOmega';

	//NEWTON_API void NewtonHingeGetJointForce (
  //const NewtonJoint* hinge,
  //dFloat* force);
  procedure NewtonHingeGetJointForce(
    const hinge: TNewtonJoint;
    force: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonHingeGetJointForce';

	//NEWTON_API dFloat NewtonHingeCalculateStopAlpha (
  //const NewtonJoint* hinge,
  //const NewtonHingeSliderUpdateDesc* desc,
  //dFloat angle);
  function NewtonHingeCalculateStopAlpha(
    const hinge: TNewtonJoint;
    const desc: TNewtonHingeSliderUpdateDesc;
    angle: dFloat
  ): dFloat; cdecl; external NEWTON_API name 'NewtonHingeCalculateStopAlpha';


	// **********************************************************************************************
	//
	// Slider joint functions
	//
	// **********************************************************************************************

	//NEWTON_API NewtonJoint* NewtonConstraintCreateSlider (
  //const NewtonWorld* newtonWorld,
  //const dFloat* pivotPoint,
  //const dFloat* pinDir,
  //const NewtonBody* childBody,
  //const NewtonBody* parentBody);
  function NewtonConstraintCreateSlider(
    const newtonWorld: TNewtonWorld;
    const pivotPoint: PdFloat;
    const pinDir: PdFloat;
    const childBody, parentBody: TNewtonBody
  ): TNewtonJoint; cdecl; external NEWTON_API name 'NewtonConstraintCreateSlider';

	//NEWTON_API void NewtonSliderSetUserCallback (
  //const NewtonJoint* slider,
  //NewtonSliderCallBack callback);
  procedure NewtonSliderSetUserCallback(
    const slider: TNewtonJoint;
    callback: TNewtonSliderCallback
  ); cdecl; external NEWTON_API name 'NewtonSliderSetUserCallback';

	//NEWTON_API dFloat NewtonSliderGetJointPosit (
  //const NewtonJoint* slider);
  function NewtonSliderGetJointPosit(
    const slider: TNewtonJoint
  ): dFloat; cdecl; external NEWTON_API name 'NewtonSliderGetJointPosit';

	//NEWTON_API dFloat NewtonSliderGetJointVeloc (
  //const NewtonJoint* slider);
  function NewotnSliderGetJointVeloc(
    const slider: TNewtonJoint
  ): dFloat; cdecl; external NEWTON_API name 'NewtonSliderGetJointVeloc';

	//NEWTON_API void NewtonSliderGetJointForce (
  //const NewtonJoint* slider,
  //dFloat* force);
  procedure NewtonSliderGetJointForce(
    const slider: TNewtonJoint;
    force: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonSliderGetJointForce';

	//NEWTON_API dFloat NewtonSliderCalculateStopAccel (
  //const NewtonJoint* slider,
  //const NewtonHingeSliderUpdateDesc* desc,
  //dFloat position);
  function NewtonSliderCalculateStopAccel(
    const slider: TNewtonJoint;
    const desc: TNewtonHingeSliderUpdateDesc;
    position: dFloat
  ): dFloat; cdecl; external NEWTON_API name 'NewtonSliderCalculateStopAccel';


	// **********************************************************************************************
	//
	// Corkscrew joint functions
	//
	// **********************************************************************************************

	//NEWTON_API NewtonJoint* NewtonConstraintCreateCorkscrew (
  //const NewtonWorld* newtonWorld,
  //const dFloat* pivotPoint,
  //const dFloat* pinDir,
  //const NewtonBody* childBody,
  //const NewtonBody* parentBody);
  function NewtonConstraintCreateCorkscrew(
    const newtonWorld: TNewtonWorld;
    const pivotPoint: PdFloat;
    const pinDir: PdFloat;
    const childBody, parentBody: TNewtonBody
  ): TNewtonJoint; cdecl; external NEWTON_API name 'NewtonConstraintCreateCorkscrew';

	//NEWTON_API void NewtonCorkscrewSetUserCallback (
  //const NewtonJoint* corkscrew,
  //NewtonCorkscrewCallBack callback);
  procedure NewtonCorkscrewSetUserCallback(
    const corkscrew: TNewtonJoint;
    callback: TNewtonCorkscrewCallback
  ); cdecl; external NEWTON_API name 'NewtonCorkscrewSetUserCallback';

	//NEWTON_API dFloat NewtonCorkscrewGetJointPosit (
  //const NewtonJoint* corkscrew);
  function NewtonCorkscrewGetJointPosit(
    const corkscrew: TNewtonJoint
  ): dFloat; cdecl; external NEWTON_API name 'NewtonCorkscrewGetJointPosit';

	//NEWTON_API dFloat NewtonCorkscrewGetJointAngle (
  //const NewtonJoint* corkscrew);
  function NewtonCorkscrewGetJointAngle(
    const corkscrew: TNewtonJoint
  ): dFloat; cdecl; external NEWTON_API name 'NewtonCorkscrewGetJointAngle';

	//NEWTON_API dFloat NewtonCorkscrewGetJointVeloc (
  //const NewtonJoint* corkscrew);
  function NewtonCorkscrewGetJointVeloc(
    const corkscrew: TNewtonJoint
  ): dFloat; cdecl; external NEWTON_API name 'NewtonCorkscrewGetJointVeloc';

	//NEWTON_API dFloat NewtonCorkscrewGetJointOmega (
  //const NewtonJoint* corkscrew);
  function NewtonCorkscrewGetJointOmega(
    const corkscrew: TNewtonJoint
  ): dFloat; cdecl; external NEWTON_API name 'NewtonCorkscrewGetJointOmega';

	//NEWTON_API void NewtonCorkscrewGetJointForce (
  //const NewtonJoint* corkscrew,
  //dFloat* force);
  procedure NewtonCorkscrewGetJointForce(
    const corkscrew: TNewtonJoint;
    force: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonCorkscrewGetJointForce';

	//NEWTON_API dFloat NewtonCorkscrewCalculateStopAlpha (
  //const NewtonJoint* corkscrew,
  //const NewtonHingeSliderUpdateDesc* desc,
  //dFloat angle);
  function NewtonCorkscrewCalculateStopAlpha(
    const corkscrew: TNewtonJoint;
    const desc: TNewtonHingeSliderUpdateDesc;
    angle: dFloat
  ): dFloat; cdecl; external NEWTON_API name 'NewtonCorkscrewCalculateStopAlpha';

	//NEWTON_API dFloat NewtonCorkscrewCalculateStopAccel (
  //const NewtonJoint* corkscrew,
  //const NewtonHingeSliderUpdateDesc* desc,
  //dFloat position);
  function NewtonCorkscrewCalculateStopAccel(
    const corkscrew: TNewtonJoint;
    const desc: TNewtonHingeSliderUpdateDesc;
    position: dFloat
  ): dFloat; cdecl; external NEWTON_API name 'NewtonCorkscrewCalculateStopAccel';


	// **********************************************************************************************
	//
	// Universal joint functions
	//
	// **********************************************************************************************

	//NEWTON_API NewtonJoint* NewtonConstraintCreateUniversal (
  //const NewtonWorld* newtonWorld,
  //const dFloat* pivotPoint,
  //const dFloat* pinDir0,
  //const dFloat* pinDir1,
  //const NewtonBody* childBody,
  //const NewtonBody* parentBody);
  function NewtonConstraintCreateUniversal(
    const newtonWorld: TNewtonWorld;
    const pivotPoint: PdFloat;
    const pinDir0, pinDir1: PdFloat;
    const childBody, parentBody: TNewtonBody
  ): TNewtonJoint; cdecl; external NEWTON_API name 'NewtonConstraintCreateUniversal';

	//NEWTON_API void NewtonUniversalSetUserCallback (
  //const NewtonJoint* universal,
  //NewtonUniversalCallBack callback);
  procedure NewtonUniversalSetUserCallback(
    const universal: TNewtonJoint;
    callback: TNewtonUniversalCallback
  ); cdecl; external NEWTON_API name 'NewtonUniversalSetUserCallback';

	//NEWTON_API dFloat NewtonUniversalGetJointAngle0 (
  //const NewtonJoint* universal);
  function NewtonUniversalGetJointAngle0(
    const universal: TNewtonJoint
  ): dFloat; cdecl; external NEWTON_API name 'NewtonUniversalGetJointAngle0';

	//NEWTON_API dFloat NewtonUniversalGetJointAngle1 (
  //const NewtonJoint* universal);
  function NewtonUniversalGetJointAngle1(
    const universal: TNewtonJoint
  ): dFloat; cdecl; external NEWTON_API name 'NewtonUniversalGetJointAngle1';

	//NEWTON_API dFloat NewtonUniversalGetJointOmega0 (
  //const NewtonJoint* universal);
  function NewtonUniversalGetJointOmega0(
    const universal: TNewtonJoint
  ): dFloat; cdecl; external NEWTON_API name 'NewtonUniversalGetJointOmega0';

	//NEWTON_API dFloat NewtonUniversalGetJointOmega1 (
  //const NewtonJoint* universal);
  function NewtonUniversalGetJointOmega1(
    const universal: TNewtonJoint
  ): dFloat; cdecl; external NEWTON_API name 'NewtonUniversalGetJointOmega1';

	//NEWTON_API void NewtonUniversalGetJointForce (
  //const NewtonJoint* universal,
  //dFloat* force);
  procedure NewtonUniversalGetJointForce(
    const universal: TNewtonJoint;
    force: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonUniversalGetJointForce';

	//NEWTON_API dFloat NewtonUniversalCalculateStopAlpha0 (
  //const NewtonJoint* universal,
  //const NewtonHingeSliderUpdateDesc* desc,
  //dFloat angle);
  function NewtonUniversalCalculateStopAlpha0(
    const universal: TNewtonJoint;
    const desc: TNewtonHingeSliderUpdateDesc;
    angle: dFloat
  ): dFloat; cdecl; external NEWTON_API name 'NewtonUniversalCalculateStopAlpha0';

	//NEWTON_API dFloat NewtonUniversalCalculateStopAlpha1 (
  //const NewtonJoint* universal,
  //const NewtonHingeSliderUpdateDesc* desc,
  //dFloat angle);
  function NewtonUniversalCalculateStopAlpha1(
    const universal: TNewtonJoint;
    const desc: TNewtonHingeSliderUpdateDesc;
    angle: dFloat
  ): dFloat; cdecl; external NEWTON_API name 'NewtonUniversalCalculateStopAlpha1';


	// **********************************************************************************************
	//
	// Up vector joint functions
	//
	// **********************************************************************************************

	//NEWTON_API NewtonJoint* NewtonConstraintCreateUpVector (
  //const NewtonWorld* newtonWorld,
  //const dFloat* pinDir,
  //const NewtonBody* body);
  function NewtonConstraintCreateUpVector(
    const newtonWorld: TNewtonWorld;
    const pinDir: PdFloat;
    const body: TNewtonBody
  ): TNewtonJoint; cdecl; external NEWTON_API name 'NewtonConstraintCreateUpVector';

	//NEWTON_API void NewtonUpVectorGetPin (
  //const NewtonJoint* upVector,
  //dFloat *pin);
  procedure NewtonUpVectorGetPin(
    const upVector: TNewtonJoint;
    pin: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonUpVectorGetPin';

	//NEWTON_API void NewtonUpVectorSetPin (
  //const NewtonJoint* upVector,
  //const dFloat *pin);
  procedure NewtonUpVectorSetPin(
    const upVector: TNewtonJoint;
    pin: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonUpVectorSetPin';


	// **********************************************************************************************
	//
	// User defined bilateral Joint
	//
	// **********************************************************************************************

	//NEWTON_API NewtonJoint* NewtonConstraintCreateUserJoint (
  //const NewtonWorld* newtonWorld,
  //int maxDOF,
	//NewtonUserBilateralCallBack callback,
	//NewtonUserBilateralGetInfoCallBack getInfo,
	//const NewtonBody* childBody,
  //const NewtonBody* parentBody) ;
  function NewtonConstraintCreateUserJoint(
    const newtonWorld: TNewtonWorld;
    maxDOF: Integer;
    callback: TNewtonUserBilateralCallback;
    getInfo: TNewtonUserBilateralGetInfoCallback;
    const childBody,
    parentBody: TNewtonBody
  ): TNewtonJoint; cdecl; external NEWTON_API name 'NewtonConstraintCreateUserJoint';

	//NEWTON_API void NewtonUserJointSetFeedbackCollectorCallback (
  //const NewtonJoint* joint,
  //NewtonUserBilateralCallBack getFeedback);
  procedure NewtonUserJointSetFeedbackCollectorCallback(
    const joint: TNewtonJoint;
    getFeedback: TNewtonUserBilateralCallback
  ); cdecl; external NEWTON_API name 'NewtonUserJointSetFeedbackCollectorCallback';

	//NEWTON_API void NewtonUserJointAddLinearRow (
  //const NewtonJoint* joint,
  //const dFloat *pivot0,
  //const dFloat *pivot1,
  //const dFloat *dir);
  procedure NewtonUserJointAddLinearRow(
    const joint: TNewtonJoint;
    const pivot0, pivot1, dir: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonUserJointAddLinearRow';

	//NEWTON_API void NewtonUserJointAddAngularRow (
  //const NewtonJoint* joint,
  //dFloat relativeAngle,
  //const dFloat *dir);
  procedure NewtonUserJointAddAngularRow(
    const joint: TNewtonJoint;
    relativeAngle: dFloat;
    const dir: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonUserJointAddAngularRow';

	//NEWTON_API void NewtonUserJointAddGeneralRow (
  //const NewtonJoint* joint,
  //const dFloat *jacobian0,
  //const dFloat *jacobian1);
  procedure NewtonUserJointAddGeneralRow(
    const joint: TNewtonJoint;
    const jacobian0, jacobian1: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonUserJointAddGeneralRow';

	//NEWTON_API void NewtonUserJointSetRowMinimumFriction (
  //const NewtonJoint* joint,
  //dFloat friction);
  procedure NewtonUserJointSetRowMinimumFriction(
    const joint: TNewtonJoint;
    friction: dFloat
  ); cdecl; external NEWTON_API name 'NewtonUserJointSetRowMinimumFriction';

	//NEWTON_API void NewtonUserJointSetRowMaximumFriction (
  //const NewtonJoint* joint,
  //dFloat friction);
  procedure NewtonUserJointSetRowMaximumFriction(
    const joint: TNewtonJoint;
    friction: dFloat
  ); cdecl; external NEWTON_API name 'NewtonUserJointSetRowMaximumFriction';

	//NEWTON_API void NewtonUserJointSetRowAcceleration (
  //const NewtonJoint* joint,
  //dFloat acceleration);
  procedure NewtonUserJointSetRowAcceleration(
    const joint: TNewtonJoint;
    acceleration: dFloat
  ); cdecl; external NEWTON_API name 'NewtonUserJointSetRowAcceleration';

	//NEWTON_API void NewtonUserJointSetRowSpringDamperAcceleration (
  //const NewtonJoint* joint,
  //dFloat springK,
  //dFloat springD);
  procedure NewtonUserJointSetRowSpringDamperAcceleration(
    const joint: TNewtonJoint;
    springK, spring0: dFloat
  ); cdecl; external NEWTON_API name 'NewtonUserJointSetRowSpringDamperAcceleration';

	//NEWTON_API void NewtonUserJointSetRowStiffness (
  //const NewtonJoint* joint,
  //dFloat stiffness);
  procedure NewtonUserJointSetRowStiffness(
    const joint: TNewtonJoint;
    stiffness: dFloat
  ); cdecl; external NEWTON_API name 'NewtonUserJointSetRowStiffness';

	//NEWTON_API dFloat NewtonUserJointGetRowForce (
  //const NewtonJoint* joint,
  //int row);
  function NewtonUserJointGetRowForce(
    const joint: TNewtonJoint;
    row: Integer
  ): dFloat; cdecl; external NEWTON_API name 'NewtonUserJointGetRowForce';


	// **********************************************************************************************
	//
	// Mesh joint functions
	//
	// **********************************************************************************************

	//NEWTON_API NewtonMesh* NewtonMeshCreate(
  //const NewtonWorld* world);
  function NewtonMeshCreate(
    const world: TNewtonWorld
  ): TNewtonMesh; cdecl; external NEWTON_API name 'NewtonMeshCreate';

	//NEWTON_API NewtonMesh* NewtonMeshCreateFromMesh(
  //const NewtonMesh* mesh);
  function NewtonNeshCreateFromMesh(
    const mesh: TNewtonMesh
  ): TNewtonMesh; cdecl; external NEWTON_API name 'NewtonMeshCreateFromMesh';

	//NEWTON_API NewtonMesh* NewtonMeshCreateFromCollision(
  //const NewtonCollision* collision);
  function NewtonMeshCreateFromCollision(
    const collision: TNewtonCollision
  ): TNewtonMesh; cdecl; external NEWTON_API name 'NewtonMeshCreateFromCollision';

	//NEWTON_API NewtonMesh* NewtonMeshCreatePlane (
  //const NewtonWorld* world,
  //const dFloat* locationMatrix,
  //dFloat witdth,
  //dFloat breadth,
  //int material,
  //const dFloat* textureMatrix0,
  //const dFloat* textureMatrix1);
  function NewtonMeshCreatePlane(
    const world: TNewtonWorld;
    const localMatrix: PdFloat;
    width, breadth: dFloat; material: Integer;
    const textureMatrix0, textureMatrix1: PdFloat
  ): TNewtonMesh; cdecl; external NEWTON_API name 'NewtonMeshCreatePlane';

	//NEWTON_API int NewtonMeshConvexApproximation (
  //const NewtonMesh* mesh,
  //const NewtonWorld* world,
  //dFloat maxConvexity,
  //int maxCount,
  //NewtonCollision** convexArray) ;
  function NewtonMeshConvexApproximation(
    const mesh: TNewtonMesh;
    const world: TNewtonWorld;
    maxConvexity: dFloat;
    maxCount: Integer;
    convexArray: Pointer
  ): Integer; cdecl; external NEWTON_API name 'NewtonMeshConvexApproximation';


	//NEWTON_API void NewtonMeshDestroy(
  //const NewtonMesh*mesh);
  procedure NewtonMeshDestroy(
    const mesh: TNewtonMesh
  ); cdecl; external NEWTON_API name 'NewtonMeshDestroy';


	//NEWTON_API void NewtonMeshCalculateOOBB(
  //const NewtonMesh* mesh,
  //dFloat* matrix,
  //dFloat* x,
  //dFloat* y,
  //dFloat* z);
  procedure NewtonMeshCalculateOOBB(
    const mesh: TNewtonMesh;
    matrix: PdFloat;
    x, y, z: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonMeshCalculateOOBB';


	//NEWTON_API void NewtonMeshCalculateVertexNormals(
  //const NewtonMesh* mesh,
  //dFloat angleInRadians);
  procedure NewtonMeshCalculateVertexNormals(
    const mesh: TNewtonMesh;
    angleInRadians: dFloat
  ); cdecl; external NEWTON_API name 'NewtonMeshCalculateVertexNormals';

	//NEWTON_API void NewtonMeshApplySphericalMapping(
  //const NewtonMesh* mesh,
  //int material);
  procedure NewtonMeshApplySphericalMapping(
    const mesh: TNewtonMesh;
    material: Integer
  ); cdecl; external NEWTON_API name 'NewtonMeshApplySphericalMapping';

	//NEWTON_API void NewtonMeshApplyBoxMapping(
  //const NewtonMesh* mesh,
  //int front,
  //int side,
  //int top);
  procedure NewtonMeshApplyBoxMapping(
    const mesh: TNewtonMesh;
    front, side, top: Integer
  ); cdecl; external NEWTON_API name 'NewtonMeshApplyBoxMapping';

	//NEWTON_API void NewtonMeshApplyCylindricalMapping(
  //const NewtonMesh* mesh,
  //int cylinderMaterial,
  //int capMaterial);
  procedure NewtonMeshApplyCylindricalMapping(
    const mesh: TNewtonMesh;
    cylindricalMaterial, capMaterial: Integer
  ); cdecl; external NEWTON_API name 'NewtonMeshApplyCylindricalMapping';


	//NEWTON_API int NewtonMeshIsOpenMesh (
  //const NewtonMesh* mesh);
  function NewtonMeshIsOpenMesh(
    const mesh: TNewtonMesh
  ): Integer; cdecl; external NEWTON_API name 'NewtonMeshIsOpenMesh';

	//NEWTON_API void NewtonMeshPolygonize (
  //const NewtonMesh* mesh);
  procedure NewtonMeshPolygonize(
    const mesh: TNewtonMesh
  ); cdecl; external NEWTON_API name 'NewtonMeshPolygonize';

	//NEWTON_API void NewtonMeshTriangulate (
  //const NewtonMesh* mesh);
  procedure NewtonMeshTriangulate(
    const mesh: TNewtonMesh
  ); cdecl; external NEWTON_API name 'NewtonMeshTriangulate';

	//NEWTON_API NewtonMesh* NewtonMeshUnion (
  //const NewtonMesh* mesh,
  //const NewtonMesh* clipper,
  //const dFloat* clipperMatrix);
  function NewtonMeshUnion(
    const mesh, clipper: TNewtonMesh;
    const clipperMatrix: PdFloat
  ): TNewtonMesh; cdecl; external NEWTON_API name 'NewtonMeshUnion';

	//NEWTON_API NewtonMesh* NewtonMeshDifference (
  //const NewtonMesh* mesh,
  //const NewtonMesh* clipper,
  //const dFloat* clipperMatrix);
  function NewtonMeshDifference(
    const mesh, clipper: TNewtonMesh;
    const clipperMatrix: PdFloat
  ): TNewtonMesh; cdecl; external NEWTON_API name 'NewtonMeshDifference';

	//NEWTON_API NewtonMesh* NewtonMeshIntersection (
  //const NewtonMesh* mesh,
  //const NewtonMesh* clipper,
  //const dFloat* clipperMatrix);
  function NewtonMeshIntersection(
    const mesh, clipper: TNewtonMesh;
    const clipperMatrix: PdFloat
  ): TNewtonMesh; cdecl; external NEWTON_API name 'NewtonMeshIntersection';

	//NEWTON_API void NewtonMeshClip (
  //const NewtonMesh* mesh,
  //const NewtonMesh* clipper,
  //const dFloat* clipperMatrix,
  //NewtonMesh** topMesh,
  //NewtonMesh** bottomMesh);
  procedure NewtonMeshClip(
    const mesh, clipper: TNewtonMesh;
    const clipperMatrix: PdFloat;
    topMesh, bottomMesh: Pointer
  ); cdecl; external NEWTON_API name 'NewtonMeshClip';


	//NEWTON_API void NewtonMeshBeginFace(
  //const NewtonMesh *mesh);
  procedure NewtonMeshBeginFace(
    const mesh: TNewtonMesh
  ); cdecl; external NEWTON_API name 'NewtonMeshBeginFace';

	//NEWTON_API void NewtonMeshAddFace(
  //const NewtonMesh *mesh,
  //int vertexCount,
  //const dFloat* vertex,
  //int strideInBytes,
  //int materialIndex);
  procedure NewtonMeshAddFace(
    const mesh: TNewtonMesh;
    vertexCount: Integer;
    const vertex: PdFloat;
    strideInBytes: Integer;
    materialIndex: Integer
  ); cdecl; external NEWTON_API name 'NewtonMeshAddFace';

	//NEWTON_API void NewtonMeshEndFace(
  //const NewtonMesh *mesh);
  procedure NewtonMeshEndFace(
    const mesh: TNewtonMesh
  ); cdecl; external NEWTON_API name 'NewtonMeshEndFace';


	//NEWTON_API void NewtonMeshBuildFromVertexListIndexList(
  //const NewtonMesh *mesh,
  //int faceCount,
  //const int* const faceIndexCount,
  //const int* const faceMaterialIndex,
  //const dFloat* const vertex,
  //int vertexStrideInBytes,
  //const int* const vertexIndex,
  //const dFloat* const normal,
  //int normalStrideInBytes,
  //const int* const normalIndex,
  //const dFloat* const uv0,
  //int uv0StrideInBytes,
  //const int* const uv0Index,
  //const dFloat* const uv1,
  //int uv1StrideInBytes,
  //const int* const uv1Index);
  procedure NewtonMeshBuildFromVertexListIndexList(
    const mesh: TNewtonMesh;
    faceCount: Integer;
    const faceIndexCount: PInteger;
    const faceMaterialIndex: PInteger;
    const vertex: PdFloat;
    vertexStrideInBytes: Integer;
    const vertexIndex: PInteger;
    const normal: PdFloat;
    normalStrideInBytes: Integer;
    const normalIndex: PInteger;
    const uv0: PdFloat;
    uv0StrideInBytes: Integer;
    const uv0Index: PInteger;
    const uv1: PdFloat;
    uv1StrideInBytes: Integer;
    const uv1Index: PInteger
  ); cdecl; external NEWTON_API name 'NewtonMeshBuildFromVertexListIndexList';


	//NEWTON_API void NewtonMeshGetVertexStreams (
  //const NewtonMesh *mesh,
	//int vertexStrideInByte,
  //dFloat* vertex,
	//int normalStrideInByte,
  //dFloat* normal,
	//int uvStrideInByte0,
  //dFloat* uv0,
	//int uvStrideInByte1,
  //dFloat* uv1);
  procedure NewtonMeshGetVertexStreams (
    const mesh: TNewtonMesh;
    vertexStrideInBytes: Integer;
    vertex: PdFloat;
    normalStrideInBytes: Integer;
    normal: PdFloat;
    uv0StrideInBytes: Integer;
    uv0: PdFloat;
    uv1StrideInBytes: Integer;
    uv1: PdFloat
  ); cdecl; external NEWTON_API name 'NewtonMeshGetVertexStreams';

	//NEWTON_API void NewtonMeshGetIndirectVertexStreams(
  //const NewtonMesh *mesh,
	//int vertexStrideInByte,
  //dFloat* vertex,
  //int* vertexIndices,
  //int* vertexCount,
	//int normalStrideInByte,
  //dFloat* normal,
  //int* normalIndices,
  //int* normalCount,
	//int uvStrideInByte0,
  //dFloat* uv0,
  //int* uvIndices0,
  //int* uvCount0,
	//int uvStrideInByte1,
  //dFloat* uv1,
  //int* uvIndices1,
  //int* uvCount1);
  procedure NewtonMeshGetIndirectVertexStreams(
    const mesh: TNewtonMesh;
    vertexStrideInBytes: Integer;
    vertex: PdFloat;
    vertexIndices: PInteger;
    vertexCount: PInteger;
    normalStrideInBytes: Integer;
    normal: PdFloat;
    normalIndices: PInteger;
    normalCount: PInteger;
    uv0StrideInBytes: Integer;
    uv0: PdFloat;
    uv0Indices: PInteger;
    uv0Count: PInteger;
    uv1StrideInBytes: Integer;
    uv1: PdFloat;
    uv1Indices: PInteger;
    uv1Count: PInteger
  ); cdecl; external NEWTON_API name 'NewtonMeshGetIndirectVertexStreams';

	//NEWTON_API void* NewtonMeshBeginHandle (
  //const NewtonMesh *mesh);
  function NewtonMeshBeginHandle(
    const mesh: TNewtonMesh
  ): Pointer; cdecl; external NEWTON_API name 'NewtonMeshBeginHandle';

	//NEWTON_API void NewtonMeshEndHandle (
  //const NewtonMesh *mesh,
  //void* Handle);
  procedure NewtonMeshEndHandle(
    const mesh: TNewtonMesh;
    Handle: Pointer
  ); cdecl; external NEWTON_API name 'NewtonMeshEndHandle';

	//NEWTON_API int NewtonMeshFirstMaterial (
  //const NewtonMesh *mesh,
  //void* Handle);
  function NewtonMeshFirstMaterial(
    const mesh: TNewtonMesh;
    Handle: Pointer
  ): Integer; cdecl; external NEWTON_API name 'NewtonMeshFirstMaterial';

	//NEWTON_API int NewtonMeshNextMaterial (
  //const NewtonMesh *mesh,
  //void* Handle,
  //int materialId);
  function NewtonMeshNextMaterial(
    const mesh: TNewtonMesh;
    Handle: Pointer;
    materialID: Integer
  ): Integer; cdecl; external NEWTON_API name 'NewtonMeshNextMaterial';

	//NEWTON_API int NewtonMeshMaterialGetMaterial (
  //const NewtonMesh *mesh,
  //void* Handle,
  //int materialId);
  function NewtonMeshMaterialGetMaterial(
    const mesh: TNewtonMesh;
    Handle: Pointer;
    materialID: Integer
  ): Integer; cdecl; external NEWTON_API name 'NewtonMeshMaterialGetMaterial';

	//NEWTON_API int NewtonMeshMaterialGetIndexCount (
  //const NewtonMesh *mesh,
  //void* Handle,
  //int materialId);
  function NewtonMeshMaterialGetIndexCount(
    const mesh: TNewtonMesh;
    Handle: Pointer;
    materialID: Integer
  ): Integer; cdecl; external NEWTON_API name 'NewtonMeshMaterialGetIndexCount';

	//NEWTON_API void NewtonMeshMaterialGetIndexStream (
  //const NewtonMesh *mesh,
  //void* Handle,
  //int materialId,
  //int* index);
  procedure NewtonMeshMaterialGetIndexStream(
    const mesh: TNewtonMesh;
    Handle: Pointer;
    materialID: Integer;
    index: PInteger
  ); cdecl; external NEWTON_API name 'NewtonMeshMaterialGetIndexStream';

	//NEWTON_API void NewtonMeshMaterialGetIndexStreamShort (
  //const NewtonMesh *mesh,
  //void* Handle,
  //int materialId,
  //short int* index);
  procedure NewtonMeshMaterialGetIndexStreamShort(
    const mesh: TNewtonMesh;
    Handle: Pointer;
    materialID: Integer;
    Inder: PSmallInt
  ); cdecl; external NEWTON_API name 'NewtonMeshMaterialGetIndexStreamShort';


	//NEWTON_API NewtonMesh* NewtonMeshCreateFirstSingleSegment (
  //const NewtonMesh *mesh);
  function NewtonMeshCreateFirstSingleSegment(
    const mesh: TNewtonMesh
  ): TNewtonMesh; cdecl; external NEWTON_API name 'NewtonMeshCreateFirstSingleSegment';

	//NEWTON_API NewtonMesh* NewtonMeshCreateNextSingleSegment (
  //const NewtonMesh *mesh,
  //const NewtonMesh *segment);
  function NewtonMeshCreateNextSingleSegment(
    const mesh: TNewtonMesh;
    const segment: TNewtonMesh
  ): TNewtonMesh; cdecl; external NEWTON_API name 'NewtonMeshCreateNextSingleSegment';


	//NEWTON_API int NewtonMeshGetTotalFaceCount (
  //const NewtonMesh *mesh);
  function NewtonMeshGetTotalFaceCount(
    const mesh: TNewtonMesh
  ): Integer; cdecl; external NEWTON_API name 'NewtonMeshGetTotalFaceCount';

	//NEWTON_API int NewtonMeshGetTotalIndexCount (
  //const NewtonMesh *mesh);
  function NewtonMeshGetTotalIndexCount(
    const mesh: TNewtonMesh
  ): Integer; cdecl; external NEWTON_API name 'NewtonMeshGetTotalIndexCount';

	//NEWTON_API void NewtonMeshGetFaces (
  //const NewtonMesh *mesh,
  //int* const faceIndexCount,
  //int* const faceMaterial,
  //int* const faceIndices);
  procedure NewtonMeshGetFaces(
    const mesh: TNewtonMesh;
    const faceIndexCount: PInteger;
    const faceMaterial: PInteger;
    const faceIndices: PInteger
  ); cdecl; external NEWTON_API name 'NewtonMeshGetFaces';


	//NEWTON_API int NewtonMeshGetPointCount (
  //const NewtonMesh *mesh);
  function NewtonMeshGetPointCount(
    const mesh: TNewtonMesh
  ): Integer; cdecl; external NEWTON_API name 'NewtonMeshGetPointCount';

	//NEWTON_API int NewtonMeshGetPointStrideInByte (
  //const NewtonMesh *mesh);
  function NewtonMeshGetPointStrideInByte(
    const mesh: TNewtonMesh
  ): Integer; cdecl; external NEWTON_API name 'NewtonMeshGetPointStrideInByte';

	//NEWTON_API dFloat* NewtonMeshGetPointArray (
  //const NewtonMesh *mesh);
  function NewtonMeshGetPointArray(
    const mesh: TNewtonMesh
  ): PdFloat; cdecl; external NEWTON_API name 'NewtonMeshGetPointArray';


	//NEWTON_API int NewtonMeshGetVertexCount (
  //const NewtonMesh *mesh);
  function NewtonMeshGetVertexCount(
    const mesh: TNewtonMesh
  ): Integer; cdecl; external NEWTON_API name 'NewtonMeshGetVertexCount';

	//NEWTON_API int NewtonMeshGetVertexStrideInByte (
  //const NewtonMesh *mesh);
  function NewtonMeshGetVertexStrideInByte(
    const mesh: TNewtonMesh
  ): Integer; cdecl; external NEWTON_API name 'NewtonMeshGetVertexStrideInByte';

	//NEWTON_API dFloat* NewtonMeshGetVertexArray (
  //const NewtonMesh *mesh);
  function NewtonMeshGetVertexArray(
    const mesh: TNewtonMesh
  ): PdFloat; cdecl; external NEWTON_API name 'NewtonMeshGetVertexArray';


	//NEWTON_API void* NewtonMeshGetFirstVertex (
  //const NewtonMesh *mesh);
  function NewtonMeshGetFirstVertex(
    const mesh: TNewtonMesh
  ): Pointer; cdecl; external NEWTON_API name 'NewtonMeshGetFirstVertex';

	//NEWTON_API void* NewtonMeshGetNextVertex (
  //const NewtonMesh *mesh,
  //const void* vertex);
  function NewtonMeshGetNextVertex(
    const mesh: TNewtonMesh;
    const vertex: Pointer
  ): Pointer; cdecl; external NEWTON_API name 'NewtonMeshGetNextVertex';

	//NEWTON_API int NewtonMeshGetVertexIndex (
  //const NewtonMesh *mesh,
  //const void* vertex);
  function NewtonMeshGetVertexIndex(
    const mesh: TNewtonMesh;
    const vertex: Pointer
  ): Integer; cdecl; external NEWTON_API name 'NewtonMeshGetVertexIndex';


	//NEWTON_API void* NewtonMeshGetFirstPoint (
  //const NewtonMesh *mesh);
  function NewtonMeshGetFirstPoint(
    const mesh: TNewtonMesh
  ): Pointer; cdecl; external NEWTON_API name 'NewtonMeshGetFirstPoint';

	//NEWTON_API void* NewtonMeshGetNextPoint (
  //const NewtonMesh *mesh,
  //const void* point);
  function NewtonMeshGetNextPoint(
    const mesh: TNewtonMesh;
    const point: Pointer
  ): Pointer; cdecl; external NEWTON_API name 'NewtonMeshGetNextPoint';

	//NEWTON_API int NewtonMeshGetPointIndex (
  //const NewtonMesh *mesh,
  //const void* point);
  function NewtonMeshGetPointIndex(
    const mesh: TNewtonMesh;
    const point: Pointer
  ): Integer; cdecl; external NEWTON_API name 'NewtonMeshGetPointIndex';

	//NEWTON_API int NewtonMeshGetVertexIndexFromPoint (
  //const NewtonMesh *mesh,
  //const void* point);
  function NewtonMeshGetVertexIndexFromPoint(
    const mesh: TNewtonMesh;
    const point: Pointer
  ): Integer; cdecl; external NEWTON_API name 'NewtonMeshGetVertexIndexFromPoint';


	//NEWTON_API void* NewtonMeshGetFirstEdge (
  //const NewtonMesh *mesh);
  function NewtonMeshGetFirstEdge(
    const mesh: TNewtonMesh
  ): Pointer; cdecl; external NEWTON_API name 'NewtonMeshGetFirstEdge';

	//NEWTON_API void* NewtonMeshGetNextEdge (
  //const NewtonMesh *mesh,
  //const void* edge);
  function NewtonMeshGetNextEdge(
    const mesh: TNewtonMesh;
    const edge: Pointer
  ): Pointer; cdecl; external NEWTON_API name 'NewtonMeshGetNextEdge';

	//NEWTON_API void NewtonMeshGetEdgeIndices (
  //const NewtonMesh *mesh,
  //const void* edge,
  //int* v0,
  //int* v1);
  procedure NewotnMeshGetEdgeIndices(
    const mesh: TNewtonMesh;
    const edge: Pointer;
    v0, v1: PInteger
  ); cdecl; external NEWTON_API name 'NewtonMeshGetEdgeIndices';

//	NEWTON_API void NewtonMeshGetEdgePointIndices (const NewtonMesh *mesh, const void* edge, int* v0, int* v1);


	//NEWTON_API void* NewtonMeshGetFirstFace (
  //const NewtonMesh *mesh);
  function NewtonMeshGetFirstFace(
    const mesh: TNewtonMesh
  ): Pointer; cdecl; external NEWTON_API name 'NewtonMeshGetFirstFace';

	//NEWTON_API void* NewtonMeshGetNextFace (
  //const NewtonMesh *mesh,
  //const void* face);
  function NewtonMeshGetNextFace(
    const mesh: TNewtonMesh;
    const face: Pointer
  ): Pointer; cdecl; external NEWTON_API name 'NewtonMeshGetNextFace';

	//NEWTON_API int NewtonMeshIsFaceOpen (
  //const NewtonMesh *mesh,
  //const void* face);
  function NewtonMeshIsFaceOpen(
    const mesh: TNewtonMesh;
    const face: Pointer
  ): Integer; cdecl; external NEWTON_API name 'NewtonMeshIsFaceOpen';

	//NEWTON_API int NewtonMeshGetFaceMaterial (
  //const NewtonMesh *mesh,
  //const void* face);
  function NewtonMeshGetFaceMaterial(
    const mesh: TNewtonMesh;
    const face: Pointer
  ): Integer; cdecl; external NEWTON_API name 'NewtonMeshGetFaceMaterial';

	//NEWTON_API int NewtonMeshGetFaceIndexCount (
  //const NewtonMesh *mesh,
  //const void* face);
  function NewtonMeshGetFaceIndexCount(
    const mesh: TNewtonMesh;
    const face: Pointer
  ): Integer; cdecl; external NEWTON_API name 'NewtonMeshGetFaceIndexCount';

	//NEWTON_API void NewtonMeshGetFaceIndices (
  //const NewtonMesh *mesh,
  //const void* face,
  //int* indices);
  procedure NewtonMeshGetFaceIndices(
    const mesh: TNewtonMesh;
    const face: Pointer;
    indices: PInteger
  ); cdecl; external NEWTON_API name 'NewtonMeshGetFaceIndices';

	//NEWTON_API void NewtonMeshGetFacePointIndices (
  //const NewtonMesh *mesh,
  //const void* face,
  //int* indices);
  procedure NewtonMeshGetFacePointIndices(
    const mesh: TNewtonMesh;
    const face: Pointer;
    indices: PInteger
  ); cdecl; external NEWTON_API name 'NewtonMeshGetFacePointIndices';


	// **********************************************************************************************
	//
	// Rag doll joint container functions
	//
	// **********************************************************************************************
	//	NEWTON_API NewtonRagDoll* NewtonCreateRagDoll (const NewtonWorld* newtonWorld);
	//	NEWTON_API void NewtonDestroyRagDoll (const NewtonWorld* newtonWorld, const NewtonRagDoll* ragDoll);
	//	NEWTON_API void NewtonRagDollBegin (const NewtonRagDoll* ragDoll);
	//	NEWTON_API void NewtonRagDollEnd (const NewtonRagDoll* ragDoll);
	//	NEWTON_API NewtonRagDollBone* NewtonRagDollFindBone (const NewtonRagDoll* ragDoll, int id);
	//	NEWTON_API void NewtonRagDollSetForceAndTorqueCallback (const NewtonRagDoll* ragDoll, NewtonApplyForceAndTorque callback);
	//	NEWTON_API void NewtonRagDollSetTransformCallback (const NewtonRagDoll* ragDoll, NewtonSetRagDollTransform callback);
	//	NEWTON_API NewtonRagDollBone* NewtonRagDollAddBone (const NewtonRagDoll* ragDoll, const NewtonRagDollBone* parent,
	//		void *userData, dFloat mass, const dFloat* matrix,
	//		const NewtonCollision* boneCollision, const dFloat* size);
	//	NEWTON_API void* NewtonRagDollBoneGetUserData (const NewtonRagDollBone* bone);
	//	NEWTON_API NewtonBody* NewtonRagDollBoneGetBody (const NewtonRagDollBone* bone);
	//	NEWTON_API void NewtonRagDollBoneSetID (const NewtonRagDollBone* bone, int id);
	//	NEWTON_API void NewtonRagDollBoneSetLimits (const NewtonRagDollBone* bone,
	//		const dFloat* coneDir, dFloat minConeAngle, dFloat maxConeAngle, dFloat maxTwistAngle,
	//		const dFloat* bilateralConeDir, dFloat negativeBilateralConeAngle, dFloat positiveBilateralConeAngle);

	//	NEWTON_API void NewtonRagDollBoneGetLocalMatrix (const NewtonRagDollBone* bone, dFloat* matrix);
	//	NEWTON_API void NewtonRagDollBoneGetGlobalMatrix (const NewtonRagDollBone* bone, dFloat* matrix);


	// **********************************************************************************************
	//
	// Vehicle joint functions
	//
	// **********************************************************************************************
	//	NEWTON_API NewtonJoint* NewtonConstraintCreateVehicle (const NewtonWorld* newtonWorld, const dFloat* upDir, const NewtonBody* body);
	//	NEWTON_API void NewtonVehicleReset (const NewtonJoint* vehicle);
	//	NEWTON_API void NewtonVehicleSetTireCallback (const NewtonJoint* vehicle, NewtonVehicleTireUpdate update);
	//	NEWTON_API void* NewtonVehicleAddTire (const NewtonJoint* vehicle, const dFloat* localMatrix, const dFloat* pin, dFloat mass, dFloat width, dFloat radius, dFloat suspesionShock, dFloat suspesionSpring, dFloat suspesionLength, void* userData, int collisionID);
	//	NEWTON_API void NewtonVehicleRemoveTire (const NewtonJoint* vehicle, void* tireId);
	//	NEWTON_API void* NewtonVehicleGetFirstTireID (const NewtonJoint* vehicle);
	//	NEWTON_API void* NewtonVehicleGetNextTireID (const NewtonJoint* vehicle, void* tireId);
	//	NEWTON_API int NewtonVehicleTireIsAirBorne (const NewtonJoint* vehicle, void* tireId);
	//	NEWTON_API int NewtonVehicleTireLostSideGrip (const NewtonJoint* vehicle, void* tireId);
	//	NEWTON_API int NewtonVehicleTireLostTraction (const NewtonJoint* vehicle, void* tireId);
	//	NEWTON_API void* NewtonVehicleGetTireUserData (const NewtonJoint* vehicle, void* tireId);
	//	NEWTON_API dFloat NewtonVehicleGetTireOmega (const NewtonJoint* vehicle, void* tireId);
	//	NEWTON_API dFloat NewtonVehicleGetTireNormalLoad (const NewtonJoint* vehicle, void* tireId);
	//	NEWTON_API dFloat NewtonVehicleGetTireSteerAngle (const NewtonJoint* vehicle, void* tireId);
	//	NEWTON_API dFloat NewtonVehicleGetTireLateralSpeed (const NewtonJoint* vehicle, void* tireId);
	//	NEWTON_API dFloat NewtonVehicleGetTireLongitudinalSpeed (const NewtonJoint* vehicle, void* tireId);
	//	NEWTON_API void NewtonVehicleGetTireMatrix (const NewtonJoint* vehicle, void* tireId, dFloat* matrix);
	//	NEWTON_API void NewtonVehicleSetTireTorque (const NewtonJoint* vehicle, void* tireId, dFloat torque);
	//	NEWTON_API void NewtonVehicleSetTireSteerAngle (const NewtonJoint* vehicle, void* tireId, dFloat angle);
	//	NEWTON_API void NewtonVehicleSetTireMaxSideSleepSpeed (const NewtonJoint* vehicle, void* tireId, dFloat speed);
	//	NEWTON_API void NewtonVehicleSetTireSideSleepCoeficient (const NewtonJoint* vehicle, void* tireId, dFloat coeficient);
	//	NEWTON_API void NewtonVehicleSetTireMaxLongitudinalSlideSpeed (const NewtonJoint* vehicle, void* tireId, dFloat speed);
	//	NEWTON_API void NewtonVehicleSetTireLongitudinalSlideCoeficient (const NewtonJoint* vehicle, void* tireId, dFloat coeficient);
	//	NEWTON_API dFloat NewtonVehicleTireCalculateMaxBrakeAcceleration (const NewtonJoint* vehicle, void* tireId);
	//	NEWTON_API void NewtonVehicleTireSetBrakeAcceleration (const NewtonJoint* vehicle, void* tireId, dFloat accelaration, dFloat torqueLimit);


  // Generic joint call back and user data

	//typedef struct NewtonUserJoint{} NewtonUserJoint;
  type TNewtonUserJoint = Pointer;

	//typedef void (*NewtonUserJointDestructorCallback) (const NewtonUserJoint* me);
  type TNewtonUserJointDestructorCallback = procedure (const me: TNewtonUserJoint);

	//typedef void (*NewtonUserJointSubmitConstraintCallback) (const NewtonUserJoint* me, dFloat timestep, int threadIndex);
  type TNewtonUserJointSubmitConstraintCallback = procedure (const me: TNewtonUserJoint; timestep: dFloat; threadIndex: Integer);

	// generic joint functions

	//JOINTLIBRARY_API void CustomDestroyJoint(
  //const NewtonUserJoint *joint);
  procedure NewtonCustomDestroyJoint(
    const joint: TNewtonUserJoint
  ); cdecl; external JOINTLIBRARY_API name 'CustomDestroyJoint';

	//JOINTLIBRARY_API NewtonJoint* CustomGetNewtonJoint (
  //const NewtonUserJoint *joint);
  function NewtonCustomGetNewtonJoint(
    const joint: TNewtonUserJoint
  ): TNewtonJoint; cdecl; external JOINTLIBRARY_API name 'CustomGetNewtonJoint';

	//JOINTLIBRARY_API int CustomGetJointID (
  //const NewtonUserJoint *joint);
  function NewtonCustomGetJointID(
    const joint: TNewtonUserJoint
  ): Integer; cdecl; external JOINTLIBRARY_API name 'CustomGetJointID';

	//JOINTLIBRARY_API void CustomSetJointID (
  //const NewtonUserJoint *joint,
  //int rttI);
  procedure NewtonCustomSetJointID(
    const joint: TNewtonUserJoint;
    rttI: Integer
  ); cdecl; external JOINTLIBRARY_API name 'CustomSetJointID';

	//JOINTLIBRARY_API const NewtonBody* CustomGetBody0 (
  //const NewtonUserJoint *joint);
  function NewtonCustonGetBody0(
    const joint: TNewtonUserJoint
  ): TNewtonBody; cdecl; external JOINTLIBRARY_API name 'CustomGetBody0';

	//JOINTLIBRARY_API const NewtonBody* CustomGetBody1 (
  //const NewtonUserJoint *joint);
  function NewtonCustomGetBody1(
    const joint: TNewtonUserJoint
  ): TNewtonBody; cdecl; external JOINTLIBRARY_API name 'CustomGetBody1';

	//JOINTLIBRARY_API int CustomGetBodiesCollisionState (
  //const NewtonUserJoint *joint);
  function NewtonCustomGetBodiesCollisionState(
    const joint: TNewtonUserJoint
  ): Integer; cdecl; external JOINTLIBRARY_API name 'CustomGetBodiesCollisionState';

	//JOINTLIBRARY_API void CustomSetBodiesCollisionState (
  //const NewtonUserJoint *joint,
  //int state);
  procedure NewtonCustomSetBodiesCollisionState(
    const joint: TNewtonUserJoint;
    state: Integer
  ); cdecl; external JOINTLIBRARY_API name 'CustomSetBodiesCollisionState';

	//JOINTLIBRARY_API void* CustomGetUserData (
  //const NewtonUserJoint *joint);
  function NewtonCustomGetUserData(
    const joint: TNewtonUserJoint
  ): Pointer; cdecl; external JOINTLIBRARY_API name 'CustomGetUserData';

	//JOINTLIBRARY_API void CustomSetUserData (
  //const NewtonUserJoint *joint,
  //void* userData);
  procedure NewtonCustomSetUserData(
    const joint: TNewtonUserJoint;
    userData: Pointer
  ); cdecl; external JOINTLIBRARY_API name 'CustomSetUserData';

	//JOINTLIBRARY_API void CustomSetDestructorCallback (
  //const NewtonUserJoint *joint,
  //NewtonUserJointDestructorCallback callback);
  procedure NewtonCustomSetDestructorCallback(
    const joint: TNewtonUserJoint;
    callback: TNewtonUserJointDestructorCallback
  ); cdecl; external JOINTLIBRARY_API name 'CustomSetDestructorCallback';

	//JOINTLIBRARY_API void CustomSetSubmitContraintCallback (
  //const NewtonUserJoint *joint,
  //NewtonUserJointSubmitConstraintCallback callback);
  procedure NewtonCustomSetSubmitConstraintCallback(
    const joint: TNewtonUserJoint;
    callback: TNewtonUserJointSubmitConstraintCallback
  ); cdecl; external JOINTLIBRARY_API name 'CustomSetSubmitContraintCallback';


	// this is a plain blank joint that can be used by advanced users who want to make their own joints
	// but that can only use languages that can only interface with C code.
	// we recommend using the CPP library to make the joints and then add a C interface, but this join is here for completion
	//typedef void (*BlankJointGetInfo) (const NewtonUserJoint* me, NewtonJointRecord* info);
  type TBlankJointGetInfo = procedure (const me: TNewtonUserJoint; info: TNewtonJointRecord);

	//JOINTLIBRARY_API NewtonUserJoint* CustomCreateBlankJoint(
  //int maxDof,
  //const NewtonBody* body0,
  //const NewtonBody* body1,
  //BlankJointGetInfo info);
  function NewtonCustomCreateBlankJoint(
    maxDof: Integer;
    const body0, body1: TNewtonBody;
    info: TBlankJointGetInfo
  ): TNewtonUserJoint; cdecl; external JOINTLIBRARY_API name 'CustomCreateBlankJoint';


	// Kinematic control joint
	//JOINTLIBRARY_API NewtonUserJoint *CreateCustomKinematicController (
  //const NewtonBody* targetBody,
  //dFloat* attachmentPointInGlobalSpace);
  function NewtonCreateCustomKinematicController(
    const targetBody: TNewtonBody;
    attachmentPointInGlobalSpace: PdFloat
  ): TNewtonUserJoint; cdecl; external JOINTLIBRARY_API name 'CreateCustomKinematicController';

	//JOINTLIBRARY_API void CustomKinematicControllerSetPickMode (
  //const NewtonUserJoint *pick,
  //int mode);
  procedure NewtonCustomKinematicControllerSetPickMode(
    const pick: TNewtonUserJoint;
    mode: Integer
  ); cdecl; external JOINTLIBRARY_API name 'CustomKinematicControllerSetPickMode';

	//JOINTLIBRARY_API void CustomKinematicControllerSetMaxLinearFriction(
  //const NewtonUserJoint *pick,
  //dFloat accel);
  procedure NewtonCustomKinematicControllerSetMaxLinearFriction(
    const pick: TNewtonUserJoint;
    accel: dFloat
  ); cdecl; external JOINTLIBRARY_API name 'CustomKinematicControllerSetMaxLinearFriction';

	//JOINTLIBRARY_API void CustomKinematicControllerSetMaxAngularFriction(
  //const NewtonUserJoint *pick,
  //dFloat alpha);
  procedure NewtonCustomKinematicControllerSetMaxAngularFriction(
    const pick: TNewtonUserJoint;
    alpha: dFloat
  ); cdecl; external JOINTLIBRARY_API name 'CustomKinematicControllerSetMaxAngularFriction';

	//JOINTLIBRARY_API void CustomKinematicControllerSetTargetPosit (
  //const NewtonUserJoint *pick,
  //dFloat* posit);
  procedure NewtonCustomKinematicControllerSetTargetPosit(
    const pick: TNewtonUSerJoint;
    posit: PdFloat
  ); cdecl; external JOINTLIBRARY_API name 'CustomKinematicControllerSetTargetPosit';

	//JOINTLIBRARY_API void CustomKinematicControllerSetTargetRotation (
  //const NewtonUserJoint *pick,
  //dFloat* rotation);
  procedure NewtonCustomKinematicControllerSetTargetRotation(
    const pick: TNewtonUserJoint;
    rotation: PdFloat
  ); cdecl; external JOINTLIBRARY_API name 'CustomKinematicControllerSetTargetRotation';

	//JOINTLIBRARY_API void CustomKinematicControllerSetTargetMatrix (
  //const NewtonUserJoint *pick,
  //dFloat* matrix);
  procedure NewtonCustomKinematicControllerSetTargetMatrix(
    const pici: TNewtonUserJoint;
    matrix: PdFloat
  ); cdecl; external JOINTLIBRARY_API name 'CustomKinematicControllerSetTargetMatrix';

	//JOINTLIBRARY_API void CustomKinematicControllerGetTargetMatrix (
  //const NewtonUserJoint *pick,
  //dFloat* matrix);
  procedure NewtonKinematicControllerGetTargetMatrix(
    const pick: TNewtonUserJoint;
    matrix: PdFloat
  ); cdecl; external JOINTLIBRARY_API name 'CustomKinematicControllerGetTargetMatrix';


	// Generic 6 degree of Freedom Joint

	//JOINTLIBRARY_API NewtonUserJoint *CreateCustomJoint6DOF (
  //const dFloat* pinsAndPivoChildFrame,
  //const dFloat* pinsAndPivoParentFrame,
  //const NewtonBody* child, const NewtonBody* parent);
  function NewtonCreateCustomJoint6DOF(
    const pinsAndPivoChildFrame: PdFloat;
    const pinsAndPivoParentFrame: PdFloat;
    const child, parent: TNewtonBody
  ): TNewtonUserJoint; cdecl; external JOINTLIBRARY_API name 'CreateCustomJoint6DOF';

	//JOINTLIBRARY_API void CustomJoint6DOF_SetLinearLimits (
  //NewtonUserJoint* customJoint6DOF,
  //const dFloat* minLinearLimits,
  //const dFloat* maxLinearLimits);
  procedure NewtonCustom6DOF_SetLinearLimits(
    customJoint6DOF: TNewtonUserJoint;
    const minLinearLimits: PdFloat;
    const maxLinearLimits: PdFloat
  ); cdecl; external JOINTLIBRARY_API name 'CustomJoint6DOF_SetLinearLimits';

	//JOINTLIBRARY_API void CustomJoint6DOF_SetAngularLimits (
  //NewtonUserJoint* customJoint6DOF,
  //const dFloat* minAngularLimits,
  //const dFloat* maxAngularLimits);
  procedure NewtonCustom6DOF_SetAngularLimits(
    customJoint6DOF: TNewtonUserJoint;
    const minAngularLimits: PdFloat;
    const maxAngularLimits: PdFloat
  ); cdecl; external JOINTLIBRARY_API name 'CustomJoint6DOF_SetAngularLimits';

	//JOINTLIBRARY_API void CustomJoint6DOF_GetLinearLimits (
  //NewtonUserJoint* customJoint6DOF,
  //dFloat* minLinearLimits,
  //dFloat* maxLinearLimits);
  procedure NewtonCustomJoint6DOF_GetLinearLimits(
    customJoint6DOF: TNewtonUserJoint;
    minLinearLimits: PdFloat;
    maxLinearLimits: PdFloat
  ); cdecl; external JOINTLIBRARY_API name 'CustomJoint6DOF_GetLinearLimits';

	//JOINTLIBRARY_API void CustomJoint6DOF_GetAngularLimits (
  //NewtonUserJoint* customJoint6DOF,
  //dFloat* minAngularLimits,
  //dFloat* maxAngularLimits);
  procedure NewtonCustomJoint6DOF_GetAngularLimits(
    customJoint6DOF: TNewtonUserJoint;
    minAngularLimits: PdFloat;
    maxAngularLimits: PdFloat
  ); cdecl; external JOINTLIBRARY_API name 'CustomJoint6DOF_GetAngularLimits';

	//JOINTLIBRARY_API void CustomJoint6DOF_SetReverseUniversal (
  //NewtonUserJoint* customJoint6DOF,
  //int order);
  procedure NewtonCustomJoint6DOF_SetReverseUniversal(
    customJoint6DOF: TNewtonUserJoint;
    order: Integer
  ); cdecl; external JOINTLIBRARY_API name 'CustomJoint6DOF_SetReverseUniversal';


	// Interface for a custom BallAndSocket joint with Limits
	//JOINTLIBRARY_API NewtonUserJoint *CreateCustomBallAndSocket (
  //const dFloat* pinsAndPivoChildFrame,
  //const NewtonBody* child,
  //const NewtonBody* parent);
  function NewtonCreateCustomBallAndSocket(
    const pinsAndPivoChildFrame: PdFloat;
    const child, parent: TNewtonBody
  ): TNewtonUserJoint; cdecl; external JOINTLIBRARY_API name 'CreateCustomBallAndSocket';

	//JOINTLIBRARY_API void BallAndSocketSetConeAngle (
  //NewtonUserJoint* ballJoint,
  //dFloat angle);
  procedure NewtonBallAndSocketSetConeAngle(
    ballJoint: TNewtonUserJoint;
    angle: dFloat
  ); cdecl; external JOINTLIBRARY_API name 'BallAndSocketSetConeAngle';

	//JOINTLIBRARY_API void BallAndSocketSetTwistAngle (
  //NewtonUserJoint* ballJoint,
  //dFloat minAngle,
  //dFloat maxAngle);
  procedure NewtonBallAnsSocketSetTwistAngle(
    ballJoint: TNewtonUserJoint;
    minAngle: dFloat;
    maxAngle: dFloat
  ); cdecl; external JOINTLIBRARY_API name 'BallAndSocketSetTwistAngle';


	// Interface for a custom Hinge joint with Limits

	//JOINTLIBRARY_API NewtonUserJoint *CreateCustomHinge (
  //const dFloat* pinsAndPivoChildFrame,
  //const NewtonBody* child,
  //const NewtonBody* parent);
  function NewtonCreateCustomHinge(
    const pinsAndPivoChildFrame: PdFloat;
    const child, parent: TNewtonBody
  ): TNewtonUserJoint; cdecl; external JOINTLIBRARY_API name 'CreateCustomHinge';

	//JOINTLIBRARY_API void HingeEnableLimits(
  //NewtonUserJoint* hingeJoint,
  //int state);
  procedure NewtonCustomHingeEnableLimits(
    hingeJoint: TNewtonUserJoint;
    state: Integer
  ); cdecl; external JOINTLIBRARY_API name 'HingeEnableLimits';

	//JOINTLIBRARY_API void HingeSetLimis (
  //NewtonUserJoint* hingeJoint,
  //dFloat minAngle,
  //dFloat maxAngle);
  procedure NewtonCustomHingeSetLimits(
    hingeJoint: TNewtonUserJoint;
    minAngle: dFloat;
    maxAngle: dFloat
  ); cdecl; external JOINTLIBRARY_API name 'HingeSetLimis';

	//JOINTLIBRARY_API dFloat HingeGetJointAngle (
  //const NewtonUserJoint* hingeJoint);
  function NewtonCustomHingeGetJointAngle(
    const hingeJoint: TNewtonUserJoint
  ): dFloat; cdecl; external JOINTLIBRARY_API name 'HingeGetJointAngle';

	//JOINTLIBRARY_API void HingeGetPinAxis (
  //const NewtonUserJoint* hingeJoint,
  //dFloat* pin);
  procedure NewtonCustomHingeGetPinAxis(
    const hingeJoint: TNewtonUserJoint;
    pin: PdFloat
  ); cdecl; external JOINTLIBRARY_API name 'HingeGetPinAxis';

	//JOINTLIBRARY_API dFloat HingeCalculateJointOmega (
  //const NewtonUserJoint* hingeJoint);
  function NewtonCustomHingeCalculateJointOmega(
    const hingeJoint: TNewtonUserJoint
  ): dFloat; cdecl; external JOINTLIBRARY_API name 'HingeCalculateJointOmega';


	// Interface for a custom Slider joint with Limits

	//JOINTLIBRARY_API NewtonUserJoint *CreateCustomSlider (
  //const dFloat* pinsAndPivoChildFrame,
  //const NewtonBody* child,
  //const NewtonBody* parent);
  function NewtonCreateCustomSlider(
    const pinsAndPivoChildFrame: PdFloat;
    const child, parent: TNewtonBody
  ): TNewtonUserJoint; cdecl; external JOINTLIBRARY_API name 'CreateCustomSlider';

	//JOINTLIBRARY_API void SliderEnableLimits(
  //NewtonUserJoint* sliderJoint,
  //int state);
  procedure NewtonSliderEnableLimits(
    sliderJoint: TNewtonUserJoint;
    state: Integer
  ); cdecl; external JOINTLIBRARY_API name 'SliderEnableLimits';

	//JOINTLIBRARY_API void SliderSetLimis (
  //NewtonUserJoint* sliderJoint,
  //dFloat mindist,
  //dFloat maxdist);
  procedure NewtonSliderSetLimits(
    sliderJoint: TNewtonUSerJoint;
    mindist, maxdist: dFloat
  ); cdecl; external JOINTLIBRARY_API name 'SliderSetLimis';


	// player controller functions

//	typedef int (*PlayerCanPuchThisBodyCalback) (NewtonUserJoint *me, const NewtonBody* hitBody);

	//JOINTLIBRARY_API NewtonUserJoint *CreateCustomPlayerController (
  //const dFloat* pins,
  //const NewtonBody* player,
  //dFloat maxStairStepFactor,
  //dFloat cushion);
  function NewtonCreateCustomPlayerController(
    const pins: PdFloat;
    const player: TNewtonBody;
    maxStairStepFactor: dFloat;
    cushion: dFloat
  ): TNewtonUserJoint; cdecl; external JOINTLIBRARY_API name 'CreateCustomPlayerController';

	//JOINTLIBRARY_API void CustomPlayerControllerSetVelocity (
  //const NewtonUserJoint* playerController,
  //dFloat forwardSpeed,
  //dFloat sideSpeed,
  //dFloat heading);
  procedure NewtonCustomPlayerControllerSetVelocity(
    const playerController: TNewtonUserJoint;
    forwardSpeed, sideSpeed, heading: dFloat
  ); cdecl; external JOINTLIBRARY_API name 'CustomPlayerControllerSetVelocity';

	//JOINTLIBRARY_API void CustomPlayerControllerGetVisualMaTrix (
  //const NewtonUserJoint* playerController,
  //dFloat* matrix);
  procedure NewtonCustomPlayerControllerGetVisualMatrix(
    const playerController: TNewtonUserJoint;
    matrix: PdFloat
  ); cdecl; external JOINTLIBRARY_API name 'CustomPlayerControllerGetVisualMaTrix';

	//JOINTLIBRARY_API dFloat CustomPlayerControllerGetMaxSlope (
  //const NewtonUserJoint* playerController);
  function NewtonCustomPlayerControllerGetMaxSlope(
    const playerController: TNewtonUserJoint
  ): dFloat; cdecl; external JOINTLIBRARY_API name 'CustomPlayerControllerGetMaxSlope';

	//JOINTLIBRARY_API void CustomPlayerControllerSetMaxSlope (
  //const NewtonUserJoint* playerController,
  //dFloat maxSlopeAngleIndRadian);
  procedure NewtonCustomPlayerControllerSetMaxSlope(
    const playerController: TNewtonUserJoint;
    maxSlopeAngleInRadians: dFloat
  ); cdecl; external JOINTLIBRARY_API name 'CustomPlayerControllerSetMaxSlope';

	//JOINTLIBRARY_API const NewtonCollision* CustomPlayerControllerGetSensorShape (
  //const NewtonUserJoint* playerController);
  function NewtonCustomPlayerControllerGetSensorShape(
    const playerController: TNewtonUserJoint
  ): TNewtonCollision; cdecl; external JOINTLIBRARY_API name 'CustomPlayerControllerGetSensorShape';


//	JOINTLIBRARY_API void CustomPlayerControllerSetPushActorCallback (NewtonUserJoint* playerController, PlayerCanPuchThisBodyCalback callback);
//	JOINTLIBRARY_API const NewtonCollision* CustomPlayerControllerGetVerticalSensorShape (NewtonUserJoint* playerController);
//	JOINTLIBRARY_API const NewtonCollision* CustomPlayerControllerGetDynamicsSensorShape (NewtonUserJoint* playerController);


	// Multi rigid BodyCar controller functions

//	JOINTLIBRARY_API NewtonUserJoint *CreateCustomMultiBodyVehicle (const dFloat* frontDir, const dFloat* upDir, const NewtonBody* carBody);
//	JOINTLIBRARY_API int CustomMultiBodyVehicleAddTire (NewtonUserJoint *car, const void* userData, const dFloat* localPosition,
//													    dFloat mass, dFloat radius, dFloat width,
//													    dFloat suspensionLength, dFloat springConst, dFloat springDamper);
//	JOINTLIBRARY_API int CustomMultiBodyVehicleAddSlipDifferencial (NewtonUserJoint *car, int leftTireIndex, int rightToreIndex, dFloat maxFriction);
//	JOINTLIBRARY_API int CustomMultiBodyVehicleGetTiresCount(NewtonUserJoint *car);
//	JOINTLIBRARY_API const NewtonBody* CustomMultiBodyVehicleGetTireBody(NewtonUserJoint *car, int tireIndex);
//	JOINTLIBRARY_API dFloat CustomMultiBodyVehicleGetSpeed(NewtonUserJoint *car);
//	JOINTLIBRARY_API dFloat CustomMultiBodyVehicleGetTireSteerAngle (NewtonUserJoint *car, int index);
//	JOINTLIBRARY_API void CustomMultiBodyVehicleApplyTorque (NewtonUserJoint *car, int tireIndex, dFloat torque);
//	JOINTLIBRARY_API void CustomMultiBodyVehicleApplySteering (NewtonUserJoint *car, int tireIndex, dFloat angle);
//	JOINTLIBRARY_API void CustomMultiBodyVehicleApplyBrake (NewtonUserJoint *car, int tireIndex, dFloat brakeTorque);
//	JOINTLIBRARY_API void CustomMultiBodyVehicleApplyTireRollingDrag (NewtonUserJoint *car, int index, dFloat angularDampingCoef);


	// BEGIN k00m (Dave Gravel simple ray cast world vehicle)

	//typedef void (*DGRaycastVehicleTireTransformCallback) (NewtonUserJoint *car);

  type TDGRaycastVehicleTireTransformCallback = procedure (car: TNewtonUserJoint);

  //JOINTLIBRARY_API NewtonUserJoint *DGRaycastVehicleCreate (
  //int maxTireCount,
  //const dFloat* cordenateSytemInLocalSpace,
  //NewtonBody* carBody);
  function DGRaycastVehicleCreate(
    maxTireCount: Integer;
    const cordenateSystemInLocalSpace: PdFloat;
    carBody: TNewtonBody
  ): TNewtonUSerJoint; cdecl; external JOINTLIBRARY_API name 'DGRaycastVehicleCreate';

	//JOINTLIBRARY_API void DGRaycastVehicleAddTire (
  //NewtonUserJoint *car,
  //void *userData,
  //const dFloat* localPosition,
  //dFloat mass,
  //dFloat radius,
  //dFloat width,
  //dFloat friction,
  //dFloat suspensionLength,
  //dFloat springConst,
  //dFloat springDamper,
  //int castMode);
  procedure DGRaycastVehicleAddTire(
    car: TNewtonUserJoint;
    userData: Pointer;
    const localPosition: PdFloat;
    mass, radius, width, friction, suspensionLength, springCount, springDamper: dFloat;
    castMode: Integer
  ); cdecl; external JOINTLIBRARY_API name 'DGRaycastVehicleAddTire';

	//JOINTLIBRARY_API void DGRaycastVehicleSetTireTransformCallback (
  //NewtonUserJoint *car,
  //DGRaycastVehicleTireTransformCallback callback);
  procedure DGRaycastVehicleSetTireTransformCallback(
    car: TNewtonUSerJoint;
    callback: TDGRaycastVehicleTireTransformCallback
  ); cdecl; external JOINTLIBRARY_API name 'DGRaycastVehicleSetTireTransformCallback';

	//JOINTLIBRARY_API int DGRaycastVehicleGetTiresCount(
  //NewtonUserJoint *car);
  function DGRaycastVehicleGetTiresCount(
    car: TNewtonUSerJoint
  ): Integer; cdecl; external JOINTLIBRARY_API name 'DGRaycastVehicleGetTiresCount';

	//JOINTLIBRARY_API void* DGRaycastVehicleGetTiresUserData(
  //NewtonUserJoint *car,
  //int tireIndex);
  function DGRaycastVehicleGetTiresUserData(
    car: TNewtonUSerJoint;
    tireIndex: Integer
  ): Pointer; cdecl; external JOINTLIBRARY_API name 'DGRaycastVehicleGetTiresUserData';

  //JOINTLIBRARY_API void DGRaycastVehicleGetTireMatrix(
  //NewtonUserJoint *car,
  //int tireIndex,
  //dFloat* tireMatrix);
  procedure DGRaycastVehicleGetTireMatrix(
    car: TNewtonUserJoint;
    tireIndex: Integer;
    tireMatrix: PdFloat
  ); cdecl; external JOINTLIBRARY_API name 'DGRaycastVehicleGetTireMatrix';


	//JOINTLIBRARY_API void DGRaycastVehicleInitNormalizeTireLateralForce(
  //NewtonUserJoint *car,
  //int pointsCount,
  //dFloat* const piceSizeStepAxis,
  //dFloat* const normalizedForceValue);
  procedure DGRaycastVehicleInitNormalizeTireLateralForce(
    car: TNewtonUSerJoint;
    pointsCount: Integer;
    const piceSizeStepAxis: PdFloat;
    const normalizedForceValue: PdFloat
  ); cdecl; external JOINTLIBRARY_API name 'DGRaycastVehicleInitNormalizeTireLateralForce';

	//JOINTLIBRARY_API void DGRaycastVehicleInitNormalizeTireLongitudinalForce(
  //NewtonUserJoint *car,
  //int pointsCount,
  //dFloat* const piceSizeStepAxis,
  //dFloat* const normalizedForceValue);
  procedure DGRaycastVehicleInitNormalizeTireLongitudinalForce(
    car: TNewtonUserJoint;
    pointsCount: Integer;
    const piceSizeStepAxis: PdFloat;
    const normalizedForceValue: PdFloat
  ); cdecl; external JOINTLIBRARY_API name 'DGRaycastVehicleInitNormalizeTireLongitudinalForce';


//	JOINTLIBRARY_API void DGRayCarGetChassisMatrixLocal(NewtonUserJoint *car, dFloat* chassisMatrix);
//	JOINTLIBRARY_API void DGRayCarTireMatrix(NewtonUserJoint *car, int tire, dFloat* tireMatrix);
//	JOINTLIBRARY_API void DGRayCarSuspensionMatrix(NewtonUserJoint *car, int tire, dFloat param, dFloat* SuspensionMatrix);
//	JOINTLIBRARY_API const NewtonCollision* DGRayCarTireShape(NewtonUserJoint *car, int tireIndex);
//	JOINTLIBRARY_API dFloat DGRaycastVehicleGetSpeed(NewtonUserJoint *car);
//	JOINTLIBRARY_API void DGRaycastVehicleSetCustomTireBrake (NewtonUserJoint *car, int index, dFloat torque);
//	JOINTLIBRARY_API void DGRaycastVehicleSetCustomTireTorque (NewtonUserJoint *car, int index, dFloat torque);
//	JOINTLIBRARY_API void DGRaycastVehicleSetCustomTireSteerAngleForce (NewtonUserJoint *car, int index, dFloat angle, dFloat turnforce);
//	JOINTLIBRARY_API dFloat DGRaycastVehicleGenerateTiresBrake (NewtonUserJoint *car, dFloat value);
//	JOINTLIBRARY_API dFloat DGRaycastVehicleGenerateTiresTorque (NewtonUserJoint *car, dFloat value);
//	JOINTLIBRARY_API dFloat DGRaycastVehicleGenerateTiresSteerForce (NewtonUserJoint *car, dFloat value);
//	JOINTLIBRARY_API dFloat DGRaycastVehicleGenerateTiresSteerAngle (NewtonUserJoint *car, dFloat value);
//	JOINTLIBRARY_API void DGRaycastVehicleSetVarTireMovePointForceFront (NewtonUserJoint *car, int index, dFloat distance);
//	JOINTLIBRARY_API void DGRaycastVehicleSetVarTireMovePointForceRight (NewtonUserJoint *car, int index, dFloat distance);
//	JOINTLIBRARY_API void DGRaycastVehicleSetVarTireMovePointForceUp (NewtonUserJoint *car, int index, dFloat distance);
//	JOINTLIBRARY_API void DGRaycastVehicleSetVarFixDeceleration (NewtonUserJoint *car, dFloat value);
//	JOINTLIBRARY_API void DGRaycastVehicleSetVarChassisRotationLimit (NewtonUserJoint *car, dFloat value);
//	JOINTLIBRARY_API void DGRaycastVehicleSetVarMaxSteerAngle (NewtonUserJoint *car, dFloat value);
//	JOINTLIBRARY_API void DGRaycastVehicleSetVarMaxSteerRate (NewtonUserJoint *car, dFloat value);
//	JOINTLIBRARY_API void DGRaycastVehicleSetVarMaxSteerForceRate (NewtonUserJoint *car, dFloat value);
//	JOINTLIBRARY_API void DGRaycastVehicleSetVarMaxSteerForce (NewtonUserJoint *car, dFloat value);
//	JOINTLIBRARY_API void DGRaycastVehicleSetVarMaxSteerSpeedRestriction (NewtonUserJoint *car, dFloat value);
//	JOINTLIBRARY_API void DGRaycastVehicleSetVarMaxBrakeForce (NewtonUserJoint *car, dFloat value);
//	JOINTLIBRARY_API void DGRaycastVehicleSetVarMaxTorque (NewtonUserJoint *car, dFloat value);
//	JOINTLIBRARY_API void DGRaycastVehicleSetVarMaxTorqueRate (NewtonUserJoint *car, dFloat value);
//	JOINTLIBRARY_API void DGRaycastVehicleSetVarEngineSteerDiv (NewtonUserJoint *car, dFloat value);
//	JOINTLIBRARY_API void DGRaycastVehicleSetVarTireSuspenssionHardLimit (NewtonUserJoint *car, int index, dFloat value);
//	JOINTLIBRARY_API void DGRaycastVehicleSetVarTireFriction (NewtonUserJoint *car, int index, dFloat value);
//	JOINTLIBRARY_API int DGRaycastVehicleGetVehicleOnAir(NewtonUserJoint *car);
//	JOINTLIBRARY_API int DGRaycastVehicleGetTireOnAir(NewtonUserJoint *car, int index);
//	JOINTLIBRARY_API void DGRaycastVehicleDestroy (NewtonUserJoint *car);

implementation

end.
