Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have just started with Java3D programming. I thought I had built up some basic intuition about how the scene graph works, but something that should work, does not work.

I made a simple program for rotating a pyramid around the y-axis. This was done just by adding a RotationInterpolator R to the TransformGroup above the pyramid. Then I thought hey, can I now remove the RotationInterpolator from this TransformGroup, then add it to the TransformGroup above my ViewPlatform leaf. This should work if I have understood how things work. Adding the RotationInterpolator to this TransformGroup, should make the children of this TransformGroup rotate, and the ViewingPlatform is a child of the TransformGroup. Any ideas on where my reasoning is flawed?

Here is the code for setting up the universe, and the view branchgroup.

import java.awt.*; 
import java.awt.event.*;
import javax.vecmath.*;

public class UniverseBuilder {

    // User-specified canvas

    Canvas3D canvas; 

    // Scene graph elements to which the user may want access

    VirtualUniverse               universe;
    Locale                        locale;
    TransformGroup                vpTrans;
    View                          view;

    public UniverseBuilder(Canvas3D c) {
        this.canvas = c;

        // Establish a virtual universe that has a single
        // hi-res Locale

        universe = new VirtualUniverse();
        locale = new Locale(universe);

        // Create a PhysicalBody and PhysicalEnvironment object

        PhysicalBody body = new PhysicalBody();
        PhysicalEnvironment environment = new PhysicalEnvironment();

        // Create a View and attach the Canvas3D and the physical
        // body and environment to the view.

        view = new View();

        // Create a BranchGroup node for the view platform

        BranchGroup vpRoot = new BranchGroup();

        // Create a ViewPlatform object, and its associated
        // TransformGroup object, and attach it to the root of the
        // subgraph. Attach the view to the view platform.
        Transform3D t = new Transform3D();
        Transform3D s = new Transform3D();
        t.set(new Vector3f(0.0f, 0.0f, 10.0f));

        s.set(new Vector3f(0.0f, 0.0f, 10.0f)); //forandre verdier her for å endre viewing position

        ViewPlatform vp = new ViewPlatform();

    vpTrans = new TransformGroup(t); 

    // Rotator stuff
    Transform3D yAxis = new Transform3D();
        Alpha rotationAlpha = new Alpha(
                -1, Alpha.INCREASING_ENABLE,
                0, 0,4000, 0, 0, 0, 0, 0);

        RotationInterpolator rotator = new RotationInterpolator(
                rotationAlpha, vpTrans, yAxis,
                0.0f, (float) Math.PI*2.0f);
        RotationInterpolator rotator2 = new RotationInterpolator(
            rotationAlpha, vpTrans);
        BoundingSphere bounds =
            new BoundingSphere(new Point3d(0.0,0.0,0.0), 1000.0);



        // Attach the branch graph to the universe, via the
        // Locale. The scene graph is now live!


    public void addBranchGraph(BranchGroup bg) {
share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.