Results 1 to 4 of 4

Thread: ODE Sample #01 - 2 seconds with flying sphere :)

  1. #1
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,153
    Rep Power
    736

    ODE Sample #01 - 2 seconds with flying sphere :)

    Hi,

    here is translation of Python ODE01.PY script to our precious ( thinBASIC )
    thinBASIC source adds saving to file as bonus

    [code=thinBASIC]

    uses "FILE"
    #include "thinbasic_ode.inc"

    ' -- Yes, to create new world is that easy
    dim myWorld as dWorldID = dWorldCreate

    ' -- Creates generall body
    dim myBody as dBodyID = dBodyCreate( myWorld )

    ' -- Here we will store mass
    dim myMass AS dMass

    ' -- Planet Earth
    dWorldSetGravity(myWorld, 0, -9.81, 0)

    ' -- Although it might seem like something else, we give DENSITY and RADIUS
    dMassSetSphere( myMass, 2500.0, 0.05 )

    ' -- Here the actual mass
    myMass.mass = 1

    ' -- Assign mass to body
    dBodySetMass( myBody, myMass )

    ' -- Lets position mass at x, y, z
    dBodySetPosition( myBody, 0, 2, 0 )

    ' -- May the Force be with our body
    dBodyAddForce( myBody, 0, 200, 0 )

    dim total_time as double

    ' -- Delta of time - 0.04 => like 25 FPS
    dim dt as double = 0.04

    ' -- Variables to store position and speed
    dim x, y, z, u, v, w AS dReal

    dim fileOutput as string

    while ( total_time < 2.0 )

    ParseVector(dBodyGetPosition ( myBody ), x, y, z)
    ParseVector(dBodyGetLinearVel ( myBody ), u, v, w)

    fileoutput += FORMAT$( total_time, "0.00")+" sec: " + _
    "pos=("+FORMAT$( x, "0.000")+","+FORMAT$( y, "0.000")+","+FORMAT$( z, "0.000")+")"+ _
    "vel=("+FORMAT$( u, "0.000")+","+FORMAT$( v, "0.000")+","+FORMAT$( w, "0.000")+")"+$CRLF

    dWorldStep( myworld, dt) ' -- Increases step in simulation
    total_time +=dt

    WEND

    FILE_SAVE( APP_SOURCEPATH+"ODE_Output.txt", fileoutput )

    ' -- All created must be destroyed
    dBodyDestroy( myBody )
    dWorldDestroy( myWorld )

    msgbox 0, "Script finished, results saved to ODE_Output.txt"

    sub ParseVector( byval pointer as dword, byref b as SINGLE, byref c as single, byref d as single )

    b = peek(single, pointer)
    c = peek(single, pointer+4)
    d = peek(single, pointer+

    end sub
    [/code]

    I will try to translate even the 2 more examples, although I am not sure if they need callbacks yet.


    Bye,
    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  2. #2
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,865
    Rep Power
    405

    Re: ODE Sample #01 - 2 seconds with flying sphere :)

    Petr this is giving me the same error that example # 2 does. Eros's version worked but yours give this error. Hope it helps in finding what it could be. I don't see anything wrong:

    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,153
    Rep Power
    736

    Re: ODE Sample #01 - 2 seconds with flying sphere :)

    Hi Kent,

    this is simply the error in original headers I corrected yesterday
    Just re-download latest header.


    Thanks,
    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  4. #4
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,865
    Rep Power
    405

    Re: ODE Sample #01 - 2 seconds with flying sphere :)

    Hmmmm, I thought of that Petr and redownloaded it numerous times and cleared my cache and even saved to different folders, I still keep getting the same error.
    Maybe my thinCore is messed up, I did some of the updates that Eros has last week or the week before and maybe didn't get the latest. I will redownload thinBasic and try again. Thanks.
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

Similar Threads

  1. looking for sphere
    By largo_winch in forum Shout Box Area
    Replies: 7
    Last Post: 17-04-2011, 19:03
  2. Sphere physics
    By Petr Schreiber in forum TBGL General
    Replies: 39
    Last Post: 20-07-2008, 16:24

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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