Official Pascal-Header (SDK 2.0)

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Official Pascal-Header (SDK 2.0)

Postby Stucuk » Wed Feb 04, 2009 2:08 pm

Below is a list of Newton Headers for Delphi. If you can not find a matching header below you may find more at either www.saschawillems.de or newton.freemapeditor.com.

2.35 Revision #2:
- NGD 2.35 Revision #2 Header (1st April 2012)

2.35 Revision #1:
- NGD 2.35 Revision #1 Header (14th February 2012)

2.24 Header:
- NGD 2.22 Beta Header (7th September 2010)

2.23 Header:
- NGD 2.23 Beta Header (6th July 2010)

2.22 Header:
- NGD 2.22 Beta Header (28th June 2010)

2.16 Header:
- NGD 2.16 Beta Header (26th May 2010)

2.15 Header:
- NGD 2.15 Beta Header (31th December 2009)

2.11 Header:
- NGD 2.11 Beta Header (20th November 2009)

2.10 Header:
- NGD 2.10 Beta Header (03th October 2009)

2.09 Header:
- NGD 2.09 Beta Header (25th September 2009)

2.07 Header:
- NGD 2.07 Beta Header (19th August 2009)

2.0-2.03 Header:
- NGD 2.0 Beta Header (9th March 2009)
Last edited by Stucuk on Sun Sep 05, 2010 3:23 am, edited 14 times in total.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Official Pascal-Header (SDK 1.53), last update 26.05.2006

Postby Stucuk » Fri Mar 06, 2009 12:11 pm

While there is still quite a bit to convert below is a link to the current version of the 2.0 Headers iv been working on. Which is based on the 1.53 headers.

Newton2.0BetaHeaders_WIP_06-03-09.rar ~57KB
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Official Pascal-Header (SDK 1.53), last update 26.05.2006

Postby JernejL » Sat Mar 07, 2009 1:46 pm

After building a game engine using newton betas i am left with a lot of serialized compound collisions made of convex hulls that need converting to new newton version, so i came up with a plan, to use NewtonCollisionGetInfo to get pointers to all collisions that make the compound, then i use NewtonCollisionForEachPolygonDo to access the vertex cloud, and re-create the convex hulls with the new newton version.

It doesn't work right, the vertices i get aren't the vertices i sent (because NewtonCreateConvexHull returns null, and the data in hex editor looks wrong) but i assume the problem is in the NewtonCollisionForEachPolygonDo callback function:

Code: Select all
procedure Newpolies(const userdata: pointer; vertexCount: integer; const FaceArray: PFloat; faceId: integer); cdecl;
begin
  Tmemorystream(userdata).Write( facearray^, vertexCount * 12);
  vcnt:= vcnt + vertexCount;
end;


Does anybody have any idea what i'm doing wrong? i don't know the right "pointer wrestling" so that memorystream would write the right data.

EDIT: nevermind, i fixed, first i write sizeof blank bytes and overwrite it it using:

Code: Select all
  CopyMemory( pointer(integer(Tmemorystream(userdata).memory) + Tmemorystream(userdata).Position - vertexCount * 12),
  FaceArray, vertexCount * 12
    );
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Official Pascal-Header (SDK 1.53), last update 26.05.2006

Postby Stucuk » Sun Mar 08, 2009 9:24 pm

Iv finished converting every procedure/function, tho its still missing the NewtonCollisionInfoRecord as i have no clue how to convert it(Help would be nice). Anyway you can download the 2.0 Beta header below.

- http://newton.freemapeditor.com/downloads/DelphiNewtonImport_NGD2.0Beta_WIP.rar ~62KB

Note: I have only converted the NewtonImport.h, not the Joint Libary's header.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Official Pascal-Header (SDK 1.53), last update 26.05.2006

Postby JernejL » Thu Jul 09, 2009 3:51 am

I'm translating the NewtonCollisionInfoRecordTag record now, i have added case into the record, to accomodate the structure having different records based on collision type, there's however a problem with these structures at the end:

Code: Select all
      int m_referenceCount;            // the current reference count for this collision      
      char m_collisionType[32];         // tag id to identify the collision primitive


Because delphi engineers in all their sillyness made records with variable structure only possible at end of a record, so i will have to split this record into two separate ones, in altogether 3 "packed records", i will ask julio if he can move those parts of record, then we can use a clean single record
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Official Pascal-Header (SDK 1.53), last update 26.05.2006

Postby Stucuk » Thu Jul 09, 2009 7:37 am

If Julio has modified the header since i last posted then some functions in the header i posted may be out of data (Not checked).
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Official Pascal-Header (SDK 1.53), last update 26.05.2006

Postby JernejL » Thu Jul 09, 2009 8:17 am

There are some added functions and few changed structs which may be missing in your header, my header i posted isnt up to date either, but the one i use for tdc is since i'm adding changes regularly with each new beta release i do a diff to see what changed.

I havent published my up to date header yet because im trying to resolve the NewtonCollisionInfoRecordTag record problem so it will be 100% complete.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Official Pascal-Header (SDK 1.53), last update 26.05.2006

Postby JernejL » Thu Jul 09, 2009 2:59 pm

I talked to Julio, and the record will be changed in next beta release, m_referenceCount and m_collisionUserID will be moved to start of structure and variable part will be at the end, so this is how the translation should be correct structure for the next release (unless other things are added / changed):

Code: Select all
      // NewtonCollisionInfoRecord

      TNewtonBoxParam = packed record
             m_x,
             m_y,
             m_z: float;
      end;

       TNewtonSphereParam = packed record
             m_r0,
             m_r1,
             m_r2: single;
      end;

      TNewtonCylinderParam = packed record
          m_r0,
          m_r1,
        m_height: single;
      end;

      TNewtonCapsuleParam = packed record
          m_r0,
          m_r1,
        m_height: single;
      end;

      TNewtonConeParam = packed record
          m_r,
          m_height: single;
      end;

       TNewtonChamferCylinderParam = packed record
             m_r,
             m_height: single;
      end;

      TNewtonConvexHullModifierParam = packed record
         m_chidren: PNewtonCollision;
      end;

      TNewtonCompoundCollisionParam = packed record
         m_chidrenCount: integer;
        m_chidren: pointer; // pointer to array of pnewtoncollisions
      end;

      TNewtonHeightFieldCollisionParam = packed record
             m_width,
             m_height,
             m_gridsDiagonals: integer;
             m_horizonalScale,
             m_verticalScale: single;
             m_elevation: pointer; //unsigned short *m_elevation;
             m_atributes: pchar;
      end;

      TNewtonSceneCollisionParam = packed record
          m_childrenProxyCount: integer;
      end;

       TNewtonCollisionInfoRecord = packed record
        m_offsetMatrix: array[0..3,0..3] of single;
          m_collisionType,               // tag id to identify the collision primitive
          m_referenceCount,                // the current reference count for this collision
          m_collisionUserID: integer;
      Case collisiontype: 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:  );
            SERIALIZE_ID_CONVEXMODIFIER :
             (shapedataxonvexhull: TNewtonConvexHullModifierParam );
            SERIALIZE_ID_CHAMFERCYLINDER :
             (shapedatachamfercylinder: TNewtonChamferCylinderParam );
    //        SERIALIZE_ID_TREE :
    //         (shapedata:  );
    //        SERIALIZE_ID_NULL :
    //         (shapedata:  );
            SERIALIZE_ID_HEIGHTFIELD :
             (shapedataheightfield: TNewtonHeightFieldCollisionParam );
           SERIALIZE_ID_USERMESH :
             (m_paramArray: array[0..63] of float);
            SERIALIZE_ID_SCENE :
             (shapedatascenecollision: TNewtonSceneCollisionParam);
      end;

      PNewtonCollisionInfoRecord = ^TNewtonCollisionInfoRecord;


Edit: i split this topic in two parts, so that 1.53 code and newton2 code arent mixed, should make it easier for people to find delphi headers for newton 2.0.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Official Pascal-Header (SDK 2.0)

Postby Stucuk » Fri Jul 10, 2009 10:25 pm

Iv replaced my first post. Imo first post of the topic should have the latest downloadable links. Feel free to edit it. Note that if you add your own headers in the first post plz remove the link to mine (Should only work on one set rather than maintaining two). It would be good if Julio could put the latest Delphi headers in with the latest Beta's with a note somewhere (Say a readme) stating to check this topic for the latest ones.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Official Pascal-Header (SDK 2.0)

Postby JernejL » Sat Jul 11, 2009 10:10 am

Like i said in the PM, my header is a minimalistic one like the sury's original header, while yours & sascha's is made to work around glscene / delphigl.de headers so there's a distinct difference in some data type declarations used.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Official Pascal-Header (SDK 2.0)

Postby Corpsman » Wed Aug 19, 2009 1:50 am

Hello,

I tried to use the Header files on a Kubuntu Jaunty Machine, with Lazarus.

To Compile the Headers i had to insert :

{$linklib stdc++}

in the FPC parts, and delete some units only aviable under Windows.

After this i could compile it.

I have written a game ( Balanced ) with Newton1.53 and now want to compile it under Linux, using the newton2.0. So i swapped the Header files without the need of changing one sourcecode file.

But unfortunatunely it does not work.

My "Ball" falls through all not moving objects without any collision.

So is there a tutorial or something like that, in wich i can read what i have to do different than :

Code: Select all
type
  TGLfloat = Single;

  TVector3f = Record
    x: GLfloat;
    y: GLfloat;
    z: GLfloat;
  End;

Var
  Collision: PNewtonCollision;
  Fpoints: Array Of TVector3f;   
Begin
  If High(Fpoints) = -1 Then exit; // Array with Points
  // Create collision
  Collision := NewtonCreateConvexHull(newtonworld, high(Fpoints) + 1, @fpoints[0], 12, Nil);
  // Create the rigid body
  fNewtonBody := NewtonCreateBody(NewtonWorld, Collision);
  // Remove the collider, we don't need it anymore
  NewtonReleaseCollision(NewtonWorld, Collision);
  // Solid Object
  NewtonBodySetMassMatrix(fNewtonBody, 0, 0, 0, 0);
  // Now set the position of the body's matrix
  NewtonBodyGetMatrix(fNewtonBody, @FMatrix[0, 0]);
  fMatrix[3, 0] := fPosition.x;
  fMatrix[3, 1] := fPosition.y;
  fMatrix[3, 2] := fPosition.z;
  NewtonBodySetMatrix(fNewtonBody, @fMatrix[0, 0]);
  //   Finally set the callback in which the forces on this body will be applied
  (*
  is this really necessary for solid objects ???
  *)
  NewtonBodySetForceAndTorqueCallBack(fNewtonBody, @ForceAndTorqueCallBack);

  NewtonBodySetMaterialGroupID(fnewtonbody, Material);

End;

--
You want to Know more about me and my projects visit http://www.Corpsman.de
I use Newton in Balanced2
Corpsman
 
Posts: 38
Joined: Mon May 01, 2006 11:42 am

Newton 2.0 Pascal Header

Postby Corpsman » Wed Aug 19, 2009 4:32 am

The function
Old One:
Code: Select all
function  NewtonCreateConvexHull( const newtonWorld : PNewtonWorld; count : int; const vertexCloud : PFloat; strideInBytes : int; const offsetMatrix : PFloat) : PNewtonCollision; cdecl; external{$IFDEF __GPC__}name 'NewtonCreateConvexHull'{$ELSE}NewtonDLL{$ENDIF __GPC__};


new
Code: Select all
function NewtonCreateConvexHull (const NewtonWorld : PnewtonWorld; count:int; const vertexCloud:PFloat; strideInBytes:Int; tolerance: Float;  const offsetMatrix:PFloat) : PNewtonCollision; cdecl; external{$IFDEF __GPC__}name 'NewtonCreateConvexHull'{$ELSE}NewtonDLL{$ENDIF __GPC__};


and in delphinewton.inc

Old
Code: Select all
{$IFDEF FPC}
  {$MODE Delphi}          { use Delphi compatibility mode }
  {$H+}
  {$PACKRECORDS 4}        // Added for record
  {$MACRO ON}             // Added For OpenGL
  {$THREADING on}
  {$DEFINE Delphi}
  {$DEFINE UseAT}
  {$UNDEF USE_STDCALL}
  {$DEFINE OS_BigMem}
  {$DEFINE NO_EXPORTS}
  {$DEFINE Has_Int64}
  {$DEFINE NOCRT}
  {$IFDEF unix}
     {$DEFINE fpc_unix}
  {$ELSE}
     {$DEFINE __OS_DOS__}
  {$ENDIF}
  {$IFDEF WIN32}
   {$DEFINE UseWin}
  {$ENDIF}
{$ENDIF FPC}



New

Code: Select all
{$IFDEF FPC}
  {$MODE Delphi}          { use Delphi compatibility mode }
  {$H+}
  {$PACKRECORDS 4}        // Added for record
  {$MACRO ON}             // Added For OpenGL
  {$THREADING on}
  {$DEFINE Delphi}
  {$DEFINE UseAT}
  {$UNDEF USE_STDCALL}
  {$DEFINE OS_BigMem}
  {$DEFINE NO_EXPORTS}
  {$DEFINE Has_Int64}
  {$DEFINE NOCRT}
  {$IFDEF unix}
     {$DEFINE fpc_unix}
     {$linklib stdc++}   // Added by Corpsman, to support c++ code in libnewton.so
  {$ELSE}
     {$DEFINE __OS_DOS__}
  {$ENDIF}
  {$IFDEF WIN32}
   {$DEFINE UseWin}
  {$ENDIF}
{$ENDIF FPC}

--
You want to Know more about me and my projects visit http://www.Corpsman.de
I use Newton in Balanced2
Corpsman
 
Posts: 38
Joined: Mon May 01, 2006 11:42 am

Re: Official Pascal-Header (SDK 2.0)

Postby JernejL » Wed Aug 19, 2009 6:34 am

Corpsman: i merged your #2 post here.

About your #1 post: you should check if you set the positions properly - try the debug rendering, also how fast does the ball move?
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Official Pascal-Header (SDK 2.0)

Postby Stucuk » Wed Aug 19, 2009 2:17 pm

If you use "My" header with a version above about 2.03 then it shouldn't work correctly as the header has changed for some things (Mainly creating collisions). I havn't had any time to update it.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Official Pascal-Header (SDK 2.0)

Postby Stucuk » Wed Aug 19, 2009 4:33 pm

I have updated "my" header to 2.07 . But be warned i may have missed some changes. I have also included Delfi's NewtonCollisionInfoRecord code seen above, since i have never used it i don't know if its compatible with the latest version or not (Or if it works on any version) but its better than nothing :P . Corpsman's changes have also been included. See top post for link to the latest header.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 17 guests

cron