Rotating cylinders (continuation)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Rotating cylinders (continuation)

bchinfosieeuw
This post was updated on .
Thanks, the first example of SwingInteraction is helpful for me. Next question: how to rotate cylinder4, while rotating a cylinder 5 around cylinder4? Code I have is:

public void processStimulus(Enumeration criteria) {
                 
            angle += Math.toRadians(-10.0)* signrad;
            angle5 += Math.toRadians(-10.0)* signrad;
                        //System.out.println(angle);
                        if (Math.abs(angle) >= 0.6 || angle >= 0) {signrad = -1.0f * signrad;}
            trans.rotX(angle);
                        Transform3D t4 = new Transform3D();
                        float position = angle/4;
                        //t4.set(new Vector3f(0.0f, position, 0.0f));    
                        t4.mul(trans);
            transformGroup.setTransform(t4);  
            //transformGroup5.setTransform(t5);

        // step 1: translate toward origin
        Transform3D transform = new Transform3D();
        Transform3D t5 = new Transform3D();
        Transform3D translate1 = new Transform3D();
        translate1.setTranslation(new Vector3d(0.0, -0.4, 0.0));//-0.20 with angle5 = -20.0
        t5.mul(translate1, t5);
        // step 2: rotation
        Transform3D rotate = new Transform3D();
    rotate.rotX(angle5);
    t5.mul(rotate, t5);
    // step 3: translate back up
    Transform3D translate2 = new Transform3D();
    translate2.setTranslation(new Vector3d(0.0, 0.4, 0.0));//0.20 with angle5 = -20.0
    t5.mul(translate2, t5);
    // create a TransformGroup
    transformGroup5.setTransform(t5);
                       
            wakeupOn(criterion);
}

How to get cylinder5 attached to cylinder4 in order to rotate cylinder5 around cylinder4?