Particle candy and jv-ode?

Blitz3D Forums/Blitz3D Userlibs/Particle candy and jv-ode?

Pete Carter(Posted 2007) [#1]
Ok this should be easy but its giving me problems.

in my jv_ode driving game. Ive been trying to have particles of smoke get left behind my tyres when the car first pulls away or accelerates sharply. ive been trying to limit the emitter so that it only comes on when a force is applied then cut off when it passes a higher force value. it kind of works but its cutting the smoke off a bit early, whatever i try I cant seam to get it right.

also is there a way in JV-ODE of telling how fast a body is moving, i tried some of the commands from the docs but i dont think im using the right.

thanks Pete


Dreamora(Posted 2007) [#2]
If you cut uf the smoke early this sounds like you used stopemitter with forced end. You can as well just modify its lifetime so it does not spawn any further particles, this would most likely be what you desire, correct?


Pete Carter(Posted 2007) [#3]
Its not that, if i hold the handbrake and then accerate,which hold the car to a really slow speed the smoke keeps emitting because it keeps the force from going above the limit where ive set it to turn off the emitter. without limiting the emitter the car would drive round with smoke trailing it. i know the Particle system is set right, but i need to be able to control emitters to give smoke just when you accerate and only for the first sec or so to make it look like wheel spin. id like to have smoke when the car skid round corners but i have no idea how to do it.

thanks for the really though. I have trouble expaining sometime im sorry


VIP3R(Posted 2007) [#4]
Hi Pete,

You can return the rotational velocity of the wheels in JV-ODE. Combine this with the overall velocity of the car and detect it is in contact with the ground to start/stop the emitter.

For example, if there is a high rotation velocity of the wheels and the car velocity is low, it indicates the wheel is slipping and would be emitting smoke if it was in contact with the ground.

Try the following code in the main loop of the car demos to detect the rotational velocity of wheel 3 (rear/left).
Text 0,100,"Rotation Velocity:"+dJointGetHinge2Angle2Rate(Joint(3))



Pete Carter(Posted 2007) [#5]
Ok but which velocity command do i use for the car?

Plus in my game ive made a second car using the same code but changing the entity names. whats the handle for the car body?

thanks for your help this is really good fun


VIP3R(Posted 2007) [#6]
To get the velocity of the car, you use a pivot and EntityDistance(). Each frame you return the distance between the current car location and the previous car location, the faster the car moves, the further it travels each frame.

Here's a modified car demo which has the above method implemented...


To store the handles of each car body you can use an array, each time you create a car, store a copy of the ode/body handle...

Car(number)=ode\body

The ODE body handle for car number two will then be 'Car(2)'.

As an alternative to arrays you can extend the ODEGeom type to include a car ID number and then cycle through each type to get the ode\body handle.


Pete Carter(Posted 2007) [#7]
thanks. The calcvelocity function is great I wouldnt have thought of doing it like that.

Ive been using the first one of your two options for getting the handle of the car, good to know im not doing it wrong.

Thanks for your quick replys and code example.


VIP3R(Posted 2007) [#8]
You're welcome :)


Blitzplotter(Posted 2007) [#9]
thanks for this additional piece of code VIP3R.