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

1. 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

2. 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:

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

Hi Kent,

this is simply the error in original headers I corrected yesterday

Thanks,
Petr

4. 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.

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
•