NearCallback in ode anyone?

BlitzMax Forums/BlitzMax Programming/NearCallback in ode anyone?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I wrote a callback and implemented a test using aurora.

Strict
Import "Aurora.bmx"
Import "Ode.bmx"

Const Max_Contacts = 40
Global ode_actworld,ode_actGroup
Function NearCallBack( data:Byte Ptr,o1:Int,o2:Int )
	Local b1:Int,b2:Int
	 b1 = dGeomGetBody(o1);
	 b2 = dGeomGetBody(o2);

	If b1 And b2 And dAreConnectedExcluding( b1,b2,dJointTypeContact)
		Return 
	End If
	Local cons:dContact[Max_Contacts]
	For Local i=0 Until Max_Contacts
		cons[i] = New dContact
		cons[i].mode = dContactBounce | dContactSoftCFM
		cons[i].mu = dInfinity
		cons[i].mu2 = 0
		cons[i].bounce = 0.1
		cons[i].bounce_vel = 0.1
		cons[i].soft_cfm = 0.01
	Next
	
	Local numc:Int = dCollide( o1,o2,max_contacts,Byte Ptr(cons[0]),SizeOf(dContact) )
	Print "Collisions:"+numc
	If numc
		
		For Local i:Int = 0 Until numc
			Local jid = dJointCreateContact( ode_actworld,ode_actgroup,Byte Ptr(cons[i]) )
			dJointAttach( jid,b1,b2 )
		Next
	EndIf
	
End Function


Local fp:Byte Ptr = Byte Ptr( nearcallback )

Local Display:TDisplay = TDisplay.Create()
Display.OpenScreen()

Global World        : Int
Global Space        : Int

Global BoxBody      : Int
Global BoxMass      : dMass
Global BoxGeom      : Int
Local BoxM:TEntity 

Global PlaneGeom    : Int
Global PlaneMesh    : TEntity

Global Camera       : TCamera = tCamera.Create()

Global Position     : Float Ptr



' Erstelle Welt
World = dWorldCreate()
dWorldSetGravity(World, 0.0, -0.01, 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)

BoxM = TEntity.CreateMesh("box.mesh")
BoxM.Scale(2.0, 2.0, 2.0)
BoxM.Position(0.0, 40.0, 0.0)

' Erstelle Boden
PlaneGeom = dCreatePlane(Space, 0.0, 1.0, 0.0, 0.0)
PlaneMesh = TPrefab.Plane(100,100)

ode_actgroup = dJointGroupCreate( 0 )
ode_actworld = world 

' Erstelle Kamera
Camera.Position(0.0, 10.0, 50.0)
Camera.LookAt( 0,0,0 )

'PlaneMesh.SetMaterial("dirt")

BoxM.setmaterial("dirt")

While Not KeyDown(KEY_ESCAPE)
	dSpaceCollide( space,Null,fp )
	dWorldQuickStep(World, 0.1)
	dJointGroupEmpty( ode_actGroup) 
	If dBodyIsEnabled(BoxBody) Then
		Position = dGeomGetPosition(BoxGeom)
		BoxM.Position(Position[0],Position[1],Position[2])
	EndIf
	
	Render3D()
	CaptureInput()



Wend




But it fails in the callback on the joint creation saying Dnormalize4 was based a zero value.