need some animation advice

hi,

im making a crowd simulatior in java3d. the basic idea is the user drags and drops people and obstacles onto a 2d map and then hits run. then using this info a java3d representation will appear showing the people moving around avoiding each other and the obstacles.

what happens is that at each time step each person object is sent to a behaviour object (e.g. a separation or a collision avoidance behaviour) and a vector3d is calculated and applied to the person object. this then updates the java3d rep.

i need help as i dont know how to update the java3d representation at each time step and what unit of time to use as i dont think System.currentTime Millis is the right way to go about it?

ive attached my class diagram in case anyones interested. im still only at the design stage so any advice now would be a big help:)
many thanks.

If you were working in 2D you might be able to call “render” every few milliseconds to keep updating the view but that isn’t really how java3d works.

What Java3D does is to update the scene as often as it possibly can- it is constantly updating it. You change things in the scene using behaviours and usually you do it regardless of what java3d is doing at the time. You can use a behaviour that tells you every time that a frame is rendered but you have to be careful because on different hardware you will potentially get very different results.

It’s quite conceptually tricky to get started with but once you get your head round the way it works it’s reasonably easy to use.

The magic of frame by frame update is using the WakeOnFrame(0) wakeup conditio nfor the beahvior.

This ensurs that the behavior will be woken once per frame and only once per frame.

Using behavior priority groups you can specify the order in which all your WakeOnFrame(0) behaviors are executed.

HOWEVER its important to realize that changes applied to transforms dont effect things like bouding volumes right away. Thats not calculated til the behaviors all all done. So you may get odd effects if you try to read those thinsg back and use them in your logic.