Results 1 to 9 of 9

Thread: Help me translate this c code to pascal!

  1. #1

    Help me translate this c code to pascal!

    I am really getting desparate getting new car physics for use with TDC to work, i can't possibly find the problem, which makes the vehicle dance instead standing stable. The goal of this is, to find the bug, fix the code, and help me get the project back on track, i have here a MSVC project, which can be compiled with MSVC + Newton SDK, and Delphi 7 project (uses glscene).

    The original code Was written by sergey / cyko74 from newton physics engine forum. The RCV is acronym for RayCast Vehicle, the most common way of eficiently simulating a vehicle (used by practically every car game out there), each tire is a ray, raycasted onto terrain with suspension, and simulated with great stability and widely adjustable realism, it also features a simulated differential, gearbox and a drivetrain.

    The facts: delphi version does not work as expected, the car dances due to unknown misterious forces.

    To get the program to run, edit glscene utils3ds.pas with this quich hack to allow loading 3ds files from Zmodeler properly:

    [pascal]
    // uncomment this line:

    // if MatEntry.Tag <> MAT_ENTRY then ShowError(Error3DS_INVALID_CHUNK);

    // and this line here:

    MAT_DECAL:
    ; // don't know what do to with it
    else
    // ShowError(Error3DS_INVALID_CHUNK)
    [/pascal]

    Source Code:

    MSVC:
    http://www.gtatools.com/TDC/Developm...ode/tdcrcv.rar
    http://www.gtatools.com/TDC/Developm...%20project.rar (Newer version, more stable simulation, i can't even translate older properly)

    Delphi 7:
    http://www.gtatools.com/TDC/Developm.../delphircv.rar

    There is also a working Delphi 7 demo that uses a much older version of RCV dll, i can't get newer dll's to work with delphi, due to weird MSVC memory alingment in records, but it is doable.
    This is here just to show how stable the simulation is, under proper circumstances
    http://www.gtatools.com/TDC/Developm...i_with_dll.rar

    The main code is in tdcvehicle.cpp, delphi pas file is TDC_RCV.pas.
    The source code is free to use for everybody and has no restrictions placed on it, so feel free to use it in other games (if you can fix it )

    beware, the whole translated code looks rather ugly, since i did extensive re-testing and cutting/pasting code trying to fix the bug, a single run thru jedi code formatter should clean it up a bit, and i intend to re-format, improve, optimize and cleanup the code when it works.

    If you can help me get the code to work, i am sure we can work out some kind of fair compensation
    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. #2

    Help me translate this c code to pascal!

    Here is the most fresh translation of new code:

    http://www.gtatools.com/TDC/Developm...e/tdc_rcv2.pas

    I did this again from scratch, and it ends up broken in same way as the old translation, i blame the matrix code for that. Please help.
    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

  3. #3

    Help me translate this c code to pascal!

    Having a quick look. Will let you know how I go.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  4. #4

    Help me translate this c code to pascal!

    When I try and run the demo, Terrain.3ds crashes with the following error

    ---------------------------
    Demo1
    ---------------------------
    An invalid Chunk structure was encountered while reading
    the database. Usually caused by a corrupt database or file.
    ---------------------------
    OK
    ---------------------------
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  5. #5

    Help me translate this c code to pascal!

    Read the first post, there's a quick fix / hack for that, it is glscene bug, one day i will make a proper fix and submit it to them.

    edit: i suspect one of these routines to be faulty: RotateVector, UnrotateVector, dgRollMatrix. these are translated from newton SDK's vector class headers. each function has in code several implementations that i tried, but i didn't have much luck making proper ones, so that would be a good start to start searching for the bug.
    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. #6

    Help me translate this c code to pascal!

    Btw, have you looked at using OxNewton - http://www.dave.serveusers.com/oxNewton.html ?

    It is a set of dynamic,static tools more...
    Working only under GLScene environement, and now all is build under Turbo Delphi.
    Dynamic and Static: Cube, Sphere, Cylinder, Capped Cylinder, ChamferCylinder,
    Cone, FPS Character, Ragdoll, Ragdoll SMD format with bones, vehicle and more...
    All of this is already ready to use.
    The oxNewton component base have change now it is a inherited TGLScene editor component.
    Vehicle and ragdoll have change too and it is not only little changes but it is not so hard to convert old project.
    I have a lot updates too ready to add but in the moment it is in test, I start to add this new updates in the next coming week.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  7. #7

    Help me translate this c code to pascal!

    Quote Originally Posted by savage
    Btw, have you looked at using OxNewton - http://www.dave.serveusers.com/oxNewton.html ?
    heard of it, but this is not to be used with glscene, but my own engine, glscene is used just for this sandbox app to test the code. this is not same as newton's vehicle joint.
    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

  8. #8

    Help me translate this c code to pascal!

    I have not used GLScene so I'm not sure that would be the best way to sandbox it as GLScene may be doing things *its own way* that may not be directly compatible with Newton, hence the need for the OxNewteon component.

    I could not find what was the problem. If I were to look into it further I would send an email to Sascha as I'm sure he would be more than happy to help with the intricasies of Newton.

    Also take a look at http://newton.delphigl.de/ and in particular his http://www.delphigl.de/files/glNewtonCarDemo2.zip . Maybe that might shed some light. It's straight OpenGL ( IIRC ).
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  9. #9

    Help me translate this c code to pascal!

    Quote Originally Posted by savage
    I have not used GLScene so I'm not sure that would be the best way to sandbox it as GLScene may be doing things *its own way* that may not be directly compatible with Newton, hence the need for the OxNewteon component.

    I could not find what was the problem. If I were to look into it further I would send an email to Sascha as I'm sure he would be more than happy to help with the intricasies of Newton.

    Also take a look at http://newton.delphigl.de/ and in particular his http://www.delphigl.de/files/glNewtonCarDemo2.zip . Maybe that might shed some light. It's straight OpenGL ( IIRC ).
    i don't think i explained what this is properly, so i will try to again:

    this is not a normal newton vehicle joint vehicle simulation, NGD vehicle joint uses rigid bodies for wheels, and therefore a such simulation has its drawback: instability and high processing need.

    This project is implementing a raycast car for use with newton, raycast / hovercraft car instead of using bodies to simulate wheels, use raycasting where the wheel should be, and simulates the tire reactions, this is much less intensive way and more stable to simulate vehicles.

    The code is implementation of RCV / raycast vehicle in C, i am trying to translate it to pascal, C version uses some utilities from newton sdk's own vector library which are probably not working in my translation. in delphi translated implementation, glscene is only used to render the vehicle, i don't use glscene's vector libs or anything else from glscene in the vehicle sim. code.
    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

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
  •