JV-ODE Physics Thread 5

Blitz3D Forums/Blitz3D Userlibs/JV-ODE Physics Thread 5

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.

Hey OJay,

Not sure if this helps you with the collisions, but here a Function I came up with to both play a "Crash" sound file and Slow the car down and also put Particles at the point of collision:

Function ShowCarBodyCollisions()

;### Check if a Collision has happened between Car and World Objects ###
	If dGeom1CountCollisions(CGeom) > 1


; ### IF YES a collision grab the X,Y,Z of the point of impact ###
		XPos# = dGeom1CollisionX(CGeom,1)
		YPos# = dGeom1CollisionY(CGeom,1)		
		ZPos# = dGeom1CollisionZ(CGeom,1)
		
; ### If The collision happens at speeds Greater than 6 then play Sound and Cut Current Speed in Half ###

		If Speed# > 6
			PlaySample(Hit01,0)
			Speed# = Speed# / 2
		EndIf

; ### If the Velocity of the Car (float) is fast enuff then create a random (1 of 3) particle at point of collision ###

		If Velocity# > 0.5
			I = Rnd(1,3)
		CrashParticle(0, HitSpark(I), 4, XPos#, YPos#, ZPos#, 1, 5, 1, 2, 1, 4, 0.1, 1.0)
		EndIf
	EndIf


So basically you have to be moving fast enough to play the sound and generate a sparking particle, otherwise if your just puttering along slow and nudge a wall or rail you just bump it.

Oh BTW, here's the Function that the crew here, I believe VIP3R posted to help me figure out the car's velocity:
Function CalcVelocity()

	PositionEntity PrevPosPivot,PrevX,PrevY,PrevZ

	Velocity#      = EntityDistance(CMesh,PrevPosPivot)

	        PrevX# = EntityX(CMesh)
		PrevY# = EntityY(CMesh)
		PrevZ# = EntityZ(CMesh)

End Function


As for the Friction, that's something I'd also be interested in knowing how to preform or suggestions for it, it's my next step to try to generate for drifting corners...:)

Topknot ;)