#ifndef __TRUEAXIS_BI__
#define __TRUEAXIS_BI__

' TrueAxis.bi

' A list of units used for different properties. 
' Distance/Position:  meters (m). 
' Mass:               kilograms (kg). 
' Time:               seconds (s). 
' Velocity:           meters per seconds m/s. 
' Acceleration:       meters per seconds squared m/(s*s). 
' Impulse:            kilogram meters per second (kg*m)/s. 
' Force:              kilogram meters per second squared (kg*m)/(s*s) or newtons (N). 
' Rotational inertia: kilogram meters squared kg*(m*m). 
' Torque:             newton meters N*m.
' AngularVelocity:    rad per second

#define USEOPENGL

#ifdef USEOPENGL
#include once "GL/gl.bi"
#endif

#ifdef USEDEBUG 
' if defined TrueAxisDebug.dll or libTrueAxisDebug.so are linked
' this enables PhysicsRender() and PhysicsRenderBoundingBoxes()
' and a file "debug.txt" for a error report
#inclib "TrueAxisDebug"

#else

#inclib "TrueAxis"

#endif


#ifndef PI
const as single PI = atn(1)*4
#endif
const as single RAD2DEG = 180.0/PI
const as single DEG2RAD = PI/180.0

' used by PhysicsTest Ray/Line ForCollision
enum ePHYSICS_FLAGS
  DYNAMIC_OBJECTS         = 1
  STATIC_OBJECTS          = 2
  ALL_OBJECTS             = DYNAMIC_OBJECTS or STATIC_OBJECTS
  GHOST_OBJECTS           = 8
end enum

'  flags marked as "*" are usable after a collision
' the most important flag are FLAG_COLLISION_OCCURRED
enum eCOLLISION_FLAGS
  FLAG_CONSTRAIN_IN_BOTH_DIRECTIONS = &H000001
  FLAG_FRICTION                     = &H000002 ' *
  FLAG_FRICTION_GENERATING_IMPULSE  = &H000004
  FLAG_NO_FRICTION                  = &H000008 ' *
  FLAG_JOINT                        = &H000010 ' *
  FLAG_JOINT_LIMIT                  = &H000020 ' *
  FLAG_COLLISION_OCCURRED           = &H000040 ' *
  FLAG_DISABLE_PUSHOUT              = &H000080
  FLAG_FRICTION_GENERATING_IMPULSE2 = &H000100
  FLAG_MARKED                       = &H000200
  FLAG_RESTITUTION_CALCULATED       = &H000400
  FLAG_OBJECTA_SOLID                = &H001000
  FLAG_OBJECTB_SOLID                = &H002000
  FLAG_NEW_COLLISION                = &H004000
  FLAG_ROTATION_CONSTRAINT          = &H008000 ' *
  FLAG_OBJECTB_INFINITE_MASS        = &H010000
  FLAG_DEPTH_CALCULATED_FROM_TIME   = &H020000
  FLAG_USE_PUSH_OUT_MODIFIER        = &H040000
  FLAG_OBJECTA_SOLID_INTERNAL       = &H080000
  FLAG_OBJECTB_SOLID_INTERNAL       = &H100000
end enum

' every triangle from static AABB mesh can define
' it's own surface attribute default is -1
const as integer DEFAULT_SURFACE_ATTRIBUTE = -1

' used by PhysicsSetDynamicObjectIsMoving
enum ePHYSICS_MOVING_PRIORITIES
  SET_MOVING_PRIORITY_LOW  = 0
  SET_MOVING_PRIORITY_HIGH = 1
end enum

' used by Physics Set/Get SpacialDivisionType
enum ePHYSICS_SPACIAL_DIVISION_TYPES
  FLAG_XY_COLLISION_GRID = &H020
  FLAG_XZ_COLLISION_GRID = &H040
  FLAG_YZ_COLLISION_GRID = &H060
  FLAG_DYNAMIC_OCTREE    = &H080
  FLAG_CTREE             = &H100
end enum

' used by PhysicsJointGetType
enum ePHYSICS_JOINT_TYPES
  BALL_AND_SOCKET = 0
  LIMITED_BALL_AND_SOCKET
  SQUARE_SOCKET
  EULER_ANGLE_CONSTRAINT
  LINEAR_SLIDER
  ROTATION_CONSTRAINT
  VECTOR_CONSTRAINT
end enum

' used by CollisionObjectGetCollisionObjectType
enum eCOLLISIONOBJECT_TYPES
  TYPE_CONVEX = 0
  TYPE_LINE_LIST
  TYPE_CAPSULE
  TYPE_SPHERE
  TYPE_CYLINDER
  TYPE_COMPLEX
  TYPE_CACHED_POLY_DATA
  TYPE_COMBO
end enum

type TA_Vec3
  declare operator cast as single ptr
  declare operator cast as string
  as single x,y,z,pad
end type
operator TA_Vec3.cast as single ptr
  operator = @x
end operator

operator TA_Vec3.cast as string
  operator = str(x) & "," & y & "," & z
end operator

type TA_AABB
  as TA_Vec3 v3Center
  as TA_Vec3 v3Extent
end type

enum eROTATION_AXIS
  ROTATION_AXIS_X = 0
  ROTATION_AXIS_Y
  ROTATION_AXIS_Z
end enum

type TA_EulerAngles
  as single x
  as single y
  as single z
end type

type TA_Mat33
  as TA_Vec3 v3X
  as TA_Vec3 v3Y
  as TA_Vec3 v3Z
end type

type TA_MFrame
  as TA_Mat33 m33Rotation
  as TA_Vec3 v3Translation
end type

type PhysicsObject
  private:
  as integer dummy
end type

type StaticObject extends PhysicsObject
  private:
  as integer dummy
end type

type DynamicObject extends PhysicsObject
  private:
  as integer dummy
end type

type DynamicObjectTemplate extends DynamicObject
  private:
  as integer Dummy
end type

type DynamicObjectTank extends DynamicObject
  private:
  as integer Dummy
end type

type CarTemplate
  private:
  as integer dummy
end type

type DynamicObjectCar extends DynamicObject
  private:
  as integer Dummy
end type

type CollisionObject
  private:
  as integer dummy
end type

' A CollisionObjectSimple descripts an CollisionObject by params not polygones.
type CollisionObjectSimple extends CollisionObject
  private:
  as integer dummy
end type

' A CollisionObjectSphere are defined by it's center and radius
type CollisionObjectSphere extends CollisionObjectSimple
  private:
  as integer dummy
end type

' A CollisionObjectCylinder are defined by two points and radius
type CollisionObjectCylinder extends CollisionObjectSimple
  private:
  as integer dummy
end type

' A CollisionObjectCapsule are defined by two points and radius
type CollisionObjectCapsule extends CollisionObjectSimple
  private:
  as integer dummy
end type

' A CollisionObjectLineList is a colection of lines.
' This lines can be used as sensors for collision detection.
type CollisionObjectLineList extends CollisionObjectSimple
  private:
  as integer dummy
end type

' CollisionObjectConvex descripts a convex shape
' by faces like a box, pyramid ...
type CollisionObjectConvex extends CollisionObjectSimple
  private:
  as integer dummy
end type

' CollisionObjectCombo is a collection of multiply CollisionObjectSimple
type CollisionObjectCombo extends CollisionObject
  private:
  as integer dummy
end type

' A CollisionObjectComplex descripts a CollisionObject
' by polygon data like vertices, edges and face normal's
type CollisionObjectComplex extends CollisionObject
  private:
  as integer dummy
end type

' A CollisionObjectAABBMesh is a complex (large) static shape like a terrain.
type CollisionObjectAABBMesh extends CollisionObjectComplex
  private:
  as integer dummy
end type

' A PhysicsJoint descripts the contrains between DynamicObject's.
type PhysicsJoint
  private:
  as integer dummy
end type

type PreCollision
  private:
  as integer dummy
end type

type PostCollision
  private:
  as integer dummy
end type

' if a CollisionObjectLineList collided with any object
' this struct descripts a line collision.
type LineIntersection
  as single              fIntersectingDepth
  as DynamicObject ptr   pDynamicObject
  as CollisionObject ptr pCollisionObject
  as integer             nSurfaceAttribute
  as TA_Vec3             v3Position
  as TA_Vec3             v3Normal
end type


' ######################
' # optional callbacks #
' ######################
#define TA_CB cdecl 
' A DynamicOject made from DynamicObjectTemplate must be updated.
type UpdateCB as sub TA_CB (byval pObj as DynamicObjectTemplate ptr, byval fDt as single)

' A joint that was broken.
type OnBrokenJointCB as sub TA_CB (byval pJoint as PhysicsJoint ptr)

' A DynamicObject may be moving or at rest.
' When an object is at rest no physics calculations or collision testing is done 
' on this object until another hits it, at which point it is set moving.
type OnMovingCB  as sub TA_CB (byval pObj as DynamicObject ptr, byval pUserData as any ptr)
type OnRestingCB as sub TA_CB (byval pObj as DynamicObject ptr, byval pUserData as any ptr)

' This function allows users to provide their own function to be called "BEFORE" 
' each collision test between 2 dynamic objects is performed during PhysicsUpdate().
' The provided function will only be called when at least one of the objects are moving 
' and it has been determined that the objects are in close proximity.
' Users can use this functionality as flexible way to disallow collisions between objects 
' if they so wish before full and more computationally expensive collision testing is done. 
' If the callback returns false=0, the collision test will be skipped.
type DynamicVsDynamicCollisionTestCB as function TA_CB (byval pObjA as DynamicObject ptr, _
                                                        byval pObjB as DynamicObject ptr) as ubyte

' The function provided by the user through this method will be called for each collision 
' that occurs, "BEFORE" its affects are applied to the simulation. 
' By returning false=0, users can choose to ignore a particular collision. 
type PreProcessCollisionCB as function TA_CB (byval collision as PreCollision ptr) as ubyte

' The function provided by the user through this method will be called for each collision
' that occurs, "AFTER" its affects have been applied to the simulation. 
' The effect of strength of the collision can be found from PostCollisionGetImpulse.
type PostProcessCollisionCB as sub TA_CB (byval collision as PostCollision ptr)

extern "C"

' ###########
' # Physics #
' ###########
' The instance of the Physics class is singleton and must be created at first.
declare function PhysicsCreateInstance() as integer

' Call this function to clean up when the instance of Physics is no longer needed.
' Any objects still added to the simulation will be automatically removed and released. 
declare sub      PhysicsDestroyInstance()

' Call this function to set the position and size of the world that the physics simulation will run in. 
' This may affect the speed and memory usage of culling algorithms.
' The size of the world should be made only as big as necessary. (default are 2000m x 2000m x 2000m)
declare sub      PhysicsSetWorldDimensions(byval centerX as single, byval centerY as single, byval centerZ as single, _
                                           byval width_  as single, byval height  as single, byval depth as single)

declare sub      PhysicsGetWorldDimensions(byref centerX as single, byref centerY as single, byref centerZ as single, _
                                           byref width_  as single, byref height  as single, byref depth   as single)

declare sub      PhysicsV3SetWorldDimensions(byref v3Center as const TA_Vec3, byref v3Dimension as const TA_Vec3)

declare sub      PhysicsV3GetWorldDimensions(byref v3Center as       TA_Vec3, byref v3Dimension as       TA_Vec3)

declare sub      PhysicsAABBSetWorldDimensions(byref aabb as const TA_AABB)

declare sub      PhysicsAABBGetWorldDimensions(byref aabb as TA_AABB)

' Call this function to set the acceleration due to gravity applied 
' to all objects in the simulation. (default are 0.0 ,8.91, 0.0 )
declare sub      PhysicsSetGravity(byval x as single, byval y as single, byval z as single)

declare sub      PhysicsGetGravity(byref x as single, byref y as single, byref z as single)

declare sub      PhysicsV3SetGravity(byref v3Gravity as const TA_Vec3)

declare sub      PhysicsV3GetGravity(byref v3Gravity as       TA_Vec3)

' Call this function to set the maximum number of collisions allowed at once.
declare sub      PhysicsSetMaxNumCollisions(n as integer)

declare function PhysicsGetMaxNumCollisions() as integer

' Call this function to set the maximum number of moving objects allowed at once.
declare sub      PhysicsSetMaxNumMovingObjects(byval n as integer)

declare function PhysicsGetMaxNumMovingObjects() as integer

' Call this function to set the number of collisions at which true axis will swap 
' from using a the slow solver to the, fast solver physics solver.
declare sub      PhysicsSetSlowSolverMaxNumCollisions(byval n as integer)

declare function PhysicsGetSlowSolverMaxNumCollisions() as integer

' Call this function to set the number of objects at which true axis will swap 
' from using a the slow solver to the, fast solver physics solver. 
declare sub      PhysicsSetSlowSolverMaxNumObjects(byval n as integer)

declare function PhysicsGetSlowSolverMaxNumObjects() as integer

' Call this function to set the maximum number of object pairs.
' This value controls the amount of memory allocated for object pairs. 
' If this number is too low, efficiency may be impacted and if not enough pairs are available, some collisions may be ignored.
' If this number is too high, memory is wasted and in some cases, memory cache efficiency may be impacted.
declare sub      PhysicsSetMaxNumObjectPairs(byval nPairs as integer)

declare function PhysicsGetMaxNumObjectPairs() as integer

' Call this function to set the type of spacial sub division used by the True Axis Physics SDK.
' (default are FLAG_DYNAMIC_OCTREE)
declare sub      PhysicsSetSpacialDivisionType(byval DivisionType as ePHYSICS_SPACIAL_DIVISION_TYPES)

declare function PhysicsGetSpacialDivisionType() as ePHYSICS_SPACIAL_DIVISION_TYPES

' Call this function to enable or disable movement propagation. The default value is true. (<>0)
declare sub      PhysicsSetMovementPropagationEnabled(byval bEnabled as integer)

declare function PhysicsIsMovementPropagationEnabled() as integer

' Initialise the simulation based on the settings set above.
declare sub      PhysicsSetupSimulation(byval MaxObjects as integer=0)

' Call this function to update the physics simulation one frame.
declare sub      PhysicsUpdate(byval dt as single=1.0/75.0)

' Call this functions to draw all physics parts (DEBUG mode only)
declare sub      PhysicsRender()
declare sub      PhysicsRenderBoundingBoxes()

' ########################
' # Physics StaticObject #
' ########################
declare sub      PhysicsAddStaticObject(byval pObj as const StaticObject ptr)

declare sub      PhysicsRemoveStaticObject(byval pObj as const StaticObject ptr)

declare function PhysicsAddStaticGround(byval fSize as single=-1.0) as StaticObject ptr

' #########################
' # Physics DynamicObject #
' #########################
declare sub      PhysicsAddDynamicObject(byval pObj as const DynamicObject ptr, byval bInitiallyMoving as integer=1)

declare sub      PhysicsRemoveDynamicObject(byval pObj as const DynamicObject ptr)

declare sub      PhysicsSetDynamicObjectIsMoving(byval pObj as const DynamicObject ptr, byval priority as ePHYSICS_MOVING_PRIORITIES = SET_MOVING_PRIORITY_LOW)


' Call this function to wake up all objects that intersect with a given bounding box. 
declare sub      PhysicsWakeUpAllIntersectingObjects(byval centerX as single, byval centerY as single, byval centerZ as single, _
                                                     byval width_  as single, byval height  as single, byval depth   as single)

declare sub      PhysicsAABBWakeUpAllIntersectingObjects(byref aabb as const TA_AABB)

' ##############################
' # Physics Ray/Line Collision #
' ##############################
declare function PhysicsTestRayForCollision (byval startX as single, byval startY as single, byval startZ as single, _
                                             byval dirX   as single, byval dirY   as single, byval dirZ   as single, _
                                             byval length as single, byval flags as ePHYSICS_FLAGS=ALL_OBJECTS) as eCOLLISION_FLAGS

declare function PhysicsV3TestRayForCollision(byref v3Start as const TA_Vec3, byref v3Dir as const TA_Vec3, _
                                              byval length as single, byval flags as ePHYSICS_FLAGS=ALL_OBJECTS) as eCOLLISION_FLAGS


declare function PhysicsTestLineForCollision(byval startX as single, byval startY as single, byval startZ as single, _
                                             byval endX   as single, byval endY   as single, byval endZ   as single, _
                                             byval flags as ePHYSICS_FLAGS=ALL_OBJECTS) as eCOLLISION_FLAGS

declare function PhysicsV3TestLineForCollision(byref v3Start as const TA_Vec3, byref v3End as const TA_Vec3, _
                                               byval flags as ePHYSICS_FLAGS=ALL_OBJECTS) as eCOLLISION_FLAGS
' ####################
' # PhysicsCallbacks #
' ####################
declare sub      PhysicsSetOnBrokenJointCallBack(cb as OnBrokenJointCB)

declare sub      PhysicsSetOnRestingCallBack(cb as OnRestingCB, pUserData as any ptr)

declare sub      PhysicsSetOnMovingCallBack (cb as OnMovingCB , pUserData as any ptr)

declare sub      PhysicsSetPreProcessCollisionCallBack (cb as PreProcessCollisionCB)

declare sub      PhysicsSetPostProcessCollisionCallBack(cb as PostProcessCollisionCB)

' ###########################
' # PhysicsSurfaceAttribute #
' ###########################
declare function PhysicsAddSurfaceAttribute() as integer
declare sub      PhysicsRemoveSurfaceAttribute(n as integer)
declare function PhysicsGetNumSurfaceAttributes() as integer

declare sub      SurfaceAttributeSetCollisionFriction(byval n as integer, byval fCollisionFriction as single)
declare function SurfaceAttributeGetCollisionFriction(byval n as integer) as single

declare sub      SurfaceAttributeSetRestitution(byval n as integer, byval fRestitution as single)
declare function SurfaceAttributeGetRestitution(byval n as integer) as single

declare sub      SurfaceAttributeSetUserData(byval n as integer, byval pUserData as const any ptr)
declare function SurfaceAttributeGetUserData(byval n as integer) as any ptr

' #####################
' # LineRay Collision #
' #####################
' after a PhysicsTestRay or PhysicsTestLine Collision
declare function CollisionOccurred() as integer

declare function CollisionIsObjectA() as integer
declare function CollisionGetObjectA() as DynamicObject ptr
declare function CollisionGetAttributeA() as integer

declare function CollisionIsObjectB() as integer
declare function CollisionGetObjectB() as DynamicObject ptr
declare function CollisionGetAttributeB() as integer

declare function CollisionIsJoint() as integer
declare function CollisionGetJoint() as PhysicsJoint ptr

declare sub      CollisionGetPosition(byref x as single, byref y as single, byref z as single)
declare sub      CollisionV3GetPosition(byref v3Position as TA_Vec3)

declare sub      CollisionGetNormal  (byref x as single, byref y as single, byref z as single)
declare sub      CollisionV3GetNormal(byref v3Normal as TA_Vec3)

declare function CollisionGetFlags() as eCOLLISION_FLAGS
declare function CollisionGetRestitution() as single
declare function CollisionGetImpulse() as single
declare function CollisionGetFrictionCoefficient() as single
declare function CollisionGetTime() as single
declare function CollisionGetIntersectingDepth() as single

' ################
' # PreCollision #
' ################
' inside a PreCollisionCallback
declare function PreCollisionGetNext(byval pPreCollision as PreCollision ptr) as PreCollision ptr

declare function PreCollisionIsObjectA(byval pPreCollision as PreCollision ptr) as integer
declare function PreCollisionGetObjectA(byval pPreCollision as PreCollision ptr) as DynamicObject ptr
declare function PreCollisionGetAttributeA(byval pPreCollision as PreCollision ptr) as integer

declare function PreCollisionIsObjectB(byval pPreCollision as PreCollision ptr) as integer
declare function PreCollisionGetObjectB(byval pPreCollision as PreCollision ptr) as DynamicObject ptr
declare function PreCollisionGetAttributeB(byval pPreCollision as PreCollision ptr) as integer

declare function PreCollisionIsJoint(byval pPreCollision as PreCollision ptr) as integer
declare function PreCollisionGetJoint(byval pPreCollision as PreCollision ptr) as PhysicsJoint ptr

declare function PreCollisionGetFlags(byval pPreCollision as PreCollision ptr) as integer

declare function PreCollisionGetIntersectingDepth(byval pPreCollision as PreCollision ptr) as single

declare function PreCollisionGetRestitution(byval pPreCollision as PreCollision ptr) as single
declare function PreCollisionGetFrictionCoefficient(byval pPreCollision as PreCollision ptr) as single

declare sub      PreCollisionGetNormal(byval pPreCollision as PreCollision ptr, byref nx as single, byref ny as single, byref nz as single)
declare sub      PreCollisionV3GetNormal(byval pPreCollision as PreCollision ptr, byref v3Normal as TA_Vec3)

declare sub      PreCollisionGetPosition(byval pPreCollision as PreCollision ptr, byref px as single, byref py as single, byref pz as single)
declare sub      PreCollisionV3GetPosition(byval pPreCollision as PreCollision ptr, byref v3Position as TA_Vec3)

' #################
' # PostCollision #
' #################
' inside a PostCollisionCallback
declare function PostCollisionGetNext(byval pPostCollision as PostCollision ptr) as PostCollision ptr

declare function PostCollisionIsObjectA(byval pPostCollision as PostCollision ptr) as integer
declare function PostCollisionGetObjectA(byval pPostCollision as PostCollision ptr) as DynamicObject ptr
declare function PostCollisionGetAttributeA(byval pPostCollision as PostCollision ptr) as integer

declare function PostCollisionIsObjectB(byval pPostCollision as PostCollision ptr) as integer
declare function PostCollisionGetObjectB(byval pPostCollision as PostCollision ptr) as DynamicObject ptr
declare function PostCollisionGetAttributeB(byval pPostCollision as PostCollision ptr) as integer

declare function PostCollisionIsJoint(byval pPostCollision as PostCollision ptr) as integer
declare function PostCollisionGetJoint(byval pPostCollision as PostCollision ptr) as PhysicsJoint ptr

declare function PostCollisionGetFlags(byval pPostCollision as PostCollision ptr) as integer

declare function PostCollisionGetImpulse(byval pPostCollision as PostCollision ptr) as single

declare function PostCollisionGetIntersectingDepth(byval pPostCollision as PostCollision ptr) as single

declare sub      PostCollisionGetNormal(byval pPostCollision as PostCollision ptr, byref nx as single, byref ny as single, byref nz as single)
declare sub      PostCollisionV3GetNormal(byval pPostCollision as PostCollision ptr, byref v3Normal as TA_Vec3)

declare sub      PostCollisionGetPosition(byval pPostCollision as PostCollision ptr, byref px as single, byref py as single, byref pz as single)
declare sub      PostCollisionV3GetPosition(byval pPostCollision as PostCollision ptr, byref v3Position as TA_Vec3)


' ###################
' # CollisionObject #
' ###################
declare function CollisionObjectGetCollisionObjectType(byval pObj as const CollisionObject ptr) as eCOLLISIONOBJECT_TYPES

' #########################
' # CollisionObjectConvex #
' #########################
declare function CollisionObjectConvexCreateNew() as CollisionObjectConvex ptr

declare sub      CollisionObjectConvexRelease(byref pObj as CollisionObjectConvex ptr)

declare sub      CollisionObjectConvexInitialiseAsACube(byval pObj as const CollisionObjectConvex ptr, _
                                                        byval centerX as single, byval centerY as single, byval centerZ as single, _
                                                        byval size as single)

declare sub      CollisionObjectConvexV3InitialiseAsACube(byval pObj as const CollisionObjectConvex ptr, _
                                                          byref v3Center as const TA_Vec3, byval size as single)

declare sub      CollisionObjectConvexInitialiseAsAnOrientedCube(byval pObj as const CollisionObjectConvex ptr, _
                                                                 byval cx as single, byval cy as single, byval cz as single, _ ' center
                                                                 byval size as single, _
                                                                 byval px as single, byval py as single, byval pz as single, _ ' position
                                                                 byval pitch as single, byval yaw as single, byval roll as single)

declare sub      CollisionObjectConvexV3InitialiseAsAnOrientedCube(byval pObj as const CollisionObjectConvex ptr, _
                                                                   byref v3Center as const TA_Vec3, _
                                                                   byval size as single, _
                                                                   byref v3Position as const TA_Vec3, _
                                                                   byval pitch as single, byval yaw as single, byval roll as single)

declare sub      CollisionObjectConvexInitialiseAsABox (byval pObj as const CollisionObjectConvex ptr, _
                                                        byval centerX as single, byval centerY as single, byval centerZ as single, _
                                                        byval sizeX   as single, byval sizeY   as single, byval sizeZ   as single)

declare sub      CollisionObjectConvexV3InitialiseAsABox (byval pObj as const CollisionObjectConvex ptr, _
                                                          byref v3Center as const TA_Vec3, byref v3Size as const TA_Vec3)

declare sub      CollisionObjectConvexAABBInitialiseAsABox(byval pObj as const CollisionObjectConvex ptr, _
                                                           byref aabb as const TA_AABB)

declare sub      CollisionObjectConvexInitialiseAsAnOrientedBox(byval pObj as const CollisionObjectConvex ptr, _
                                                                byval cx as single, byval cy as single, byval cz as single, _ ' center
                                                                byval w  as single, byval h  as single, byval d  as single, _ ' size
                                                                byval px as single, byval py as single, byval pz as single, _ ' position
                                                                byval pitch as single, byval yaw as single, byval roll as single)

declare sub      CollisionObjectConvexV3InitialiseAsAnOrientedBox(byval pObj       as const CollisionObjectConvex ptr, _
                                                                  byref v3Center   as const TA_Vec3, _
                                                                  byref v3Size     as const TA_Vec3, _
                                                                  byref v3Position as const TA_Vec3, _
                                                                  byval pitch as single, byval yaw as single, byval roll as single)

declare sub      CollisionObjectConvexAABBInitialiseAsAnOrientedBox(byval pObj  as const CollisionObjectConvex ptr, _
                                                                    byref aabb  as const TA_AABB, _ ' center and extend
                                                                    byref frame as const TA_MFrame) ' rotation and position


declare sub      CollisionObjectConvexInitialiseFromPointList(byval pObj as const CollisionObjectConvex ptr, _
                                                              byval pFloat as single ptr, byval nPoints as integer)

declare sub      CollisionObjectConvexV3InitialiseFromPointList(byval pObj as const CollisionObjectConvex ptr, _
                                                                byref pV3 as const TA_Vec3 ptr, byval nPoints as integer)


declare sub      CollisionObjectConvexTransform (byval pObj as const CollisionObjectConvex ptr, _
                                                 byval posX     as single, byval posY   as single, byval posZ    as single, _
                                                 byval pitchRad as single, byval yawRad as single, byval rollRad as single)

declare sub      CollisionObjectConvexV3Transform (byval pObj as const CollisionObjectConvex ptr, _
                                                   byref v3Position as const TA_Vec3, _
                                                   byval pitchRad as single, byval yawRad as single, byval rollRad as single)


declare sub      CollisionObjectConvexTransformD(byval pObj as const CollisionObjectConvex ptr, _
                                                 byval posX     as single, byval posY   as single, byval posZ    as single, _
                                                 byval pitchDeg as single, byval yawDeg as single, byval rollDeg as single)

declare sub      CollisionObjectConvexV3TransformD(byval pObj as const CollisionObjectConvex ptr, _
                                                   byref v3Position as const TA_Vec3, _
                                                   byval pitchDeg as single, byval yawDeg as single, byval rollDeg as single)

' #########################
' # CollisionObjectSphere #
' #########################
declare function CollisionObjectSphereCreateNew () as CollisionObjectSphere ptr
declare sub      CollisionObjectSphereRelease   (byref pObj as CollisionObjectSphere ptr)

declare sub      CollisionObjectSphereInitialise(byval pObj as const CollisionObjectSphere ptr, _
                                                 byval centerX as single, byval centerY as single, byval centerZ as single, _
                                                 byval radius  as single)
declare sub      CollisionObjectSphereV3Initialise(byval pObj as const CollisionObjectSphere ptr, _
                                                   byref v3Center as const TA_Vec3, byval radius as single)


declare sub      CollisionObjectSphereGetPoint  (byval pObj as const CollisionObjectSphere ptr, _
                                                 byref centerX as single, byref centerY as single, byref centerZ as single)
declare sub      CollisionObjectSphereV3GetPoint  (byval pObj as const CollisionObjectSphere ptr, byref v3Point as TA_Vec3)

declare function CollisionObjectSphereGetRadius (byval pObj as const CollisionObjectSphere ptr) as single

' ###########################
' # CollisionObjectCylinder #
' ###########################
declare function CollisionObjectCylinderCreateNew () as CollisionObjectCylinder ptr
declare sub      CollisionObjectCylinderRelease   (byref pObj as CollisionObjectCylinder ptr)

declare sub      CollisionObjectCylinderInitialise(byval pObj as const CollisionObjectCylinder ptr, _
                                                   byval startX as single, byval startY as single, byval startZ as single, _
                                                   byval endX   as single, byval endY   as single, byval endZ   as single, _
                                                   byval radius as single)
declare sub      CollisionObjectCylinderV3Initialise(byval pObj as const CollisionObjectCylinder ptr, _
                                                     PointA as const TA_Vec3, PointB as const TA_Vec3, radius as single)

declare sub      CollisionObjectCylinderGetPointA (byval pObj as const CollisionObjectCylinder ptr, _
                                                   byref startX as single, byref startY as single, byref startZ as single)
declare sub      CollisionObjectCylinderV3GetPointA(byval pObj as const CollisionObjectCylinder ptr, byref v3PointA as TA_Vec3)

declare sub      CollisionObjectCylinderGetPointB (byval pObj as const CollisionObjectCylinder ptr, _
                                                   byref endX as single, byref endY as single, byref endZ as single)
declare sub      CollisionObjectCylinderV3GetPointB(byval pObj as const CollisionObjectCylinder ptr, byref v3PointB as TA_Vec3)

declare function CollisionObjectCylinderGetRadius (byval pObj as const CollisionObjectCylinder ptr) as single

' ##########################
' # CollisionObjectCapsule #
' ##########################
declare function CollisionObjectCapsuleCreateNew () as CollisionObjectCapsule ptr
declare sub      CollisionObjectCapsuleRelease   (byref pObj as const CollisionObjectCapsule ptr)

declare sub      CollisionObjectCapsuleInitialise(byval pObj as const CollisionObjectCapsule ptr, _
                                                  byval startX as single, byval startY as single, byval startZ as single, _
                                                  byval endX   as single, byval endY   as single, byval endZ   as single, _
                                                  byval radius as single)
declare sub      CollisionObjectCapsuleV3Initialise(byval pObj as const CollisionObjectCapsule ptr, _
                                                    byref PointA as const TA_Vec3, byref PointB as const TA_Vec3, byval radius as single)

declare sub      CollisionObjectCapsuleGetPointA (byval pObj as const CollisionObjectCapsule ptr, _
                                                   byref startX as single, byref startY as single, byref startZ as single)
declare sub      CollisionObjectCapsuleV3GetPointA(byval pObj as const CollisionObjectCapsule ptr, byref v3PointA as TA_Vec3)

declare sub      CollisionObjectCapsuleGetPointB (byval pObj as const CollisionObjectCapsule ptr, _
                                                   byref endX as single, byref endY as single, byref endZ as single)
declare sub      CollisionObjectCapsuleV3GetPointB(byval pObj as const CollisionObjectCapsule ptr, byref v3PointB as TA_Vec3)

declare function CollisionObjectCapsuleGetRadius (byval pObj as const CollisionObjectCapsule ptr) as single

' ###########################
' # CollisionObjectLineList #
' ###########################
declare function CollisionObjectLineListCreateNew() as CollisionObjectLineList ptr
declare sub      CollisionObjectLineListRelease(byref co as CollisionObjectLineList ptr)

' pFloat points to a liat of x,y,z coords 6 for each line (startX,startY,startZ, endX,endY,endZ)
declare sub      CollisionObjectLineListInitialise (byval pObj   as const CollisionObjectLineList ptr, _
                                                    byval pFloat as const single ptr, byval nLines as integer)
' pV3 points to a list of vertices 2 vertex for each line (v3Start,v3End)
declare sub      CollisionObjectLineListV3Initialise(byval pObj as const CollisionObjectLineList ptr, _
                                                     byval pV3  as const TA_Vec3 ptr, byval nLines as integer)

declare sub      CollisionObjectLineListSetLine(byval pObj as const CollisionObjectLineList ptr, _
                                                byval nLineIndex as integer, _
                                                byval sx as single, byval sy as single, byval sz as single, _
                                                byval ex as single, byval ey as single, byval ez as single)

declare sub      CollisionObjectLineListV3SetLine(byval pObj as const CollisionObjectLineList ptr, _
                                                  byval nLineIndex as integer, _
                                                  byref v3Start as const TA_Vec3, _
                                                  byref v3End   as const TA_Vec3)

declare function CollisionObjectLineListGetNumLines(byval pObj as const CollisionObjectLineList ptr) as integer

' ########################
' # CollisionObjectCombo #
' ########################
declare function CollisionObjectComboCreateNew() as CollisionObjectCombo ptr
declare sub      CollisionObjectComboRelease(byref pObj as const CollisionObjectCombo ptr)

declare sub      CollisionObjectComboInitialise(byval pObj as const CollisionObjectCombo ptr)

declare sub      CollisionObjectComboInitialiseAsACube(byval pObj as const CollisionObjectCombo ptr, _
                                                       byval centerX as single, byval centerY as single, byval centerZ as single, _
                                                       byval size as single)

declare sub      CollisionObjectComboV3InitialiseAsACube(byval pObj as const CollisionObjectCombo ptr, _
                                                         byref v3Center as const TA_Vec3, _
                                                         byval size as single)

declare sub      CollisionObjectComboInitialiseAsAnOrientedCube(byval pObj as const CollisionObjectCombo ptr, _
                                                                 byval cx as single, byval cy as single, byval cz as single, _ ' center
                                                                 byval size as single, _
                                                                 byval px as single, byval py as single, byval pz as single, _ ' position
                                                                 byval pitch as single, byval yaw as single, byval roll as single)

declare sub      CollisionObjectComboV3InitialiseAsAnOrientedCube(byval pObj as const CollisionObjectCombo ptr, _
                                                                   byref v3Center as const TA_Vec3, _
                                                                   byval size as single, _
                                                                   byref v3Position as const TA_Vec3, _
                                                                   byval pitch as single, byval yaw as single, byval roll as single)

declare sub      CollisionObjectComboInitialiseAsABox(byval pObj as const CollisionObjectCombo ptr, _
                                                      byval centerX as single, byval centerY as single, byval centerZ as single, _
                                                      byval extentX as single, byval extentY as single, byval extentZ as single)

declare sub      CollisionObjectComboV3InitialiseAsABox(byval pObj as const CollisionObjectCombo ptr, _
                                                        byref v3Center as const TA_Vec3, byref v3Dimension as const TA_Vec3)

declare sub      CollisionObjectComboAABBInitialiseAsABox(byval pObj as const CollisionObjectCombo ptr, _
                                                          byref aabb as const TA_AABB)

declare sub      CollisionObjectComboInitialiseAsAnOrientedBox(byval pObj as const CollisionObjectCombo ptr, _
                                                                byval cx as single, byval cy as single, byval cz as single, _ ' center
                                                                byval w  as single, byval h  as single, byval d  as single, _ ' size
                                                                byval px as single, byval py as single, byval pz as single, _ ' position
                                                                byval pitch as single, byval yaw as single, byval roll as single)

declare sub      CollisionObjectComboV3InitialiseAsAnOrientedBox(byval pObj       as const CollisionObjectCombo ptr, _
                                                                  byref v3Center   as const TA_Vec3, _
                                                                  byref v3Size     as const TA_Vec3, _
                                                                  byref v3Position as const TA_Vec3, _
                                                                  byval pitch as single, byval yaw as single, byval roll as single)

declare sub      CollisionObjectComboAABBInitialiseAsAnOrientedBox(byval pObj  as const CollisionObjectCombo ptr, _
                                                                    byref aabb  as const TA_AABB, _ ' center and extend
                                                                    byref frame as const TA_MFrame) ' rotation and position

declare sub      CollisionObjectComboInitialiseAsACapsule(byval pObj as const CollisionObjectCombo ptr, _
                                                          byval startX as single, byval startY as single, byval startZ as single, _
                                                          byval endX   as single, byval endY   as single, byval endZ   as single, byval radius as single)
declare sub      CollisionObjectComboV3InitialiseAsACapsule(byval pObj as CollisionObjectCombo ptr, _
                                                            byref v3PointA as const TA_Vec3, byref v3PointA as const TA_Vec3, byval radius as single)

declare sub      CollisionObjectComboInitialiseAsACylinder(byval pObj as const CollisionObjectCombo ptr, _
                                                           byval startX as single, byval startY as single, byval startZ as single, _
                                                           byval endX   as single, byval endY   as single, byval endZ   as single, byval radius as single)
declare sub      CollisionObjectComboV3InitialiseAsACylinder(byval pObj as CollisionObjectCombo ptr, _
                                                             byref v3PointA as const TA_Vec3, byref v3PointA as const TA_Vec3, byval radius as single)

declare sub      CollisionObjectComboInitialiseAsASphere(byval pObj as const CollisionObjectCombo ptr, _
                                                         byval centerX as single, byval centerY as single, byval centerZ as single, _
                                                         byval radius  as single)
declare sub      CollisionObjectComboV3InitialiseAsASphere(byval pObj as const CollisionObjectCombo ptr, _
                                                           byref v3Center as const TA_Vec3, byval radius  as single)

declare sub      CollisionObjectComboAddCollisionObject (byval pA as const CollisionObjectCombo ptr, byval pB as const CollisionObjectSimple ptr)

declare function CollisionObjectComboGetNumCollisionObjects(byval pObj as const CollisionObjectCombo ptr) as integer

declare sub      CollisionObjectComboRemoveCollisionObject (byval pObj as const CollisionObjectCombo ptr, byval n as integer)


' ###############
' # CarTemplate #
' ###############
declare function CarTemplateCreateNew() as CarTemplate ptr
declare sub      CarTemplateRelease(byref pObj as CarTemplate ptr)

declare sub      CarTemplateBeginInitialise(byval pObj as const CarTemplate ptr)
declare sub      CarTemplateEndInitialise  (byval pObj as const CarTemplate ptr)

declare sub      CarTemplateAddCollisionObjectConvex  (byval pObj as const CarTemplate ptr, byval pColObj as const CollisionObjectConvex   ptr)
declare sub      CarTemplateAddCollisionObjectCylinder(byval pObj as const CarTemplate ptr, byval pColObj as const CollisionObjectCylinder ptr)
declare sub      CarTemplateAddCollisionObjectCapsule (byval pObj as const CarTemplate ptr, byval pColObj as const CollisionObjectCapsule  ptr)
declare sub      CarTemplateAddCollisionObjectSphere  (byval pObj as const CarTemplate ptr, byval pColObj as const CollisionObjectSphere   ptr)

declare sub      CarTemplateSetOrientation(byval pObj as const CarTemplate ptr, _
                                           byval forwardX as single, byval forwardY as single, byval forwardZ as single, _
                                           byval upX      as single, byval upY      as single, byval upZ      as single)

declare sub      CarTemplateGetForward    (byval pObj as const CarTemplate ptr, _
                                           byref forwardX as single, byref forwardY as single, byref forwardZ as single)
declare sub      CarTemplateV3GetForward  (byval pObj as const CarTemplate ptr, byref v3Forward as TA_Vec3)

declare sub      CarTemplateGetUp         (byval pObj as const CarTemplate ptr, _
                                           byref upX as single, byref upY as single, byref upZ as single)
declare sub      CarTemplateV3GetUp       (byval pObj as const CarTemplate ptr, byref v3Up as TA_Vec3)


declare sub      CarTemplateSetNumGears(byval pObj as const CarTemplate ptr, byval nGear as integer)
declare function CarTemplateGetNumGears(byval pObj as const CarTemplate ptr) as integer

declare sub      CarTemplateSetGearRatio(byval pObj as const CarTemplate ptr, byval nGear as integer, byval ratio as single)
declare function CarTemplateGetGearRatio(byval pObj as const CarTemplate ptr, byval nGear as integer) as single

declare sub      CarTemplateSetDifferentialRatio(byval pObj as const CarTemplate ptr, ratio as single)
declare function CarTemplateGetDifferentialRatio(byval pObj as const CarTemplate ptr) as single

declare sub      CarTemplateSetMass(byval pObj as const CarTemplate ptr, byval mass as single)
declare function CarTemplateGetMass(byval pObj as const CarTemplate ptr) as single

declare sub      CarTemplateSetTransmissionEfficiency(byval pObj as const CarTemplate ptr, byval efficiency as single)
declare function CarTemplateGetTransmissionEfficiency(byval pObj as const CarTemplate ptr) as single

declare sub      CarTemplateSetTorqueMultiplier(byval pObj as const CarTemplate ptr, byval multiplier as single)
declare function CarTemplateGetTorqueMultiplier(byval pObj as const CarTemplate ptr) as single

declare sub      CarTemplateSetAirResistance(byval pObj as const CarTemplate ptr, byval resistance as single)
declare function CarTemplateGetAirResistance(byval pObj as const CarTemplate ptr) as single

declare sub      CarTemplateSetDownForce(byval pObj as const CarTemplate ptr, byval force as single)
declare function CarTemplateGetDownForce(byval pObj as const CarTemplate ptr) as single

declare sub      CarTemplateSetAntiRollFudge(byval pObj as const CarTemplate ptr, byval fudge as single)
declare function CarTemplateGetAntiRollFudge(byval pObj as const CarTemplate ptr) as single

declare sub      CarTemplateAddWheel(byval pObj as const CarTemplate ptr)

' ####################
' # CarTemplateWheel #
' ####################
declare sub      CarTemplateWheelClear()

declare sub      CarTemplateWheelSetSuspensionTop(byval x as single, byval y as single, byval z as single)
declare sub      CarTemplateWheelGetSuspensionTop(byref x as single , byref y as single, byref z as single)

declare sub      CarTemplateWheelV3SetSuspensionTop(byref v3Top as const TA_Vec3)
declare sub      CarTemplateWheelV3GetSuspensionTop(byref v3Top as       TA_Vec3)

declare sub      CarTemplateWheelSetSuspensionBottom(byval x as single, byval y as single, byval z as single)
declare sub      CarTemplateWheelGetSuspensionBottom(byref x as single, byref y as single, byref z as single)

declare sub      CarTemplateWheelV3SetSuspensionBottom(byref v3Bottom as const TA_Vec3)
declare sub      CarTemplateWheelV3GetSuspensionBottom(byref v3Bottom as       TA_Vec3)

declare sub      CarTemplateWheelSetRadius(byval radius as single)
declare function CarTemplateWheelGetRadius() as single

declare sub      CarTemplateWheelSetInertia(byval inertia as single)
declare function CarTemplateWheelGetInertia() as single

declare sub      CarTemplateWheelSetBrakeTorque(byval torque as single)
declare function CarTemplateWheelGetBrakeTorque() as single

declare sub      CarTemplateWheelSetRollResistance(byval resistance as single)
declare function CarTemplateWheelGetRollResistance() as single

declare sub      CarTemplateWheelSetSuspensionSpringConstant(byval springconst as single)
declare function CarTemplateWheelGetSuspensionSpringConstant() as single

declare sub      CarTemplateWheelSetSuspensionDampingConstant(byval dampingconst as single)
declare function CarTemplateWheelGetSuspensionDampingConstant() as single

declare sub      CarTemplateWheelSetSteeringFlag(byval bEnabled as integer)
declare function CarTemplateWheelGetSteeringFlag() as integer

declare sub      CarTemplateWheelSetDrivingFlag(byval bEnabled as integer)
declare function CarTemplateWheelGetDrivingFlag() as integer

declare sub      CarTemplateWheelSetHandBrakeFlag(byval bEnabled as integer)
declare function CarTemplateWheelGetHandBrakeFlag() as integer


' #################
' # PhysicsObject #
' #################
declare function PhysicsObjectAddedToPhysics(byval pObj as const PhysicsObject ptr) as integer

' ####################
' # DynamicObjectCar #
' ####################
declare function DynamicObjectCarCreateNew() as DynamicObjectCar ptr
declare sub      DynamicObjectCarRelease(byref pObj as DynamicObjectCar ptr)

declare sub      DynamicObjectCarInitialise(byval pObj as const DynamicObjectCar ptr, byval pTemplate as const CarTemplate ptr)

declare sub      DynamicObjectCarClearControls(byval pObj as const DynamicObjectCar ptr)
declare sub      DynamicObjectCarUpdateControls(byval pObj as const DynamicObjectCar ptr, _
                                                byval fSteeringAngle   as single, _
                                                byval fAccelerator     as single, _
                                                byval fBrake           as single, _
                                                byval fHandBrake       as single, _
                                                byval bSteeringHelp    as integer, _
                                                byval fTractionControl as single, _
                                                byval nGear            as integer)

declare function DynamicObjectCarGetRPM     (byval pObj as const DynamicObjectCar ptr) as single
declare function DynamicObjectCarGetGear    (byval pObj as const DynamicObjectCar ptr) as integer
declare function DynamicObjectCarGetNumGears(byval pObj as const DynamicObjectCar ptr) as integer

declare function DynamicObjectCarGetSpeed(byval pObj as const DynamicObjectCar ptr) as single
declare function DynamicObjectCarGetSpeedFromWheels(byval pObj as const DynamicObjectCar ptr) as single
declare function DynamicObjectCarGetSpeedFromVelocity(byval pObj as const DynamicObjectCar ptr) as single

declare sub      DynamicObjectCarSetTorqueMultiplier(byval pObj as const DynamicObjectCar ptr, byval fTorqueMultiplier as single)
declare function DynamicObjectCarGetTorqueMultiplier(byval pObj as const DynamicObjectCar ptr) as single

declare sub      DynamicObjectCarSetAntiRollFudge(byval pObj as const DynamicObjectCar ptr, byval fAntiRollFudge as single)
declare function DynamicObjectCarGetAntiRollFudge(byval pObj as const DynamicObjectCar ptr) as single

declare sub      DynamicObjectCarSetOrientation(byval pObj as const DynamicObjectCar ptr, _
                                                byval forwardX as single, byval forwardY as single, byval forwardZ as single, _
                                                byval upX      as single, byval upY      as single, byval upZ      as single)
declare sub      DynamicObjectCarV3SetOrientation(byval pObj as const DynamicObjectCar ptr, _
                                                  byref v3Forward as const TA_Vec3, byref v3Up as const TA_Vec3)

declare sub      DynamicObjectCarGetForward(byval pObj as const DynamicObjectCar ptr, _
                                            byref forwardX as single, byref forwardY as single, byref forwardZ as single)
declare sub      DynamicObjectCarV3GetForward(byval pObj as const DynamicObjectCar ptr, byref v3Forward as TA_Vec3)

declare sub      DynamicObjectCarGetUp     (byval pObj as const DynamicObjectCar ptr, _
                                            byref upX as single, byref upY as single, byref upZ as single)
declare sub      DynamicObjectV3CarGetUp   (byval pObj as const DynamicObjectCar ptr, byref v3Up as TA_Vec3)

declare sub      DynamicObjectCarGetFrame(byval pObj as const DynamicObjectCar ptr, byref frame as TA_MFrame)

declare function DynamicObjectCarGetNumWheels(byval pObj as const DynamicObjectCar ptr) as integer

' #########################
' # DynamicObjectCarWheel #
' #########################
declare sub      DynamicObjectCarWheelGetLocalFrame(byval pObj as const DynamicObjectCar ptr, nWheel as integer, byref frame as TA_MFrame)
declare sub      DynamicObjectCarWheelGetFrame(byval pObj as const DynamicObjectCar ptr, nWheel as integer, byref frame as TA_MFrame)

declare sub      DynamicObjectCarWheelGetLocalOpenGLMatrix (byval pObj as const DynamicObjectCar ptr, byval nWheel as integer, byval pMatrix4x4 as const single ptr)
#ifdef USEOPENGL
declare sub      DynamicObjectCarWheelMultOpenGLMatrix     (byval pObj as const DynamicObjectCar ptr, byval nWheel as integer)
declare sub      DynamicObjectCarWheelMultLocalOpenGLMatrix(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer)
#else
#define          DynamicObjectCarWheelMultOpenGLMatrix     (pObj,n) :
#define          DynamicObjectCarWheelMultLocalOpenGLMatrix(pObj,n) :
#endif

declare sub      DynamicObjectCarWheelGetLocalRotation (byval pObj as const DynamicObjectCar ptr, byval nWheel as integer, _
                                                        byref pitchRad as single, byref yawRad as single, byref rollRad as single)
declare sub      DynamicObjectCarWheelGetLocalRotationD(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer, _
                                                        byref pitchDeg as single, byref yawDeg as single, byref rollDeg as single)

declare sub      DynamicObjectCarWheelGetLocalPosition (byval pObj as const DynamicObjectCar ptr, byval nWheel as integer, _
                                                        byref x as single, byref y as single, byref z as single)
declare sub      DynamicObjectCarWheelV3GetLocalPosition(byval pObj as const DynamicObjectCar ptr, byref v3Position as TA_Vec3)

declare sub      DynamicObjectCarWheelSetRadius(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer, byval radius as single)
declare function DynamicObjectCarWheelGetRadius(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer) as single

declare sub      DynamicObjectCarWheelSetInvInertia(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer, byval inertia as single)
declare function DynamicObjectCarWheelGetInvInertia(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer) as single

declare sub      DynamicObjectCarWheelSetBrakeTorque(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer, byval torque as single)
declare function DynamicObjectCarWheelGetBrakeTorque(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer) as single

declare sub      DynamicObjectCarWheelSetRollResistance(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer, byval resistance as single)
declare function DynamicObjectCarWheelGetRollResistance(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer) as single

declare sub      DynamicObjectCarWheelSetSuspensionSpringConstant(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer, byval springconst as single)
declare function DynamicObjectCarWheelGetSuspensionSpringConstant(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer) as single

declare sub      DynamicObjectCarWheelSetSuspensionDampingConstant(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer, byval dampingconst as single)
declare function DynamicObjectCarWheelGetSuspensionDampingConstant(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer) as single

declare sub      DynamicObjectCarWheelSetSteeringFlag(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer, byval bSteeringFlag as integer)
declare function DynamicObjectCarWheelGetSteeringFlag(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer) as integer

declare sub      DynamicObjectCarWheelSetDrivingFlag(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer, byval bDrivingFlag as integer)
declare function DynamicObjectCarWheelGetDrivingFlag(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer) as integer

declare sub      DynamicObjectCarWheelSetHandBrakeFlag(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer, byval bHandBrakeFlag as integer)
declare function DynamicObjectCarWheelGetHandBrakeFlag(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer) as integer

declare function DynamicObjectCarWheelGetCollisionFlag(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer) as integer
declare function DynamicObjectCarWheelGetCollisionAttribute(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer) as integer

declare sub      DynamicObjectCarWheelSetYaw(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer, byval fYaw as single)
declare function DynamicObjectCarWheelGetYaw(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer) as single

declare sub      DynamicObjectCarWheelSetPitch(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer, byval fPitch as single)
declare function DynamicObjectCarWheelGetPitch(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer) as single

declare sub      DynamicObjectCarWheelSetPitchVelocity(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer, byval fPitchVelocity as single)
declare function DynamicObjectCarWheelGetPitchVelocity(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer) as single

declare sub      DynamicObjectCarWheelSetCamberAngle(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer, byval fCamberAngle as single)
declare function DynamicObjectCarWheelGetCamberAngle(byval pObj as const DynamicObjectCar ptr, byval nWheel as integer) as single

' #########################
' # DynamicObjectTemplate #
' #########################
declare function DynamicObjectTemplateCreateNew() as DynamicObjectTemplate ptr
declare sub      DynamicObjectTemplateRelease(byref pObj as DynamicObjectTemplate ptr )
declare sub      DynamicObjectTemplateInitialise(byval pObj   as const DynamicObject ptr, _
                                                 byval pCombo as const CollisionObjectCombo ptr, _
                                                       cb     as UpdateCB)

' #####################
' # DynamicObjectTank #
' #####################
declare function DynamicObjectTankCreateNew() as DynamicObjectTank ptr
declare sub      DynamicObjectTankRelease(byref pObj as DynamicObjectTank ptr)
declare sub      DynamicObjectTankInitialise(byval pObj as const DynamicObjectTank ptr)
declare sub      DynamicObjectTankClearControls(byval pObj as const DynamicObjectTank ptr)
declare sub      DynamicObjectTankUpdateControls(byval pObj as const DynamicObjectTank ptr, byval fLeftTred as single, byval fRightTred as single)

' #################
' # DynamicObject #
' #################
declare function DynamicObjectCreateNew() as DynamicObject ptr
declare sub      DynamicObjectRelease(byref pObj as const DynamicObject ptr )

declare sub      DynamicObjectInitialise(byval pObj as const DynamicObject ptr, byval pComboObj as const CollisionObjectCombo ptr)

declare sub      DynamicObjectInitialiseAsACube(byval pObj as const DynamicObject ptr, _
                                                byval centerX as single, byval centerY as single, byval centerZ as single, _
                                                byval size as single)
declare sub      DynamicObjectV3InitialiseAsACube(byval pObj as const DynamicObject ptr, byref v3Center as const TA_Vec3, byval size as single)

declare sub      DynamicObjectInitialiseAsAnOrientedCube(byval pObj as const DynamicObject ptr, _
                                                         byval cx as single, byval cy as single, byval cz as single, _ ' center
                                                         byval size as single, _
                                                         byval px as single, byval py as single, byval pz as single, _ ' position
                                                         byval pitch as single, byval yaw as single, byval roll as single)

declare sub      DynamicObjectV3InitialiseAsAnOrientedCube(byval pObj as const DynamicObject ptr, _
                                                           byref v3Center as const TA_Vec3, _
                                                           byval size as single, _
                                                           byref v3Position as const TA_Vec3, _
                                                           byval pitch as single, byval yaw as single, byval roll as single)

declare sub      DynamicObjectInitialiseAsABox(byval pObj as const DynamicObject ptr, _
                                               byval centerX as single, byval centerY as single, byval centerZ as single, _
                                               byval sizeX   as single, byval sizeY   as single, byval sizeZ   as single)

declare sub      DynamicObjectV3InitialiseAsABox(byval pObj as const DynamicObject ptr, _
                                                 byref v3Center as const TA_Vec3, _
                                                 byref v3Extend as const TA_Vec3)

declare sub      DynamicObjectAABBInitialiseAsABox(byval pObj as const DynamicObject ptr, byref aabb as const TA_AABB)

declare sub      DynamicObjectInitialiseAsAnOrientedBox(byval pObj as const DynamicObject ptr, _
                                                        byval cx as single, byval cy as single, byval cz as single, _ ' center
                                                        byval w  as single, byval h  as single, byval d  as single, _ ' size
                                                        byval px as single, byval py as single, byval pz as single, _ ' position
                                                        byval pitch as single, byval yaw as single, byval roll as single)

declare sub      DynamicObjectV3InitialiseAsAnOrientedBox(byval pObj       as const DynamicObject ptr, _
                                                          byref v3Center   as const TA_Vec3, _  ' (most 0,0,0)
                                                          byref v3Size     as const TA_Vec3, _
                                                          byref v3Position as const TA_Vec3, _
                                                          byval pitch as single, byval yaw as single, byval roll as single)

declare sub      DynamicObjectAABBInitialiseAsAnOrientedBox(byval pObj  as const DynamicObject ptr, _
                                                            byref aabb  as const TA_AABB, _ ' center and extend
                                                            byref frame as const TA_MFrame) ' rotation and position

declare sub      DynamicObjectInitialiseAsASphere(byval pObj as const DynamicObject ptr, _
                                                  byval centerX as single, byval centerY as single, byval centerZ as single, _
                                                  byval radius as single)
declare sub      DynamicObjectV3InitialiseAsASphere(byval pObj as const DynamicObject ptr, byref v3Center as const TA_Vec3, byval radius as single)


declare sub      DynamicObjectInitialiseAsACylinder(byval pObj as const DynamicObject ptr, _
                                                    byval startX as single, byval startY as single, byval startZ as single, _
                                                    byval endX   as single, byval endY   as single, byval endZ   as single, _
                                                    byval radius as single)
declare sub      DynamicObjectV3InitialiseAsACylinder(byval pObj as const DynamicObject ptr, _
                                                      byref v3PointA as const TA_Vec3, byref v3PointB as const TA_Vec3, byval radius as single)


declare sub      DynamicObjectInitialiseAsACapsule (byval pObj as const DynamicObject ptr, _
                                                    byval startX as single, byval startY as single, byval startZ as single, _
                                                    byval endX   as single, byval endY   as single, byval endZ   as single, _
                                                    byval radius as single)
declare sub      DynamicObjectV3InitialiseAsACapsule(byval pObj as const DynamicObject ptr, _
                                                     byref v3PointA as const TA_Vec3, byref v3PointB as const TA_Vec3, byval radius as single)

declare sub      DynamicObjectSetUserData(byval pObj as const DynamicObject ptr, byval pUserData as const any ptr)
declare function DynamicObjectGetUserData(byval pObj as const DynamicObject ptr) as any ptr

' helper only for DEBUG rendering by default all objects are visible
declare sub      DynamicObjectSetVisible(byval pObj as const DynamicObject ptr, byval bVisible as integer)
declare function DynamicObjectIsVisible(byval pObj as const DynamicObject ptr) as integer

declare sub      DynamicObjectSetMass(byval pObj as const DynamicObject ptr , byval mass as single)
declare function DynamicObjectGetMass(byval pObj as const DynamicObject ptr) as single
declare function DynamicObjectGetInverseMass(byval pObj as const DynamicObject ptr) as single

declare sub      DynamicObjectSetCenterOffset(byval pObj as const DynamicObject ptr, byval x as single, byval y as single, byval z as single)
declare sub      DynamicObjectGetCenterOffset(byval pObj as const DynamicObject ptr, byref x as single, byref y as single, byref z as single)

declare sub      DynamicObjectV3SetCenterOffset(byval pObj as const DynamicObject ptr, byref v3CenterOffset as const TA_Vec3)
declare sub      DynamicObjectV3GetCenterOffset(byval pObj as const DynamicObject ptr, byref v3CenterOffset as TA_Vec3)

declare sub      DynamicObjectSetPosition(byval pObj as const DynamicObject ptr, byval x as single, byval y as single, byval z as single)
declare sub      DynamicObjectGetPosition(byval pObj as const DynamicObject ptr, byref x as single, byref y as single, byref z as single)

declare sub      DynamicObjectV3SetPosition(byval pObj as const DynamicObject ptr, byref v3Postion as const TA_Vec3)
declare sub      DynamicObjectV3GetPosition(byval pObj as const DynamicObject ptr, byref v3Postion as TA_Vec3)

declare sub      DynamicObjectSetRotation(byval pObj as const DynamicObject ptr, byval pitchRad as single, byval yawRad as single, byval rollRad as single)
declare sub      DynamicObjectGetRotation(byval pObj as const DynamicObject ptr, byref pitchRad as single, byref yawRad as single, byref rollRad as single)

declare sub      DynamicObjectSetRotationD(byval pObj as const DynamicObject ptr, byval pitchDeg as single, byval yawDeg as single, byval rollDeg as single)
declare sub      DynamicObjectGetRotationD(byval pObj as const DynamicObject ptr, byref pitchDeg as single, byref yawDeg as single, byref rollDeg as single)

declare sub      DynamicObjectSetFriction(byval pObj as const DynamicObject ptr, byval fFriction as single)
declare function DynamicObjectGetFriction(byval pObj as const DynamicObject ptr) as single
' -1 to +1
declare sub      DynamicObjectSetRestitution(byval pObj as const DynamicObject ptr, byval fRestitution as single)
declare function DynamicObjectGetRestitution(byval pObj as const DynamicObject ptr) as single

declare sub      DynamicObjectSetGravityMult(byval pObj as const DynamicObject ptr, byval fGravityMult as single)
declare function DynamicObjectGetGravityMult(byval pObj as const DynamicObject ptr) as single

declare sub      DynamicObjectSetInfiniteMass(byval pObj as const DynamicObject ptr, byval bInfiniteMass as integer)
declare function DynamicObjectIsInfiniteMass   (byval pObj as const DynamicObject ptr) as integer

declare sub      DynamicObjectSetRotationDisabled(byval pObj as const DynamicObject ptr, byval bRotationDisabled as integer)
declare function DynamicObjectIsRotationDisabled (byval pObj as const DynamicObject ptr) as integer

declare sub      DynamicObjectSetMovementDisabled(byval pObj as const DynamicObject ptr, byval bMovementDisabled as integer)
declare function DynamicObjectIsMovementDisabled (byval pObj as const DynamicObject ptr) as integer

declare sub      DynamicObjectSetForceFastSolverEnabled(byval pObj as const DynamicObject ptr, byval bFastSolverEnabled as integer)
declare function DynamicObjectIsForceFastSolverEnabled (byval pObj as const DynamicObject ptr) as integer

declare sub      DynamicObjectSetAllDampingDisabled(byval pObj as const DynamicObject ptr, byval bAllDampingDisabled as integer)
declare function DynamicObjectIsAllDampingDisabled (byval pObj as const DynamicObject ptr) as integer

declare sub      DynamicObjectSetExtraStability(byval pObj as const DynamicObject ptr, bExtraStability as integer)
declare function DynamicObjectIsExtraStability   (byval pObj as const DynamicObject ptr) as integer

declare sub      DynamicObjectSetRigidFrictionDisabled(byval pObj as const DynamicObject ptr, byval bRigidFrictionDisabled as integer)
declare function DynamicObjectIsRigidFrictionDisabled   (byval pObj as const DynamicObject ptr) as integer

declare sub      DynamicObjectSetCollisionDisabled(byval pObj as const DynamicObject ptr, byval bCollisionDisabled as integer)
declare function DynamicObjectIsCollisionDisabled   (byval pObj as const DynamicObject ptr) as integer

declare sub      DynamicObjectSetUpdateDisabled(byval pObj as const DynamicObject ptr, byval bUpdateDisabled as integer)
declare function DynamicObjectIsUpdateDisabled   (byval pObj as const DynamicObject ptr) as integer

declare sub      DynamicObjectSetGhost(byval pObj as const DynamicObject ptr, byval bGhost as integer)
declare function DynamicObjectIsGhost   (byval pObj as const DynamicObject ptr) as integer

declare function DynamicObjectIsWorldObject(byval pObj as const DynamicObject ptr) as integer

declare sub      DynamicObjectSetRestTimeMultiplier(byval pObj as const DynamicObject ptr, byval fRestTimeMultiplier as single)
declare function DynamicObjectGetRestTimeMultiplier(byval pObj as const DynamicObject ptr) as single

declare function DynamicObjectIsInMovingList(byval pObj as const DynamicObject ptr) as integer
declare sub      DynamicObjectSetToMoving (byval pObj as const DynamicObject ptr, byval priority as ePHYSICS_MOVING_PRIORITIES)
declare sub      DynamicObjectSetToResting(byval pObj as const DynamicObject ptr)

declare sub      DynamicObjectSetLinearVelocity(byval pObj as const DynamicObject ptr, byval x as single, byval y as single, byval z as single)
declare sub      DynamicObjectGetLinearVelocity(byval pObj as const DynamicObject ptr, byref x as single, byref y as single, byref z as single)

declare sub      DynamicObjectV3SetLinearVelocity(byval pObj as const DynamicObject ptr, byref v3LinearVelocity as const TA_Vec3)
declare sub      DynamicObjectV3GetLinearVelocity(byval pObj as const DynamicObject ptr, byref v3LinearVelocity as TA_Vec3)

declare sub      DynamicObjectSetAngularVelocity(byval pObj as const DynamicObject ptr, byval x as single, byval y as single, byval z as single)
declare sub      DynamicObjectGetAngularVelocity(byval pObj as const DynamicObject ptr, byref x as single, byref y as single, byref z as single)

declare sub      DynamicObjectV3SetAngularVelocity(byval pObj as const DynamicObject ptr, byref v3AngularVelocity as const TA_Vec3)
declare sub      DynamicObjectV3GetAngularVelocity(byval pObj as const DynamicObject ptr, byref v3AngularVelocity as TA_Vec3)

declare sub      DynamicObjectGetVelocityAtWorldPosition(byval pObj as const DynamicObject ptr, _
                                                         byval worldX as single, byval worldY as single, byval worldZ as single, _
                                                         byref velX   as single, byref velY   as single, byref velZ as single)
declare sub      DynamicObjectV3GetVelocityAtWorldPosition(byval pObj as const DynamicObject ptr, byref v3WorldPos as const TA_Vec3, byref v3Velocity as TA_Vec3)

declare sub      DynamicObjectApplyImpulse(byval pObj as const DynamicObject ptr, _
                                           byval impX   as single, byval impY   as single, byval impZ   as single, _
                                           byval worldX as single, byval worldY as single, byval worldZ as single)
declare sub      DynamicObjectV3ApplyImpulse(byval pObj as const DynamicObject ptr, byref v3Impulse as const TA_Vec3, byref v3WorldPos as const TA_Vec3)

declare sub      DynamicObjectApplyLinearImpulse(byval pObj as const DynamicObject ptr, _
                                                 byval impX as single, byval impY as single, byval impZ as single)
declare sub      DynamicObjectV3ApplyLinearImpulse(byval pObj as const DynamicObject ptr, byref v3LinearImpulse as const TA_Vec3)

declare sub      DynamicObjectApplyAngularImpulse(byval pObj as const DynamicObject ptr, _
                                                  byval impX as single, byval impY as single, byval impZ as single)
declare sub      DynamicObjectV3ApplyAngularImpulse(byval pObj as const DynamicObject ptr, byref v3AngularImpulse as const TA_Vec3)

' ##############################################
' #´DynamicObject with CollisionObjectLineList #
' ##############################################
declare function DynamicObjectGetNumLineCollisions(byval pObj as const DynamicObject ptr) as integer
declare function DynamicObjectGetLineCollision(byval pObj as const DynamicObject ptr, byval nLineIndex as integer) as LineIntersection ptr

declare function DynamicObjectLineCollisionsGetIntersectionDepth(byval pObj as const DynamicObject ptr, byval nLineIndex as integer) as single
declare function DynamicObjectLineCollisionsGetAttribute(byval pObj as const DynamicObject ptr, byval nLineIndex as integer) as integer

declare sub      DynamicObjectLineCollisionsGetPosition(byval pObj as const DynamicObject ptr, byval nLineIndex as integer, byref x as single, byref y as single, byref z as single)
declare sub      DynamicObjectLineCollisionsV3GetPosition(byval pObj as const DynamicObject ptr, byval nLineIndex as integer, byref v3Position as TA_Vec3)
' v3WorldPosition = LineCollisionsGetPosition() * DynamicObjectGetFrame()
declare sub      DynamicObjectLineCollisionsGetWorldPosition(byval pObj as const DynamicObject ptr, byval nLineIndex as integer, byref x as single, byref y as single, byref z as single)
declare sub      DynamicObjectLineCollisionsV3GetWorldPosition(byval pObj as const DynamicObject ptr, byval nLineIndex as integer, byref v3Position as TA_Vec3)

declare sub      DynamicObjectLineCollisionsGetNormal(byval pObj as const DynamicObject ptr, byval nLineIndex as integer, byref x as single, byref y as single, byref z as single)
declare sub      DynamicObjectLineCollisionsV3GetNormal(byval pObj as const DynamicObject ptr, byval nLineIndex as integer, byref v3Normal as TA_Vec3)

declare function DynamicObjectLineCollisionsGetDynamicObject(byval pObj as const DynamicObject ptr, byval nLineIndex as integer) as DynamicObject ptr
declare function DynamicObjectLineCollisionsGetCollisionObjectType(byval pObj as const DynamicObject ptr, byval nLineIndex as integer) as eCOLLISIONOBJECT_TYPES

declare sub      DynamicObjectAdjustLineCollisionFromNextFrame(byval pObj as const DynamicObject ptr, byval nLineIndex as integer)

' #######################
' # DynamicObject Joint #
' #######################
declare function DynamicObjectAddWorldJoint(byval pObj as const DynamicObject ptr) as PhysicsJoint ptr
declare function DynamicObjectAddJoint(byval pObj1 as const DynamicObject ptr, byval pObj2 as const DynamicObject ptr) as PhysicsJoint ptr

declare sub      DynamicObjectRemoveJoint(byval pObj as const DynamicObject ptr, byval pJoint as const PhysicsJoint ptr)
declare sub      DynamicObjectRemoveAllJoints(byval pObj as const DynamicObject ptr)

' ###########################
' # DynamicObject Usergroup #
' ###########################
declare function DynamicObjectCreateUserGroup(byval pObj as const DynamicObject ptr) as integer
declare sub      DynamicObjectSetUserGroup(byval pObj as const DynamicObject ptr, byval nUserGroup as integer)
declare function DynamicObjectGetUserGroup(byval pObj as const DynamicObject ptr) as integer

declare sub      DynamicObjectSetUserGroupItemId(byval pObj as const DynamicObject ptr, byval nItemId as integer)
declare function DynamicObjectGetUserGroupItemId(byval pObj as const DynamicObject ptr) as integer
declare sub      DynamicObjectDisallowCollisionWithUserGroupItemId(byval pObj as const DynamicObject ptr, byval nItemId as integer)
declare sub      DynamicObjectAllowCollisionWithUserGroupItemId(byval pObj as const DynamicObject ptr, byval nItemId as integer)

declare function DynamicObjectIsAllowedToCollideWith(byval pObjA as const DynamicObject ptr, byval pObjB as const DynamicObject ptr) as integer

' ###################################
' # DynamicObject physic simualtion # 
' ###################################
' optional for advanced users 
' use it inside of the DynamicObjectTemplate UpdateCallback

' step 1. Make sure that force and torque have been cleared.
declare sub      DynamicObjectAssertForceAndTorqueCleared(byval pObj as const DynamicObject ptr)

' step 2. Do gravity
declare sub      DynamicObjectAccumulateGravity(byval pObj as const DynamicObject ptr)

' step 3. Apply a force to the dynamic object
declare sub      DynamicObjectAccumulateForceAndTorque(byval pObj as const DynamicObject ptr, _
                                                       byval worldForceX as single, byval worldForceY as single, byval worldForceZ as single, _
                                                       byval worldPosX   as single, byval worldPosY   as single, byval worldPosZ   as single)

declare sub      DynamicObjectV3AccumulateForceAndTorque(byval pObj as const DynamicObject ptr, _
                                                         byref v3WorldForce    as const TA_Vec3, _
                                                         byref v3WorldPosition as const TA_Vec3)

' step 4. Apply the forces to linear and angular velocity
declare sub      DynamicObjectApplyForceAndTorqueToVelocities(byval pObj as const DynamicObject ptr, byval fDt as single)

' step 5. Clear force and torque  (kg.m/s2). 
declare sub      DynamicObjectClearForceAndTorque(byval pObj as const DynamicObject ptr)

' step 6. Update date the next frame of the dynamic object, ready for collision testing.
declare sub      DynamicObjectApplyVelocityToNextFrame(byval pObj as const DynamicObject ptr, byval fDt as single)
declare sub      DynamicObjectApplyVelocityFromNextFrame(byval pObj as const DynamicObject ptr, byval fDt as single)

' step 7. optional if the DynamicObject used a CollisionObjectLineList
declare sub      DynamicObjectClearLineIntersections(byval pObj as const DynamicObject ptr)

' ApplyNextFrame will be called to by Update automatically after the collision response has been done.
declare sub      DynamicObjectApplyNextFrame(byval pObj as const DynamicObject ptr)

declare sub      DynamicObjectAccumulateLinearForce(byval pObj as const DynamicObject ptr, _
                                                    byval worldForceX as single, byval worldForceY as single, byval worldForceZ as single)

declare sub      DynamicObjectV3AccumulateLinearForce(byval pObj as const DynamicObject ptr, byref v3WorldForce as const TA_Vec3)

declare sub      DynamicObjectSetFindVelocityFromNextFrame(byval pObj as const DynamicObject ptr, byval bEnable as integer)
declare function DynamicObjectGetFindVelocityFromNextFrame(byval pObj as const DynamicObject ptr) as integer

declare sub      DynamicObjectUpdateWorldSpaceInertialTensor(byval pObj as const DynamicObject ptr)

declare sub      DynamicObjectGetWorldAABB(byval pObj as const DynamicObject ptr, byref aabb as TA_AABB)

declare sub      DynamicObjectSetFrame(byval pObj as const DynamicObject ptr, byref frame as const TA_MFrame)
declare sub      DynamicObjectSetFrameDirect(byval pObj as const DynamicObject ptr, byref frame as const TA_MFrame)

declare sub      DynamicObjectGetFrame(byval pObj as const DynamicObject ptr, byref frame as TA_MFrame)
declare sub      DynamicObjectGetNextFrame(byval pObj as const DynamicObject ptr, byref frame as TA_MFrame)

declare sub      DynamicObjectGetPreviousFrame(byval pObj as const DynamicObject ptr, byref frame as TA_MFrame)

declare sub      DynamicObjectGetGraphicsFrame(byval pObj as const DynamicObject ptr, byref frame as TA_MFrame)

declare sub      DynamicObjectGetCenterOfMass    (byval pObj as const DynamicObject ptr, byref v3CenterOfMass as TA_Vec3)
declare sub      DynamicObjectGetNextCenterOfMass(byval pObj as const DynamicObject ptr, byref v3CenterOfMass as TA_Vec3)

declare sub      DynamicObjectGetFrameRotation   (byval pObj as const DynamicObject ptr, byref m33 as TA_Mat33)
declare sub      DynamicObjectGetFrameRotationV3X(byval pObj as const DynamicObject ptr, byref v3X as TA_Vec3)
declare sub      DynamicObjectGetFrameRotationV3Y(byval pObj as const DynamicObject ptr, byref v3Y as TA_Vec3)
declare sub      DynamicObjectGetFrameRotationV3Z(byval pObj as const DynamicObject ptr, byref v3Z as TA_Vec3)

declare sub      DynamicObjectGetNextFrameRotation   (byval pObj as const DynamicObject ptr, byref m33 as TA_Mat33)
declare sub      DynamicObjectGetNextFrameRotationV3X(byval pObj as const DynamicObject ptr, byref v3X as TA_Vec3)
declare sub      DynamicObjectGetNextFrameRotationV3Y(byval pObj as const DynamicObject ptr, byref v3Y as TA_Vec3)
declare sub      DynamicObjectGetNextFrameRotationV3Z(byval pObj as const DynamicObject ptr, byref v3Z as TA_Vec3)

declare sub      DynamicObjectGetFrameRotationTransposeAsInverse(byval pObj as const DynamicObject ptr, byref m33 as TA_Mat33)


' #######################
' # DynamicObject Tools #
' #######################
declare sub      DynamicObjectGetOpenGLMatrix(byval pObj as const DynamicObject ptr, byval pMatrix4x4 as const single ptr)
declare sub      DynamicObjectGetOpenGLFrame (byval pObj as const DynamicObject ptr, byref frame as TA_MFrame)
#ifdef USEOPENGL
declare sub      DynamicObjectMultOpenGLMatrix(byval pObj as const DynamicObject ptr)
#else
#define          DynamicObjectMultOpenGLMatrix(pObj) :
#endif

' out=in*DynamicObjectGetFrame().Rotation()
declare sub      DynamicObjectRotate(byval pObj as const DynamicObject ptr, _
                                     byval inX  as single, byval inY  as single, byval inZ  as single, _
                                     byref outX as single, byref outY as single, byref outZ as single)
declare sub      DynamicObjectV3Rotate(byval pObj as const DynamicObject ptr, _
                                       byref v3In as const TA_Vec3, _
                                       byref v3Out as TA_Vec3)
' out=in*DynamicObjectGetFrame().
declare sub      DynamicObjectTransform(byval pObj as const DynamicObject ptr, _
                                        byval inX  as single, byval inY  as single, byval inZ  as single, _
                                        byref outX as single, byref outY as single, byref outZ as single)
declare sub      DynamicObjectV3Transform(byval pObj     as const DynamicObject ptr, _
                                          byref v3Vector as const TA_Vec3, _
                                          byref v3Result as TA_Vec3)


' ################
' # PhysicsJoint #
' ################
' To disable any rotation use the return value of this function as min/max angle param.
declare function JointLimitDisabled() as single 

' Call this function to initialise the joint as a Slider. 
' The Object will be constrained to slide along the line that connects the points start and end
declare sub      PhysicsJointInitialiseSlider(byval pObj as const PhysicsJoint ptr, _
                                              byval x      as single, byval y      as single, byval z      as single, _
                                              byval startX as single, byval startY as single, byval startZ as single, _
                                              byval endX   as single, byval endY   as single, byval endZ   as single)

declare sub      PhysicsJointV3InitialiseSlider(byval pObj as const PhysicsJoint ptr, _
                                                byref v3Position  as const TA_Vec3, _
                                                byref v3LineStart as const TA_Vec3, _
                                                byref v3LineEnd   as const TA_Vec3)


' Call this function to initialise the joint as a hinge.
declare sub      PhysicsJointInitialiseHinge(byval pObj as const PhysicsJoint ptr, _
                                             byval x        as single, byval y        as single, byval z     as single, _
                                             byval axisX    as single, byval axisY    as single, byval axisZ as single, _
                                             byval minAngle as single, byval maxAngle as single)

declare sub      PhysicsJointV3InitialiseHinge(byval pObj as const PhysicsJoint ptr, _
                                               byref v3Position as const TA_Vec3, _
                                               byref v3Axis     as const TA_Vec3, _
                                               byval minAngle as single, byval maxAngle as single)

' Call this function to initialise this joint as a ball and socket constraint.
declare sub      PhysicsJointInitialiseBallAndSocket(byval pObj as const PhysicsJoint ptr, _
                                                     byval x    as single, byval y    as single, byval z    as single, _
                                                     byval dirX as single, byval dirY as single, byval dirZ as single, _
                                                     byval maxAngle as single)

declare sub      PhysicsJointV3InitialiseBallAndSocket(byval pObj as const PhysicsJoint ptr, _
                                                     byref v3Position  as const TA_Vec3, _
                                                     byref v3Direction as const TA_Vec3, _
                                                     byval maxAngle as single)

' Call this function to initialise the joint as a Limited Ball And Socket constraint.
' This extends LimitedBallAndSocket by adding a twist constraint
declare sub      PhysicsJointInitialiseLimitedBallAndSocket(byval pObj as const PhysicsJoint ptr, _
                                                            byval x         as single, byval y          as single, byval z    as single, _
                                                            byval pitch     as single, byval yaw        as single, byval roll as single, _
                                                            byval maxAngleY as single, byval maxAngleXZ as single)

declare sub      PhysicsJointV3InitialiseLimitedBallAndSocket(byval pObj as const PhysicsJoint ptr, _
                                                              byref v3Position  as const TA_Vec3, _
                                                              byval pitch     as single, byval yaw        as single, byval roll as single, _
                                                              byval maxAngleY as single, byval maxAngleXZ as single)

' Call this function to initialise the joint as an Euler Angle Constraint.
' This type of joint, joins two objects at one location, and constrains their relative rotation using minimum and maximum euler angles.
' This provides a flexible method for creating different types of joints however, gimbal lock can sometimes be a problem. 
declare sub      PhysicsJointInitialiseEulerConstraint(byval pObj as const PhysicsJoint ptr, _
                                                       byval x         as single, byval y         as single, byval z         as single, _
                                                       byval pitch     as single, byval yaw       as single, byval roll      as single, _
                                                       byval minAngleX as single, byval minAngleY as single, byval minAngleZ as single, _
                                                       byval maxAngleX as single, byval maxAngleY as single, byval maxAngleZ as single)

declare sub      PhysicsJointV3InitialiseEulerConstraint(byval pObj as const PhysicsJoint ptr, _
                                                         byref v3Position as const TA_Vec3, _
                                                         byval pitch     as single, byval yaw       as single, byval roll      as single, _
                                                         byval minAngleX as single, byval minAngleY as single, byval minAngleZ as single, _
                                                         byval maxAngleX as single, byval maxAngleY as single, byval maxAngleZ as single)


declare sub      PhysicsJointInitialiseSquareSocket(byval pObj as const PhysicsJoint ptr, _
                                                    byval x     as single, byval y    as single, byval z    as single, _
                                                    byval pitch as single, byval yaw  as single, byval roll as single, _
                                                    byval minX  as single, byval maxX as single, _
                                                    byval minY  as single, byval maxY as single, _
                                                    byval minZ  as single, byval maxZ as single)

declare sub      PhysicsJointV3InitialiseSquareSocket(byval pObj as const PhysicsJoint ptr, _
                                                      byref v3Position as const TA_Vec3, _
                                                      byval pitch as single, byval yaw  as single, byval roll as single, _
                                                      byval minX  as single, byval maxX as single, _
                                                      byval minY  as single, byval maxY as single, _
                                                      byval minZ  as single, byval maxZ as single)

' Call function to initialise the joint as a Rotation Constraint. 
' Rotation is constrained by the max and min euler angles. Position is !!! not !!! constraint. 
declare sub      PhysicsJointInitialiseRotationConstraint(byval pObj as const PhysicsJoint ptr, _
                                                          byval pitch     as single, byval yaw       as single, byval roll      as single, _
                                                          byval minAngleX as single, byval minAngleY as single, byval minAngleZ as single, _
                                                          byval maxAngleX as single, byval maxAngleY as single, byval maxAngleZ as single)

' Call this function to initialise the joint as a Vector Constraint. 
' The rotation away from v3LimitCenterDirection is limited between the two objects. 
declare sub      PhysicsJointInitialiseVectorConstraint(byval pObj as const PhysicsJoint ptr, _
                                                        byval LimitCenterDirX as single, byval LimitCenterDirY as single, byval LimitCenterDirZ as single, _
                                                        byval maxAngle as single)

declare sub      PhysicsJointV3InitialiseVectorConstraint(byval pObj as const PhysicsJoint ptr, _
                                                          byref v3LimitCenterDirection as const TA_Vec3, _
                                                          byval maxAngle as single)
' ############################
' # Physics Joint Properties #
' ############################
declare function PhysicsJointGetType(byval pObj as const PhysicsJoint ptr) as ePHYSICS_JOINT_TYPES

declare function PhysicsJointIsObjectASolid(byval pObj as const PhysicsJoint ptr) as integer
declare sub      PhysicsJointSetObjectASolid(byval pObj as const PhysicsJoint ptr, byval bObjectASolid as integer)

declare function PhysicsJointIsObjectBSolid(byval pObj as const PhysicsJoint ptr) as integer
declare sub      PhysicsJointSetObjectBSolid(byval pObj as const PhysicsJoint ptr, byval bObjectBSolid as integer)

declare sub      PhysicsJointSetCollisionDisabledBetweenObjects(byval pObj as const PhysicsJoint ptr, byval bDisabled as integer)
declare function PhysicsJointIsCollisionDisabledBetweenObjects (byval pObj as const PhysicsJoint ptr) as integer

declare sub      PhysicsJointSetBreakForce(byval pObj as const PhysicsJoint ptr, byval fBreakForce as single)
declare function PhysicsJointGetBreakForce(byval pObj as const PhysicsJoint ptr) as single

declare sub      PhysicsJointSetBreakable(byval pObj as const PhysicsJoint ptr, byval bBreakable as integer)
declare function PhysicsJointIsBreakable (byval pObj as const PhysicsJoint ptr) as integer


declare sub      PhysicsJointSetBroken(byval pObj as const PhysicsJoint ptr, byval bBroken as integer)
declare function PhysicsJointIsBroken (byval pObj as const PhysicsJoint ptr) as integer

declare sub      PhysicsJointSetUserData(byval pObj as const PhysicsJoint ptr, byval pUserData as const any ptr)
declare function PhysicsJointGetUserData(byval pObj as const PhysicsJoint ptr) as any ptr

declare function PhysicsJointGetObjectA(byval pObj as const PhysicsJoint ptr) as const DynamicObject ptr

declare function PhysicsJointGetObjectB(byval pObj as const PhysicsJoint ptr) as const DynamicObject ptr

declare sub      PhysicsJointGetPosOnObjectA(byval pObj as const PhysicsJoint ptr, _
                                             byref x as single, byref y as single, byref z as single)

declare sub      PhysicsJointV3GetPosOnObjectA(byval pObj as const PhysicsJoint ptr, _
                                               byref v3Position as TA_Vec3)

declare sub      PhysicsJointGetPosOnObjectB(byval pObj as const PhysicsJoint ptr, _
                                             byref x as single, byref y as single, byref z as single)

declare sub      PhysicsJointV3GetPosOnObjectB(byval pObj as const PhysicsJoint ptr, _
                                               byref v3Position as TA_Vec3)

declare sub      PhysicsJointGetLimitNormalOnObjectA(byval pObj as const PhysicsJoint ptr, _
                                                     byref x as single, byref y as single, byref z as single)

declare sub      PhysicsJointV3GetLimitNormalOnObjectA(byval pObj as const PhysicsJoint ptr, _
                                                       byref v3Normal as TA_Vec3)

declare sub      PhysicsJointGetLimitNormalOnObjectB(byval pObj as const PhysicsJoint ptr, _
                                                     byref x as single, byref y as single, byref z as single)

declare sub      PhysicsJointV3GetLimitNormalOnObjectB(byval pObj as const PhysicsJoint ptr, _
                                                       byref v3Normal as TA_Vec3)

declare sub      PhysicsJointGetCenterDirectionOnObjectA(byval pObj as const PhysicsJoint ptr, _
                                                         byref x as single, byref y as single, byref z as single)

declare sub      PhysicsJointV3GetCenterDirectionOnObjectA(byval pObj as const PhysicsJoint ptr, byref v3CenterDir as TA_Vec3)

declare sub      PhysicsJointGetCenterDirectionOnObjectB(byval pObj as const PhysicsJoint ptr, _
                                                         byref x as single, byref y as single, byref z as single)

declare sub      PhysicsJointV3GetCenterDirectionOnObjectB(byval pObj as const PhysicsJoint ptr, _
                                                           byref v3CenterDir as TA_Vec3)

declare function PhysicsJointGetMaxAngle(byval pObj as const PhysicsJoint ptr) as single

declare sub      PhysicsJointGetJointOrientationA(byval pObj as const PhysicsJoint ptr, _
                                                  byref pitch as single, byref yaw as single, byref roll as single)

declare sub      PhysicsJointMat33GetJointOrientationA(byval pObj as const PhysicsJoint ptr, byref m33 as TA_Mat33)

declare sub      PhysicsJointGetJointOrientationB(byval pObj as const PhysicsJoint ptr, _
                                                  byref pitch as single, byref yaw as single, byref roll as single)
declare sub      PhysicsJointMat33GetJointOrientationB(byval pObj as const PhysicsJoint ptr, byref m33 as TA_Mat33)

declare sub      PhysicsJointGetMinAngles(byval pObj as const PhysicsJoint ptr, _
                                          byref minAngleX as single, byref minAngleY as single, byref minAngleZ as single)

declare sub      PhysicsJointGetMaxAngles(byval pObj as const PhysicsJoint ptr, _
                                          byref maxAngleX as single, byref maxAngleY as single, byref maxAngleZ as single)

declare sub      PhysicsJointGetSliderPos0(byval pObj as const PhysicsJoint ptr, _
                                           byref x as single, byref y as single, byref z as single)

declare sub      PhysicsJointV3GetSliderPos0(byval pObj as const PhysicsJoint ptr, _
                                             byref pos0 as TA_Vec3)

declare sub      PhysicsJointGetSliderPos1(byval pObj as const PhysicsJoint ptr, _
                                           byref x as single, byref y as single, byref z as single)

declare sub      PhysicsJointV3GetSliderPos1(byval pObj as const PhysicsJoint ptr, _
                                             byref pos1 as TA_Vec3)


' ###########################
' # CollisionObjectAABBMesh #
' ###########################
declare function CollisionObjectAABBMeshCreateNew() as CollisionObjectAABBMesh ptr
declare sub      CollisionObjectAABBMeshRelease(byref pObj as CollisionObjectAABBMesh ptr)

declare sub      CollisionObjectAABBMeshInitialise(byval pObj as const CollisionObjectAABBMesh ptr, nVertices as integer, nPolys as integer, nIndices as integer)

declare sub      CollisionObjectAABBMeshAddVertex(byval pObj as const CollisionObjectAABBMesh ptr, x as single,y as single,z as single)
declare sub      CollisionObjectAABBMeshV3AddVertex(byval pObj as const CollisionObjectAABBMesh ptr,v3Vertex as const TA_Vec3)

declare sub      CollisionObjectAABBMeshAddPolygon(byval pObj as const CollisionObjectAABBMesh ptr, nIndices as integer, pIndices as const integer ptr, surfaceAttributeIndex as integer=DEFAULT_SURFACE_ATTRIBUTE)

declare sub      CollisionObjectAABBMeshFinishedAddingGeometry(byval pObj as const CollisionObjectAABBMesh ptr)

declare sub      CollisionObjectAABBMeshSetUserData(byval pObj as const CollisionObjectAABBMesh ptr, byval pUserData as const any ptr)
declare function CollisionObjectAABBMeshGetUserData(byval pObj as const CollisionObjectAABBMesh ptr) as any ptr

declare sub      CollisionObjectAABBMeshRender(byval pObj as const CollisionObjectAABBMesh ptr)


' ################
' # StaticObject #
' ################
declare function StaticObjectCreateNew() as StaticObject ptr
declare sub      StaticObjectRelease(byref pObj as StaticObject ptr)

declare sub      StaticObjectInitialise(byval pObj as const StaticObject ptr,pMesh as const CollisionObjectAABBMesh ptr)

declare sub      StaticObjectSetPosition(byval pObj as const StaticObject ptr,x as single,y as single,z as single)
declare sub      StaticObjectV3SetPosition(byval pObj as const StaticObject ptr,v3Position as const TA_Vec3)

declare sub      StaticObjectGetPosition(byval pObj as const StaticObject ptr, byref x as single, byref y as single, byref z as single)
declare sub      StaticObjectV3GetPosition(byval pObj as const StaticObject ptr,v3Position as TA_Vec3)

declare sub      StaticObjectSetRotation(byval pObj as const StaticObject ptr,pitch as single    ,yaw as single    ,roll as single)
declare sub      StaticObjectGetRotation(byval pObj as const StaticObject ptr, byref pitch as single, byref yaw as single, byref roll as single)

declare function StaticObjectGetCollisionObject(byval pObj as const StaticObject ptr) as const CollisionObjectAABBMesh ptr 

declare function StaticObjectGetDynamicObject(byval pObj as const StaticObject ptr) as const DynamicObject ptr

declare sub      StaticObjectSetUserData(byval pObj as const StaticObject ptr, byval pUserData as const any ptr)
declare function StaticObjectGetUserData(byval pObj as const StaticObject ptr) as any ptr
' only in DEBUG mode
declare sub      StaticObjectSetVisible(byval pObj as const StaticObject ptr,bVisible as integer)
declare function StaticObjectIsVisible(byval pObj as const StaticObject ptr) as integer
declare sub      StaticObjectRender(byval pObj as const StaticObject ptr)


' #########
' # Tools #
' #########
declare sub      TA_Clamp(byref fValue as single, byval fMin as single, byval fMax as single)
declare sub      TA_ClampPosNeg(byref fValue as single, byval fPositive as single)

declare sub      TA_ClampIfLessThen(byref fValue as single, byval fMin as single)
declare sub      TA_ClampIfGreaterThen(byref fValue as single, byval fMax as single)

declare sub      TA_WrapAngle(byref fAngle as single)

declare function TA_FastFloatToInt(byref fValue as single) as integer
declare function TA_FloatIsOk(byval fValue as single) as integer

declare function TA_FastMin(byval a as single, byval b as single) as single
declare function TA_FastMax(byval a as single, byval b as single) as single

declare function TA_Min(byval a as single, byval b as single) as single
declare function TA_Max(byval a as single, byval b as single) as single

declare function TA_CubicInterpolate(byval fPosA as single, byval fPosB as single, _
                                     byval fVelA as single, byval fVelB as single, _
                                     byval fTime as single) as single

declare function TA_CubicInterpolateGradient(byval fPosA as single, byval fPosB as single, _
                                             byval fVelA as single, byval fVelB as single, _
                                             byval fTime as single) as single

declare sub TA_CubicInterpolateVec3(byref v3PosA as const TA_Vec3, byref v3PosB as const TA_Vec3, _
                                    byref v3VelA as const TA_Vec3, byref v3VelB as const TA_Vec3, _
                                    byval fTime  as single       , byref v3Result as TA_Vec3)

declare sub TA_FindClosestPointOnLineToLine(byref v3A0 as const TA_Vec3, byref v3A1 as const TA_Vec3, _
                                            byref v3B0 as const TA_Vec3, byref v3B1 as const TA_Vec3, _
                                            byref v3ResultPosOnA as TA_Vec3, byref v3ResultPosOnB as TA_Vec3)

declare sub TA_FindClosestPointOnLineToLineUnClamped(byref v3A0 as const TA_Vec3, byref v3A1 as const TA_Vec3, _
                                                     byref v3B0 as const TA_Vec3, byref v3B1 as const TA_Vec3, _
                                                     byref v3ResultPosOnA as TA_Vec3, byref v3ResultPosOnB as TA_Vec3)

declare sub TA_FindClosestPointOnLine(byref v3LineA as const TA_Vec3, _
                                      byref v3LineB as const TA_Vec3, _
                                      byref v3Point as const TA_Vec3, _
                                      byref v3Result as TA_Vec3)

declare function TA_FindShortestDistanceToLineSqrd(byref v3LineA as const TA_Vec3, _
                                                   byref v3LineB as const TA_Vec3, _
                                                   byref v3Point as const TA_Vec3) as single

declare function TA_FindShortestDistanceToLine(byref v3LineA as const TA_Vec3, _
                                               byref v3LineB as const TA_Vec3, _
                                               byref v3Point as const TA_Vec3) as single

declare function TA_FindClosestPointOnLineUnClamped(byref v3LineA as const TA_Vec3, _
                                                    byref v3LineB as const TA_Vec3, _
                                                    byref v3Point as const TA_Vec3, _
                                                    byref v3Result as TA_Vec3) as integer

' ########
' # Math #
' ########
declare function TA_Abs(byval nValue as integer) as integer
declare function TA_Fabs(byval fValue as single) as single
declare function TA_Sign(byval fValue as single) as single
declare function TA_SignsEqual(byval fA as single, byval fB as single) as integer
declare function TA_Sqrt(byval fValue as single) as single
declare function TA_ReciprocalSqrt(byval fValue as single) as single
declare function TA_Pow(byval fValue as single, byval fExponent as single) as single
declare function TA_Pow2(byval fX as single ) as single
declare function TA_Sin(byval fAngle as single) as single
declare function TA_Cos(byval fAngle as single) as single
declare sub      TA_SinAndCos(byval fAngle as single, byref fSin as single, byref fCos as single)
declare function TA_Tan(byval fAngle as single) as single
declare function TA_ATan2(byval fY as single, byval fX as single) as single
declare function TA_ACos(byval fValue as single) as single
declare function TA_FMod(byval fValue as single, byval fMod as single) as single
declare function TA_Exp(byval fValue as single) as single
declare function TA_Log(byval fValue as single) as single

' ###########
' # TA_Vec3 #
' ###########
' tmp=a : a=b : b=tmp
declare sub Vec3Swap(byref a as TA_Vec3, byref b as TA_Vec3)
' if Vec3IsEqualWithInError(a,b,0.0001) then
declare function Vec3IsEqualWithInError(byref a as const TA_Vec3, byref b as const TA_Vec3,fError as single) as integer

' self+=a
declare sub Vec3Add(byref self as TA_Vec3, byref a as const TA_Vec3)
' self=a+b
declare sub Vec3AddFrom(byref self as TA_Vec3, byref a as const TA_Vec3, byref b as const TA_Vec3)
' self-=a
declare sub Vec3Sub(byref self as TA_Vec3, byref a as const TA_Vec3)
' self=a-b
declare sub Vec3SubFrom(byref self as TA_Vec3, byref a as const TA_Vec3, byref b as const TA_Vec3)
' self*=s
declare sub Vec3Mul(byref self as TA_Vec3, s as single)
' self=a*s
declare sub Vec3MulFrom(byref self as TA_Vec3, byref a as const TA_Vec3, s as single)
' self/=s
declare sub Vec3Div(byref self as TA_Vec3, s as single)
' self=a/s
declare sub Vec3DivFrom(byref self as TA_Vec3, byref a as const TA_Vec3, s as single)

' = self.Magnitude()
declare function Vec3GetMagnitude(byref self as const TA_Vec3) as single
' = self.MagnitudeSqrd()
declare function Vec3GetMagnitudeSqrd(byref self as const TA_Vec3) as single
' =(a-self).Magnitude()
declare function Vec3GetDistance(byref self as const TA_Vec3, byref a as const TA_Vec3) as single
' =(a-self).MagnitudeSqrd()
declare function Vec3GetDistanceSqrd(byref self as const TA_Vec3, byref a as const TA_Vec3) as single
' =self.dot()
declare function Vec3GetDot(byref self as const TA_Vec3) as single
' =dot(self,a)
declare function Vec3GetDotWith(byref self as const TA_Vec3, byref a as const TA_Vec3) as single
' self.Normalize()
declare sub Vec3Normalise(byref self as TA_Vec3)
' if (self.IsNormalised()) then ...
declare function Vec3IsNormalised(byref self as const TA_Vec3) as integer
' self=a.GetNormal()
declare sub Vec3GetNormal(byref self as TA_Vec3, byref a as const TA_Vec3)
' self=cross(b-a,c-a).GetNormal()
declare sub Vec3FaceNormal(byref self  as TA_Vec3, byref a as const TA_Vec3, byref b as const TA_Vec3, byref c as const TA_Vec3)
' self=cross(b-a,c-a)
declare sub Vec3CrossFromEdges(byref self as TA_Vec3, byref a as const TA_Vec3, byref b as const TA_Vec3, byref c as const TA_Vec3)
' self.Cross(a)
declare sub Vec3CrossWith(byref self as TA_Vec3, byref a as const TA_Vec3)
' self=Cross(a,b)
declare sub Vec3CrossFrom(byref self as TA_Vec3, byref a as const TA_Vec3, byref b as const TA_Vec3)
' self*=m33
declare sub Vec3MulMat(byref self as TA_Vec3, byref m as const TA_Mat33)
' self=a*m33
declare sub Vec3MulMatFrom(byref self as TA_Vec3, byref a as const TA_Vec3, byref m as const TA_Mat33)
' self*=frame
declare sub Vec3MulFrame(byref self as TA_Vec3, byref f as const TA_MFrame)
' self=a*frame
declare sub Vec3MulFrameFrom(byref self as TA_Vec3, byref a as const TA_Vec3, byref f as const TA_MFrame)
' self/=m33
declare sub Vec3DivMat(byref self as TA_Vec3, byref m as const TA_Mat33)
' self=a/m33
declare sub Vec3DivMatFrom(byref self as TA_Vec3, byref a as const TA_Vec3, byref m as const TA_Mat33)
' self/=frame
declare sub Vec3DivFrame(byref self as TA_Vec3, byref f as const TA_MFrame)
' self=a/frame
declare sub Vec3DivFrameFrom(byref self as TA_Vec3, byref a as const TA_Vec3, byref f as const TA_MFrame)
' self = v3A*a + v3B*b
declare sub Vec3MulAdd2(byref self as TA_Vec3, _
                        byref v3A as const TA_Vec3, a as single, _
                        byref v3B as const TA_Vec3, b as single)
' self = v3A*a + v3B*b + v3C*c
declare sub Vec3MulAdd3(byref self as TA_Vec3, _
                        byref v3A as const TA_Vec3, a as single, _
                        byref v3B as const TA_Vec3, b as single, _
                        byref v3C as const TA_Vec3, c as single)
' ############
' # TA_Mat33 #
' ############
' tmp=a : a=b : b=tmp
declare sub Mat33Swap(byref a as TA_Mat33, byref b as TA_Mat33)
' self.Identity()
declare sub Mat33Identity(byref self as TA_Mat33)
' self=EulerAngles(rad,rad,rad)
declare sub Mat33InitialiseEulerAngles(byref self as TA_Mat33, byval pitch as single, byval yaw as single, byval roll as single)
' self=EulerAngles(deg,deg,deg)
declare sub Mat33InitialiseEulerAnglesD(byref self as TA_Mat33, byval pitch as single, byval yaw as single, byval roll as single)
' self=Initialise(TA_Vec3,rad)
declare sub Mat33InitialiseAxisAngle(byref self as TA_Mat33, byref axis as const TA_Vec3, byval angle as single)
' self=Initialise(eRotationAxis,rad)
declare sub Mat33InitialiseRotationAxis(byref self as TA_Mat33, byval axis as const eROTATION_AXIS, byval angle as single)
' self=PreRotate(eRotationAxis,rad)
declare sub Mat33PreRotate(byref self as TA_Mat33, byval axis as const eROTATION_AXIS, byval angle as single)
' self=SetToLookAt(position,up)
declare sub Mat33SetToLookAt(byref self as TA_Mat33, byref position as const TA_Vec3, byref up as const TA_Vec3)
' self=SetToLookDownVector(v)
declare sub Mat33SetToLookDownVector(byref self as TA_Mat33, byref v as const TA_Vec3)
' self+=m33
declare sub Mat33Add(byref self as TA_Mat33, byref a as const TA_Mat33)
' self-=m33
declare sub Mat33Sub(byref self as TA_Mat33, byref a as const TA_Mat33)
' self*=s
declare sub Mat33Mul(byref self as TA_Mat33, s as single)
' self/=s
declare sub Mat33Div(byref self as TA_Mat33, s as single)
' self*=a33
declare sub Mat33MulMat(byref self as TA_Mat33, byref a as const TA_Mat33)
' self=a33*b33
declare sub Mat33MulMatFrom(byref self as TA_Mat33, byref a as const TA_Mat33, byref b as const TA_Mat33)
' self/=a33
declare sub Mat33DivMat(byref self as TA_Mat33, byref a as const TA_Mat33)
' self=a33/b33
declare sub Mat33DivMatFrom(byref self as TA_Mat33, byref a as const TA_Mat33, byref b as const TA_Mat33)

' self.Invert()
declare sub Mat33Invert(byref self as TA_Mat33)
' self=a.GetInverse()
declare sub Mat33GetInerseFrom(byref self as TA_Mat33,a as const TA_Mat33)
' self.Interpolate(a,b,t);
declare sub Mat33Interpolate(byref self as TA_Mat33, byref a as const TA_Mat33, byref b as const TA_Mat33, t as single)
' self.GetRotationAxisAndMagnitude(v3Axis,fMagnitude)
declare sub Mat33GetRotationAxisAndMagnitude(byref self as const TA_Mat33, byref v3Axis as TA_Vec3, byref fMagnitude as single)
' self=self.GetTransposeAsInverse()
declare sub Mat33GetTransposeAsInverse(byref self as TA_Mat33)
' r=a.GetTransposeAsInverse()
declare sub Mat33GetTransposeAsInverseFrom(byref r as TA_Mat33, byref a as const TA_Mat33)

' #############
' # TA_MFrame #
' #############
' tmp=a: a=b : b=tmp
declare sub MFrameSwap(byref a as TA_MFrame, byref b as TA_MFrame)
' self.Identity()
declare sub MFrameIdentity(byref self as TA_MFrame)
' self.Initialise(rad,rad,rad)
declare sub MFrameInitialiseTA_EulerAngles(byref self as TA_MFrame, byval pitch as single, byval yaw as single, byval roll as single)
' self.Initialise(deg,deg,deg)
declare sub MFrameInitialiseTA_EulerAnglesD(byref self as TA_MFrame, byval pitch as single, byval yaw as single, byval roll as single)
' sef=Initialise(TA_Vec3,rad)
declare sub MFrameInitialiseAxisAngle(byref self as TA_MFrame, byref axis as const TA_Vec3, byval angle as single)
' sef=Initialise(TA_Vec3,deg)
declare sub MFrameInitialiseAxisAngleD(byref self as TA_MFrame, byref axis as const TA_Vec3, byval angle as single)
' sef=Initialise(TA_RotationAxis,rad)
declare sub MFrameInitialiseTA_RotationAxis(byref self as TA_MFrame, byval axis as eROTATION_AXIS, byval angle as single)
' self*=a
declare sub MFrameMul(byref self as TA_MFrame, byref a as const TA_MFrame)
' self=a*b
declare sub MFrameMulFrom(byref self as TA_MFrame, byref a as const TA_MFrame, byref b as const TA_MFrame)
' self/=a
declare sub MFrameDiv(byref self as TA_MFrame, byref a as const TA_MFrame)
' self=a/b
declare sub MFrameDivFrom(byref self as TA_MFrame, byref a as const TA_MFrame, byref b as const TA_MFrame)
' self*=a33
declare sub MFrameMulMat(byref self as TA_MFrame, byref a as const TA_Mat33)
' self=a33*b33
declare sub MFrameMulFromMat(byref self as TA_MFrame, byref a as const TA_MFrame, byref b as const TA_Mat33)
' self.Invert()
declare sub MFrameInvert(byref self as TA_MFrame)
' self=a.GetInverse()
declare sub MFrameInerseFrom(byref self as TA_MFrame, byref a as const TA_MFrame, byref b as const TA_MFrame)
' self.Interpolate(a,b,t);
declare sub MFrameInterpolate(byref self as TA_MFrame, byref a as const TA_MFrame, byref b as const TA_MFrame, byval t as single)


' ###########
' # TA_AABB #
' ###########
' tmp=a : a=b : b=tmp
declare sub AABBSwap(byref a as TA_AABB, byref b as TA_AABB)
' self.Initialise(v3Center,v3Extend)
declare sub AABBInitialise(byref self as TA_AABB, byref v3Center as const TA_Vec3, byref v3Extent as const TA_Vec3)
' self+=a
declare sub AABBAdd(byref self as TA_AABB, byref a as const TA_AABB)
' self=a+b
declare sub AABBAddFrom(byref self as TA_AABB, byref a as const TA_AABB, byref b as const TA_AABB)
' self*=s
declare sub AABBScale(byref self as TA_AABB, s as single)
' self=a*s
declare sub AABBScaleFrom(byref self as TA_AABB, byref a as const TA_AABB, s as single)
' self*=frame
declare sub AABBRotate(byref self as TA_AABB, byref f as const TA_MFrame)
' selöf=a*frame
declare sub AABBRotateFrom(byref r as TA_AABB, byref a as const TA_AABB, byref f as const TA_MFrame)
' self.ExpandToFit(a)
declare sub AABBExpandToFit(byref self as TA_AABB, byref a as const TA_Vec3)
' self.InitialiseToFit2Points(a,b)
declare sub AABBInitialiseToFit2Points(byref self as TA_AABB, byref a as const TA_Vec3, byref b as const TA_Vec3)
' bool=self.Intersecs(a)
declare function AABBIntersecs(byref self as const TA_AABB, byref a as const TA_AABB) as integer
' bool=self.IntersecsPoint(a)
declare function AABBIntersecsPoint(byref self as const TA_AABB, byref a as const TA_Vec3) as integer
' bool=self.IsInside(a)
declare function AABBIsInside(byref self as const TA_AABB, byref a as const TA_AABB) as integer

end extern

#endif ' __TRUEAXIS_BI__
