Hi, I am currently trying to have a camera, looking at a cube from the
top view, then when I press up/down/left/right, camera will move along
the x-z plane, since I am using virtual universe, I cannot use
viewingplatform, and I don't like behavior class so I would like to use
normal keylistener attach to the transformgroup of the viewplatform to
make any changes. But when I do that, it does not show anything, but if
I move the cube instead, I can see the cube.
The second question I wanna ask is that how do I use lookAt()? There is
a game engine called irrlicht, which has a camera that has properties:
target and location, target is where the camera looks at and location of
the camera, how do I have the same thing in Java3D? Here is my code of
the transformgroup, any hints? Thanks.
// This is in the main
VirtualUniverse universe = new VirtualUniverse();
Locale locale = new Locale(universe);
BranchGroup objRoot = new BranchGroup();
TransformGroup tg = new TransformGroup();
// Modify the camera here
objRoot.addChild(tg);
tg.addChild(ccube);
objRoot.compile();
locale.addBranchGraph(objRoot);
locale.addBranchGraph(camera.createPanCamera());
// Modify the camera here
camera.move(0, 0, -10);
// This is in the camera class
public BranchGroup createPanCamera(){
// Gravity will be attached later by physics engine
/*** Create all necessary objects for a camera ***/
bGroup = new BranchGroup();
tg = new TransformGroup();
tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
view = new View();
vp = new ViewPlatform();
vp.setCapability(ViewPlatform.ALLOW_POLICY_READ);
vp.setCapability(ViewPlatform.ALLOW_POLICY_WRITE);
pb = new PhysicalBody();
pe = new PhysicalEnvironment();
/*** Attach all parts to make it a normal scene graph ***/
view.setPhysicalBody(pb);
view.setPhysicalEnvironment(pe);
view.attachViewPlatform(vp);
view.addCanvas3D(canvas);
bGroup.addChild(tg);
tg.addChild(vp);
return bGroup;
}
public void move(int x, int y, int z){
ct3d = new Transform3D();
ct3d.set(new Vector3f(0.0f, 0, 5.0f));
ct3d.lookAt(new Point3d(0, 0, 5f), new Point3d(0, 0, 0), new
Vector3d(0, -1, 0));
tg.setTransform(ct3d);
}
===========================================================================
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".