Newton Module (2-22-7)

BlitzMax Forums/BlitzMax Programming/Newton Module (2-22-7)

Here is my Newton module for BlitzMax, as of February 22, 2007:
Strict

Module Pub.Newton

Import Pub.Win32

Extern
	Function FreeLibrary(hlib:Int)="FreeLibrary@4"
EndExtern

'================================================
' World Functions
'================================================
Global NewtonTreeCollisionGetVertexListIndexListInAABB:Int(collision:Byte Ptr,p0:Byte Ptr,p1:Byte Ptr,vertexarray:Byte Ptr,vertexcount:Byte Ptr,vertexstride:Byte Ptr,indicelist:Byte Ptr,indicelistsize:Int)
Global NewtonWorldForEachBodyInAABBDo(world:Byte Ptr,p0:Byte Ptr,p1:Byte Ptr,callback:Byte Ptr)

Global NewtonCreate:Byte Ptr( mallocFnt: Byte Ptr, mfreeFnt:Byte Ptr)
Global NewtonDestroy(nWorld: Byte Ptr)
Global NewtonUpdate(newtonWorld: Byte Ptr, time:Float)
Global NewtonDestroyAllBodies(newtonWorld: Byte Ptr)
Global NewtonSetSolverModel(newtonWorld:Byte Ptr, model:Int)
Global NewtonSetFrictionModel(newtonWorld:Byte Ptr, model:Int)
Global NewtonGetTimeStep:Float(newtonWorld:Byte Ptr)
Global NewtonSetMinimumFrameRate(newtonWorld:Byte Ptr, frameRate:Float)
Global NewtonSetBodyLeaveWorldEvent(newtonWorld:Byte Ptr, BodyLeaveWorld_callback:Byte Ptr)
Global NewtonSetWorldSize(newtonWorld: Byte Ptr, minPoint: Byte Ptr, maxPoint:Byte Ptr)
Global NewtonWorldFreezeBody(newtonWorld:Byte Ptr, body:Byte Ptr)
Global NewtonWorldUnfreezeBody(newtonWorld: Byte Ptr, body:Byte Ptr)
Global NewtonWorldForEachBodyDo(newtonWorld:Byte Ptr, BodyIterator_callback:Byte Ptr)
Global NewtonWorldSetUserData(newtonWorld:Byte Ptr, userData:Byte Ptr)
Global NewtonWorldGetUserData:Byte Ptr(newtonWorld:Byte Ptr)
Global NewtonWorldGetVersion:Int(newtonWorld:Byte Ptr)
Global NewtonWorldRayCast(newtonWorld:Byte Ptr, p0:Byte Ptr, p1:Byte Ptr, WorldRayFilterCallback:Byte Ptr, userData:Byte Ptr,WorldRayPrefilterCallback:Byte Ptr)
Global NewtonWorldCollide:Int(newtonWorld:Byte Ptr, maxSize:Int,collsionA:Byte Ptr, matrixA:Byte Ptr, collsionB:Byte Ptr, matrixB:Byte Ptr, contacts:Byte Ptr, normals:Byte Ptr, penetration:Byte Ptr)
Global NewtonMaterialGetDefaultGroupID:Int(newtonWorld:Byte Ptr)
Global NewtonMaterialCreateGroupID:Int(newtonWorld:Byte Ptr)
Global NewtonMaterialDestroyAllGroupID(newtonWorld:Byte Ptr)
Global NewtonMaterialSetDefaultSoftness(newtonWorld:Byte Ptr, id0:Int, id1:Int, value:Float)
Global NewtonMaterialSetDefaultElasticity(newtonWorld:Byte Ptr, id0:Int, id1:Int, elasticCoef:Float)
Global NewtonMaterialSetDefaultCollidable(newtonWorld:Byte Ptr, id0:Int, id1:Int, state:Int)
Global NewtonMaterialSetDefaultFriction(newtonWorld:Byte Ptr, id0:Int, id1:Int, staticFriction:Float, kineticFriction:Float)
Global NewtonMaterialSetCollisionCallback(newtonWorld:Byte Ptr, id0:Int, id1:Int, userData:Byte Ptr, begin:Byte Ptr, process:Byte Ptr, NEnd:Byte Ptr)
Global NewtonMaterialGetUserData:Byte Ptr(newtonWorld:Byte Ptr, id0:Int, id1:Int)
Global NewtonMaterialDisableContact (material:Byte Ptr)
Global NewtonMaterialGetCurrentTimestep:Float(material:Byte Ptr)
Global NewtonMaterialGetMaterialPairUserData:Byte Ptr(material:Byte Ptr)
Global NewtonMaterialGetContactFaceAttribute:Int(material: Byte Ptr)
Global NewtonMaterialGetBodyCollisionID:Int(material: Byte Ptr, body:Byte Ptr)
Global NewtonMaterialGetContactNormalSpeed:Float(material:Byte Ptr, contactlHandle:Byte Ptr)
Global NewtonMaterialGetContactForce(material: Byte Ptr, force:Byte Ptr)
Global NewtonMaterialGetContactPositionAndNormal(material:Byte Ptr, posit:Byte Ptr, normal:Byte Ptr)
Global NewtonMaterialGetContactTangentDirections(material:Byte Ptr, dir0:Byte Ptr, dir:Byte Ptr)
Global NewtonMaterialGetContactTangentSpeed:Float(material:Byte Ptr, NewtonContact:Byte Ptr, index:Int)

Global NewtonBodySetCentreOfMass(body:Byte Ptr,pos:Byte Ptr)

Global NewtonMaterialSetContactNormalAcceleration(material:Byte Ptr,vec:Byte Ptr)

Global NewtonSetPlatformArchitecture(world:Byte Ptr,mode:Int)

Global NewtonMaterialSetContactSoftness(NewtonMaterial:Byte Ptr, softness:Float)
Global NewtonMaterialSetContactElasticity(NewtonMaterial:Byte Ptr, restitution:Float)
Global NewtonMaterialSetContactFrictionState(NewtonMaterial:Byte Ptr, state:Int, index:Int)
Global NewtonMaterialSetContactStaticFrictionCoef(NewtonMaterial:Byte Ptr, coef:Float, index:Int)
Global NewtonMaterialSetContactKineticFrictionCoef(NewtonMaterial:Byte Ptr, coef:Float, index:Int)
Global NewtonMaterialSetContactTangentAcceleration(NewtonMaterial:Byte Ptr, accel:Float, index:Int)

Global NewtonMaterialSetContactNormalDirection(NewtonMaterial:Byte Ptr,normal:Byte Ptr)

Global NewtonMaterialContactRotateTangentDirections(NewtonMaterial:Byte Ptr, directionVector:Byte Ptr)

'================================================
' convex collision primitives creation functions
'================================================
Global NewtonCreateNull:Byte Ptr(newtonWorld:Byte Ptr)	'NewtonCollision
Global NewtonCreateSphere:Byte Ptr(newtonWorld:Byte Ptr, radiusX:Float, radiusY:Float, radiusZ:Float, offsetMatrix:Byte Ptr)
Global NewtonCreateBox:Byte Ptr(newtonWorld:Byte Ptr, dx:Float, dy:Float, dz:Float, offsetMatrix:Byte Ptr)
Global NewtonCreateCone:Byte Ptr(newtonWorld:Byte Ptr, radius:Float, height:Float, offsetMatrix:Byte Ptr)
Global NewtonCreateCapsule:Byte Ptr(newtonWorld:Byte Ptr, radius:Float, height:Float, offsetMatrix:Byte Ptr)
Global NewtonCreateCylinder:Byte Ptr(newtonWorld:Byte Ptr, radius:Float, height:Float, offsetMatrix:Byte Ptr)
Global NewtonCreateChamferCylinder:Byte Ptr(newtonWorld:Byte Ptr, radius:Float, height:Float, offsetMatrix:Byte Ptr)
Global NewtonCreateConvexHull:Byte Ptr(newtonWorld:Byte Ptr, count:Int, vertexCloud:Byte Ptr, strideInBytes:Int, offsetMatrix:Byte Ptr)
Global NewtonCreateConvexHullModifier:Byte Ptr(newtonWorld:Byte Ptr, convexHullCollision:Byte Ptr)
Global NewtonConvexHullModifierGetMatrix(convexHullCollision:Byte Ptr, matrix:Byte Ptr)
Global NewtonConvexHullModifierSetMatrix(convexHullCollision:Byte Ptr, matrix:Byte Ptr)
	
Global NewtonConvexCollisionSetUserID(convexCollision:Byte Ptr, id:Int)
Global NewtonConvexCollisionGetUserID:Int(convexCollision:Byte Ptr)

Global NewtonConvexCollisionCalculateInertialMatrix(collision:Byte Ptr,inertia:Byte Ptr,center:Byte Ptr)

'================================================
'complex collision primitives creation functions
'================================================
Global NewtonCreateCompoundCollision:Byte Ptr(newtonWorld:Byte Ptr, count:Int, collisionPrimitiveArray:Byte Ptr)
Global NewtonCreateUserMeshCollision:Byte Ptr(newtonWorld:Byte Ptr, minBox:Byte Ptr, maxBox:Byte Ptr, userData:Byte Ptr, collideCallback:Byte Ptr, rayHitCallback:Byte Ptr, destroyCallback:Byte Ptr)

'================================================
' CollisionTree Utility functions
'================================================
Global NewtonCreateTreeCollision:Byte Ptr(newtonWorld:Byte Ptr, userCallback:Byte Ptr)
Global NewtonTreeCollisionBeginBuild(NewtonCollision: Byte Ptr)
Global NewtonTreeCollisionAddFace(NewtonCollision: Byte Ptr, vertexCount:Int, vertexPtr: Byte Ptr, strideInBytes:Int, faceAttribute:Int)
Global NewtonTreeCollisionEndBuild(NewtonCollision: Byte Ptr, optimize:Int)
'	NEWTON_API void NewtonTreeCollisionSerialize (Const NewtonCollision* treeCollision, NewtonSerialize serializeFunction, 
'		void* serializeHandle);
Global NewtonCreateTreeCollisionFromSerialization:Byte Ptr(newtonWorld:Byte Ptr, userCallback:Byte Ptr,deserializeFunction:Byte Ptr, serializeHandle:Byte Ptr)
Global NewtonTreeCollisionGetFaceAtribute:Int(NewtonCollision:Byte Ptr, faceIndexArray:Byte Ptr) 
Global NewtonTreeCollisionSetFaceAtribute(NewtonCollision: Byte Ptr, faceIndexArray: Byte Ptr, attribute:Int) 

'================================================
' Collision Miscelaneos Function
'================================================
Global NewtonReleaseCollision(newtonWorld:Byte Ptr, NewtonCollision:Byte Ptr)
Global NewtonCollisionCalculateAABB(NewtonCollision:Byte Ptr, matrix:Byte Ptr, p0:Byte Ptr, p1:Byte Ptr)
Global NewtonCollisionRayCast:Float(NewtonCollision:Byte Ptr, p0:Byte Ptr, p1:Byte Ptr, normals:Byte Ptr, attribute:Byte Ptr)

'================================================
' transforms utility functions
'================================================
Global NewtonGetEulerAngle(matrix:Byte Ptr, eulersAngles:Byte Ptr)
Global NewtonSetEulerAngle(eulersAngles:Byte Ptr, matrix:Byte Ptr)


Global NewtonCollisionCollide:Int(world:Byte Ptr,maxSize:Int,collision0:Byte Ptr,matrix0:Byte Ptr,collision1:Byte Ptr,matrix1:Byte Ptr,contacts:Byte Ptr,normals:Byte Ptr,penetration:Byte Ptr)

'================================================
' body manipulation functions
'================================================
Global NewtonCreateBody:Byte Ptr(newtonWorld:Byte Ptr, NewtonCollision:Byte Ptr)
Global NewtonDestroyBody(newtonWorld:Byte Ptr, body:Byte Ptr)

Global NewtonBodyAddForce(body:Byte Ptr, force:Byte Ptr)
Global NewtonBodyAddTorque(body:Byte Ptr, torque:Byte Ptr)

Global NewtonBodySetMatrix(body:Byte Ptr, matrix:Byte Ptr)
Global NewtonBodySetMatrixRecursive(body:Byte Ptr, matrix:Byte Ptr)
Global NewtonBodySetMassMatrix(body:Byte Ptr, mass:Float, Ixx:Float, Iyy:Float, Izz:Float)
Global NewtonBodySetMaterialGroupID(body:Byte Ptr, id:Int)
Global NewtonBodySetContinuousCollisionMode(body:Byte Ptr, state:Int)
Global NewtonBodySetJointRecursiveCollision(body:Byte Ptr, state:Int)
Global NewtonBodySetOmega(body:Byte Ptr, omega:Byte Ptr)
Global NewtonBodySetVelocity(body:Byte Ptr, velocity:Byte Ptr)
Global NewtonBodySetForce (body:Byte Ptr, force:Byte Ptr)
Global NewtonBodySetTorque(body:Byte Ptr, torque:Byte Ptr)
Global NewtonBodySetLinearDamping(body:Byte Ptr, linearDamp:Float)
Global NewtonBodySetAngularDamping(body:Byte Ptr, angularDamp:Byte Ptr)
Global NewtonBodySetUserData(body:Byte Ptr, userData:Byte Ptr)
Global NewtonBodyCoriolisForcesMode(body:Byte Ptr, mode:Int)
Global NewtonBodySetCollision(body:Byte Ptr, collision:Byte Ptr)
Global NewtonBodySetAutoFreeze(body:Byte Ptr, state:Int)
Global NewtonBodySetFreezeTreshold(body:Byte Ptr, freezeSpeed2:Float, freezeOmega2:Float, framesCount:Int)
	
Global NewtonBodySetTransformCallback(body:Byte Ptr, SetTransform_callback:Byte Ptr)
Global NewtonBodySetDestructorCallback(body:Byte Ptr, BodyDest_callback:Byte Ptr)
Global NewtonBodySetAutoactiveCallback(body:Byte Ptr, BodyActState_callback:Byte Ptr)
Global NewtonBodySetForceAndTorqueCallback(body:Byte Ptr, ApplyForceTorque_callback:Byte Ptr)

Global NewtonBodyGetWorld:Byte Ptr(body:Byte Ptr)
Global NewtonBodyGetUserData:Byte Ptr(body:Byte Ptr)
Global NewtonBodyGetCollision:Byte Ptr(body:Byte Ptr)
Global NewtonBodyGetMaterialGroupID:Int(body:Byte Ptr)
Global NewtonBodyGetContinuousCollisionMode:Int(body:Byte Ptr)
Global NewtonBodyGetJointRecursiveCollision:Int(body:Byte Ptr)
Global NewtonBodyGetMatrix(body:Byte Ptr, matrix:Byte Ptr)
Global NewtonBodyGetMassMatrix(body:Byte Ptr, mass:Byte Ptr, Ixx:Byte Ptr, Iyy:Byte Ptr, Izz:Byte Ptr)
Global NewtonBodyGetInvMass(body:Byte Ptr, invMass:Byte Ptr, invIxx:Byte Ptr, invIyy:Byte Ptr, invIzz:Byte Ptr)
Global NewtonBodyGetOmega(body:Byte Ptr, vector:Byte Ptr)
Global NewtonBodyGetVelocity(body:Byte Ptr, vector:Byte Ptr)
Global NewtonBodyGetForce(body:Byte Ptr, vector:Byte Ptr)
Global NewtonBodyGetTorque(body:Byte Ptr, vector:Byte Ptr)
	
Global NewtonBodyGetSleepingState:Int(body:Byte Ptr)
Global NewtonBodyGetAutoFreeze:Int(body:Byte Ptr)
Global NewtonBodyGetLinearDamping:Float(body:Byte Ptr)
Global NewtonBodyGetAngularDamping (body:Byte Ptr, vector:Byte Ptr)
Global NewtonBodyGetAABB (body:Byte Ptr, p0:Byte Ptr, p1:Byte Ptr)	
Global NewtonBodyGetFreezeTreshold(body:Byte Ptr, freezeSpeed2:Byte Ptr, freezeOmega2:Byte Ptr)
Global NewtonBodyGetTotalVolume:Float(body:Byte Ptr)
Global NewtonBodyAddBuoyancyForce(body:Byte Ptr, fluidDensity:Float, fluidLinearViscosity:Float, fluidAngularViscosity:Float,gravityVector:Byte Ptr, buoyancyPlane:Byte Ptr, context:Byte Ptr)

Global NewtonBodyForEachPolygonDo (body:Byte Ptr, CollisionIterator_callback:Byte Ptr)
Global NewtonAddBodyImpulse(body:Byte Ptr, pointDeltaVeloc:Byte Ptr, pointPosit:Byte Ptr)

'================================================
' Common joint funtions
'================================================
Global NewtonJointGetUserData:Byte Ptr(joint:Byte Ptr)
Global NewtonJointSetUserData(joint:Byte Ptr, userData:Byte Ptr)

Global NewtonJointGetCollisionState:Int(joint:Byte Ptr)
Global NewtonJointSetCollisionState(joint:Byte Ptr, state:Int)

Global NewtonJointGetStiffness:Float(joint:Byte Ptr)
Global NewtonJointSetStiffness(joint:Byte Ptr, state:Float)

Global NewtonDestroyJoint(newtonWorld:Byte Ptr, joint:Byte Ptr)
Global NewtonJointSetDestructor(joint:Byte Ptr, destructor:Byte Ptr)

'================================================
' Ball And Socket joint functions
'================================================
Global NewtonConstraintCreateBall:Byte Ptr(newtonWorld:Byte Ptr, pivotPoint:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)
Global NewtonBallSetUserCallback(ball:Byte Ptr, BallCallBack_callback:Byte Ptr)
Global NewtonBallGetJointAngle (ball:Byte Ptr, angle:Byte Ptr)
Global NewtonBallGetJointOmega (ball:Byte Ptr, omega:Byte Ptr)
Global NewtonBallGetJointForce (ball:Byte Ptr, force:Byte Ptr)
Global NewtonBallSetConeLimits (ball:Byte Ptr, pin:Byte Ptr, maxConeAngle:Float, maxTwistAngle:Float)

'================================================
' Hinge joint functions
'================================================
Global NewtonConstraintCreateHinge:Byte Ptr(newtonWorld:Byte Ptr, pivotPoint:Byte Ptr, pinDir:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)

Global NewtonHingeSetUserCallback(hinge:Byte Ptr, HingeCallBack_callback:Byte Ptr)
Global NewtonHingeGetJointAngle:Float(hinge:Byte Ptr)
Global NewtonHingeGetJointOmega:Float(hinge:Byte Ptr)
Global NewtonHingeGetJointForce(hinge:Byte Ptr,  force:Byte Ptr)
Global NewtonHingeCalculateStopAlpha:Float(hinge:Byte Ptr, desc:Byte Ptr, angle:Float)


'================================================
' Slider joint functions
'================================================
Global NewtonConstraintCreateSlider:Byte Ptr(newtonWorld:Byte Ptr,pivotPoint:Byte Ptr, pinDir:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)
Global NewtonSliderSetUserCallback(slider:Byte Ptr, SliderCallBack_callback:Byte Ptr)
Global NewtonSliderGetJointPosit:Float(slider:Byte Ptr)
Global NewtonSliderGetJointVeloc:Float(slider:Byte Ptr)
Global NewtonSliderGetJointForce (slider:Byte Ptr,  force:Byte Ptr)
Global NewtonSliderCalculateStopAccel:Float(slider:Byte Ptr, desc:Byte Ptr, position:Float)


'================================================
' Corkscrew joint functions
'================================================
Global NewtonConstraintCreateCorkscrew:Byte Ptr(newtonWorld:Byte Ptr,pivotPoint:Byte Ptr, pinDir:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)
Global NewtonCorkscrewSetUserCallback(corkscrew:Byte Ptr, CorkscrewCallBack_callback:Byte Ptr)
Global NewtonCorkscrewGetJointPosit:Float (corkscrew:Byte Ptr)
Global NewtonCorkscrewGetJointAngle:Float( corkscrew:Byte Ptr)
Global NewtonCorkscrewGetJointVeloc:Float(corkscrew:Byte Ptr)
Global NewtonCorkscrewGetJointOmega:Float( corkscrew:Byte Ptr)
Global NewtonCorkscrewGetJointForce(corkscrew:Byte Ptr, force:Byte Ptr)
Global NewtonCorkscrewCalculateStopAlpha:Float(corkscrew:Byte Ptr, desc:Byte Ptr, angle:Float)
Global NewtonCorkscrewCalculateStopAccel:Float(corkscrew:Byte Ptr, desc:Byte Ptr, position:Float)


'================================================
' Universal joint functions
'================================================
Global NewtonConstraintCreateUniversal:Byte Ptr(newtonWorld:Byte Ptr, pivotPoint:Byte Ptr, pinDir0:Byte Ptr, pinDir1:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)
Global NewtonUniversalSetUserCallback(universal:Byte Ptr, UniversalCallBack_callback:Byte Ptr)
Global NewtonUniversalGetJointAngle0:Float( universal:Byte Ptr)
Global NewtonUniversalGetJointAngle1:Float(universal:Byte Ptr)
Global NewtonUniversalGetJointOmega0:Float( universal:Byte Ptr)
Global NewtonUniversalGetJointOmega1:Float (universal:Byte Ptr)
Global NewtonUniversalGetJointForce(universal:Byte Ptr, force:Byte Ptr)
Global NewtonUniversalCalculateStopAlpha0:Float(universal:Byte Ptr, desc:Byte Ptr, angle:Float)
Global NewtonUniversalCalculateStopAlpha1:Float(universal:Byte Ptr, desc:Byte Ptr, angle:Float)


'================================================
'Up vector joint functions
'================================================
Global NewtonConstraintCreateUpVector:Byte Ptr(newtonWorld:Byte Ptr, pinDir:Byte Ptr, body:Byte Ptr) 
Global NewtonUpVectorGetPin(upVector:Byte Ptr, pin:Byte Ptr)
Global NewtonUpVectorSetPin(upVector:Byte Ptr, pin:Byte Ptr)


'================================================
' User defined bilateral Joint
'================================================
Global NewtonConstraintCreateUserJoint:Byte Ptr(newtonWorld:Byte Ptr, maxDOF:Int, UserBilateralCallBack_callback:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr) 
Global NewtonUserJointAddLinearRow(joint:Byte Ptr, pivot0:Byte Ptr, pivot1:Byte Ptr, dir:Byte Ptr)
Global NewtonUserJointAddAngularRow(joint:Byte Ptr, relativeAngle:Float, dir:Byte Ptr)
Global NewtonUserJointSetRowMinimunFriction(joint:Byte Ptr,  friction:Float)
Global NewtonUserJointSetRowMaximunFriction( joint:Float, friction:Float)
Global NewtonUserJointSetRowAcceleration(joint:Byte Ptr,  acceleration:Float)
Global NewtonUserJointSetRowStiffness( joint:Float,stiffness:Float)
Global NewtonUserJointGetRowForce:Float(joint:Byte Ptr, row:Int)


'================================================
' Ragdoll joint contatiner funtion
'================================================
Global NewtonCreateRagDoll:Byte Ptr(newtonWorld:Byte Ptr)
Global NewtonDestroyRagDoll(newtonWorld:Byte Ptr, ragDoll:Byte Ptr)

Global NewtonRagDollBegin( ragDoll:Byte Ptr)
Global NewtonRagDollEnd( ragDoll:Byte Ptr)


Global NewtonRagDollFindBone:Byte Ptr( ragDoll:Byte Ptr, id:Int)
Global NewtonRagDollGetRootBone:Byte Ptr( ragDoll:Byte Ptr)

Global NewtonRagDollSetForceAndTorqueCallback( ragDoll:Byte Ptr, ApplyForceAndTorque_callback:Byte Ptr)
Global NewtonRagDollSetTransformCallback(ragDoll:Byte Ptr, SetRagDollTransform_callback:Byte Ptr)
Global NewtonRagDollAddBone:Byte Ptr(ragDoll:Byte Ptr, parent:Byte Ptr, userData:Byte Ptr, mass:Float, matrix:Byte Ptr, boneCollision:Byte Ptr, size:Byte Ptr)

Global NewtonRagDollBoneGetUserData:Byte Ptr( bone:Byte Ptr)
Global NewtonRagDollBoneGetBody:Byte Ptr( bone:Byte Ptr)
Global NewtonRagDollBoneSetID(bone:Byte Ptr, id:Int)


Global NewtonRagDollBoneSetLimits(bone:Byte Ptr, coneDir:Byte Ptr, minConeAngle:Float, maxConeAngle:Float, maxTwistAngle:Float, bilateralConeDir:Byte Ptr, negativeBilateralConeAngle:Float, positiveBilateralConeAngle:Float)
	

Global NewtonRagDollBoneGetLocalMatrix(bone:Byte Ptr,  matrix:Byte Ptr)
Global NewtonRagDollBoneGetGlobalMatrix( bone:Byte Ptr,  matrix:Byte Ptr)


'================================================
' Vehicle joint functions
'================================================
Global NewtonConstraintCreateVehicle:Byte Ptr(newtonWorld:Byte Ptr, upDir:Byte Ptr, body:Byte Ptr) 
Global NewtonVehicleReset(vehicle:Byte Ptr) 
Global NewtonVehicleSetTireCallback(vehicle:Byte Ptr, update:Byte Ptr)
Global NewtonVehicleAddTire:Int(vehicle:Byte Ptr, localMatrix:Byte Ptr, pin:Byte Ptr, mass:Float, width:Float, radius:Float, suspesionShock:Float, suspesionSpring:Float, suspesionLength:Float, userData:Byte Ptr, collisionID:Int)
Global NewtonVehicleRemoveTire(vehicle:Byte Ptr, tireIndex:Int)
Global NewtonVehicleBalanceTires(vehicle:Byte Ptr, gravityMag:Float)

Global NewtonVehicleGetFirstTireID:Int(vehicle:Byte Ptr)
Global NewtonVehicleGetNextTireID:Int(vehicle:Byte Ptr, tireId:Int)

Global NewtonVehicleTireIsAirBorne:Int (vehicle:Byte Ptr, tireId:Int)
Global NewtonVehicleTireLostSideGrip:Int(vehicle:Byte Ptr, tireId:Int)
Global NewtonVehicleTireLostTraction:Int(vehicle:Byte Ptr, tireId:Int)

Global NewtonVehicleGetTireUserData:Byte Ptr(vehicle:Byte Ptr, tireId:Int)
Global NewtonVehicleGetTireOmega:Float(vehicle:Byte Ptr, tireId:Int)
Global NewtonVehicleGetTireNormalLoad:Float(vehicle:Byte Ptr, tireId:Int)
Global NewtonVehicleGetTireSteerAngle:Float (vehicle:Byte Ptr, tireId:Int)
Global NewtonVehicleGetTireLateralSpeed:Float(vehicle:Byte Ptr, tireId:Int)
Global NewtonVehicleGetTireLongitudinalSpeed:Float(vehicle:Byte Ptr, tireId:Int)
Global hicleGetTireMatrix(vehicle:Byte Ptr, tireId:Int , matrix:Byte Ptr)


Global NewtonVehicleSetTireTorque(vehicle:Byte Ptr, tireId:Int, torque:Float)
Global NewtonVehicleSetTireSteerAngle(vehicle:Byte Ptr, tireId:Int,  angle:Float)
	
Global NewtonVehicleSetTireMaxSideSleepSpeed(vehicle:Byte Ptr, tireId:Int, speed:Float)
Global NewtonVehicleSetTireSideSleepCoeficient(vehicle:Byte Ptr, tireId:Int,  coeficient:Float)
Global NewtonVehicleSetTireMaxLongitudinalSlideSpeed(vehicle:Byte Ptr, tireId:Int, speed:Float)
Global NewtonVehicleSetTireLongitudinalSlideCoeficient(vehicle:Byte Ptr, tireId:Int, coeficient:Float)

Global NewtonVehicleTireCalculateMaxBrakeAcceleration:Float(vehicle:Byte Ptr, tireId:Int)
Global NewtonVehicleTireSetBrakeAcceleration(vehicle:Byte Ptr, tireId:Int,  accelaration:Float, torqueLimit:Float)

Global phBodyGetPitch:Float(body:Int)
Global phBodyGetYaw:Float(body:Int)
Global phBodyGetRoll:Float(body:Int)


Global HLIB_NEWTON:Int

Function StartNewton:Int()
	If HLIB_NEWTON Return True
	HLIB_NEWTON=LoadLibraryA("bin\Newton.dll")
	If Not HLIB_NEWTON HLIB_NEWTON=LoadLibraryA("dlls\Newton.dll")
	If Not HLIB_NEWTON HLIB_NEWTON=LoadLibraryA("Newton.dll")
	If Not HLIB_NEWTON Return

	'Retrieve function pointers
	NewtonTreeCollisionGetVertexListIndexListInAABB=getprocaddress(HLIB_NEWTON,"NewtonTreeCollisionGetVertexListIndexListInAABB")
	NewtonSetPlatformArchitecture=getprocaddress(HLIB_NEWTON,"NewtonSetPlatformArchitecture")
	NewtonCreate=GetProcAddress(HLIB_NEWTON,"NewtonCreate")
	NewtonDestroy=GetProcAddress(HLIB_NEWTON,"NewtonDestroy")
	NewtonUpdate=GetProcAddress(HLIB_NEWTON,"NewtonUpdate")
	NewtonDestroyAllBodies=GetProcAddress(HLIB_NEWTON,"NewtonDestroyAllBodies")
	NewtonSetSolverModel=GetProcAddress(HLIB_NEWTON,"NewtonSetSolverModel")
	NewtonSetFrictionModel=GetProcAddress(HLIB_NEWTON,"NewtonSetFrictionModel")
	NewtonGetTimeStep=GetProcAddress(HLIB_NEWTON,"NewtonGetTimeStep")
	NewtonSetMinimumFrameRate=GetProcAddress(HLIB_NEWTON,"NewtonSetMinimumFrameRate")
	NewtonSetBodyLeaveWorldEvent=GetProcAddress(HLIB_NEWTON,"NewtonSetBodyLeaveWorldEvent")
	NewtonSetWorldSize=GetProcAddress(HLIB_NEWTON,"NewtonSetWorldSize")
	NewtonWorldFreezeBody=GetProcAddress(HLIB_NEWTON,"NewtonWorldFreezeBody")
	NewtonWorldUnfreezeBody=GetProcAddress(HLIB_NEWTON,"NewtonWorldUnfreezeBody")
	NewtonWorldForEachBodyDo=GetProcAddress(HLIB_NEWTON,"NewtonWorldForEachBodyDo")
	NewtonWorldSetUserData=GetProcAddress(HLIB_NEWTON,"NewtonWorldSetUserData")
	NewtonWorldGetUserData=GetProcAddress(HLIB_NEWTON,"NewtonWorldGetUserData")
	NewtonWorldGetVersion=GetProcAddress(HLIB_NEWTON,"NewtonWorldGetVersion")
	NewtonWorldRayCast=GetProcAddress(HLIB_NEWTON,"NewtonWorldRayCast")
	NewtonWorldCollide=GetProcAddress(HLIB_NEWTON,"NewtonWorldCollide")
	NewtonMaterialGetDefaultGroupID=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetDefaultGroupID")
	NewtonMaterialCreateGroupID=GetProcAddress(HLIB_NEWTON,"NewtonMaterialCreateGroupID")
	NewtonMaterialDestroyAllGroupID=GetProcAddress(HLIB_NEWTON,"NewtonMaterialDestroyAllGroupID")
	NewtonMaterialSetDefaultSoftness=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetDefaultSoftness")
	NewtonMaterialSetDefaultElasticity=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetDefaultElasticity")
	NewtonMaterialSetDefaultCollidable=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetDefaultCollidable")
	NewtonMaterialSetDefaultFriction=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetDefaultFriction")
	NewtonMaterialSetCollisionCallback=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetCollisionCallback")
	NewtonMaterialGetUserData=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetUserData")
	NewtonMaterialDisableContact=GetProcAddress(HLIB_NEWTON,"NewtonMaterialDisableContact")
	NewtonMaterialGetCurrentTimestep=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetCurrentTimestep")
	NewtonMaterialGetMaterialPairUserData=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetMaterialPairUserData")
	NewtonMaterialGetContactFaceAttribute=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetContactFaceAttribute")
	NewtonMaterialGetBodyCollisionID=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetBodyCollisionID")
	NewtonMaterialGetContactNormalSpeed=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetContactNormalSpeed")
	NewtonMaterialGetContactForce=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetContactForce")
	NewtonMaterialGetContactPositionAndNormal=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetContactPositionAndNormal")
	NewtonMaterialGetContactTangentDirections=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetContactTangentDirections")
	NewtonMaterialGetContactTangentSpeed=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetContactTangentSpeed")
	NewtonMaterialSetContactSoftness=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetContactSoftness")
	NewtonMaterialSetContactElasticity=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetContactElasticity")
	NewtonMaterialSetContactFrictionState=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetContactFrictionState")
	NewtonMaterialSetContactStaticFrictionCoef=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetContactStaticFrictionCoef")
	NewtonMaterialSetContactKineticFrictionCoef=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetContactKineticFrictionCoef")
	NewtonMaterialSetContactTangentAcceleration=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetContactTangentAcceleration")
	NewtonMaterialContactRotateTangentDirections=GetProcAddress(HLIB_NEWTON,"NewtonMaterialContactRotateTangentDirections")
	NewtonCreateNull=GetProcAddress(HLIB_NEWTON,"NewtonCreateNull")
	NewtonCreateSphere=GetProcAddress(HLIB_NEWTON,"NewtonCreateSphere")
	NewtonCreateBox=GetProcAddress(HLIB_NEWTON,"NewtonCreateBox")
	NewtonCreateCone=GetProcAddress(HLIB_NEWTON,"NewtonCreateCone")
	NewtonCreateCapsule=GetProcAddress(HLIB_NEWTON,"NewtonCreateCapsule")
	NewtonCreateCylinder=GetProcAddress(HLIB_NEWTON,"NewtonCreateCylinder")
	NewtonCreateChamferCylinder=GetProcAddress(HLIB_NEWTON,"NewtonCreateChamferCylinder")
	NewtonCreateConvexHull=GetProcAddress(HLIB_NEWTON,"NewtonCreateConvexHull")
	NewtonCreateConvexHullModifier=GetProcAddress(HLIB_NEWTON,"NewtonCreateConvexHullModifier")
	NewtonConvexHullModifierGetMatrix=GetProcAddress(HLIB_NEWTON,"NewtonConvexHullModifierGetMatrix")
	NewtonConvexHullModifierSetMatrix=GetProcAddress(HLIB_NEWTON,"NewtonConvexHullModifierSetMatrix")
	NewtonConvexCollisionSetUserID=GetProcAddress(HLIB_NEWTON,"NewtonConvexCollisionSetUserID")
	NewtonConvexCollisionGetUserID=GetProcAddress(HLIB_NEWTON,"NewtonConvexCollisionGetUserID")
	NewtonCreateCompoundCollision=GetProcAddress(HLIB_NEWTON,"NewtonCreateCompoundCollision")
	NewtonCreateUserMeshCollision=GetProcAddress(HLIB_NEWTON,"NewtonCreateUserMeshCollision")
	NewtonCreateTreeCollision=GetProcAddress(HLIB_NEWTON,"NewtonCreateTreeCollision")
	NewtonTreeCollisionBeginBuild=GetProcAddress(HLIB_NEWTON,"NewtonTreeCollisionBeginBuild")
	NewtonTreeCollisionAddFace=GetProcAddress(HLIB_NEWTON,"NewtonTreeCollisionAddFace")
	NewtonTreeCollisionEndBuild=GetProcAddress(HLIB_NEWTON,"NewtonTreeCollisionEndBuild")
	NewtonCreateTreeCollisionFromSerialization=GetProcAddress(HLIB_NEWTON,"NewtonCreateTreeCollisionFromSerialization")
	NewtonTreeCollisionGetFaceAtribute=GetProcAddress(HLIB_NEWTON,"NewtonTreeCollisionGetFaceAtribute")
	NewtonTreeCollisionSetFaceAtribute=GetProcAddress(HLIB_NEWTON,"NewtonTreeCollisionSetFaceAtribute")
	NewtonReleaseCollision=GetProcAddress(HLIB_NEWTON,"NewtonReleaseCollision")
	NewtonCollisionCalculateAABB=GetProcAddress(HLIB_NEWTON,"NewtonCollisionCalculateAABB")
	NewtonCollisionRayCast=GetProcAddress(HLIB_NEWTON,"NewtonCollisionRayCast")
	NewtonGetEulerAngle=GetProcAddress(HLIB_NEWTON,"NewtonGetEulerAngle")
	NewtonSetEulerAngle=GetProcAddress(HLIB_NEWTON,"NewtonSetEulerAngle")
	NewtonCreateBody=GetProcAddress(HLIB_NEWTON,"NewtonCreateBody")
	NewtonDestroyBody=GetProcAddress(HLIB_NEWTON,"NewtonDestroyBody")
	NewtonBodyAddForce=GetProcAddress(HLIB_NEWTON,"NewtonBodyAddForce")
	NewtonBodyAddTorque=GetProcAddress(HLIB_NEWTON,"NewtonBodyAddTorque")
	NewtonBodySetMatrix=GetProcAddress(HLIB_NEWTON,"NewtonBodySetMatrix")
	NewtonBodySetMatrixRecursive=GetProcAddress(HLIB_NEWTON,"NewtonBodySetMatrixRecursive")
	NewtonBodySetMassMatrix=GetProcAddress(HLIB_NEWTON,"NewtonBodySetMassMatrix")
	NewtonBodySetMaterialGroupID=GetProcAddress(HLIB_NEWTON,"NewtonBodySetMaterialGroupID")
	NewtonBodySetContinuousCollisionMode=GetProcAddress(HLIB_NEWTON,"NewtonBodySetContinuousCollisionMode")
	NewtonBodySetJointRecursiveCollision=GetProcAddress(HLIB_NEWTON,"NewtonBodySetJointRecursiveCollision")
	NewtonBodySetOmega=GetProcAddress(HLIB_NEWTON,"NewtonBodySetOmega")
	NewtonBodySetVelocity=GetProcAddress(HLIB_NEWTON,"NewtonBodySetVelocity")
	NewtonBodySetForce=GetProcAddress(HLIB_NEWTON,"NewtonBodySetForce")
	NewtonBodySetTorque=GetProcAddress(HLIB_NEWTON,"NewtonBodySetTorque")
	NewtonBodySetLinearDamping=GetProcAddress(HLIB_NEWTON,"NewtonBodySetLinearDamping")
	NewtonBodySetAngularDamping=GetProcAddress(HLIB_NEWTON,"NewtonBodySetAngularDamping")
	NewtonBodySetUserData=GetProcAddress(HLIB_NEWTON,"NewtonBodySetUserData")
	NewtonBodyCoriolisForcesMode=GetProcAddress(HLIB_NEWTON,"NewtonBodyCoriolisForcesMode")
	NewtonBodySetCollision=GetProcAddress(HLIB_NEWTON,"NewtonBodySetCollision")
	NewtonBodySetAutoFreeze=GetProcAddress(HLIB_NEWTON,"NewtonBodySetAutoFreeze")
	NewtonBodySetFreezeTreshold=GetProcAddress(HLIB_NEWTON,"NewtonBodySetFreezeTreshold")
	NewtonBodySetTransformCallback=GetProcAddress(HLIB_NEWTON,"NewtonBodySetTransformCallback")
	NewtonBodySetDestructorCallback=GetProcAddress(HLIB_NEWTON,"NewtonBodySetDestructorCallback")
	NewtonBodySetAutoactiveCallback=GetProcAddress(HLIB_NEWTON,"NewtonBodySetAutoactiveCallback")
	NewtonBodySetForceAndTorqueCallback=GetProcAddress(HLIB_NEWTON,"NewtonBodySetForceAndTorqueCallback")
	NewtonBodyGetWorld=GetProcAddress(HLIB_NEWTON,"	NewtonBodyGetWorld")
	NewtonBodyGetUserData=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetUserData")
	NewtonBodyGetCollision=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetCollision")
	NewtonBodyGetMaterialGroupID=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetMaterialGroupID")
	NewtonBodyGetContinuousCollisionMode=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetContinuousCollisionMode")
	NewtonBodyGetJointRecursiveCollision=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetJointRecursiveCollision")
	NewtonBodyGetMatrix=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetMatrix")
	NewtonBodyGetMassMatrix=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetMassMatrix")
	NewtonBodyGetInvMass=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetInvMass")
	NewtonBodyGetOmega=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetOmega")
	NewtonBodyGetVelocity=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetVelocity")
	NewtonBodyGetForce=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetForce")
	NewtonBodyGetTorque=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetTorque")
	NewtonBodyGetSleepingState=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetSleepingState")
	NewtonBodyGetAutoFreeze=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetAutoFreeze")
	NewtonBodyGetLinearDamping=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetLinearDamping")
	NewtonBodyGetAngularDamping=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetAngularDamping")
	NewtonBodyGetAABB=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetAABB")
	NewtonBodyGetFreezeTreshold=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetFreezeTreshold")
	NewtonBodyGetTotalVolume=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetTotalVolume")
	NewtonBodyAddBuoyancyForce=GetProcAddress(HLIB_NEWTON,"NewtonBodyAddBuoyancyForce")
	NewtonBodyForEachPolygonDo=GetProcAddress(HLIB_NEWTON,"NewtonBodyForEachPolygonDo")
	NewtonAddBodyImpulse=GetProcAddress(HLIB_NEWTON,"NewtonAddBodyImpulse")
	NewtonJointGetUserData=GetProcAddress(HLIB_NEWTON,"NewtonJointGetUserData")
	NewtonJointSetUserData=GetProcAddress(HLIB_NEWTON,"NewtonJointSetUserData")
	NewtonJointGetCollisionState=GetProcAddress(HLIB_NEWTON,"NewtonJointGetCollisionState")
	NewtonJointSetCollisionState=GetProcAddress(HLIB_NEWTON,"NewtonJointSetCollisionState")
	NewtonJointGetStiffness=GetProcAddress(HLIB_NEWTON,"NewtonJointGetStiffness")
	NewtonJointSetStiffness=GetProcAddress(HLIB_NEWTON,"NewtonJointSetStiffness")
	NewtonDestroyJoint=GetProcAddress(HLIB_NEWTON,"NewtonDestroyJoint")
	NewtonJointSetDestructor=GetProcAddress(HLIB_NEWTON,"NewtonJointSetDestructor")
	NewtonConstraintCreateBall=GetProcAddress(HLIB_NEWTON,"NewtonConstraintCreateBall")
	NewtonBallSetUserCallback=GetProcAddress(HLIB_NEWTON,"NewtonBallSetUserCallback")
	NewtonBallGetJointAngle=GetProcAddress(HLIB_NEWTON,"NewtonBallGetJointAngle")
	NewtonBallGetJointOmega=GetProcAddress(HLIB_NEWTON,"NewtonBallGetJointOmega")
	NewtonBallGetJointForce=GetProcAddress(HLIB_NEWTON,"NewtonBallGetJointForce")
	NewtonBallSetConeLimits=GetProcAddress(HLIB_NEWTON,"NewtonBallSetConeLimits")
	NewtonConstraintCreateHinge=GetProcAddress(HLIB_NEWTON,"NewtonConstraintCreateHinge")
	NewtonHingeSetUserCallback=GetProcAddress(HLIB_NEWTON,"NewtonHingeSetUserCallback")
	NewtonHingeGetJointAngle=GetProcAddress(HLIB_NEWTON,"NewtonHingeGetJointAngle")
	NewtonHingeGetJointOmega=GetProcAddress(HLIB_NEWTON,"NewtonHingeGetJointOmega")
	NewtonHingeGetJointForce=GetProcAddress(HLIB_NEWTON,"NewtonHingeGetJointForce")
	NewtonHingeCalculateStopAlpha=GetProcAddress(HLIB_NEWTON,"NewtonHingeCalculateStopAlpha")
	NewtonConstraintCreateSlider=GetProcAddress(HLIB_NEWTON,"NewtonConstraintCreateSlider")
	NewtonSliderSetUserCallback=GetProcAddress(HLIB_NEWTON,"NewtonSliderSetUserCallback")
	NewtonSliderGetJointPosit=GetProcAddress(HLIB_NEWTON,"NewtonSliderGetJointPosit")
	NewtonSliderGetJointVeloc=GetProcAddress(HLIB_NEWTON,"NewtonSliderGetJointVeloc")
	NewtonSliderGetJointForce=GetProcAddress(HLIB_NEWTON,"NewtonSliderGetJointForce")
	NewtonSliderCalculateStopAccel=GetProcAddress(HLIB_NEWTON,"NewtonSliderCalculateStopAccel")
	NewtonConstraintCreateCorkscrew=GetProcAddress(HLIB_NEWTON,"NewtonConstraintCreateCorkscrew")
	NewtonCorkscrewSetUserCallback=GetProcAddress(HLIB_NEWTON,"NewtonCorkscrewSetUserCallback")
	NewtonCorkscrewGetJointPosit=GetProcAddress(HLIB_NEWTON,"NewtonCorkscrewGetJointPosit")
	NewtonCorkscrewGetJointAngle=GetProcAddress(HLIB_NEWTON,"NewtonCorkscrewGetJointAngle")
	NewtonCorkscrewGetJointVeloc=GetProcAddress(HLIB_NEWTON,"NewtonCorkscrewGetJointVeloc")
	NewtonCorkscrewGetJointOmega=GetProcAddress(HLIB_NEWTON,"NewtonCorkscrewGetJointOmega")
	NewtonCorkscrewGetJointForce=GetProcAddress(HLIB_NEWTON,"NewtonCorkscrewGetJointForce")
	NewtonCorkscrewCalculateStopAlpha=GetProcAddress(HLIB_NEWTON,"NewtonCorkscrewCalculateStopAlpha")
	NewtonCorkscrewCalculateStopAccel=GetProcAddress(HLIB_NEWTON,"NewtonCorkscrewCalculateStopAccel")
	NewtonConstraintCreateUniversal=GetProcAddress(HLIB_NEWTON,"NewtonConstraintCreateUniversal")
	NewtonUniversalSetUserCallback=GetProcAddress(HLIB_NEWTON,"NewtonUniversalSetUserCallback")
	NewtonUniversalGetJointAngle0=GetProcAddress(HLIB_NEWTON,"NewtonUniversalGetJointAngle0")
	NewtonUniversalGetJointAngle1=GetProcAddress(HLIB_NEWTON,"NewtonUniversalGetJointAngle1")
	NewtonUniversalGetJointOmega0=GetProcAddress(HLIB_NEWTON,"NewtonUniversalGetJointOmega0")
	NewtonUniversalGetJointOmega1=GetProcAddress(HLIB_NEWTON,"NewtonUniversalGetJointOmega1")
	NewtonUniversalGetJointForce=GetProcAddress(HLIB_NEWTON,"NewtonUniversalGetJointForce")
	NewtonUniversalCalculateStopAlpha0=GetProcAddress(HLIB_NEWTON,"NewtonUniversalCalculateStopAlpha0")
	NewtonUniversalCalculateStopAlpha1=GetProcAddress(HLIB_NEWTON,"NewtonUniversalCalculateStopAlpha1")
	NewtonConstraintCreateUpVector=GetProcAddress(HLIB_NEWTON,"NewtonConstraintCreateUpVector")
	NewtonUpVectorGetPin=GetProcAddress(HLIB_NEWTON,"NewtonUpVectorGetPin")
	NewtonUpVectorSetPin=GetProcAddress(HLIB_NEWTON,"NewtonUpVectorSetPin")
	NewtonConstraintCreateUserJoint=GetProcAddress(HLIB_NEWTON,"NewtonConstraintCreateUserJoint")
	NewtonUserJointAddLinearRow=GetProcAddress(HLIB_NEWTON,"NewtonUserJointAddLinearRow")
	NewtonUserJointAddAngularRow=GetProcAddress(HLIB_NEWTON,"NewtonUserJointAddAngularRow")
	NewtonUserJointSetRowMinimunFriction=GetProcAddress(HLIB_NEWTON,"NewtonUserJointSetRowMinimunFriction")
	NewtonUserJointSetRowMaximunFriction=GetProcAddress(HLIB_NEWTON,"NewtonUserJointSetRowMaximunFriction")
	NewtonUserJointSetRowAcceleration=GetProcAddress(HLIB_NEWTON,"NewtonUserJointSetRowAcceleration")
	NewtonUserJointSetRowStiffness=GetProcAddress(HLIB_NEWTON,"NewtonUserJointSetRowStiffness")
	NewtonUserJointGetRowForce=GetProcAddress(HLIB_NEWTON,"NewtonUserJointGetRowForce")
	NewtonCreateRagDoll=GetProcAddress(HLIB_NEWTON,"NewtonCreateRagDoll")
	NewtonDestroyRagDoll=GetProcAddress(HLIB_NEWTON,"NewtonDestroyRagDoll")
	NewtonRagDollBegin=GetProcAddress(HLIB_NEWTON,"NewtonRagDollBegin")
	NewtonRagDollEnd=GetProcAddress(HLIB_NEWTON,"NewtonRagDollEnd")
	NewtonRagDollFindBone=GetProcAddress(HLIB_NEWTON,"NewtonRagDollFindBone")
	NewtonRagDollGetRootBone=GetProcAddress(HLIB_NEWTON,"NewtonRagDollGetRootBone")
	NewtonRagDollSetForceAndTorqueCallback=GetProcAddress(HLIB_NEWTON,"NewtonRagDollSetForceAndTorqueCallback")
	NewtonRagDollSetTransformCallback=GetProcAddress(HLIB_NEWTON,"NewtonRagDollSetTransformCallback")
	NewtonRagDollAddBone=GetProcAddress(HLIB_NEWTON,"NewtonRagDollAddBone")
	NewtonRagDollBoneGetUserData=GetProcAddress(HLIB_NEWTON,"NewtonRagDollBoneGetUserData")
	NewtonRagDollBoneGetBody=GetProcAddress(HLIB_NEWTON,"NewtonRagDollBoneGetBody")
	NewtonRagDollBoneSetID=GetProcAddress(HLIB_NEWTON,"NewtonRagDollBoneSetID")
	NewtonRagDollBoneSetLimits=GetProcAddress(HLIB_NEWTON,"NewtonRagDollBoneSetLimits")
	NewtonRagDollBoneGetLocalMatrix=GetProcAddress(HLIB_NEWTON,"NewtonRagDollBoneGetLocalMatrix")
	NewtonRagDollBoneGetGlobalMatrix=GetProcAddress(HLIB_NEWTON,"NewtonRagDollBoneGetGlobalMatrix")
	NewtonConstraintCreateVehicle=GetProcAddress(HLIB_NEWTON,"NewtonConstraintCreateVehicle")
	NewtonVehicleReset=GetProcAddress(HLIB_NEWTON,"NewtonVehicleReset")
	NewtonVehicleSetTireCallback=GetProcAddress(HLIB_NEWTON,"NewtonVehicleSetTireCallback")
	NewtonVehicleAddTire=GetProcAddress(HLIB_NEWTON,"NewtonVehicleAddTire")
	NewtonVehicleRemoveTire=GetProcAddress(HLIB_NEWTON,"NewtonVehicleRemoveTire")
	NewtonVehicleBalanceTires=GetProcAddress(HLIB_NEWTON,"NewtonVehicleBalanceTires")
	NewtonVehicleGetFirstTireID=GetProcAddress(HLIB_NEWTON,"NewtonVehicleGetFirstTireID")
	NewtonVehicleGetNextTireID=GetProcAddress(HLIB_NEWTON,"NewtonVehicleGetNextTireID")
	NewtonVehicleTireIsAirBorne=GetProcAddress(HLIB_NEWTON,"NewtonVehicleTireIsAirBorne")
	NewtonVehicleTireLostSideGrip=GetProcAddress(HLIB_NEWTON,"NewtonVehicleTireLostSideGrip")
	NewtonVehicleTireLostTraction=GetProcAddress(HLIB_NEWTON,"NewtonVehicleTireLostTraction")
	NewtonVehicleGetTireUserData=GetProcAddress(HLIB_NEWTON,"NewtonVehicleGetTireUserData")
	NewtonVehicleGetTireOmega=GetProcAddress(HLIB_NEWTON,"NewtonVehicleGetTireOmega")
	NewtonVehicleGetTireNormalLoad=GetProcAddress(HLIB_NEWTON,"NewtonVehicleGetTireNormalLoad")
	NewtonVehicleGetTireSteerAngle=GetProcAddress(HLIB_NEWTON,"NewtonVehicleGetTireSteerAngle")
	NewtonVehicleGetTireLateralSpeed=GetProcAddress(HLIB_NEWTON,"NewtonVehicleGetTireLateralSpeed")
	NewtonVehicleGetTireLongitudinalSpeed=GetProcAddress(HLIB_NEWTON,"NewtonVehicleGetTireLongitudinalSpeed")
	hicleGetTireMatrix=GetProcAddress(HLIB_NEWTON,"hicleGetTireMatrix")
	NewtonVehicleSetTireTorque=GetProcAddress(HLIB_NEWTON,"NewtonVehicleSetTireTorque")
	NewtonVehicleSetTireSteerAngle=GetProcAddress(HLIB_NEWTON,"NewtonVehicleSetTireSteerAngle")
	NewtonVehicleSetTireMaxSideSleepSpeed=GetProcAddress(HLIB_NEWTON,"NewtonVehicleSetTireMaxSideSleepSpeed")
	NewtonVehicleSetTireSideSleepCoeficient=GetProcAddress(HLIB_NEWTON,"NewtonVehicleSetTireSideSleepCoeficient")
	NewtonVehicleSetTireMaxLongitudinalSlideSpeed=GetProcAddress(HLIB_NEWTON,"NewtonVehicleSetTireMaxLongitudinalSlideSpeed")
	NewtonVehicleSetTireLongitudinalSlideCoeficient=GetProcAddress(HLIB_NEWTON,"NewtonVehicleSetTireLongitudinalSlideCoeficient")
	NewtonVehicleTireCalculateMaxBrakeAcceleration=GetProcAddress(HLIB_NEWTON,"NewtonVehicleTireCalculateMaxBrakeAcceleration")
	NewtonVehicleTireSetBrakeAcceleration=GetProcAddress(HLIB_NEWTON,"NewtonVehicleTireSetBrakeAcceleration")
	NewtonMaterialSetContactNormalDirection=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetContactNormalDirection")
	NewtonMaterialSetContactNormalAcceleration=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetContactNormalAcceleration")
	NewtonCollisionCollide=GetProcAddress(HLIB_NEWTON,"NewtonCollisionCollide")
	NewtonBodySetCentreOfMass=GetProcAddress(HLIB_NEWTON,"NewtonBodySetCentreOfMass")
	NewtonConvexCollisionCalculateInertialMatrix=GetProcAddress(HLIB_NEWTON,"NewtonConvexCollisionCalculateInertialMatrix")
	Return True
EndFunction

Function StopNewton()
	If HLIB_NEWTON
		'NewtonDestroy NP_WORLD
		'NP_WORLD=Null
		FreeLibrary HLIB_NEWTON
		HLIB_NEWTON=0
	EndIf
EndFunction


hicleGetTireMatrix=GetProcAddress(HLIB_NEWTON,"hicleGetTireMatrix")


Just wanted to point out the typo above in case anyone missed it. I'm assuming it should start with NewtonVe.

Anyone know how you would statically link to Newton?

yes.
the needed mingw lib is offically available here:
http://www.newtondynamics.com/downloads/NewtonMinGW-1.53.zip

Rem
bbdoc: Newton Module
End Rem
Module klepto.newton

ModuleInfo "Version: 1.00"
ModuleInfo "Author: Leadwerks,Klepto2"
ModuleInfo "License: see www.physicsengine.com"
ModuleInfo "Modserver: klepto"

?win32
Import "libNewton.a"
?linux
Import "libNewton.a"
?MacOS
Import "libnewton32.a"
?


Extern
'================================================
' World Functions
'================================================
Function NewtonCreate:Byte Ptr( mallocFnt: Byte Ptr, mfreeFnt:Byte Ptr)
Function NewtonDestroy(nWorld: Byte Ptr)
Function NewtonUpdate(newtonWorld: Byte Ptr, time:Float)
Function NewtonDestroyAllBodies(newtonWorld: Byte Ptr)
Function NewtonSetSolverModel(NewtonWorld:Byte Ptr, model:Int)
Function NewtonSetFrictionModel(NewtonWorld:Byte Ptr, model:Int)
Function NewtonGetTimeStep:Float(NewtonWorld:Byte Ptr)
Function NewtonSetMinimumFrameRate(NewtonWorld:Byte Ptr, frameRate:Float)
Function NewtonSetBodyLeaveWorldEvent(NewtonWorld:Byte Ptr, BodyLeaveWorld_callback:Byte Ptr)
Function NewtonSetWorldSize(newtonWorld:Byte Ptr, minPoint: Byte Ptr, maxPoint:Byte Ptr)
Function NewtonWorldFreezeBody(NewtonWorld:Byte Ptr, body:Byte Ptr)
Function NewtonWorldUnfreezeBody(newtonWorld:Byte Ptr, body:Byte Ptr)
Function NewtonWorldForEachBodyDo(NewtonWorld:Byte Ptr, BodyIterator_callback:Byte Ptr)
Function NewtonWorldSetUserData(NewtonWorld:Byte Ptr, userData:Byte Ptr)
Function NewtonWorldGetUserData:Byte Ptr(NewtonWorld:Byte Ptr)
Function NewtonWorldGetVersion:Int(NewtonWorld:Byte Ptr)
Function NewtonWorldRayCast(NewtonWorld:Byte Ptr, p0:Byte Ptr, p1:Byte Ptr, WorldRayFilterCallback:Byte Ptr, userData:Byte Ptr)
Function NewtonWorldCollide:Int(NewtonWorld:Byte Ptr, maxSize:Int,collsionA:Byte Ptr, matrixA:Byte Ptr, collsionB:Byte Ptr, matrixB:Byte Ptr, contacts:Byte Ptr, normals:Byte Ptr, penetration:Byte Ptr)
Function NewtonMaterialGetDefaultGroupID:Int(NewtonWorld:Byte Ptr)
Function NewtonMaterialCreateGroupID:Int(NewtonWorld:Byte Ptr)
Function NewtonMaterialDestroyAllGroupID(NewtonWorld:Byte Ptr)
Function NewtonMaterialSetDefaultSoftness(NewtonWorld:Byte Ptr, id0:Int, id1:Int, value:Float)
Function NewtonMaterialSetDefaultElasticity(NewtonWorld:Byte Ptr, id0:Int, id1:Int, elasticCoef:Float)
Function NewtonMaterialSetDefaultCollidable(NewtonWorld:Byte Ptr, id0:Int, id1:Int, state:Int)
Function NewtonMaterialSetDefaultFriction(NewtonWorld:Byte Ptr, id0:Int, id1:Int, staticFriction:Float, kineticFriction:Float)
Function NewtonMaterialSetCollisionCallback(NewtonWorld:Byte Ptr, id0:Int, id1:Int, userData:Byte Ptr, begin:Byte Ptr, process:Byte Ptr, NEnd:Byte Ptr)
Function NewtonMaterialGetUserData:Byte Ptr(NewtonWorld:Byte Ptr, id0:Int, id1:Int)
Function NewtonMaterialDisableContact (material:Byte Ptr)
Function NewtonMaterialGetCurrentTimestep:Float(material:Byte Ptr)
Function NewtonMaterialGetMaterialPairUserData:Byte Ptr(material:Byte Ptr)
Function NewtonMaterialGetContactFaceAttribute:Int(material: Byte Ptr)
Function NewtonMaterialGetBodyCollisionID:Int(material: Byte Ptr, body:Byte Ptr)
Function NewtonMaterialGetContactNormalSpeed:Float(material:Byte Ptr, contactlHandle:Byte Ptr)
Function NewtonMaterialGetContactForce(material: Byte Ptr, force:Byte Ptr)
Function NewtonMaterialGetContactPositionAndNormal(material:Byte Ptr, posit:Byte Ptr, normal:Byte Ptr)
Function NewtonMaterialGetContactTangentDirections(material:Byte Ptr, dir0:Byte Ptr, dir:Byte Ptr)
Function NewtonMaterialGetContactTangentSpeed:Float(material:Byte Ptr, NewtonContact:Byte Ptr, index:Int)

Function NewtonSetPlatformArchitecture(world:Byte Ptr,mode:Int)

Function NewtonMaterialSetContactSoftness(NewtonMaterial:Byte Ptr, softness:Float)
Function NewtonMaterialSetContactElasticity(NewtonMaterial:Byte Ptr, restitution:Float)
Function NewtonMaterialSetContactFrictionState(NewtonMaterial:Byte Ptr, state:Int, index:Int)
Function NewtonMaterialSetContactStaticFrictionCoef(NewtonMaterial:Byte Ptr, coef:Float, index:Int)
Function NewtonMaterialSetContactKineticFrictionCoef(NewtonMaterial:Byte Ptr, coef:Float, index:Int)
Function NewtonMaterialSetContactTangentAcceleration(NewtonMaterial:Byte Ptr, accel:Float, index:Int)

Function NewtonMaterialContactRotateTangentDirections(NewtonMaterial:Byte Ptr, directionVector:Byte Ptr)

'================================================
' convex collision primitives creation functions
'================================================
Function NewtonCreateNull:Byte Ptr(NewtonWorld:Byte Ptr)	'NewtonCollision
Function NewtonCreateSphere:Byte Ptr(NewtonWorld:Byte Ptr, radiusX:Float, radiusY:Float, radiusZ:Float, offsetMatrix:Byte Ptr)
Function NewtonCreateBox:Byte Ptr(NewtonWorld:Byte Ptr, dx:Float, dy:Float, dz:Float, offsetMatrix:Byte Ptr)
Function NewtonCreateCone:Byte Ptr(NewtonWorld:Byte Ptr, radius:Float, height:Float, offsetMatrix:Byte Ptr)
Function NewtonCreateCapsule:Byte Ptr(NewtonWorld:Byte Ptr, radius:Float, height:Float, offsetMatrix:Byte Ptr)
Function NewtonCreateCylinder:Byte Ptr(NewtonWorld:Byte Ptr, radius:Float, height:Float, offsetMatrix:Byte Ptr)
Function NewtonCreateChamferCylinder:Byte Ptr(NewtonWorld:Byte Ptr, radius:Float, height:Float, offsetMatrix:Byte Ptr)
Function NewtonCreateConvexHull:Byte Ptr(NewtonWorld:Byte Ptr, count:Int, vertexCloud:Byte Ptr, strideInBytes:Int, offsetMatrix:Byte Ptr)
Function NewtonCreateConvexHullModifier:Byte Ptr(NewtonWorld:Byte Ptr, convexHullCollision:Byte Ptr)
Function NewtonConvexHullModifierGetMatrix(convexHullCollision:Byte Ptr, matrix:Byte Ptr)
Function NewtonConvexHullModifierSetMatrix(convexHullCollision:Byte Ptr, matrix:Byte Ptr)
	
Function NewtonConvexCollisionSetUserID(convexCollision:Byte Ptr, id:Int)
Function NewtonConvexCollisionGetUserID:Int(convexCollision:Byte Ptr)

'================================================
'complex collision primitives creation functions
'================================================
Function NewtonCreateCompoundCollision:Byte Ptr(NewtonWorld:Byte Ptr, count:Int, collisionPrimitiveArray:Byte Ptr[])
Function NewtonCreateUserMeshCollision:Byte Ptr(NewtonWorld:Byte Ptr, minBox:Byte Ptr, maxBox:Byte Ptr, userData:Byte Ptr, collideCallback:Byte Ptr, rayHitCallback:Byte Ptr, destroyCallback:Byte Ptr)

'================================================
' CollisionTree Utility functions
'================================================
Function NewtonCreateTreeCollision:Byte Ptr(NewtonWorld:Byte Ptr, userCallback:Byte Ptr)
Function NewtonTreeCollisionBeginBuild(NewtonCollision: Byte Ptr)
Function NewtonTreeCollisionAddFace(NewtonCollision: Byte Ptr, vertexCount:Int, vertexPtr: Byte Ptr, strideInBytes:Int, faceAttribute:Int)
Function NewtonTreeCollisionEndBuild(NewtonCollision: Byte Ptr, optimize:Int)
'	NEWTON_API void NewtonTreeCollisionSerialize (Const NewtonCollision* treeCollision, NewtonSerialize serializeFunction, 
'		void* serializeHandle);
Function NewtonCreateTreeCollisionFromSerialization:Byte Ptr(NewtonWorld:Byte Ptr, userCallback:Byte Ptr,deserializeFunction:Byte Ptr, serializeHandle:Byte Ptr)
Function NewtonTreeCollisionGetFaceAtribute:Int(NewtonCollision:Byte Ptr, faceIndexArray:Byte Ptr) 
Function NewtonTreeCollisionSetFaceAtribute(NewtonCollision: Byte Ptr, faceIndexArray: Byte Ptr, attribute:Int) 

'================================================
' Collision Miscelaneos Function
'================================================
Function NewtonReleaseCollision(NewtonWorld:Byte Ptr, NewtonCollision:Byte Ptr)
Function NewtonCollisionCalculateAABB(NewtonCollision:Byte Ptr, matrix:Byte Ptr, p0:Byte Ptr, p1:Byte Ptr)
Function NewtonCollisionRayCast:Float(NewtonCollision:Byte Ptr, p0:Byte Ptr, p1:Byte Ptr, normals:Byte Ptr, attribute:Byte Ptr)

'================================================
' transforms utility functions
'================================================
Function NewtonGetEulerAngle(matrix:Byte Ptr, eulersAngles:Byte Ptr)
Function NewtonSetEulerAngle(eulersAngles:Byte Ptr, matrix:Byte Ptr)

'================================================
' body manipulation functions
'================================================
Function NewtonCreateBody:Byte Ptr(NewtonWorld:Byte Ptr, NewtonCollision:Byte Ptr)
Function NewtonDestroyBody(NewtonWorld:Byte Ptr, body:Byte Ptr)

Function NewtonBodyAddForce(body:Byte Ptr, force:Byte Ptr)
Function NewtonBodyAddTorque(body:Byte Ptr, torque:Byte Ptr)

Function NewtonBodySetMatrix(body:Byte Ptr, matrix:Byte Ptr)
Function NewtonBodySetMatrixRecursive(body:Byte Ptr, matrix:Byte Ptr)
Function NewtonBodySetMassMatrix(body:Byte Ptr, mass:Float, Ixx:Float, Iyy:Float, Izz:Float)
Function NewtonBodySetMaterialGroupID(body:Byte Ptr, id:Int)
Function NewtonBodySetContinuousCollisionMode(body:Byte Ptr, state:Int)
Function NewtonBodySetJointRecursiveCollision(body:Byte Ptr, state:Int)
Function NewtonBodySetOmega(body:Byte Ptr, omega:Byte Ptr)
Function NewtonBodySetVelocity(body:Byte Ptr, velocity:Byte Ptr)
Function NewtonBodySetForce (body:Byte Ptr, force:Byte Ptr)
Function NewtonBodySetTorque(body:Byte Ptr, torque:Byte Ptr)
Function NewtonBodySetLinearDamping(body:Byte Ptr, linearDamp:Float)
Function NewtonBodySetAngularDamping(body:Byte Ptr, angularDamp:Byte Ptr)
Function NewtonBodySetUserData(body:Byte Ptr, userData:Byte Ptr)
Function NewtonBodyCoriolisForcesMode(body:Byte Ptr, mode:Int)
Function NewtonBodySetCollision(body:Byte Ptr, collision:Byte Ptr)
Function NewtonBodySetAutoFreeze(body:Byte Ptr, state:Int)
Function NewtonBodySetFreezeTreshold(body:Byte Ptr, freezeSpeed2:Float, freezeOmega2:Float, framesCount:Int)
	
Function NewtonBodySetTransformCallback(body:Byte Ptr, SetTransform_callback:Byte Ptr)
Function NewtonBodySetDestructorCallback(body:Byte Ptr, BodyDest_callback:Byte Ptr)
Function NewtonBodySetAutoactiveCallback(body:Byte Ptr, BodyActState_callback:Byte Ptr)
Function NewtonBodySetForceAndTorqueCallback(body:Byte Ptr, ApplyForceTorque_callback:Byte Ptr)

Function NewtonBodyGetWorld:Byte Ptr(body:Byte Ptr)
Function NewtonBodyGetUserData:Byte Ptr(body:Byte Ptr)
Function NewtonBodyGetCollision:Byte Ptr(body:Byte Ptr)
Function NewtonBodyGetMaterialGroupID:Int(body:Byte Ptr)
Function NewtonBodyGetContinuousCollisionMode:Int(body:Byte Ptr)
Function NewtonBodyGetJointRecursiveCollision:Int(body:Byte Ptr)
Function NewtonBodyGetMatrix(body:Byte Ptr, matrix:Byte Ptr)
Function NewtonBodyGetMassMatrix(body:Byte Ptr, mass:Byte Ptr, Ixx:Byte Ptr, Iyy:Byte Ptr, Izz:Byte Ptr)
Function NewtonBodyGetInvMass(body:Byte Ptr, invMass:Byte Ptr, invIxx:Byte Ptr, invIyy:Byte Ptr, invIzz:Byte Ptr)
Function NewtonBodyGetOmega(body:Byte Ptr, vector:Byte Ptr)
Function NewtonBodyGetVelocity(body:Byte Ptr, vector:Byte Ptr)
Function NewtonBodyGetForce(body:Byte Ptr, vector:Byte Ptr)
Function NewtonBodyGetTorque(body:Byte Ptr, vector:Byte Ptr)
	
Function NewtonBodyGetSleepingState:Int(body:Byte Ptr)
Function NewtonBodyGetAutoFreeze:Int(body:Byte Ptr)
Function NewtonBodyGetLinearDamping:Float(body:Byte Ptr)
Function NewtonBodyGetAngularDamping (body:Byte Ptr, vector:Byte Ptr)
Function NewtonBodyGetAABB (body:Byte Ptr, p0:Byte Ptr, p1:Byte Ptr)	
Function NewtonBodyGetFreezeTreshold(body:Byte Ptr, freezeSpeed2:Byte Ptr, freezeOmega2:Byte Ptr)
Function NewtonBodyGetTotalVolume:Float(body:Byte Ptr)
Function NewtonBodyAddBuoyancyForce(body:Byte Ptr, fluidDensity:Float, fluidLinearViscosity:Float, fluidAngularViscosity:Float,gravityVector:Byte Ptr, buoyancyPlane:Byte Ptr, context:Byte Ptr)

Function NewtonBodyForEachPolygonDo (body:Byte Ptr, CollisionIterator_callback:Byte Ptr)
Function NewtonAddBodyImpulse(body:Byte Ptr, pointDeltaVeloc:Byte Ptr, pointPosit:Byte Ptr)

'================================================
' Common joint funtions
'================================================
Function NewtonJointGetUserData:Byte Ptr(joint:Byte Ptr)
Function NewtonJointSetUserData(joint:Byte Ptr, userData:Byte Ptr)

Function NewtonJointGetCollisionState:Int(joint:Byte Ptr)
Function NewtonJointSetCollisionState(joint:Byte Ptr, state:Int)

Function NewtonJointGetStiffness:Float(joint:Byte Ptr)
Function NewtonJointSetStiffness(joint:Byte Ptr, state:Float)

Function NewtonDestroyJoint(NewtonWorld:Byte Ptr, joint:Byte Ptr)
Function NewtonJointSetDestructor(joint:Byte Ptr, destructor:Byte Ptr)

'================================================
' Ball And Socket joint functions
'================================================
Function NewtonConstraintCreateBall:Byte Ptr(NewtonWorld:Byte Ptr, pivotPoint:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)
Function NewtonBallSetUserCallback(ball:Byte Ptr, BallCallBack_callback:Byte Ptr)
Function NewtonBallGetJointAngle (ball:Byte Ptr, angle:Byte Ptr)
Function NewtonBallGetJointOmega (ball:Byte Ptr, omega:Byte Ptr)
Function NewtonBallGetJointForce (ball:Byte Ptr, force:Byte Ptr)
Function NewtonBallSetConeLimits (ball:Byte Ptr, pin:Byte Ptr, maxConeAngle:Float, maxTwistAngle:Float)

'================================================
' Hinge joint functions
'================================================
Function NewtonConstraintCreateHinge:Byte Ptr(NewtonWorld:Byte Ptr, pivotPoint:Byte Ptr, pinDir:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)

Function NewtonHingeSetUserCallback(hinge:Byte Ptr, HingeCallBack_callback:Byte Ptr)
Function NewtonHingeGetJointAngle:Float(hinge:Byte Ptr)
Function NewtonHingeGetJointOmega:Float(hinge:Byte Ptr)
Function NewtonHingeGetJointForce(hinge:Byte Ptr,  force:Byte Ptr)
Function NewtonHingeCalculateStopAlpha:Float(hinge:Byte Ptr, desc:Byte Ptr, angle:Float)


'================================================
' Slider joint functions
'================================================
Function NewtonConstraintCreateSlider:Byte Ptr(NewtonWorld:Byte Ptr,pivotPoint:Byte Ptr, pinDir:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)
Function NewtonSliderSetUserCallback(slider:Byte Ptr, SliderCallBack_callback:Byte Ptr)
Function NewtonSliderGetJointPosit:Float(slider:Byte Ptr)
Function NewtonSliderGetJointVeloc:Float(slider:Byte Ptr)
Function NewtonSliderGetJointForce (slider:Byte Ptr,  force:Byte Ptr)
Function NewtonSliderCalculateStopAccel:Float(slider:Byte Ptr, desc:Byte Ptr, position:Float)


'================================================
' Corkscrew joint functions
'================================================
Function NewtonConstraintCreateCorkscrew:Byte Ptr(NewtonWorld:Byte Ptr,pivotPoint:Byte Ptr, pinDir:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)
Function NewtonCorkscrewSetUserCallback(corkscrew:Byte Ptr, CorkscrewCallBack_callback:Byte Ptr)
Function NewtonCorkscrewGetJointPosit:Float (corkscrew:Byte Ptr)
Function NewtonCorkscrewGetJointAngle:Float( corkscrew:Byte Ptr)
Function NewtonCorkscrewGetJointVeloc:Float(corkscrew:Byte Ptr)
Function NewtonCorkscrewGetJointOmega:Float( corkscrew:Byte Ptr)
Function NewtonCorkscrewGetJointForce(corkscrew:Byte Ptr, force:Byte Ptr)
Function NewtonCorkscrewCalculateStopAlpha:Float(corkscrew:Byte Ptr, desc:Byte Ptr, angle:Float)
Function NewtonCorkscrewCalculateStopAccel:Float(corkscrew:Byte Ptr, desc:Byte Ptr, position:Float)


'================================================
' Universal joint functions
'================================================
Function NewtonConstraintCreateUniversal:Byte Ptr(NewtonWorld:Byte Ptr, pivotPoint:Byte Ptr, pinDir0:Byte Ptr, pinDir1:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)
Function NewtonUniversalSetUserCallback(universal:Byte Ptr, UniversalCallBack_callback:Byte Ptr)
Function NewtonUniversalGetJointAngle0:Float( universal:Byte Ptr)
Function NewtonUniversalGetJointAngle1:Float(universal:Byte Ptr)
Function NewtonUniversalGetJointOmega0:Float( universal:Byte Ptr)
Function NewtonUniversalGetJointOmega1:Float (universal:Byte Ptr)
Function NewtonUniversalGetJointForce(universal:Byte Ptr, force:Byte Ptr)
Function NewtonUniversalCalculateStopAlpha0:Float(universal:Byte Ptr, desc:Byte Ptr, angle:Float)
Function NewtonUniversalCalculateStopAlpha1:Float(universal:Byte Ptr, desc:Byte Ptr, angle:Float)


'================================================
'Up vector joint functions
'================================================
Function NewtonConstraintCreateUpVector:Byte Ptr(NewtonWorld:Byte Ptr, pinDir:Byte Ptr, body:Byte Ptr) 
Function NewtonUpVectorGetPin(upVector:Byte Ptr, pin:Byte Ptr)
Function NewtonUpVectorSetPin(upVector:Byte Ptr, pin:Byte Ptr)


'================================================
' User defined bilateral Joint
'================================================
Function NewtonConstraintCreateUserJoint:Byte Ptr(NewtonWorld:Byte Ptr, maxDOF:Int, UserBilateralCallBack_callback:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr) 
Function NewtonUserJointAddLinearRow(joint:Byte Ptr, pivot0:Byte Ptr, pivot1:Byte Ptr, dir:Byte Ptr)
Function NewtonUserJointAddAngularRow(joint:Byte Ptr, relativeAngle:Float, dir:Byte Ptr)
Function NewtonUserJointSetRowMinimunFriction(joint:Byte Ptr,  friction:Float)
Function NewtonUserJointSetRowMaximunFriction( joint:Float, friction:Float)
Function NewtonUserJointSetRowAcceleration(joint:Byte Ptr,  acceleration:Float)
Function NewtonUserJointSetRowStiffness( joint:Float,stiffness:Float)
Function NewtonUserJointGetRowForce:Float(joint:Byte Ptr, row:Int)


'================================================
' Ragdoll joint contatiner funtion
'================================================
Function NewtonCreateRagDoll:Byte Ptr(NewtonWorld:Byte Ptr)
Function NewtonDestroyRagDoll(NewtonWorld:Byte Ptr, ragDoll:Byte Ptr)

Function NewtonRagDollBegin( ragDoll:Byte Ptr)
Function NewtonRagDollEnd( ragDoll:Byte Ptr)


Function NewtonRagDollFindBone:Byte Ptr( ragDoll:Byte Ptr, id:Int)
Function NewtonRagDollGetRootBone:Byte Ptr( ragDoll:Byte Ptr)

Function NewtonRagDollSetForceAndTorqueCallback( ragDoll:Byte Ptr, ApplyForceAndTorque_callback:Byte Ptr)
Function NewtonRagDollSetTransformCallback(ragDoll:Byte Ptr, SetRagDollTransform_callback:Byte Ptr)
Function NewtonRagDollAddBone:Byte Ptr(ragDoll:Byte Ptr, parent:Byte Ptr, userData:Byte Ptr, mass:Float, matrix:Byte Ptr, boneCollision:Byte Ptr, size:Byte Ptr)

Function NewtonRagDollBoneGetUserData:Byte Ptr( bone:Byte Ptr)
Function NewtonRagDollBoneGetBody:Byte Ptr( bone:Byte Ptr)
Function NewtonRagDollBoneSetID(bone:Byte Ptr, id:Int)


Function NewtonRagDollBoneSetLimits(bone:Byte Ptr, coneDir:Byte Ptr, minConeAngle:Float, maxConeAngle:Float, maxTwistAngle:Float, bilateralConeDir:Byte Ptr, negativeBilateralConeAngle:Float, positiveBilateralConeAngle:Float)
	

Function NewtonRagDollBoneGetLocalMatrix(bone:Byte Ptr,  matrix:Byte Ptr)
Function NewtonRagDollBoneGetFunctionMatrix( bone:Byte Ptr,  matrix:Byte Ptr)


'================================================
' Vehicle joint functions
'================================================
Function NewtonConstraintCreateVehicle:Byte Ptr(NewtonWorld:Byte Ptr, upDir:Byte Ptr, body:Byte Ptr) 
Function NewtonVehicleReset(vehicle:Byte Ptr) 
Function NewtonVehicleSetTireCallback(vehicle:Byte Ptr, update:Byte Ptr)
Function NewtonVehicleAddTire:Int(vehicle:Byte Ptr, localMatrix:Byte Ptr, pin:Byte Ptr, mass:Float, width:Float, radius:Float, suspesionShock:Float, suspesionSpring:Float, suspesionLength:Float, userData:Byte Ptr, collisionID:Int)
Function NewtonVehicleRemoveTire(vehicle:Byte Ptr, tireIndex:Int)
Function NewtonVehicleBalanceTires(vehicle:Byte Ptr, gravityMag:Float)

Function NewtonVehicleGetFirstTireID:Int(vehicle:Byte Ptr)
Function NewtonVehicleGetNextTireID:Int(vehicle:Byte Ptr, tireId:Int)

Function NewtonVehicleTireIsAirBorne:Int (vehicle:Byte Ptr, tireId:Int)
Function NewtonVehicleTireLostSideGrip:Int(vehicle:Byte Ptr, tireId:Int)
Function NewtonVehicleTireLostTraction:Int(vehicle:Byte Ptr, tireId:Int)

Function NewtonVehicleGetTireUserData:Byte Ptr(vehicle:Byte Ptr, tireId:Int)
Function NewtonVehicleGetTireOmega:Float(vehicle:Byte Ptr, tireId:Int)
Function NewtonVehicleGetTireNormalLoad:Float(vehicle:Byte Ptr, tireId:Int)
Function NewtonVehicleGetTireSteerAngle:Float (vehicle:Byte Ptr, tireId:Int)
Function NewtonVehicleGetTireLateralSpeed:Float(vehicle:Byte Ptr, tireId:Int)
Function NewtonVehicleGetTireLongitudinalSpeed:Float(vehicle:Byte Ptr, tireId:Int)
Function hicleGetTireMatrix(vehicle:Byte Ptr, tireId:Int , matrix:Byte Ptr)


Function NewtonVehicleSetTireTorque(vehicle:Byte Ptr, tireId:Int, torque:Float)
Function NewtonVehicleSetTireSteerAngle(vehicle:Byte Ptr, tireId:Int,  angle:Float)
	
Function NewtonVehicleSetTireMaxSideSleepSpeed(vehicle:Byte Ptr, tireId:Int, speed:Float)
Function NewtonVehicleSetTireSideSleepCoeficient(vehicle:Byte Ptr, tireId:Int,  coeficient:Float)
Function NewtonVehicleSetTireMaxLongitudinalSlideSpeed(vehicle:Byte Ptr, tireId:Int, speed:Float)
Function NewtonVehicleSetTireLongitudinalSlideCoeficient(vehicle:Byte Ptr, tireId:Int, coeficient:Float)

Function NewtonVehicleTireCalculateMaxBrakeAcceleration:Float(vehicle:Byte Ptr, tireId:Int)
Function NewtonVehicleTireSetBrakeAcceleration(vehicle:Byte Ptr, tireId:Int,  accelaration:Float, torqueLimit:Float)

Function NewtonConvexCollisionCalculateInertialMatrix(body:Byte Ptr,inertia:Byte Ptr,mass:Byte Ptr)
Function NewtonBodySetCentreOfMass(Node:Byte Ptr,Massp:Byte Ptr)
Function NewtonConvexCollisionCalculateVolume:Float(body:Byte Ptr)
'Function NewtonMaterialContactRotateTangentDirections(NewtonMaterial:Byte Ptr, directionVector:Byte Ptr)
Function NewtonMaterialSetContinuousCollisionMode(NewtonWorld:Byte Ptr, id0:Int,id1:Int,state:Int)


End Extern


The only restriction with this is, that you have to set the:
NewtonSetPlatformArchitecture(world:Byte Ptr,mode:Int)
to the mode 0. This is due the lack of current mmx,sse etc problems with the current build. (Hopefully this is solved in the next version)

Anyone have a small demo that uses Halo's newton wrapper?

This is as far as I've gotten:
Strict

Import Pub.Newton

Graphics 800,600,0,0

Local NewtonStatus:Int = StartNewton()
If NewtonStatus = False Then Notify("Newton Failure.")

While Not KeyHit(KEY_ESCAPE)
Cls

Flip
Wend
StopNewton()
EndGraphics
End


Any chance to see some examples ?? :)

Read the manual and the Newton forum, it's easy to set up.

I've been using the Newton SDK docs to get your module working and it's a bit complex, I'm no c++ programmer so bare with me, it has transform matrix code which I can't convert
dMatrix matrix (box.getMatrix())
matrix.m_poit_x = 0.0f;
matrix.m_poit_y = 1.0f;
matrix.m_poit_z = 0.0f;

NewtonBodySetMatrix(rigidBodyBox, &matrix[0][0]);


How can this be converted in BlitzMax? Thanks.

In my engine I do this:
NewtonBodySetMatrix(rigidBodyBox,mat.grid)

However, I rewrote MiniB3D's matrix routines to work with a left-handed coordinate system. MiniB3D stores the z-axis backwards and renders it in a right-handed coord system, so I am not sure if you will have to make changes to the matrix you give Newton.

This adds syntax highlighting and a couple of extra functions.

I am not going to document this, but if someone else wants to, I will use whatever they give me. Newton comes with a chm file you could cut and paste from.
Strict

Rem
bbdoc: www.newtongamedynamics.com
End Rem
Module Pub.Newton

Import Pub.Win32

Extern
	Function FreeLibrary(hlib:Int)="FreeLibrary@4"
EndExtern

'================================================
' World Functions
'================================================
Rem
bbdoc: la la la
End Rem
Global NewtonTreeCollisionGetVertexListIndexListInAABB:Int(collision:Byte Ptr,p0:Byte Ptr,p1:Byte Ptr,vertexarray:Byte Ptr,vertexcount:Byte Ptr,vertexstride:Byte Ptr,indicelist:Byte Ptr,indicelistsize:Int)

Rem
bbdoc: la la la
End Rem
Global NewtonWorldForEachBodyInAABBDo(world:Byte Ptr,p0:Byte Ptr,p1:Byte Ptr,callback:Byte Ptr)

Rem
bbdoc: la la la
End Rem
Global NewtonCollisionMakeUnique( nworld:Byte Ptr,collisionPtr:Byte Ptr)

Rem
bbdoc: la la la
End Rem
Global NewtonCreate:Byte Ptr( mallocFnt: Byte Ptr, mfreeFnt:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonDestroy(nWorld: Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonUpdate(newtonWorld: Byte Ptr, time:Float)
Rem
bbdoc: la la la
End Rem
Global NewtonDestroyAllBodies(newtonWorld: Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonSetSolverModel(newtonWorld:Byte Ptr, model:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonSetFrictionModel(newtonWorld:Byte Ptr, model:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonGetTimeStep:Float(newtonWorld:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonSetMinimumFrameRate(newtonWorld:Byte Ptr, frameRate:Float)
Rem
bbdoc: la la la
End Rem
Global NewtonSetBodyLeaveWorldEvent(newtonWorld:Byte Ptr, BodyLeaveWorld_callback:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonSetWorldSize(newtonWorld: Byte Ptr, minPoint: Byte Ptr, maxPoint:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonWorldFreezeBody(newtonWorld:Byte Ptr, body:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonWorldUnfreezeBody(newtonWorld: Byte Ptr, body:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonWorldForEachBodyDo(newtonWorld:Byte Ptr, BodyIterator_callback:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonWorldSetUserData(newtonWorld:Byte Ptr, userData:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonWorldGetUserData:Byte Ptr(newtonWorld:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonWorldGetVersion:Int(newtonWorld:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonWorldRayCast(newtonWorld:Byte Ptr, p0:Byte Ptr, p1:Byte Ptr, WorldRayFilterCallback:Byte Ptr, userData:Byte Ptr,WorldRayPrefilterCallback:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonWorldCollide:Int(newtonWorld:Byte Ptr, maxSize:Int,collsionA:Byte Ptr, matrixA:Byte Ptr, collsionB:Byte Ptr, matrixB:Byte Ptr, contacts:Byte Ptr, normals:Byte Ptr, penetration:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialGetDefaultGroupID:Int(newtonWorld:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialCreateGroupID:Int(newtonWorld:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialDestroyAllGroupID(newtonWorld:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialSetDefaultSoftness(newtonWorld:Byte Ptr, id0:Int, id1:Int, value:Float)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialSetDefaultElasticity(newtonWorld:Byte Ptr, id0:Int, id1:Int, elasticCoef:Float)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialSetDefaultCollidable(newtonWorld:Byte Ptr, id0:Int, id1:Int, state:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialSetDefaultFriction(newtonWorld:Byte Ptr, id0:Int, id1:Int, staticFriction:Float, kineticFriction:Float)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialSetCollisionCallback(newtonWorld:Byte Ptr, id0:Int, id1:Int, userData:Byte Ptr, begin:Byte Ptr, process:Byte Ptr, NEnd:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialGetUserData:Byte Ptr(newtonWorld:Byte Ptr, id0:Int, id1:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialDisableContact (material:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialGetCurrentTimestep:Float(material:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialGetMaterialPairUserData:Byte Ptr(material:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialGetContactFaceAttribute:Int(material: Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialGetBodyCollisionID:Int(material: Byte Ptr, body:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialGetContactNormalSpeed:Float(material:Byte Ptr, contactlHandle:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialGetContactForce(material: Byte Ptr, force:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialGetContactPositionAndNormal(material:Byte Ptr, posit:Byte Ptr, normal:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialGetContactTangentDirections(material:Byte Ptr, dir0:Byte Ptr, dir:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialGetContactTangentSpeed:Float(material:Byte Ptr, NewtonContact:Byte Ptr, index:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetCentreOfMass(body:Byte Ptr,pos:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialSetContactNormalAcceleration(material:Byte Ptr,vec:Byte Ptr)

Rem
bbdoc: la la la
End Rem
Global NewtonSetPlatformArchitecture(world:Byte Ptr,mode:Int)

Rem
bbdoc: la la la
End Rem
Global NewtonMaterialSetContactSoftness(NewtonMaterial:Byte Ptr, softness:Float)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialSetContactElasticity(NewtonMaterial:Byte Ptr, restitution:Float)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialSetContactFrictionState(NewtonMaterial:Byte Ptr, state:Int, index:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialSetContactStaticFrictionCoef(NewtonMaterial:Byte Ptr, coef:Float, index:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialSetContactKineticFrictionCoef(NewtonMaterial:Byte Ptr, coef:Float, index:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonMaterialSetContactTangentAcceleration(NewtonMaterial:Byte Ptr, accel:Float, index:Int)
Rem
bbdoc: la la la
End Rem

Global NewtonMaterialSetContactNormalDirection(NewtonMaterial:Byte Ptr,normal:Byte Ptr)

Rem
bbdoc: la la la
End Rem
Global NewtonMaterialContactRotateTangentDirections(NewtonMaterial:Byte Ptr, directionVector:Byte Ptr)

'================================================
' convex collision primitives creation functions
'================================================
Rem
bbdoc: la la la
End Rem
Global NewtonCreateNull:Byte Ptr(newtonWorld:Byte Ptr)	'NewtonCollision
Rem
bbdoc: la la la
End Rem
Global NewtonCreateSphere:Byte Ptr(newtonWorld:Byte Ptr, radiusX:Float, radiusY:Float, radiusZ:Float, offsetMatrix:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonCreateBox:Byte Ptr(newtonWorld:Byte Ptr, dx:Float, dy:Float, dz:Float, offsetMatrix:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonCreateCone:Byte Ptr(newtonWorld:Byte Ptr, radius:Float, height:Float, offsetMatrix:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonCreateCapsule:Byte Ptr(newtonWorld:Byte Ptr, radius:Float, height:Float, offsetMatrix:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonCreateCylinder:Byte Ptr(newtonWorld:Byte Ptr, radius:Float, height:Float, offsetMatrix:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonCreateChamferCylinder:Byte Ptr(newtonWorld:Byte Ptr, radius:Float, height:Float, offsetMatrix:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonCreateConvexHull:Byte Ptr(newtonWorld:Byte Ptr, count:Int, vertexCloud:Byte Ptr, strideInBytes:Int, offsetMatrix:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonCreateConvexHullModifier:Byte Ptr(newtonWorld:Byte Ptr, convexHullCollision:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonConvexHullModifierGetMatrix(convexHullCollision:Byte Ptr, matrix:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonConvexHullModifierSetMatrix(convexHullCollision:Byte Ptr, matrix:Byte Ptr)
	
Rem
bbdoc: la la la
End Rem
Global NewtonConvexCollisionSetUserID(convexCollision:Byte Ptr, id:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonConvexCollisionGetUserID:Int(convexCollision:Byte Ptr)

Rem
bbdoc: la la la
End Rem
Global NewtonConvexCollisionCalculateInertialMatrix(collision:Byte Ptr,inertia:Byte Ptr,center:Byte Ptr)

'================================================
'complex collision primitives creation functions
'================================================
Rem
bbdoc: la la la
End Rem
Global NewtonCreateCompoundCollision:Byte Ptr(newtonWorld:Byte Ptr, count:Int, collisionPrimitiveArray:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonCreateUserMeshCollision:Byte Ptr(newtonWorld:Byte Ptr, minBox:Byte Ptr, maxBox:Byte Ptr, userData:Byte Ptr, collideCallback:Byte Ptr, rayHitCallback:Byte Ptr, destroyCallback:Byte Ptr)

'================================================
' CollisionTree Utility functions
'================================================
Rem
bbdoc: la la la
End Rem
Global NewtonCreateTreeCollision:Byte Ptr(newtonWorld:Byte Ptr, userCallback:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonTreeCollisionBeginBuild(NewtonCollision: Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonTreeCollisionAddFace(NewtonCollision: Byte Ptr, vertexCount:Int, vertexPtr: Byte Ptr, strideInBytes:Int, faceAttribute:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonTreeCollisionEndBuild(NewtonCollision: Byte Ptr, optimize:Int)
'	NEWTON_API void NewtonTreeCollisionSerialize (Const NewtonCollision* treeCollision, NewtonSerialize serializeFunction, 
'		void* serializeHandle);
Rem
bbdoc: la la la
End Rem
Global NewtonTreeCollisionSerialize(treeCollision:Byte Ptr,serializeFunction:Byte Ptr,serializeHandle:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonCreateTreeCollisionFromSerialization:Byte Ptr(newtonWorld:Byte Ptr, userCallback:Byte Ptr,deserializeFunction:Byte Ptr, serializeHandle:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonTreeCollisionGetFaceAtribute:Int(NewtonCollision:Byte Ptr, faceIndexArray:Byte Ptr) 
Rem
bbdoc: la la la
End Rem
Global NewtonTreeCollisionSetFaceAtribute(NewtonCollision: Byte Ptr, faceIndexArray: Byte Ptr, attribute:Int) 

'================================================
' Collision Miscelaneos Function
'================================================
Rem
bbdoc: la la la
End Rem
Global NewtonReleaseCollision(newtonWorld:Byte Ptr, NewtonCollision:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonCollisionCalculateAABB(NewtonCollision:Byte Ptr, matrix:Byte Ptr, p0:Byte Ptr, p1:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonCollisionRayCast:Float(NewtonCollision:Byte Ptr, p0:Byte Ptr, p1:Byte Ptr, normals:Byte Ptr, attribute:Byte Ptr)

'================================================
' transforms utility functions
'================================================
Rem
bbdoc: la la la
End Rem
Global NewtonGetEulerAngle(matrix:Byte Ptr, eulersAngles:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonSetEulerAngle(eulersAngles:Byte Ptr, matrix:Byte Ptr)


Rem
bbdoc: la la la
End Rem
Global NewtonCollisionCollide:Int(world:Byte Ptr,maxSize:Int,collision0:Byte Ptr,matrix0:Byte Ptr,collision1:Byte Ptr,matrix1:Byte Ptr,contacts:Byte Ptr,normals:Byte Ptr,penetration:Byte Ptr)

'================================================
' body manipulation functions
'================================================
Rem
bbdoc: la la la
End Rem
Global NewtonCreateBody:Byte Ptr(newtonWorld:Byte Ptr, NewtonCollision:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonDestroyBody(newtonWorld:Byte Ptr, body:Byte Ptr)

Rem
bbdoc: la la la
End Rem
Global NewtonBodyAddForce(body:Byte Ptr, force:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyAddTorque(body:Byte Ptr, torque:Byte Ptr)

Rem
bbdoc: la la la
End Rem
Global NewtonBodySetMatrix(body:Byte Ptr, matrix:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetMatrixRecursive(body:Byte Ptr, matrix:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetMassMatrix(body:Byte Ptr, mass:Float, Ixx:Float, Iyy:Float, Izz:Float)
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetMaterialGroupID(body:Byte Ptr, id:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetContinuousCollisionMode(body:Byte Ptr, state:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetJointRecursiveCollision(body:Byte Ptr, state:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetOmega(body:Byte Ptr, omega:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetVelocity(body:Byte Ptr, velocity:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetForce (body:Byte Ptr, force:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetTorque(body:Byte Ptr, torque:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetLinearDamping(body:Byte Ptr, linearDamp:Float)
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetAngularDamping(body:Byte Ptr, angularDamp:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetUserData(body:Byte Ptr, userData:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyCoriolisForcesMode(body:Byte Ptr, mode:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetCollision(body:Byte Ptr, collision:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetAutoFreeze(body:Byte Ptr, state:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetFreezeTreshold(body:Byte Ptr, freezeSpeed2:Float, freezeOmega2:Float, framesCount:Int)
	
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetTransformCallback(body:Byte Ptr, SetTransform_callback:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetDestructorCallback(body:Byte Ptr, BodyDest_callback:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetAutoactiveCallback(body:Byte Ptr, BodyActState_callback:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodySetForceAndTorqueCallback(body:Byte Ptr, ApplyForceTorque_callback:Byte Ptr)

Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetWorld:Byte Ptr(body:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetUserData:Byte Ptr(body:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetCollision:Byte Ptr(body:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetMaterialGroupID:Int(body:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetContinuousCollisionMode:Int(body:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetJointRecursiveCollision:Int(body:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetMatrix(body:Byte Ptr, matrix:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetMassMatrix(body:Byte Ptr, mass:Byte Ptr, Ixx:Byte Ptr, Iyy:Byte Ptr, Izz:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetInvMass(body:Byte Ptr, invMass:Byte Ptr, invIxx:Byte Ptr, invIyy:Byte Ptr, invIzz:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetOmega(body:Byte Ptr, vector:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetVelocity(body:Byte Ptr, vector:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetForce(body:Byte Ptr, vector:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetTorque(body:Byte Ptr, vector:Byte Ptr)
	
Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetSleepingState:Int(body:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetAutoFreeze:Int(body:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetLinearDamping:Float(body:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetAngularDamping (body:Byte Ptr, vector:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetAABB (body:Byte Ptr, p0:Byte Ptr, p1:Byte Ptr)	
Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetFreezeTreshold(body:Byte Ptr, freezeSpeed2:Byte Ptr, freezeOmega2:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyGetTotalVolume:Float(body:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBodyAddBuoyancyForce(body:Byte Ptr, fluidDensity:Float, fluidLinearViscosity:Float, fluidAngularViscosity:Float,gravityVector:Byte Ptr, buoyancyPlane:Byte Ptr, context:Byte Ptr)

Rem
bbdoc: la la la
End Rem
Global NewtonBodyForEachPolygonDo (body:Byte Ptr, CollisionIterator_callback:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonAddBodyImpulse(body:Byte Ptr, pointDeltaVeloc:Byte Ptr, pointPosit:Byte Ptr)

'================================================
' Common joint funtions
'================================================
Rem
bbdoc: la la la
End Rem
Global NewtonJointGetUserData:Byte Ptr(joint:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonJointSetUserData(joint:Byte Ptr, userData:Byte Ptr)

Rem
bbdoc: la la la
End Rem
Global NewtonJointGetCollisionState:Int(joint:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonJointSetCollisionState(joint:Byte Ptr, state:Int)

Rem
bbdoc: la la la
End Rem
Global NewtonJointGetStiffness:Float(joint:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonJointSetStiffness(joint:Byte Ptr, state:Float)

Rem
bbdoc: la la la
End Rem
Global NewtonDestroyJoint(newtonWorld:Byte Ptr, joint:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonJointSetDestructor(joint:Byte Ptr, destructor:Byte Ptr)

'================================================
' Ball And Socket joint functions
'================================================
Rem
bbdoc: la la la
End Rem
Global NewtonConstraintCreateBall:Byte Ptr(newtonWorld:Byte Ptr, pivotPoint:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBallSetUserCallback(ball:Byte Ptr, BallCallBack_callback:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBallGetJointAngle (ball:Byte Ptr, angle:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBallGetJointOmega (ball:Byte Ptr, omega:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBallGetJointForce (ball:Byte Ptr, force:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonBallSetConeLimits (ball:Byte Ptr, pin:Byte Ptr, maxConeAngle:Float, maxTwistAngle:Float)

'================================================
' Hinge joint functions
'================================================
Rem
bbdoc: la la la
End Rem
Global NewtonConstraintCreateHinge:Byte Ptr(newtonWorld:Byte Ptr, pivotPoint:Byte Ptr, pinDir:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)

Rem
bbdoc: la la la
End Rem
Global NewtonHingeSetUserCallback(hinge:Byte Ptr, HingeCallBack_callback:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonHingeGetJointAngle:Float(hinge:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonHingeGetJointOmega:Float(hinge:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonHingeGetJointForce(hinge:Byte Ptr,  force:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonHingeCalculateStopAlpha:Float(hinge:Byte Ptr, desc:Byte Ptr, angle:Float)


'================================================
' Slider joint functions
'================================================
Rem
bbdoc: la la la
End Rem
Global NewtonConstraintCreateSlider:Byte Ptr(newtonWorld:Byte Ptr,pivotPoint:Byte Ptr, pinDir:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonSliderSetUserCallback(slider:Byte Ptr, SliderCallBack_callback:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonSliderGetJointPosit:Float(slider:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonSliderGetJointVeloc:Float(slider:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonSliderGetJointForce (slider:Byte Ptr,  force:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonSliderCalculateStopAccel:Float(slider:Byte Ptr, desc:Byte Ptr, position:Float)


'================================================
' Corkscrew joint functions
'================================================
Rem
bbdoc: la la la
End Rem
Global NewtonConstraintCreateCorkscrew:Byte Ptr(newtonWorld:Byte Ptr,pivotPoint:Byte Ptr, pinDir:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonCorkscrewSetUserCallback(corkscrew:Byte Ptr, CorkscrewCallBack_callback:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonCorkscrewGetJointPosit:Float (corkscrew:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonCorkscrewGetJointAngle:Float( corkscrew:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonCorkscrewGetJointVeloc:Float(corkscrew:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonCorkscrewGetJointOmega:Float( corkscrew:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonCorkscrewGetJointForce(corkscrew:Byte Ptr, force:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonCorkscrewCalculateStopAlpha:Float(corkscrew:Byte Ptr, desc:Byte Ptr, angle:Float)
Rem
bbdoc: la la la
End Rem
Global NewtonCorkscrewCalculateStopAccel:Float(corkscrew:Byte Ptr, desc:Byte Ptr, position:Float)


'================================================
' Universal joint functions
'================================================
Rem
bbdoc: la la la
End Rem
Global NewtonConstraintCreateUniversal:Byte Ptr(newtonWorld:Byte Ptr, pivotPoint:Byte Ptr, pinDir0:Byte Ptr, pinDir1:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonUniversalSetUserCallback(universal:Byte Ptr, UniversalCallBack_callback:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonUniversalGetJointAngle0:Float( universal:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonUniversalGetJointAngle1:Float(universal:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonUniversalGetJointOmega0:Float( universal:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonUniversalGetJointOmega1:Float (universal:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonUniversalGetJointForce(universal:Byte Ptr, force:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonUniversalCalculateStopAlpha0:Float(universal:Byte Ptr, desc:Byte Ptr, angle:Float)
Rem
bbdoc: la la la
End Rem
Global NewtonUniversalCalculateStopAlpha1:Float(universal:Byte Ptr, desc:Byte Ptr, angle:Float)


'================================================
'Up vector joint functions
'================================================
Rem
bbdoc: la la la
End Rem
Global NewtonConstraintCreateUpVector:Byte Ptr(newtonWorld:Byte Ptr, pinDir:Byte Ptr, body:Byte Ptr) 
Rem
bbdoc: la la la
End Rem
Global NewtonUpVectorGetPin(upVector:Byte Ptr, pin:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonUpVectorSetPin(upVector:Byte Ptr, pin:Byte Ptr)


'================================================
' User defined bilateral Joint
'================================================
Rem
bbdoc: la la la
End Rem
Global NewtonConstraintCreateUserJoint:Byte Ptr(newtonWorld:Byte Ptr, maxDOF:Int, UserBilateralCallBack_callback:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr) 
Rem
bbdoc: la la la
End Rem
Global NewtonUserJointAddLinearRow(joint:Byte Ptr, pivot0:Byte Ptr, pivot1:Byte Ptr, dir:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonUserJointAddAngularRow(joint:Byte Ptr, relativeAngle:Float, dir:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonUserJointSetRowMinimunFriction(joint:Byte Ptr,  friction:Float)
Rem
bbdoc: la la la
End Rem
Global NewtonUserJointSetRowMaximunFriction( joint:Float, friction:Float)
Rem
bbdoc: la la la
End Rem
Global NewtonUserJointSetRowAcceleration(joint:Byte Ptr,  acceleration:Float)
Rem
bbdoc: la la la
End Rem
Global NewtonUserJointSetRowStiffness( joint:Float,stiffness:Float)
Rem
bbdoc: la la la
End Rem
Global NewtonUserJointGetRowForce:Float(joint:Byte Ptr, row:Int)


'================================================
' Ragdoll joint contatiner funtion
'================================================
Rem
bbdoc: la la la
End Rem
Global NewtonCreateRagDoll:Byte Ptr(newtonWorld:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonDestroyRagDoll(newtonWorld:Byte Ptr, ragDoll:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonRagDollBegin( ragDoll:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonRagDollEnd( ragDoll:Byte Ptr)


Rem
bbdoc: la la la
End Rem
Global NewtonRagDollFindBone:Byte Ptr( ragDoll:Byte Ptr, id:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonRagDollGetRootBone:Byte Ptr( ragDoll:Byte Ptr)

Rem
bbdoc: la la la
End Rem
Global NewtonRagDollSetForceAndTorqueCallback( ragDoll:Byte Ptr, ApplyForceAndTorque_callback:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonRagDollSetTransformCallback(ragDoll:Byte Ptr, SetRagDollTransform_callback:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonRagDollAddBone:Byte Ptr(ragDoll:Byte Ptr, parent:Byte Ptr, userData:Byte Ptr, mass:Float, matrix:Byte Ptr, boneCollision:Byte Ptr, size:Byte Ptr)

Rem
bbdoc: la la la
End Rem
Global NewtonRagDollBoneGetUserData:Byte Ptr( bone:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonRagDollBoneGetBody:Byte Ptr( bone:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonRagDollBoneSetID(bone:Byte Ptr, id:Int)


Rem
bbdoc: la la la
End Rem
Global NewtonRagDollBoneSetLimits(bone:Byte Ptr, coneDir:Byte Ptr, minConeAngle:Float, maxConeAngle:Float, maxTwistAngle:Float, bilateralConeDir:Byte Ptr, negativeBilateralConeAngle:Float, positiveBilateralConeAngle:Float)
	

Rem
bbdoc: la la la
End Rem
Global NewtonRagDollBoneGetLocalMatrix(bone:Byte Ptr,  matrix:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonRagDollBoneGetGlobalMatrix( bone:Byte Ptr,  matrix:Byte Ptr)


'================================================
' Vehicle joint functions
'================================================
Rem
bbdoc: la la la
End Rem
Global NewtonConstraintCreateVehicle:Byte Ptr(newtonWorld:Byte Ptr, upDir:Byte Ptr, body:Byte Ptr) 
Rem
bbdoc: la la la
End Rem
Global NewtonVehicleReset(vehicle:Byte Ptr) 
Rem
bbdoc: la la la
End Rem
Global NewtonVehicleSetTireCallback(vehicle:Byte Ptr, update:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonVehicleAddTire:Int(vehicle:Byte Ptr, localMatrix:Byte Ptr, pin:Byte Ptr, mass:Float, width:Float, radius:Float, suspesionShock:Float, suspesionSpring:Float, suspesionLength:Float, userData:Byte Ptr, collisionID:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonVehicleRemoveTire(vehicle:Byte Ptr, tireIndex:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonVehicleBalanceTires(vehicle:Byte Ptr, gravityMag:Float)

Rem
bbdoc: la la la
End Rem
Global NewtonVehicleGetFirstTireID:Int(vehicle:Byte Ptr)
Rem
bbdoc: la la la
End Rem
Global NewtonVehicleGetNextTireID:Int(vehicle:Byte Ptr, tireId:Int)

Rem
bbdoc: la la la
End Rem
Global NewtonVehicleTireIsAirBorne:Int (vehicle:Byte Ptr, tireId:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonVehicleTireLostSideGrip:Int(vehicle:Byte Ptr, tireId:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonVehicleTireLostTraction:Int(vehicle:Byte Ptr, tireId:Int)

Rem
bbdoc: la la la
End Rem
Global NewtonVehicleGetTireUserData:Byte Ptr(vehicle:Byte Ptr, tireId:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonVehicleGetTireOmega:Float(vehicle:Byte Ptr, tireId:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonVehicleGetTireNormalLoad:Float(vehicle:Byte Ptr, tireId:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonVehicleGetTireSteerAngle:Float (vehicle:Byte Ptr, tireId:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonVehicleGetTireLateralSpeed:Float(vehicle:Byte Ptr, tireId:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonVehicleGetTireLongitudinalSpeed:Float(vehicle:Byte Ptr, tireId:Int)
Rem
bbdoc: la la la
End Rem
Global hicleGetTireMatrix(vehicle:Byte Ptr, tireId:Int , matrix:Byte Ptr)


Rem
bbdoc: la la la
End Rem
Global NewtonVehicleSetTireTorque(vehicle:Byte Ptr, tireId:Int, torque:Float)
Rem
bbdoc: la la la
End Rem
Global NewtonVehicleSetTireSteerAngle(vehicle:Byte Ptr, tireId:Int,  angle:Float)
	
Rem
bbdoc: la la la
End Rem
Global NewtonVehicleSetTireMaxSideSleepSpeed(vehicle:Byte Ptr, tireId:Int, speed:Float)
Rem
bbdoc: la la la
End Rem
Global NewtonVehicleSetTireSideSleepCoeficient(vehicle:Byte Ptr, tireId:Int,  coeficient:Float)
Rem
bbdoc: la la la
End Rem
Global NewtonVehicleSetTireMaxLongitudinalSlideSpeed(vehicle:Byte Ptr, tireId:Int, speed:Float)
Rem
bbdoc: la la la
End Rem
Global NewtonVehicleSetTireLongitudinalSlideCoeficient(vehicle:Byte Ptr, tireId:Int, coeficient:Float)

Rem
bbdoc: la la la
End Rem
Global NewtonVehicleTireCalculateMaxBrakeAcceleration:Float(vehicle:Byte Ptr, tireId:Int)
Rem
bbdoc: la la la
End Rem
Global NewtonVehicleTireSetBrakeAcceleration(vehicle:Byte Ptr, tireId:Int,  accelaration:Float, torqueLimit:Float)

Rem
bbdoc: la la la
End Rem
Global phBodyGetPitch:Float(body:Int)
Rem
bbdoc: la la la
End Rem
Global phBodyGetYaw:Float(body:Int)
Rem
bbdoc: la la la
End Rem
Global phBodyGetRoll:Float(body:Int)


Rem
bbdoc: la la la
End Rem
Global HLIB_NEWTON:Int

Rem
bbdoc: la la la
End Rem
Function StartNewton:Int()
	If HLIB_NEWTON Return True
	HLIB_NEWTON=LoadLibraryA("bin\Newton.dll")
	If Not HLIB_NEWTON HLIB_NEWTON=LoadLibraryA("dlls\Newton.dll")
	If Not HLIB_NEWTON HLIB_NEWTON=LoadLibraryA("Newton.dll")
	If Not HLIB_NEWTON Return

	'Retrieve function pointers
	
	NewtonWorldForEachBodyInAABBDo=getprocaddress(HLIB_NEWTON,"NewtonWorldForEachBodyInAABBDo")
	
	NewtonTreeCollisionGetVertexListIndexListInAABB=getprocaddress(HLIB_NEWTON,"NewtonTreeCollisionGetVertexListIndexListInAABB")
	NewtonSetPlatformArchitecture=getprocaddress(HLIB_NEWTON,"NewtonSetPlatformArchitecture")
	NewtonCreate=GetProcAddress(HLIB_NEWTON,"NewtonCreate")
	NewtonDestroy=GetProcAddress(HLIB_NEWTON,"NewtonDestroy")
	NewtonUpdate=GetProcAddress(HLIB_NEWTON,"NewtonUpdate")
	NewtonDestroyAllBodies=GetProcAddress(HLIB_NEWTON,"NewtonDestroyAllBodies")
	NewtonSetSolverModel=GetProcAddress(HLIB_NEWTON,"NewtonSetSolverModel")
	NewtonSetFrictionModel=GetProcAddress(HLIB_NEWTON,"NewtonSetFrictionModel")
	NewtonGetTimeStep=GetProcAddress(HLIB_NEWTON,"NewtonGetTimeStep")
	NewtonSetMinimumFrameRate=GetProcAddress(HLIB_NEWTON,"NewtonSetMinimumFrameRate")
	NewtonSetBodyLeaveWorldEvent=GetProcAddress(HLIB_NEWTON,"NewtonSetBodyLeaveWorldEvent")
	NewtonSetWorldSize=GetProcAddress(HLIB_NEWTON,"NewtonSetWorldSize")
	NewtonWorldFreezeBody=GetProcAddress(HLIB_NEWTON,"NewtonWorldFreezeBody")
	NewtonWorldUnfreezeBody=GetProcAddress(HLIB_NEWTON,"NewtonWorldUnfreezeBody")
	NewtonWorldForEachBodyDo=GetProcAddress(HLIB_NEWTON,"NewtonWorldForEachBodyDo")
	NewtonWorldSetUserData=GetProcAddress(HLIB_NEWTON,"NewtonWorldSetUserData")
	NewtonWorldGetUserData=GetProcAddress(HLIB_NEWTON,"NewtonWorldGetUserData")
	NewtonWorldGetVersion=GetProcAddress(HLIB_NEWTON,"NewtonWorldGetVersion")
	NewtonWorldRayCast=GetProcAddress(HLIB_NEWTON,"NewtonWorldRayCast")
	NewtonWorldCollide=GetProcAddress(HLIB_NEWTON,"NewtonWorldCollide")
	NewtonMaterialGetDefaultGroupID=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetDefaultGroupID")
	NewtonMaterialCreateGroupID=GetProcAddress(HLIB_NEWTON,"NewtonMaterialCreateGroupID")
	NewtonMaterialDestroyAllGroupID=GetProcAddress(HLIB_NEWTON,"NewtonMaterialDestroyAllGroupID")
	NewtonMaterialSetDefaultSoftness=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetDefaultSoftness")
	NewtonMaterialSetDefaultElasticity=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetDefaultElasticity")
	NewtonMaterialSetDefaultCollidable=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetDefaultCollidable")
	NewtonMaterialSetDefaultFriction=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetDefaultFriction")
	NewtonMaterialSetCollisionCallback=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetCollisionCallback")
	NewtonMaterialGetUserData=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetUserData")
	NewtonMaterialDisableContact=GetProcAddress(HLIB_NEWTON,"NewtonMaterialDisableContact")
	NewtonMaterialGetCurrentTimestep=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetCurrentTimestep")
	NewtonMaterialGetMaterialPairUserData=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetMaterialPairUserData")
	NewtonMaterialGetContactFaceAttribute=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetContactFaceAttribute")
	NewtonMaterialGetBodyCollisionID=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetBodyCollisionID")
	NewtonMaterialGetContactNormalSpeed=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetContactNormalSpeed")
	NewtonMaterialGetContactForce=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetContactForce")
	NewtonMaterialGetContactPositionAndNormal=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetContactPositionAndNormal")
	NewtonMaterialGetContactTangentDirections=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetContactTangentDirections")
	NewtonMaterialGetContactTangentSpeed=GetProcAddress(HLIB_NEWTON,"NewtonMaterialGetContactTangentSpeed")
	NewtonMaterialSetContactSoftness=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetContactSoftness")
	NewtonMaterialSetContactElasticity=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetContactElasticity")
	NewtonMaterialSetContactFrictionState=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetContactFrictionState")
	NewtonMaterialSetContactStaticFrictionCoef=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetContactStaticFrictionCoef")
	NewtonMaterialSetContactKineticFrictionCoef=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetContactKineticFrictionCoef")
	NewtonMaterialSetContactTangentAcceleration=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetContactTangentAcceleration")
	NewtonMaterialContactRotateTangentDirections=GetProcAddress(HLIB_NEWTON,"NewtonMaterialContactRotateTangentDirections")
	NewtonCreateNull=GetProcAddress(HLIB_NEWTON,"NewtonCreateNull")
	NewtonCreateSphere=GetProcAddress(HLIB_NEWTON,"NewtonCreateSphere")
	NewtonCreateBox=GetProcAddress(HLIB_NEWTON,"NewtonCreateBox")
	NewtonCreateCone=GetProcAddress(HLIB_NEWTON,"NewtonCreateCone")
	NewtonCreateCapsule=GetProcAddress(HLIB_NEWTON,"NewtonCreateCapsule")
	NewtonCreateCylinder=GetProcAddress(HLIB_NEWTON,"NewtonCreateCylinder")
	NewtonCreateChamferCylinder=GetProcAddress(HLIB_NEWTON,"NewtonCreateChamferCylinder")
	NewtonCreateConvexHull=GetProcAddress(HLIB_NEWTON,"NewtonCreateConvexHull")
	NewtonCreateConvexHullModifier=GetProcAddress(HLIB_NEWTON,"NewtonCreateConvexHullModifier")
	NewtonConvexHullModifierGetMatrix=GetProcAddress(HLIB_NEWTON,"NewtonConvexHullModifierGetMatrix")
	NewtonConvexHullModifierSetMatrix=GetProcAddress(HLIB_NEWTON,"NewtonConvexHullModifierSetMatrix")
	NewtonConvexCollisionSetUserID=GetProcAddress(HLIB_NEWTON,"NewtonConvexCollisionSetUserID")
	NewtonConvexCollisionGetUserID=GetProcAddress(HLIB_NEWTON,"NewtonConvexCollisionGetUserID")
	NewtonCreateCompoundCollision=GetProcAddress(HLIB_NEWTON,"NewtonCreateCompoundCollision")
	NewtonCreateUserMeshCollision=GetProcAddress(HLIB_NEWTON,"NewtonCreateUserMeshCollision")
	NewtonCreateTreeCollision=GetProcAddress(HLIB_NEWTON,"NewtonCreateTreeCollision")
	NewtonTreeCollisionBeginBuild=GetProcAddress(HLIB_NEWTON,"NewtonTreeCollisionBeginBuild")
	NewtonTreeCollisionAddFace=GetProcAddress(HLIB_NEWTON,"NewtonTreeCollisionAddFace")
	NewtonTreeCollisionEndBuild=GetProcAddress(HLIB_NEWTON,"NewtonTreeCollisionEndBuild")
	NewtonTreeCollisionSerialize=GetProcAddress(HLIB_NEWTON,"NewtonTreeCollisionSerialize")
	NewtonCreateTreeCollisionFromSerialization=GetProcAddress(HLIB_NEWTON,"NewtonCreateTreeCollisionFromSerialization")
	NewtonTreeCollisionGetFaceAtribute=GetProcAddress(HLIB_NEWTON,"NewtonTreeCollisionGetFaceAtribute")
	NewtonTreeCollisionSetFaceAtribute=GetProcAddress(HLIB_NEWTON,"NewtonTreeCollisionSetFaceAtribute")
	NewtonReleaseCollision=GetProcAddress(HLIB_NEWTON,"NewtonReleaseCollision")
	NewtonCollisionCalculateAABB=GetProcAddress(HLIB_NEWTON,"NewtonCollisionCalculateAABB")
	NewtonCollisionRayCast=GetProcAddress(HLIB_NEWTON,"NewtonCollisionRayCast")
	NewtonGetEulerAngle=GetProcAddress(HLIB_NEWTON,"NewtonGetEulerAngle")
	NewtonSetEulerAngle=GetProcAddress(HLIB_NEWTON,"NewtonSetEulerAngle")
	NewtonCollisionMakeUnique=GetProcAddress(HLIB_NEWTON,"NewtonCollisionMakeUnique")
	NewtonCreateBody=GetProcAddress(HLIB_NEWTON,"NewtonCreateBody")
	NewtonDestroyBody=GetProcAddress(HLIB_NEWTON,"NewtonDestroyBody")
	NewtonBodyAddForce=GetProcAddress(HLIB_NEWTON,"NewtonBodyAddForce")
	NewtonBodyAddTorque=GetProcAddress(HLIB_NEWTON,"NewtonBodyAddTorque")
	NewtonBodySetMatrix=GetProcAddress(HLIB_NEWTON,"NewtonBodySetMatrix")
	NewtonBodySetMatrixRecursive=GetProcAddress(HLIB_NEWTON,"NewtonBodySetMatrixRecursive")
	NewtonBodySetMassMatrix=GetProcAddress(HLIB_NEWTON,"NewtonBodySetMassMatrix")
	NewtonBodySetMaterialGroupID=GetProcAddress(HLIB_NEWTON,"NewtonBodySetMaterialGroupID")
	NewtonBodySetContinuousCollisionMode=GetProcAddress(HLIB_NEWTON,"NewtonBodySetContinuousCollisionMode")
	NewtonBodySetJointRecursiveCollision=GetProcAddress(HLIB_NEWTON,"NewtonBodySetJointRecursiveCollision")
	NewtonBodySetOmega=GetProcAddress(HLIB_NEWTON,"NewtonBodySetOmega")
	NewtonBodySetVelocity=GetProcAddress(HLIB_NEWTON,"NewtonBodySetVelocity")
	NewtonBodySetForce=GetProcAddress(HLIB_NEWTON,"NewtonBodySetForce")
	NewtonBodySetTorque=GetProcAddress(HLIB_NEWTON,"NewtonBodySetTorque")
	NewtonBodySetLinearDamping=GetProcAddress(HLIB_NEWTON,"NewtonBodySetLinearDamping")
	NewtonBodySetAngularDamping=GetProcAddress(HLIB_NEWTON,"NewtonBodySetAngularDamping")
	NewtonBodySetUserData=GetProcAddress(HLIB_NEWTON,"NewtonBodySetUserData")
	NewtonBodyCoriolisForcesMode=GetProcAddress(HLIB_NEWTON,"NewtonBodyCoriolisForcesMode")
	NewtonBodySetCollision=GetProcAddress(HLIB_NEWTON,"NewtonBodySetCollision")
	NewtonBodySetAutoFreeze=GetProcAddress(HLIB_NEWTON,"NewtonBodySetAutoFreeze")
	NewtonBodySetFreezeTreshold=GetProcAddress(HLIB_NEWTON,"NewtonBodySetFreezeTreshold")
	NewtonBodySetTransformCallback=GetProcAddress(HLIB_NEWTON,"NewtonBodySetTransformCallback")
	NewtonBodySetDestructorCallback=GetProcAddress(HLIB_NEWTON,"NewtonBodySetDestructorCallback")
	NewtonBodySetAutoactiveCallback=GetProcAddress(HLIB_NEWTON,"NewtonBodySetAutoactiveCallback")
	NewtonBodySetForceAndTorqueCallback=GetProcAddress(HLIB_NEWTON,"NewtonBodySetForceAndTorqueCallback")
	NewtonBodyGetWorld=GetProcAddress(HLIB_NEWTON,"	NewtonBodyGetWorld")
	NewtonBodyGetUserData=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetUserData")
	NewtonBodyGetCollision=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetCollision")
	NewtonBodyGetMaterialGroupID=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetMaterialGroupID")
	NewtonBodyGetContinuousCollisionMode=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetContinuousCollisionMode")
	NewtonBodyGetJointRecursiveCollision=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetJointRecursiveCollision")
	NewtonBodyGetMatrix=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetMatrix")
	NewtonBodyGetMassMatrix=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetMassMatrix")
	NewtonBodyGetInvMass=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetInvMass")
	NewtonBodyGetOmega=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetOmega")
	NewtonBodyGetVelocity=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetVelocity")
	NewtonBodyGetForce=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetForce")
	NewtonBodyGetTorque=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetTorque")
	NewtonBodyGetSleepingState=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetSleepingState")
	NewtonBodyGetAutoFreeze=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetAutoFreeze")
	NewtonBodyGetLinearDamping=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetLinearDamping")
	NewtonBodyGetAngularDamping=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetAngularDamping")
	NewtonBodyGetAABB=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetAABB")
	NewtonBodyGetFreezeTreshold=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetFreezeTreshold")
	NewtonBodyGetTotalVolume=GetProcAddress(HLIB_NEWTON,"NewtonBodyGetTotalVolume")
	NewtonBodyAddBuoyancyForce=GetProcAddress(HLIB_NEWTON,"NewtonBodyAddBuoyancyForce")
	NewtonBodyForEachPolygonDo=GetProcAddress(HLIB_NEWTON,"NewtonBodyForEachPolygonDo")
	NewtonAddBodyImpulse=GetProcAddress(HLIB_NEWTON,"NewtonAddBodyImpulse")
	NewtonJointGetUserData=GetProcAddress(HLIB_NEWTON,"NewtonJointGetUserData")
	NewtonJointSetUserData=GetProcAddress(HLIB_NEWTON,"NewtonJointSetUserData")
	NewtonJointGetCollisionState=GetProcAddress(HLIB_NEWTON,"NewtonJointGetCollisionState")
	NewtonJointSetCollisionState=GetProcAddress(HLIB_NEWTON,"NewtonJointSetCollisionState")
	NewtonJointGetStiffness=GetProcAddress(HLIB_NEWTON,"NewtonJointGetStiffness")
	NewtonJointSetStiffness=GetProcAddress(HLIB_NEWTON,"NewtonJointSetStiffness")
	NewtonDestroyJoint=GetProcAddress(HLIB_NEWTON,"NewtonDestroyJoint")
	NewtonJointSetDestructor=GetProcAddress(HLIB_NEWTON,"NewtonJointSetDestructor")
	NewtonConstraintCreateBall=GetProcAddress(HLIB_NEWTON,"NewtonConstraintCreateBall")
	NewtonBallSetUserCallback=GetProcAddress(HLIB_NEWTON,"NewtonBallSetUserCallback")
	NewtonBallGetJointAngle=GetProcAddress(HLIB_NEWTON,"NewtonBallGetJointAngle")
	NewtonBallGetJointOmega=GetProcAddress(HLIB_NEWTON,"NewtonBallGetJointOmega")
	NewtonBallGetJointForce=GetProcAddress(HLIB_NEWTON,"NewtonBallGetJointForce")
	NewtonBallSetConeLimits=GetProcAddress(HLIB_NEWTON,"NewtonBallSetConeLimits")
	NewtonConstraintCreateHinge=GetProcAddress(HLIB_NEWTON,"NewtonConstraintCreateHinge")
	NewtonHingeSetUserCallback=GetProcAddress(HLIB_NEWTON,"NewtonHingeSetUserCallback")
	NewtonHingeGetJointAngle=GetProcAddress(HLIB_NEWTON,"NewtonHingeGetJointAngle")
	NewtonHingeGetJointOmega=GetProcAddress(HLIB_NEWTON,"NewtonHingeGetJointOmega")
	NewtonHingeGetJointForce=GetProcAddress(HLIB_NEWTON,"NewtonHingeGetJointForce")
	NewtonHingeCalculateStopAlpha=GetProcAddress(HLIB_NEWTON,"NewtonHingeCalculateStopAlpha")
	NewtonConstraintCreateSlider=GetProcAddress(HLIB_NEWTON,"NewtonConstraintCreateSlider")
	NewtonSliderSetUserCallback=GetProcAddress(HLIB_NEWTON,"NewtonSliderSetUserCallback")
	NewtonSliderGetJointPosit=GetProcAddress(HLIB_NEWTON,"NewtonSliderGetJointPosit")
	NewtonSliderGetJointVeloc=GetProcAddress(HLIB_NEWTON,"NewtonSliderGetJointVeloc")
	NewtonSliderGetJointForce=GetProcAddress(HLIB_NEWTON,"NewtonSliderGetJointForce")
	NewtonSliderCalculateStopAccel=GetProcAddress(HLIB_NEWTON,"NewtonSliderCalculateStopAccel")
	NewtonConstraintCreateCorkscrew=GetProcAddress(HLIB_NEWTON,"NewtonConstraintCreateCorkscrew")
	NewtonCorkscrewSetUserCallback=GetProcAddress(HLIB_NEWTON,"NewtonCorkscrewSetUserCallback")
	NewtonCorkscrewGetJointPosit=GetProcAddress(HLIB_NEWTON,"NewtonCorkscrewGetJointPosit")
	NewtonCorkscrewGetJointAngle=GetProcAddress(HLIB_NEWTON,"NewtonCorkscrewGetJointAngle")
	NewtonCorkscrewGetJointVeloc=GetProcAddress(HLIB_NEWTON,"NewtonCorkscrewGetJointVeloc")
	NewtonCorkscrewGetJointOmega=GetProcAddress(HLIB_NEWTON,"NewtonCorkscrewGetJointOmega")
	NewtonCorkscrewGetJointForce=GetProcAddress(HLIB_NEWTON,"NewtonCorkscrewGetJointForce")
	NewtonCorkscrewCalculateStopAlpha=GetProcAddress(HLIB_NEWTON,"NewtonCorkscrewCalculateStopAlpha")
	NewtonCorkscrewCalculateStopAccel=GetProcAddress(HLIB_NEWTON,"NewtonCorkscrewCalculateStopAccel")
	NewtonConstraintCreateUniversal=GetProcAddress(HLIB_NEWTON,"NewtonConstraintCreateUniversal")
	NewtonUniversalSetUserCallback=GetProcAddress(HLIB_NEWTON,"NewtonUniversalSetUserCallback")
	NewtonUniversalGetJointAngle0=GetProcAddress(HLIB_NEWTON,"NewtonUniversalGetJointAngle0")
	NewtonUniversalGetJointAngle1=GetProcAddress(HLIB_NEWTON,"NewtonUniversalGetJointAngle1")
	NewtonUniversalGetJointOmega0=GetProcAddress(HLIB_NEWTON,"NewtonUniversalGetJointOmega0")
	NewtonUniversalGetJointOmega1=GetProcAddress(HLIB_NEWTON,"NewtonUniversalGetJointOmega1")
	NewtonUniversalGetJointForce=GetProcAddress(HLIB_NEWTON,"NewtonUniversalGetJointForce")
	NewtonUniversalCalculateStopAlpha0=GetProcAddress(HLIB_NEWTON,"NewtonUniversalCalculateStopAlpha0")
	NewtonUniversalCalculateStopAlpha1=GetProcAddress(HLIB_NEWTON,"NewtonUniversalCalculateStopAlpha1")
	NewtonConstraintCreateUpVector=GetProcAddress(HLIB_NEWTON,"NewtonConstraintCreateUpVector")
	NewtonUpVectorGetPin=GetProcAddress(HLIB_NEWTON,"NewtonUpVectorGetPin")
	NewtonUpVectorSetPin=GetProcAddress(HLIB_NEWTON,"NewtonUpVectorSetPin")
	NewtonConstraintCreateUserJoint=GetProcAddress(HLIB_NEWTON,"NewtonConstraintCreateUserJoint")
	NewtonUserJointAddLinearRow=GetProcAddress(HLIB_NEWTON,"NewtonUserJointAddLinearRow")
	NewtonUserJointAddAngularRow=GetProcAddress(HLIB_NEWTON,"NewtonUserJointAddAngularRow")
	NewtonUserJointSetRowMinimunFriction=GetProcAddress(HLIB_NEWTON,"NewtonUserJointSetRowMinimunFriction")
	NewtonUserJointSetRowMaximunFriction=GetProcAddress(HLIB_NEWTON,"NewtonUserJointSetRowMaximunFriction")
	NewtonUserJointSetRowAcceleration=GetProcAddress(HLIB_NEWTON,"NewtonUserJointSetRowAcceleration")
	NewtonUserJointSetRowStiffness=GetProcAddress(HLIB_NEWTON,"NewtonUserJointSetRowStiffness")
	NewtonUserJointGetRowForce=GetProcAddress(HLIB_NEWTON,"NewtonUserJointGetRowForce")
	NewtonCreateRagDoll=GetProcAddress(HLIB_NEWTON,"NewtonCreateRagDoll")
	NewtonDestroyRagDoll=GetProcAddress(HLIB_NEWTON,"NewtonDestroyRagDoll")
	NewtonRagDollBegin=GetProcAddress(HLIB_NEWTON,"NewtonRagDollBegin")
	NewtonRagDollEnd=GetProcAddress(HLIB_NEWTON,"NewtonRagDollEnd")
	NewtonRagDollFindBone=GetProcAddress(HLIB_NEWTON,"NewtonRagDollFindBone")
	NewtonRagDollGetRootBone=GetProcAddress(HLIB_NEWTON,"NewtonRagDollGetRootBone")
	NewtonRagDollSetForceAndTorqueCallback=GetProcAddress(HLIB_NEWTON,"NewtonRagDollSetForceAndTorqueCallback")
	NewtonRagDollSetTransformCallback=GetProcAddress(HLIB_NEWTON,"NewtonRagDollSetTransformCallback")
	NewtonRagDollAddBone=GetProcAddress(HLIB_NEWTON,"NewtonRagDollAddBone")
	NewtonRagDollBoneGetUserData=GetProcAddress(HLIB_NEWTON,"NewtonRagDollBoneGetUserData")
	NewtonRagDollBoneGetBody=GetProcAddress(HLIB_NEWTON,"NewtonRagDollBoneGetBody")
	NewtonRagDollBoneSetID=GetProcAddress(HLIB_NEWTON,"NewtonRagDollBoneSetID")
	NewtonRagDollBoneSetLimits=GetProcAddress(HLIB_NEWTON,"NewtonRagDollBoneSetLimits")
	NewtonRagDollBoneGetLocalMatrix=GetProcAddress(HLIB_NEWTON,"NewtonRagDollBoneGetLocalMatrix")
	NewtonRagDollBoneGetGlobalMatrix=GetProcAddress(HLIB_NEWTON,"NewtonRagDollBoneGetGlobalMatrix")
	NewtonConstraintCreateVehicle=GetProcAddress(HLIB_NEWTON,"NewtonConstraintCreateVehicle")
	NewtonVehicleReset=GetProcAddress(HLIB_NEWTON,"NewtonVehicleReset")
	NewtonVehicleSetTireCallback=GetProcAddress(HLIB_NEWTON,"NewtonVehicleSetTireCallback")
	NewtonVehicleAddTire=GetProcAddress(HLIB_NEWTON,"NewtonVehicleAddTire")
	NewtonVehicleRemoveTire=GetProcAddress(HLIB_NEWTON,"NewtonVehicleRemoveTire")
	NewtonVehicleBalanceTires=GetProcAddress(HLIB_NEWTON,"NewtonVehicleBalanceTires")
	NewtonVehicleGetFirstTireID=GetProcAddress(HLIB_NEWTON,"NewtonVehicleGetFirstTireID")
	NewtonVehicleGetNextTireID=GetProcAddress(HLIB_NEWTON,"NewtonVehicleGetNextTireID")
	NewtonVehicleTireIsAirBorne=GetProcAddress(HLIB_NEWTON,"NewtonVehicleTireIsAirBorne")
	NewtonVehicleTireLostSideGrip=GetProcAddress(HLIB_NEWTON,"NewtonVehicleTireLostSideGrip")
	NewtonVehicleTireLostTraction=GetProcAddress(HLIB_NEWTON,"NewtonVehicleTireLostTraction")
	NewtonVehicleGetTireUserData=GetProcAddress(HLIB_NEWTON,"NewtonVehicleGetTireUserData")
	NewtonVehicleGetTireOmega=GetProcAddress(HLIB_NEWTON,"NewtonVehicleGetTireOmega")
	NewtonVehicleGetTireNormalLoad=GetProcAddress(HLIB_NEWTON,"NewtonVehicleGetTireNormalLoad")
	NewtonVehicleGetTireSteerAngle=GetProcAddress(HLIB_NEWTON,"NewtonVehicleGetTireSteerAngle")
	NewtonVehicleGetTireLateralSpeed=GetProcAddress(HLIB_NEWTON,"NewtonVehicleGetTireLateralSpeed")
	NewtonVehicleGetTireLongitudinalSpeed=GetProcAddress(HLIB_NEWTON,"NewtonVehicleGetTireLongitudinalSpeed")
	hicleGetTireMatrix=GetProcAddress(HLIB_NEWTON,"hicleGetTireMatrix")
	NewtonVehicleSetTireTorque=GetProcAddress(HLIB_NEWTON,"NewtonVehicleSetTireTorque")
	NewtonVehicleSetTireSteerAngle=GetProcAddress(HLIB_NEWTON,"NewtonVehicleSetTireSteerAngle")
	NewtonVehicleSetTireMaxSideSleepSpeed=GetProcAddress(HLIB_NEWTON,"NewtonVehicleSetTireMaxSideSleepSpeed")
	NewtonVehicleSetTireSideSleepCoeficient=GetProcAddress(HLIB_NEWTON,"NewtonVehicleSetTireSideSleepCoeficient")
	NewtonVehicleSetTireMaxLongitudinalSlideSpeed=GetProcAddress(HLIB_NEWTON,"NewtonVehicleSetTireMaxLongitudinalSlideSpeed")
	NewtonVehicleSetTireLongitudinalSlideCoeficient=GetProcAddress(HLIB_NEWTON,"NewtonVehicleSetTireLongitudinalSlideCoeficient")
	NewtonVehicleTireCalculateMaxBrakeAcceleration=GetProcAddress(HLIB_NEWTON,"NewtonVehicleTireCalculateMaxBrakeAcceleration")
	NewtonVehicleTireSetBrakeAcceleration=GetProcAddress(HLIB_NEWTON,"NewtonVehicleTireSetBrakeAcceleration")
	NewtonMaterialSetContactNormalDirection=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetContactNormalDirection")
	NewtonMaterialSetContactNormalAcceleration=GetProcAddress(HLIB_NEWTON,"NewtonMaterialSetContactNormalAcceleration")
	NewtonCollisionCollide=GetProcAddress(HLIB_NEWTON,"NewtonCollisionCollide")
	NewtonBodySetCentreOfMass=GetProcAddress(HLIB_NEWTON,"NewtonBodySetCentreOfMass")
	NewtonConvexCollisionCalculateInertialMatrix=GetProcAddress(HLIB_NEWTON,"NewtonConvexCollisionCalculateInertialMatrix")
	Return True
EndFunction

Rem
bbdoc: la la la
End Rem
Function StopNewton()
	If HLIB_NEWTON
		'NewtonDestroy NP_WORLD
		'NP_WORLD=Null
		FreeLibrary HLIB_NEWTON
		HLIB_NEWTON=0
	EndIf
EndFunction


Because I'm quite new here with Bmax, there is no need to re-program the functions which come with the Newton examples? eg. I started converting the functions that come with the tutorials for Newton, like this:
Function PhysicsApplyGravityForce(Body:Byte Ptr)
	Local mass:Float
	Local Ixx:Float
	Local Iyy:Float
	Local Izz:Float
	
'	NewtonBodyGetMassMatrix (body, &mass, &Ixx, &Iyy, &Izz);
	NewtonBodyGetMassMatrix(body, Varptr mass, Varptr Ixx, Varptr Iyy, Varptr Izz)

'	dVector force (0.0f, -mass * 9.8f, 0.0f);
	Local force:Float[] = [0.0, Varptr mass * GRAVITY, 0.0]
	NewtonBodySetForce (body, Varptr force[0])
	
End Function


But infact all I need to do is what you've done, type Global NewtonApplyGravityForce(Body:Byte Ptr), that's it? Or am I missing something here?

You do not need to write a wrapper.

Okay no problem, so where is the best place to go to get my code checked, I've tried posting on the programming section but noone has helped me, I'm trying to convert these c++ functions blind :( Gman started to convert the functions from Tutorial 2 and I'm carrying on from where he left off.