Page 4 of 6 FirstFirst ... 23456 LastLast
Results 31 to 40 of 55

Thread: 3d Engine Collision

  1. #31

    Re: 3d Engine Collision

    Quote Originally Posted by Memphis
    maybe, but 1... i dont like the newton forum
    RANT:

    What a excellent excuse :\ you are going to ignore the original forum that has newton developers that are more qualified to answer your questions more than anyone else because you don't like it.

    Helping mode:

    Anyway, if you need, i can give you my newton 2.0 pascal header, i think there's one on forum from koom or sury but i am not sure, if you can't find one let me know and i'll give you mine.

    does anyone had some examples of loading a mesh or so and using it with newton
    creating a newton collision object from a GLSCENE mesh (newton 1.35 but will probably work with 2.0 with no changes):

    Code:
     terrain:= NewtonCreateTreeCollision(nWorld, nil); 
    
     NewtonTreeCollisionBeginBuild(terrain);
    
     test:= street.MeshObjects.Items[0].ExtractTriangles(nil, nil);
    
     for i:= 0 to test.Count div 3 do begin
     faces[0]:= test.Items[i*3 + 0];
     faces[1]:= test.Items[i*3 + 1];
     faces[2]:= test.Items[i*3 + 2];
     NewtonTreeCollisionAddFace(terrain, 3, @faces[0], 12, 1);
     end;
    
     NewtonTreeCollisionEndBuild(terrain, 1);
    Remember to serialize the trimesh and cache it, as it'll load much faster from serialized format.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  2. #32

    Re: 3d Engine Collision

    thanks, i managed to implement version 1.5(something here) which seems to work, but if there is pascal headers for version 2, i'd be happy if you can point me in the right direction. however my new problem is still related to the newton engine... i have created a box (.x) when i load the box i have created a newton collision box, which works in my engine, however i cant get the box to be right (realistic) size around the box, and if the box size changed for example, if i loaded a differ .x mesh, i thought i could use getboundingbox with directx but i can't seem to find any info as to a way to perfect that whilst also getting the size of the box to input into newton...


    Code:
     ModelMan.InitModel('box.x');
     Box := TNewtonBox.Create(V3({X},{Y},{Z}), V3(10, 10, 0), 10);
     Box.Model := ModelMan.liModels[1];
    so basically it renders and even drops to the ground, simulates a box dropping, but the size i dont know how to get, which is the {X, Y, Z} of the mesh.

  3. #33

    Re: 3d Engine Collision

    Quote Originally Posted by Memphis
    thanks, i managed to implement version 1.5(something here) which seems to work, but if there is pascal headers for version 2, i'd be happy if you can point me in the right direction. however my new problem is still related to the newton engine... i have created a box (.x) when i load the box i have created a newton collision box, which works in my engine, however i cant get the box to be right (realistic) size around the box, and if the box size changed for example, if i loaded a differ .x mesh, i thought i could use getboundingbox with directx but i can't seem to find any info as to a way to perfect that whilst also getting the size of the box to input into newton...


    Code:
     ModelMan.InitModel('box.x');
     Box := TNewtonBox.Create(V3({X},{Y},{Z}), V3(10, 10, 0), 10);
     Box.Model := ModelMan.liModels[1];
    so basically it renders and even drops to the ground, simulates a box dropping, but the size i dont know how to get, which is the {X, Y, Z} of the mesh.
    Try calculating the AABB.

    For newton 2.0 header try this header:

    http://mathpudding.com/temp/Newton.pas
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  4. #34

    Re: 3d Engine Collision

    hi thanks dude for the header.

    ok yes i use

    Code:
     D3DXComputeBoundingBox(@Positions[0], tModel.pMesh.GetNumVertices(), D3DXGetFVFVertexSize(tModel.pMesh.GetFVF()), tModel.minBounds, tModel.maxBounds);
    this at the moment, but how would i get the size in a (x y z) format? thanks again.

  5. #35

    Re: 3d Engine Collision

    Quote Originally Posted by Memphis
    this at the moment, but how would i get the size in a (x y z) format? thanks again.
    Just calculate the length of the aabb along each axis.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  6. #36

    Re: 3d Engine Collision

    for some reason D3DXComputeBoundingBox... this returns an x and z, but y is always zero... for example

    Code:
    D3DXComputeBoundingBox(PD3DXVector3(pVertices), tModel.pMesh.GetNumVertices(), D3DXGetFVFVertexSize(tModel.pMesh.GetFVF), tModel.minBounds, tModel.maxBounds);
    gives me for min and max bounds

    x,x = -0.516241977918882
    y,y = 0
    z,z = -0.609047940488495

  7. #37

    Re: 3d Engine Collision

    is there a way to draw lines around the physics box, to see the difference in actual box physic size and render size?

  8. #38

    Re: 3d Engine Collision

    Quote Originally Posted by Memphis
    is there a way to draw lines around the physics box, to see the difference in actual box physic size and render size?
    Yes, implement newton debug rendering.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  9. #39

    Re: 3d Engine Collision

    Here's my version of debug rendering routines:

    Code:
    procedure DebugShowGeometryCollision_Wire(const body: PNewtonBody; vertexCount: integer; const FaceArray: PFloat; faceId: integer); cdecl;
    var
     i: integer;
     vn: integer;
    
     procedure rendervertex(const num: integer);
     begin
      glVertex3fv(pointer(integer(FaceArray) + num * 12));
     end;
    
    begin
     vn := vertexCount - 1;
    
     for i := 0 to vertexCount - 1 do
     begin
      rendervertex(vn);
      rendervertex(i);
      vn := i;
     end;
    end;
    
    // show rigid body collision geometry
    procedure DebugShowBodyCollision_wire(const body: Pnewtonbody); cdecl;
    var
     tempmatrix: TMatrix4f;
    begin
     //NewtonBodyForEachPolygonDo(body, @DebugShowGeometryCollision_Wire);
     NewtonBodyGetMatrix(body, @tempmatrix);
     NewtonCollisionForEachPolygonDo(NewtonBodyGetCollision(body), @tempmatrix, @DebugShowGeometryCollision_Wire, nil);
    end;
    
    procedure NewtonWorldForEachBodyDo(const newtonWorld: PNewtonWorld; callback: PNewtonBodyIterator);
    var
     thebody: PNewtonBody;
    begin
    
     thebody := NewtonWorldGetFirstBody(newtonWorld);
     while thebody <> nil do
     begin
      callback(thebody);
      thebody := NewtonWorldGetNextBody(newtonWorld, thebody);
     end;
    
    end;
    
    // show all collision geometry in debug mode
    procedure DebugShowCollision_wire;
    begin
     NewtonWorldForEachBodyDo(nWorld, DebugShowBodyCollision_wire);
    end;
    and call:

    Code:
     glBegin(gl_lines);
     DebugShowCollision_wire;
     glend;
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  10. #40

    Re: 3d Engine Collision

    hi thanks, atm i have

    after rending box's etc

    Code:
     NewtonWorldForEachBodyDo(NewtonWorld, @DebugCallback);
    Code:
    procedure DebugCallback(const body : PNewtonBody); cdecl;
    var
     matrix: TMatrix4f;
    begin
     NewtonBodyGetMatrix(body, @matrix[0,0]);
    
     //i don't know how to draw the lines here with dx in 3d space.
    end;
    ^ this being my problem, i duno how to draw the lines in 3d space with dx. i've been 'googling' for ages, checked even newton forum 3-4 times. all info i find is always opengl, and i dont understand opengl at all tbh.

Page 4 of 6 FirstFirst ... 23456 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •