Skip to Main Content

How do you rotate around a local point?

843799Jul 18 2001 — edited Jul 18 2001
Hi,
I'm having problems using RotationInterpolators.

I'm trying to build a 3d figure and animate it. I can use pickRotate behaviours to rotate the different limbs around their local centres, but I'm now trying to do it via the RotationInterpolator and every time they get moved to the central point of the whole scene, and rotated around this, rather than that of their own TransformGroup.

I have a BranchGroup (objRoot), and a TransformGroup for the entire figure (figTrnsGrp), which is the child of objRoot, and is centred. The children of figTrnsGp are a cylinder (the figure's upper chest), and four TransformGroups - one each for the neck, pelvis, left shoulder, and right shoulder. These in turn have their own TransformGroup children which deal with the other parts of the body. I added the RotationInterpolator as a child of the TransformGroup I want it to rotate.

So, for example, I want the pelvis to rotate around its own centre (taking the legs with it, which it does, but it gets moved up and rotated around the centre of the figure!). Actually, i can't work out if it's being rotated round the figure centre, or the scene centre, but anyway it's not doing what i want it to and I've been trying different things for days, and none of them work, so if anyone can PLEASE help, i'd really appreciate it!

I think the problem may be that the Transform3D which is passed to the RotationInterpolator is somehow being reset in the process, but I still can't work it out.

Here is some of the code:

**************
pelvisT3D = new Transform3D();
pelvisT3D.setTranslation(new Vector3f(0.0f, -0.4f, 0.0f));
pelvisTrnsGrp = new TransformGroup(transformPelvis);
pelvisTrnsGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
pelvisTrnsGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
figTrnsGrp.addChild(pelvisTrnsGrp);
Sphere pelvis = new Sphere(pelvissize);
pelvisTrnsGrp.addChild(pelvis);

Alpha alpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 7000, 0, 0, 0, 0, 0);
pelvisTrnsGrp.getTransform(pelvisT3D);
RotationInterpolator r = new RotationInterpolator(alpha,
pelvisTrnsGrp, pelvisT3D, 0.0f, 3.0f);
r.setSchedulingBounds(behaveBounds);
pelvisTrnsGrp.addChild(r);

*********************

many thanks to anyone who can help...
Comments
Post Details
Added on Jul 18 2001
1 comment
28 views