Hi,

I was playing around with OrientedShape3Ds, and I set up a very simple
program to see how they worked. The program creates a scene graph with two
squares, one is a regular Shape3D and the other an OrientedShape3D. I'm
using OrbitBehavior to orbit around the squares.

Well, it doesn't seem to be working as I expected. Both squares behave as
regular Shape3Ds. What puzzles me even more is that if I remove the regular
Shape3D from the graph, the OrientedShape3D starts behaving as it should.

What am I doing wrong? Is there any constraint in where/how an
OrientedShape3D is placed in the scene graph?

Any help is appreciated!

Thanks,
Martin


PS: Here's the code for the proggie...

import com.sun.j3d.utils.behaviors.vp.OrbitBehavior;
import com.sun.j3d.utils.universe.SimpleUniverse;

import javax.media.j3d.*;
import javax.swing.*;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3f;
import java.awt.*;

public class Main
{
        public static void main(String[] args)
        {
                JFrame frame = new JFrame();
                frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
                frame.setSize(800, 600);
                frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(),
BoxLayout.X_AXIS));

                GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
                GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
                GraphicsDevice device = env.getDefaultScreenDevice();
                GraphicsConfiguration config = device.getBestConfiguration(template);

                Canvas3D canvas = new Canvas3D(config);
                frame.getContentPane().add(canvas);

                SimpleUniverse universe = new SimpleUniverse(canvas);

                TransformGroup vtg =
universe.getViewingPlatform().getViewPlatformTransform();
                Transform3D moveback = new Transform3D();
                moveback.setTranslation(new Vector3f(0.0f, 0.0f, 20.0f));
                vtg.setTransform(moveback);

                OrbitBehavior orbit = new OrbitBehavior(canvas);
                orbit.setSchedulingBounds(new BoundingSphere(new Point3d(0.0, 0.0, 
0.0),
10000.0));
                universe.getViewingPlatform().setViewPlatformBehavior(orbit);


                BranchGroup content = new BranchGroup();

                // *** Oriented shape ***
                QuadArray square1 = new QuadArray(8, QuadArray.COORDINATES);
                square1.setCoordinates(0, new double[] {
                        2, 2, 0,
                        4, 2, 0,
                        4, 4, 0,
                        2, 4, 0
                });

                OrientedShape3D orientedShape = new OrientedShape3D();
                orientedShape.addGeometry(square1);
                orientedShape.setRotationPoint(3,3,0);
                orientedShape.setAlignmentMode(OrientedShape3D.ROTATE_ABOUT_POINT);
                content.addChild(orientedShape);

                // *** Normal shape ****
                QuadArray square2 = new QuadArray(8, QuadArray.COORDINATES);
                square2.setCoordinates(0, new double[] {
                        2, -1, 0,
                        4, -1, 0,
                        4, 1, 0,
                        2, 1, 0
                });

                Shape3D normalShape = new Shape3D();
                normalShape.addGeometry(square2);
                content.addChild(normalShape); // <<<<< If this line is removed, the
OrientedShape behaves as intended

                content.compile();
                universe.addBranchGraph(content);

                frame.setVisible(true);
        }

}

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to