Author Topic: Object3D.animate(float)  (Read 3858 times)

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Object3D.animate(float)
« on: August 04, 2006, 11:46:37 pm »
My X-Wing is supposed to open its wings completely at the end of its animation, but when I call animate(1f), nothing happens. I've tried rebuilding the model, but nothing happens.  Thanks for any help.

By the way, the file consists of 37 model pieces, all merged into a simple Object3D. The following code merges them:

   Object3D[] objects = Loader.load3DS("./WolfXWing/xwing.3ds", .001f);
   xWing = Object3D.mergeObjects(objects[0], objects[1]);
   for (int i = 2; i < objects.length; i++)
         xWing = Object3D.mergeObjects(xWing, objects);

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Object3D.animate(float)
« Reply #1 on: August 05, 2006, 01:15:01 pm »
Merging looks fine but how are you doing the animation? Is that an animation defined in 3DS? If so, jPCT doesn't load this. What you use animate(<float>) for, is for keyframed animations. You either have to define the keyframes yourself (raft did this for karga for example) or load them from an MD2 model (that's the only format that jPCT natively supports for keyframe animations).

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Object3D.animate(float)
« Reply #2 on: August 05, 2006, 09:16:50 pm »
Oh, that clears it up. Thanks a lot.

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Another Question
« Reply #3 on: August 06, 2006, 08:14:44 am »
The following code is supposed to make a 30-frame animation of the X-Wing opening its wings. Only, obviously, it doesn't or I wouldn't be here. :-) What's wrong with it? Any help is appreciated.


   Animation wingAnimation = new Animation(30);
   Object3D[] parts = Loader.load3DS("./WolfXWing/xwing2.3ds", .001f);
   Object3D xWingOpen = Object3D.mergeObjects(parts[0], parts[1]);
   for (int i = 2; i < parts.length; i++)
         xWingOpen.mergeObjects(xWingOpen, parts);
   xWing.build();
   xWingOpen.build();
   wingAnimation.createSubSequence("Closed");
   wingAnimation.addKeyFrame(xWing.getMesh().cloneMesh(true));
   wingAnimation.createSubSequence("Open");
   wingAnimation.addKeyFrame(xWingOpen.getMesh());
   wingAnimation.setInterpolationMethod(Animation.LINEAR);
   xWing.setAnimationSequence(wingAnimation);

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Object3D.animate(float)
« Reply #4 on: August 06, 2006, 11:36:36 am »
With this code, you'll have an animation with 30 possible frames, divided in two sequences each containing 1 frame, which is the same. Is that really your intention?

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Object3D.animate(float)
« Reply #5 on: August 06, 2006, 11:59:09 am »
No, of course not. How would you change it so that I get a thirty-frame interpolation of the x-wing opening its wings?

I'm sure it seems obvious to you but the one thing I've learned in life is that once we learn something we forget what it is we didn't understand about it in the first place. I've observed this many times with my college professors as with myself.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Object3D.animate(float)
« Reply #6 on: August 06, 2006, 12:13:34 pm »
Quote from: "AGP"
No, of course not. How would you change it so that I get a thirty-frame interpolation of the x-wing opening its wings?
The idea of keyframed animations is, that you have several keyframes that are showing different stages of the model and you interpolate between them to get a fluid animation. The keyframes are similar to what you would do in cartoons to get an animation. In your case, i can see three solutions:

a) You define the keyframes yourself, which will be a quite difficult task. At first, i would try to extract the wings and use only that for my animation. The rest should be another Object3D and remain static. Then you have to rotate/translate the wings as you wish, make this transformations permanent to the mesh (by using rotateMesh() and translateMesh()) and derive the keyframes from that. 30 shouldn't be needed. Something like 4-6 should be sufficient.

b) Don't use keyframes. If you already have seperated the model into wings and the rest, you may go one step ahead and seperate the wings into the 4 seperate parts (or 2...depending on how the model is build). Then you can quite easily open/close the wings by using simple rotations. That's the easiest way IMHO. The hard part is to determine what belongs to a wing(-part) and put that into seperate objects.

c) Use an editor that can do MD2 models and create your animation with that one. That's easy to use with jPCT, but requires some skills with the editor (depending on your talent for such things...for me, it would be close to impossible).

Hope this helps.

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Object3D.animate(float)
« Reply #7 on: August 07, 2006, 12:58:20 am »
Thanks. I went with b and it works great. Also, I want to thank you for the great work you did with the engine. Please don't ever discontinue it!

Now, for the texture-mapping...