ODE Test

BlitzMax Forums/BlitzMax Programming/ODE Test

Vertex(Posted 2005) [#1]
Hi!
This is a little test for ODE (without collision checking :()

If you don't have Mak.ODE, so you must start
syncmods.exe -u username -p password mak

Strict

Framework Pub.DreiDe
Import Mak.ODE

Global World        : Int
Global Space        : Int

Global BoxBody      : Int
Global BoxMass      : dMass
Global BoxGeom      : Int
Global BoxMesh      : TMesh

Global PlaneGeom    : Int
Global PlaneMesh    : TMesh 

Global Camera       : TCamera

Global Position     : Float Ptr

TDreiDe.Graphics3D(640, 480)

' Erstelle Welt
World = dWorldCreate()
dWorldSetGravity(World, 0.0, -9.81, 0.0)

' Erstelle Raum
Space = dHashSpaceCreate(0)

' Erstelle Box
BoxBody = dBodyCreate(World)
dBodySetPosition(BoxBody, 0.0, 40.0, 0.0)

BoxMass = New dMass
dMassSetBoxTotal(BoxMass, 0.01, 2.0, 2.0, 2.0)
dBodySetMass(BoxBody, BoxMass)

BoxGeom = dCreateBox(Space, 2.0, 2.0, 2.0)
dGeomSetBody(BoxGeom, BoxBody)

BoxMesh = TPrimitive.CreateCube()
BoxMesh.ScaleVertices(2.0, 2.0, 2.0)
BoxMesh.SetPosition(0.0, 40.0, 0.0)

' Erstelle Boden
PlaneGeom = dCreatePlane(Space, 0.0, 1.0, 0.0, 0.0)
PlaneMesh = TPrimitive.CreateQuad()
PlaneMesh.ScaleVertices(100.0, 100.0, 1.0)
PlaneMesh.SetRotation(-90.0, 0.0, 0.0)

' Erstelle Kamera
Camera = New TCamera
Camera.SetPosition(0.0, 10.0, 50.0)

While Not KeyDown(KEY_ESCAPE)
	dWorldQuickStep(World, 0.1)
	
	If dBodyIsEnabled(BoxBody) Then
		Position = dGeomGetPosition(BoxGeom)
		BoxMesh.SetPosition(Position[0], ..
		                    Position[1], ..
		                    Position[2])
	EndIf

	Camera.Render()
	Flip()
Wend

EndGraphics()


I have rewritten quickly DreiDe for BMax 1.12, so you can download the complete package with DreiDe, Source and Exe at:
http://www.blitz-pasting.net/index.php?content=bp_showupload&id=640

Mak.ODE needs dODEClose, maybe, witout the are memory leaks.
For collision detection, you must write a CallBack function.
Maybe, I will write a better ODE module with helper functions.

It's just a quick test, if ODE works.

cu olli


Leiden(Posted 2005) [#2]
I think I've found a possible bug in the TVector4 Math Type.

	Method GetDotProduct:Float(Vector:TVector4 Var)
		Return Self.Components[0]*Vector.Components[0] + ..
		       Self.Components[1]*Vector.Components[1] + ..
		       Self.Components[2]*Vector.Components[2] + ..
		       Self.Components[3]*Vector.Components[3]
	End Method


Shouldn't it be GetDotProduct:Float(Vector:TVector4) without the Var bit?

Also here:
	Method CrossProduct(Vector:TVector4 Var, Result:TVector4 Var)
		Result.Components[0] = Self.Components[1]*Vector.Components[2] - ..
		                       Self.Components[2]*Vector.Components[1]

		Result.Components[1] = Self.Components[2]*Vector.Components[0] - ..
		                       Self.Components[0]*Vector.Components[2]

		Result.Components[2] = Self.Components[0]*Vector.Components[1] - ..
		                       Self.Components[1]*Vector.Components[0]

		If (Self.Components[3] = 0.0) And (Vector.Components[3] = 0.0) Then
			Result.Components[3] = 0.0
		Else
			Result.Components[3] = 1.0
		EndIf 
	End Method


If I understand it right, That function should Take a Vector, multiply it by the Vectors components that the method was called from, then return a new Vector.


BlitzSupport(Posted 2005) [#3]
One for Mark (pointed this out before, but he does say to hassle the authors of unsupported mods!)...


Function dWorldImpluseToForce( dWorldID,stepsize#,ix#,iy#,iz#,force:Float Ptr )




Hotcakes(Posted 2005) [#4]
Yes, he brought that one on himself didn't he =]