How to make a "camera"?

Hi, there isn’t a “camera” object in Java3D, and I was wondering what the equivalent is. Is it View, ViewPlatform, or ViewingPlatform?

Basically, I have an object in my my branchgroup, and instead of using mouse behaviors to translate the object, I want to have a “camera” that translates around the object (like in real life). How should I go about setting this up? What should I be manipulating, and how should I go about doing it?

Thanks,
DAT

www.j3d.org, there is a tutorial on that site.

That’s the first place I looked, but perhaps I missed it. Could you specify where exactly the camera-view tutorial is?

Also, as a follow-up question, is any way to manipulate the camera such that it “remembers” certain positions.
For instance, I want to make 3 buttons that if you press them, it will toggle between 3 views (e.g. front, side, top views). If I just put my camera in a transform group and translate it across a vector. But my buttons can be pressed in any order, and so the camera doesn’t translate upon any set track. Is there a way to just set the position of the camera? That way maybe I can have the camera remember positions and just “jump” to different positions when I press the buttons. ?

–DAT

View and ViewPlatform are the keys to the camera.
I used to wrap them into class ‘Camera’ and ‘CameraMout’ resp… The CameraMount is coupled to a TransformGroup that can be placed somewhere in the scenegraph. It is no problem to place is anywhere you like by just setting the transform accordingly. Or didn’t I get you question?

public class CameraMount extends BranchGroup
{
      private final      TransformGroup      mTransformGroup            = new TransformGroup();
      final                  ViewPlatform      mViewPlatform            = new ViewPlatform();
      private final      Transform3D            mTransform                  = new Transform3D();
      
      public CameraMount()
      {
        this.setCapability( Group.ALLOW_CHILDREN_EXTEND );
        this.setCapability( Group.ALLOW_CHILDREN_READ );
        this.setCapability( Group.ALLOW_CHILDREN_WRITE );
        this.setCapability( BranchGroup.ALLOW_DETACH );
        
            mTransformGroup.addChild( mViewPlatform );
        mTransformGroup.setCapability( Group.ALLOW_CHILDREN_EXTEND );
        mTransformGroup.setCapability( Group.ALLOW_CHILDREN_READ );
        mTransformGroup.setCapability( Group.ALLOW_CHILDREN_WRITE );
        
            this.addChild( mTransformGroup );        
      }

      public final TransformGroup getTransformGroup()
      {
            return mTransformGroup;
      }
      
      
      public Transform3D getTransform()
      {
            mTransformGroup.getTransform( mTransform );
            return mTransform;
      }
      
      public void setTransform( Transform3D tx )
      {
            mTransformGroup.setTransform( tx );
      }
      
}

This is probably a newbie question, but you gave me a camera mount, but where’s the Camera class?

I’m using it like this, and it isn’t doing anything…please tell me what I’m doing wrong:


cameraMount = new CameraMount();
            
Vector3f translate = new Vector3f();
Transform3D T3D = new Transform3D();
translate.set(10.0f, 7.5f, 50.0f);
T3D.setTranslation(translate);

cameraMount.setTransform(T3D);      
            
cameraMount.compile();
universe.addBranchGraph(cameraMount);

By the way, I don’t know if this is a related or unrelated question, but how I think the default view is to have the origin be drawn at the center of the canvas. Is there a way so that when an object is placed onto the canvas, the origin is painted at the bottom-left corner of the canvas? I’ve tried toying around with the different ViewPolicy’s, but can’t seem to find one that does that.

The reason I’m asking is that I want to look straight down the z-axis, but I think if I change the view around (either manually or with the camera), I can have the view positioned such that the origin is at the bottom-left, but it gets skewed such that I am no longer looking straight down the z-axis.

Again, thanks for the help,
DAT

hm, Camera needs my Screen class and so on. Posting code does not make so much sense…

Basically Camera handles the View object. Look it up.

Maybe you could try to stick with SimpleUniverse for the beginning until it is not sufficient any more.