Skip to main content

How to move the camera !? And what *is* the camera?

Please note these forums are being decommissioned and use the new and improved forums at
2 replies [Last post]
Joined: 2011-02-09

Perhaps someone can help:

I have a fn that gets a texture and creates a raster at given coordinates:

// -----------------------------------------------------------------------------------
private void texturedRaster(Group group, float fSize, Vector3f pos)
Raster  r  = new Raster();
Texture2D tex =

r.setImage((ImageComponent2D) tex.getImage(0));
r.setPosition(new Point3f(pos.x, pos.y, pos.z));
r.setSize(256, 256);

Appearance appear = new Appearance();
TransparencyAttributes transAttr = new TransparencyAttributes();

Shape3D shape = new Shape3D(r, appear);

As u may see in this picture, it all looks fine if the position of the Raster is near, because the texture was created in a resolution appropiate for near viewing:

If i put the Raster a little bit farer away, it's shape is automatically scaled to the new position (it is - after all - still a Shape3D). Put the texture is *not* scaled, as u can see in this picture. (

is there a way to do that? I also experimented a little bit with OrientedShape3D… has anyone a running (and working;-) example? i was able to use it like this:

// -----------------------------------------------------------------------------------
private void texturedOrientedShape(Group group, float fSize, Vector3f pos)
OrientedShape3D os = new OrientedShape3D();
Texture2D tex =

// coordinates of texture
TexCoord2f[] q = {new TexCoord2f(), new TexCoord2f(), new TexCoord2f(),
new TexCoord2f()};

q[0].set(1.0f, 0.0f);
q[1].set(1.0f, 1.0f);
q[2].set(0.0f, 1.0f);
q[3].set(0.0f, 0.0f);

// resulting shape corners
Point3f[] p = {new Point3f(), new Point3f(), new Point3f(), new Point3f()};
p[0].set(pos.x - fSize, pos.y - fSize, pos.z);
p[1].set(pos.x + fSize, pos.y - fSize, pos.z);
p[2].set(pos.x + fSize, pos.y + fSize, pos.z);
p[3].set(pos.x - fSize, pos.y + fSize, pos.z);

Shape3D shape = texturedPlane(p, q, tex, false);
os.setAlignmentAxis(0.0f, 0.0f, -1.0f);

unfortunately, the result looks like this (pretty nice from front)… ( :

… but it doesnt orient itself dynamically to the viewpoint ;-/

BTW, i set the 'camera' with


Any suggestions so far…?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2011-02-09

OK, guess you have…
osFoo: OrientedShape3D, lets say at (3,3,0)
unWorld: SimpleUniverse
bgRoot: BranchGroup containing the world

you start a (0,0,0) and want to move to (3,3,3) … what do you have to do to set the camera (=ViewPlatform…? View…?) to that position and have osFoo orient to you and not to (0,0,0)? If i use…

Transform3D trNew = new Transform3D();
trNew.setTranslation(new Vector3d(3.0,3.0,3.0));

…then the camera ends at (3,3,3) but osFoo 'looks' at (0,0,0) !?? So i didnt actually move the view but some kind of 'offsetted' it. How do i move?
BTW, once you figured out how some Java3D objects work, you finally understand the "documentation" ;-)

Joined: 2011-02-09

I still didnt solve this, but i got a clue by experimenting with my world:

the OrientedShape does not align to the camera, but to the origin (0,0,0) and is therefore quite useless if u move with


so the question i still have to solve is: how do you move the origin?