Moderators: Sascha Willems, walaber
{$IFDEF WIN32}
NewtonDLL = 'Newton.dll';
{$IFDEF JOINTLIBRARY}
JointLibraryDLL = 'JointLibrary.dll';
{$ENDIF}
{$ENDIF}
{$IFDEF NICE_CODE_PARAMS}
PNewtonMesh = ^Pointer;
PNewtonBody = ^Pointer;
PNewtonWorld = ^Pointer;
PNewtonJoint = ^Pointer;
PNewtonContact = ^Pointer;
PNewtonMaterial = ^Pointer;
PNewtonCollision = ^Pointer;
PNewtonSceneProxy = ^Pointer;
//PNewtonRagDoll = ^Pointer;
//PNewtonRagDollBone = ^Pointer;
{$IFDEF JOINTLIBRARY}
// JointLibrary
PNewtonUserJoint = ^Pointer;
{$ENDIF}
{$ELSE}
PNewtonMesh = Pointer;
PNewtonBody = Pointer;
PNewtonWorld = Pointer;
PNewtonJoint = Pointer;
PNewtonContact = Pointer;
PNewtonMaterial = Pointer;
PNewtonCollision = Pointer;
PNewtonSceneProxy = Pointer;
//PNewtonRagDoll = Pointer;
//PNewtonRagDollBone = Pointer;
{$IFDEF JOINTLIBRARY}
// JointLibrary
PNewtonUserJoint = ^Pointer;
{$ENDIF}
{$ENDIF}
// *****************************************************************************************************************************
//
// JointLibrary Callbacks
//
// *****************************************************************************************************************************
{$IFDEF JOINTLIBRARY}
NewtonUserJointDestructorCallback = procedure( const me : PNewtonUserJoint ); cdecl;
PNewtonUserJointDestructorCallback = ^NewtonUserJointDestructorCallback;
NewtonUserJointSubmitConstraintCallback = procedure( const me : PNewtonUserJoint; timestep : Float; threadIndex : int ); cdecl;
PNewtonUserJointSubmitConstraintCallback = ^NewtonUserJointSubmitConstraintCallback;
BlankJointGetInfo = procedure( const me : PNewtonUserJoint; info : PNewtonJointRecord ); cdecl;
PBlankJointGetInfo = ^BlankJointGetInfo;
DGRaycastVehicleTireTransformCallback = procedure( car : PNewtonUserJoint ); cdecl;
PDGRaycastVehicleTireTransformCallback = ^DGRaycastVehicleTireTransformCallback;
{$ENDIF}
// *****************************************************************************************************************************
//
// JointLibrary functions
//
// *****************************************************************************************************************************
{$IFDEF JOINTLIBRARY}
// generic joint functions
procedure CustomDestroyJoint( const joint : PNewtonUserJoint ); cdecl; external{$IFDEF __GPC__}name 'CustomDestroyJoint'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
function CustomGetJointID( const joint : PNewtonUserJoint ) : int; cdecl; external{$IFDEF __GPC__}name 'CustomGetJointID'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomSetJointID( const joint : PNewtonUserJoint; rttI : int ); cdecl; external{$IFDEF __GPC__}name 'CustomSetJointID'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
function CustomGetBody0( const joint : PNewtonUserJoint ) : PNewtonBody; cdecl; external{$IFDEF __GPC__}name 'CustomGetBody0'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
function CustomGetBody1( const joint : PNewtonUserJoint ) : PNewtonBody; cdecl; external{$IFDEF __GPC__}name 'CustomGetBody1'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
function CustomGetBodiesCollisionState( const joint : PNewtonUserJoint ) : int; cdecl; external{$IFDEF __GPC__}name 'CustomGetBodiesCollisionState'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomSetBodiesCollisionState( const joint : PNewtonUserJoint; state : int ); cdecl; external{$IFDEF __GPC__}name 'CustomSetBodiesCollisionState'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
function CustomGetUserData( const joint : PNewtonUserJoint ) : Pointer; cdecl; external{$IFDEF __GPC__}name 'CustomGetUserData'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomSetUserData( const joint : PNewtonUserJoint; userData : Pointer ); cdecl; external{$IFDEF __GPC__}name 'CustomSetUserData'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomSetDestructorCallback( const joint : PNewtonUserJoint; callback : NewtonUserJointDestructorCallback ); cdecl; external{$IFDEF __GPC__}name 'CustomSetDestructorCallback'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomSetSubmitContraintCallback( const joint : PNewtonUserJoint; callback : NewtonUserJointSubmitConstraintCallback ); cdecl; external{$IFDEF __GPC__}name 'CustomSetSubmitContraintCallback'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
// this is a plain blank joint that can be used by advanced users who want to make their own joints
// but that can only use languages that can only interface with C code.
// we recommend using the CPP library to make the joints and then add a C interface, but this join is here for completion
function CustomCreateBlankJoint( maxDof : int; const body0 : PNewtonBody; const body1 : PNewtonBody; info : BlankJointGetInfo) : PNewtonUserJoint; cdecl; external{$IFDEF __GPC__}name 'CustomCreateBlankJoint'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
// Kinematic control joint
function CreateCustomKinematicController( const targetBody : PNewtonBody; attachmentPointInGlobalSpace : PFloat ) : PNewtonUserJoint; cdecl; external{$IFDEF __GPC__}name 'CreateCustomKinematicController'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomKinematicControllerSetPickMode( const pick : PNewtonUserJoint; mode : int); cdecl; external{$IFDEF __GPC__}name 'CustomKinematicControllerSetPickMode'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomKinematicControllerSetMaxLinearFriction( const pick : PNewtonUserJoint; accel : Float ); cdecl; external{$IFDEF __GPC__}name 'CustomKinematicControllerSetMaxLinearFriction'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomKinematicControllerSetMaxAngularFriction( const pick : PNewtonUserJoint; alpha : Float ); cdecl; external{$IFDEF __GPC__}name 'CustomKinematicControllerSetMaxAngularFriction'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomKinematicControllerSetTargetPosit( const pick : PNewtonUserJoint; posit : PFloat ); cdecl; external{$IFDEF __GPC__}name 'CustomKinematicControllerSetTargetPosit'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomKinematicControllerSetTargetRotation( const pick : PNewtonUserJoint; rotation : PFloat ); cdecl; external{$IFDEF __GPC__}name 'CustomKinematicControllerSetTargetRotation'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomKinematicControllerSetTargetMatrix( const pick : PNewtonUserJoint; matrix : PFloat ); cdecl; external{$IFDEF __GPC__}name 'CustomKinematicControllerSetTargetMatrix'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomKinematicControllerGetTargetMatrix( const pick : PNewtonUserJoint; matrix : PFloat ); cdecl; external{$IFDEF __GPC__}name 'CustomKinematicControllerGetTargetMatrix'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
// Generic 6 degree of Freedom Joint
function CreateCustomJoint6DOF( const pinsAndPivoChildFrame : PFloat; const pinsAndPivoParentFrame : PFloat; const child : PNewtonBody; const parent : PNewtonBody ) : PNewtonUserJoint; cdecl; external{$IFDEF __GPC__}name 'CreateCustomJoint6DOF'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomJoint6DOF_SetLinearLimits( customJoint6DOF : PNewtonUserJoint; const minLinearLimits : PFloat; const maxLinearLimits : PFloat ); cdecl; external{$IFDEF __GPC__}name 'CustomJoint6DOF_SetLinearLimits'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomJoint6DOF_SetAngularLimits( customJoint6DOF : PNewtonUserJoint; const minAngularLimits : PFloat; const maxAngularLimits : PFloat ); cdecl; external{$IFDEF __GPC__}name 'CustomJoint6DOF_SetAngularLimits'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomJoint6DOF_GetLinearLimits( customJoint6DOF : PNewtonUserJoint; minLinearLimits, maxLinearLimits : PFloat ); cdecl; external{$IFDEF __GPC__}name 'CustomJoint6DOF_GetLinearLimits'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomJoint6DOF_GetAngularLimits( customJoint6DOF : PNewtonUserJoint; minAngularLimits, maxAngularLimits : PFloat ); cdecl; external{$IFDEF __GPC__}name 'CustomJoint6DOF_GetAngularLimits'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomJoint6DOF_SetReverseUniversal( customJoint6DOF : PNewtonUserJoint; order : int ); cdecl; external{$IFDEF __GPC__}name 'CustomJoint6DOF_SetReverseUniversal'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
// Interface for a custom BallAndSocket joint with Limits
function CreateCustomBallAndSocket( const pinsAndPivoChildFrame : PFloat; const child : PNewtonBody; const parent : PNewtonBody) : PNewtonUserJoint; cdecl; external{$IFDEF __GPC__}name 'CreateCustomBallAndSocket'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure BallAndSocketSetConeAngle( ballJoint : PNewtonUserJoint; angle : Float ); cdecl; external{$IFDEF __GPC__}name 'BallAndSocketSetConeAngle'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure BallAndSocketSetTwistAngle( ballJoint : PNewtonUserJoint; minAngle, maxAngle : Float ); cdecl; external{$IFDEF __GPC__}name 'BallAndSocketSetTwistAngle'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
// Interface for a custom Hinge joint with Limits
function CreateCustomHinge( const pinsAndPivoChildFrame : PFloat; const child : PNewtonBody; const parent : PNewtonBody ) : PNewtonUserJoint; cdecl; external{$IFDEF __GPC__}name 'CreateCustomHinge'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure HingeEnableLimits( hingeJoint : PNewtonUserJoint; state : int ); cdecl; external{$IFDEF __GPC__}name 'HingeEnableLimits'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure HingeSetLimis( hingeJoint : PNewtonUserJoint; minAngle, maxAngle : Float ); cdecl; external{$IFDEF __GPC__}name 'HingeSetLimis'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
// Interface for a custom Slider joint with Limits
function CreateCustomSlider( const pinsAndPivoChildFrame : PFloat; const child : PNewtonBody; const parent : PNewtonBody ) : PNewtonUserJoint; cdecl; external{$IFDEF __GPC__}name 'CreateCustomSlider'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure SliderEnableLimits( sliderJoint : PNewtonUserJoint; state : int ); cdecl; external{$IFDEF __GPC__}name 'SliderEnableLimits'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure SliderSetLimis( sliderJoint : PNewtonUserJoint; mindist, maxdist : Float ); cdecl; external{$IFDEF __GPC__}name 'SliderSetLimis'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
// player controller functions
function CreateCustomPlayerController( const pins : PFloat; const player : PNewtonBody; maxStairStepFactor, cushion : Float ) : PNewtonUserJoint; cdecl; external{$IFDEF __GPC__}name 'CreateCustomPlayerController'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomPlayerControllerSetVelocity( const playerController : PNewtonUserJoint; forwardSpeed, sideSpeed, heading : Float ); cdecl; external{$IFDEF __GPC__}name 'CustomPlayerControllerSetVelocity'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomPlayerControllerGetVisualMaTrix( const playerController : PNewtonUserJoint; matrix : PFloat ); cdecl; external{$IFDEF __GPC__}name 'CustomPlayerControllerGetVisualMaTrix'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
function CustomPlayerControllerGetMaxSlope( const playerController : PNewtonUserJoint ) : Float; cdecl; external{$IFDEF __GPC__}name 'CustomPlayerControllerGetMaxSlope'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure CustomPlayerControllerSetMaxSlope( const playerController : PNewtonUserJoint; maxSlopeAngleIndRadian : Float ); cdecl; external{$IFDEF __GPC__}name 'CustomPlayerControllerSetMaxSlope'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
function CustomPlayerControllerGetSensorShape( const playerController : PNewtonUserJoint ) : PNewtonCollision; cdecl; external{$IFDEF __GPC__}name 'CustomPlayerControllerGetSensorShape'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
// k00m (Dave Gravel simple ray cast world vehicle)
function DGRaycastVehicleCreate( maxTireCount : int; const cordenateSytemInLocalSpace : PFloat; carBody : PNewtonBody ) : PNewtonUserJoint; cdecl; external{$IFDEF __GPC__}name 'DGRaycastVehicleCreate'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure DGRaycastVehicleAddTire( car : PNewtonUserJoint; userData : Pointer; const localPosition : PFloat; mass, radius, width, friction, suspensionLength, springConst, springDamper : Float; castMode : int ); cdecl; external{$IFDEF __GPC__}name 'DGRaycastVehicleAddTire'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure DGRaycastVehicleSetTireTransformCallback( car : PNewtonUserJoint; callback : DGRaycastVehicleTireTransformCallback ); cdecl; external{$IFDEF __GPC__}name 'DGRaycastVehicleSetTireTransformCallback'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
function DGRaycastVehicleGetTiresCount( car : PNewtonUserJoint ) : int; cdecl; external{$IFDEF __GPC__}name 'DGRaycastVehicleGetTiresCount'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
function DGRaycastVehicleGetTiresUserData( car : PNewtonUserJoint; tireIndex : int ) : Pointer; cdecl; external{$IFDEF __GPC__}name 'DGRaycastVehicleGetTiresUserData'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
procedure DGRaycastVehicleGetTireMatrix( car : PNewtonUserJoint; tireIndex : int; tireMatrix : PFloat ); cdecl; external{$IFDEF __GPC__}name 'DGRaycastVehicleGetTireMatrix'{$ELSE}JointLibraryDLL{$ENDIF __GPC__};
{$ENDIF}
TNewtonCollisionInfoRecord = packed record
m_offsetMatrix: array[0..3,0..3] of single;
m_collisionType, // tag id to identify the collision primitive
m_referenceCount: integer; // the current reference count for this collision
Case m_collisionUserID: integer of // yes we use this unfortunate element also for the case statement, that's as this variable is actually part of the record.
SERIALIZE_ID_BOX :
(shapedatabox: TNewtonBoxParam );
SERIALIZE_ID_CONE :
(shapedata: TNewtonConeParam );
SERIALIZE_ID_SPHERE :
(shapedatasphere: TNewtonSphereParam );
SERIALIZE_ID_CAPSULE :
(shapedatacapsule: TNewtonCapsuleParam );
SERIALIZE_ID_CYLINDER :
(shapedatacylinder: TNewtonCylinderParam );
SERIALIZE_ID_COMPOUND :
(shapedatacompound: TNewtonCompoundCollisionParam );
SERIALIZE_ID_CONVEXHULL :
(shapedataconvexhull: TNewtonConvexHullParam);
SERIALIZE_ID_CONVEXMODIFIER :
(shapedataxonvexhull: TNewtonConvexHullModifierParam );
SERIALIZE_ID_CHAMFERCYLINDER :
(shapedatachamfercylinder: TNewtonChamferCylinderParam );
SERIALIZE_ID_TREE :
(shapedatatree: TNewtonCollisionTreeParam );
SERIALIZE_ID_NULL :
(shapedatanull: TNewtonCollisionNullParam );
SERIALIZE_ID_HEIGHTFIELD :
(shapedataheightfield: TNewtonHeightFieldCollisionParam );
SERIALIZE_ID_USERMESH :
(m_paramArray: array[0..63] of float);
SERIALIZE_ID_SCENE :
(shapedatascenecollision: TNewtonSceneCollisionParam);
end;
TNewtonCollisionNullParam = packed record
// nothing.
end;
TNewtonCollisionInfoRecord = packed record
m_offsetMatrix: array[0..3,0..3] of single;
m_collisionType, // tag id to identify the collision primitive
m_referenceCount: integer; // the current reference count for this collision
m_collisionUserID: integer;
Case integer of
SERIALIZE_ID_BOX :
(shapedatabox: TNewtonBoxParam );
SERIALIZE_ID_CONE :
(shapedata: TNewtonConeParam );
SERIALIZE_ID_SPHERE :
(shapedatasphere: TNewtonSphereParam );
SERIALIZE_ID_CAPSULE :
(shapedatacapsule: TNewtonCapsuleParam );
SERIALIZE_ID_CYLINDER :
(shapedatacylinder: TNewtonCylinderParam );
SERIALIZE_ID_COMPOUND :
(shapedatacompound: TNewtonCompoundCollisionParam );
SERIALIZE_ID_CONVEXHULL :
(shapedataconvexhull: TNewtonConvexHullParam);
SERIALIZE_ID_CONVEXMODIFIER :
(shapedataxonvexhull: TNewtonConvexHullModifierParam );
SERIALIZE_ID_CHAMFERCYLINDER :
(shapedatachamfercylinder: TNewtonChamferCylinderParam );
SERIALIZE_ID_TREE :
(shapedatatree: TNewtonCollisionTreeParam );
SERIALIZE_ID_NULL :
(shapedatanull: TNewtonCollisionNullParam );
SERIALIZE_ID_HEIGHTFIELD :
(shapedataheightfield: TNewtonHeightFieldCollisionParam );
SERIALIZE_ID_USERMESH :
(m_paramArray: array[0..63] of float);
SERIALIZE_ID_SCENE :
(shapedatascenecollision: TNewtonSceneCollisionParam);
end;
NEWTON_API NewtonCollision* NewtonCreateCompoundBreakable (const NewtonWorld* newtonWorld, int meshCount,
const NewtonMesh* const solids[], const int* const shapeIDArray,
const dFloat* const densities, const int* const internalFaceMaterial,
int shapeID, int debriID, dFloat debrieSeapasationGap);
function NewtonCreateCompoundBreakable(
ANewtonWorld: PNewtonWorld;
AMeshCount: Integer;
ASolids: array of PNewtonMesh;
AShapeIDArray: PInteger;
ADensities: PSingle;
AInternalFaceMatrtial: PInteger;
AShapeID: Integer;
ADebriID: Integer;
ADebrieSeapastionGap): PNewtonCollision; cdecl;
NEWTON_API pNewtonCollision NewtonCreateCompoundBreakable (
const newtonWorld: pNewtonWorld;
meshCount: integer;
const solids: pNewtonMesh*;
const shapeIDArray: pInteger; // probably same way as with NewtonCreateCompoundCollision
const dFloat*
const densities,
const internalFaceMaterial: pint;
shapeID: integer;
debriID: integer;
debrieSeapasationGap: single
);
thedmd wrote:ASolids: array of PNewtonMesh;
Delfi wrote:thedmd wrote:ASolids: array of PNewtonMesh;
That is most certainly wrong, the parameter is a pointer, and delphi array is not same as a C array, for example @array of PNewtonMesh can point to one thing and @array of PNewtonMesh[0] can be on a totally different location.
TCollisionPrimitiveArray = array of PNewtonCollision;
type
PPNewtonMesh = ^PNewtonMesh;
...
ASolids: PPNewtonMesh;
...
thedmd wrote:I think this will be suitable:
- Code: Select all
type
PPNewtonMesh = ^PNewtonMesh;
...
ASolids: PPNewtonMesh;
...
What do you think Delfi?
Delfi wrote:for example @array of PNewtonMesh can point to one thing and @array of PNewtonMesh[0] can be on a totally different location.
Users browsing this forum: No registered users and 33 guests