Official Pascal-Header (SDK 2.0)

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Official Pascal-Header (SDK 2.0)

Postby JernejL » Wed Aug 19, 2009 6:55 pm

The inforecord stayed same during last few changes, my version of it is up to date.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1441
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Official Pascal-Header (SDK 2.0)

Postby Executor » Sat Sep 05, 2009 3:46 am

I could not find a JointLibrary header for delphi.
Therefore, for himself wrote it, can someone be useful:


Code: Select all
{$IFDEF WIN32}
    NewtonDLL = 'Newton.dll';
  {$IFDEF JOINTLIBRARY}
    JointLibraryDLL = 'JointLibrary.dll';
  {$ENDIF}
{$ENDIF}


Code: Select all
{$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}


Code: Select all
// *****************************************************************************************************************************
//
//  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}


Code: Select all
// *****************************************************************************************************************************
//
// 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}
Executor
 
Posts: 25
Joined: Fri Sep 04, 2009 7:01 am

Re: Official Pascal-Header (SDK 2.0)

Postby Stucuk » Fri Sep 25, 2009 6:36 pm

I have updated the Delphi header (See top post for link). I added Executor's Joint Library header translation into a new unit (The "Types" are now in a separate unit that can be accessed by both). The Joint Library translation is missing the dll names for non windows Joint Library DLL's (Im not going to download each version just to get the names). Note that i havn't tested the 2.09 modifications in any way shape or form (There wasn't actualy much difference between 2.07 and 2.09) nor have i tested the Joint Library translation.
User avatar
Stucuk
 
Posts: 800
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Official Pascal-Header (SDK 2.0)

Postby JernejL » Wed Sep 30, 2009 4:33 pm

I messed up the TNewtonCollisionInfoRecord record, here's a fixed version i now use in my engine and it works!

Code: Select all
   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;
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1441
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Official Pascal-Header (SDK 2.0)

Postby Stucuk » Thu Oct 01, 2009 1:17 am

TNewtonCollisionNullParam doesn't exist (There is no Null Param in 2.09 or 1.10's header). Could you post its deceleration?
User avatar
Stucuk
 
Posts: 800
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Official Pascal-Header (SDK 2.0)

Postby JernejL » Thu Oct 01, 2009 5:38 am

i think i'm still behind on 2.08, i'll check what has changed again when i get back home.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1441
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Official Pascal-Header (SDK 2.0)

Postby JernejL » Fri Oct 02, 2009 4:02 pm

It's just a blank record.. for consistiency:

Code: Select all
  TNewtonCollisionNullParam = packed record
    // nothing.
  end;
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1441
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Official Pascal-Header (SDK 2.0)

Postby Stucuk » Fri Oct 02, 2009 7:25 pm

Thanks. Updated the header to 2.10 and added your changes.
User avatar
Stucuk
 
Posts: 800
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Official Pascal-Header (SDK 2.0)

Postby JernejL » Wed Nov 18, 2009 8:11 pm

I came up to figure out what i did wrong with this record that i had to abuse collisionUserID for case statement in record.. actually if you don't define a name for the case var, then delphi won't take the variable as part of record!

So this should be the 100% delphi proper version:

Code: Select all
   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;
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1441
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Official Pascal-Header (SDK 2.0)

Postby Stucuk » Thu Nov 19, 2009 3:15 pm

Delfi any idea how to translate the following:

Code: Select all
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);


It makes no sense to me as some parameters have no names.
User avatar
Stucuk
 
Posts: 800
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Official Pascal-Header (SDK 2.0)

Postby thedmd » Thu Nov 19, 2009 3:42 pm

This shoult help:

Code: Select all
function NewtonCreateCompoundBreakable(
  ANewtonWorld: PNewtonWorld;
  AMeshCount: Integer;
  ASolids: array of PNewtonMesh;
  AShapeIDArray: PInteger;
  ADensities: PSingle;
  AInternalFaceMatrtial: PInteger;
  AShapeID: Integer;
  ADebriID: Integer;
  ADebrieSeapastionGap): PNewtonCollision; cdecl;
"God started from scratch too"
User avatar
thedmd
 
Posts: 149
Joined: Fri Jun 26, 2009 11:52 pm

Re: Official Pascal-Header (SDK 2.0)

Postby JernejL » Thu Nov 19, 2009 3:53 pm

something like this?

Code: Select all
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
);
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1441
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Official Pascal-Header (SDK 2.0)

Postby JernejL » Thu Nov 19, 2009 3:54 pm

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.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1441
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Official Pascal-Header (SDK 2.0)

Postby thedmd » Thu Nov 19, 2009 4:03 pm

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.

I was not sure about this one. Since it is an dynamic array it is not right. But after looking at following line in pascal header rI wasn't entirely sure.
Code: Select all
TCollisionPrimitiveArray = array of PNewtonCollision;


I think this will be suitable:
Code: Select all
type
  PPNewtonMesh = ^PNewtonMesh;
...
  ASolids: PPNewtonMesh;
...

What do you think Delfi?
"God started from scratch too"
User avatar
thedmd
 
Posts: 149
Joined: Fri Jun 26, 2009 11:52 pm

Re: Official Pascal-Header (SDK 2.0)

Postby Stucuk » Thu Nov 19, 2009 4:24 pm

Meh im stupid. The const's inbetween a parameter's decleration was throwing me off. Now i can see it. Delfi's translation looks nearly right tho densities is a PFloat. When it comes to arrays that are passed, newton headers have generally treated them as pointers of the basic type of object (I.E PIntegers).

thedmd wrote:I think this will be suitable:
Code: Select all
type
  PPNewtonMesh = ^PNewtonMesh;
...
  ASolids: PPNewtonMesh;
...

What do you think Delfi?


A PNewtonMesh is a ^Pointer unless you turn off a define(The its just a Pointer... same difference in the end). I don't see the use in creating another type which is the same thing. TCollisionPrimitiveArray type of syntax should proberly be used for Arrays so people know which ones are an array.

Delfi wrote:for example @array of PNewtonMesh can point to one thing and @array of PNewtonMesh[0] can be on a totally different location.


I have used both of your examples in things before and its never caused any problems. Both have pointed perfectly.
User avatar
Stucuk
 
Posts: 800
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: Bing [Bot] and 2 guests