Behavior question

Hi!

I want to use TimeElapsed behavior or FrameElapsed behavior or any other method. What I want to do is that if a specific time has passed e.g. 2000milsec, I run a bit of code, when 2500 milsec pass I run an other. How could this be achieved?. Thanks.

Hi,
What are you triying to do??
What does the bit of code? add shapes?? change colors?? (anything that changes the scene) or other things… (I/O to file)
If the code changes the Scene you MUST use behavior (and set the capabilities needed), else you can use Threads to make the code run in steps.

If you want to use behaviors to make your code time dependant use TimeElapsed behaviors…

Read the Java3D Tutorial from Sun, it’s really easy to understand…

Create a behaviour that runs using the WakeupOnElapsedTime as it’s wakeup criterion. Should be fairly easy.

Hi!

Thanks for the reply. I am using the TimeElapsedBehavior. What I am trying to do is animate an articulated figure. I have the various ranges and transforms setup. What I want to do is move the right leg, then after a little delay, the left arm moves, so that the character is animated. I am not sure if the ElapsedFrame or the postFrame could be used. Thanks

I guess you dont want to use a third-party api for your animations and instead want to learn how to do it yourself.

If that is the case then it would be important to know how are you modeling your animation data.
I know some ways, maybe one of them is similar to what you are doing and all of them require the use of a skeleton which is just an hierarchy of transforms. If you want to be compatible the standards check the h-anim site and name your transforms accordingly to their convenction.

About the data you could attach a piece of data to each transform (bone). It can be physical data like a force vector being applyed at certain transform. It can also be anim data, a table that associates relative time values with with a certain transformation matrix (mostly rotations). I supose you use the timeline method.
In this case its neccessary to register the absolute time when the animation starts (for instance when the forward key is pressed read current time and associate it with the start of your current animation) then wait until a frame is going to be rendered and based on the time passed after the animation started and the current time choose the required matrix for each of your bones.
To simplify things you should allow only one animation to be played at a time, otherwise you will need to create a blending process somehow.

Hi!

What other API I could use? Also is there any way to use the inverse kinematics, to calculate the joint angles and then put them in the animation file so that it looks more realistic?.

Check the “Character Animation” thread in this part of the forums. There is also the j3d.org which has a very complete library of java3d classes available for download.

I don’t know if its worth to use inverse kinematics unless you are making a 3d modeler, but of course you could use any technique with java3d as long you know the maths for it. I don’t know it myself and its not required at all to do animations. In fact it may even slow down your code considerably if you’re thinking of a game.

you could use any technique with java3d as long you know the maths for it

I am new to Java3D…can you plz mention where at j3d.org these classes are…

Thanks