Moving around a scene using cursor keys

I have tried to create a rotation object and add that to the view in order to turn the view allowing me looking around and walking around the scene. However this doesnt work. ???

Does anybody know how to add navigation to the scene using cursor keys and/or mouse?
tomcat

Please have a look at the thread named “camera movement”, aged a few days ago:
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=xith3d;action=display;num=1070332396

I think it addresses the same problem you do experience. (Actually I experienced the same one, too, when I started with Xith3d some weeks ago. :wink:

Thanks Preston, I will try this. When I move around using cursor keys, I have x,y,z values but no angles so I guess I can just pass 0. Is this right?

Another thing is that where do I attach the camera to. Do I add it to the locale or do I add it to the root BranchGroup? (to get a kind of first person view)
tomcat

[quote]Thanks Preston, I will try this. When I move around using cursor keys, I have x,y,z values but no angles so I guess I can just pass 0. Is this right?
[/quote]
Yes. And in case you prefer to handle radian angles (0 … PI) and not angles degrees (0…360) you can skip that Math.toRadians() method call, too.

[quote]Another thing is that where do I attach the camera to. Do I add it to the locale or do I add it to the root BranchGroup? (to get a kind of first person view)
tomcat
[/quote]
Yes, exactly. For my previously quoted example I’ve just made something like this:


  private View mView = new View();
  private BranchGroup mSceneBg = new BranchGroup();  // Root-Branchgroup

void initXith(Canvas3D kanvas3d)
{
  RenderPeer renderpeer = new RenderPeerImpl();
  CanvasPeer canvaspeer = renderpeer.makeCanvas(freim, 320, 200, Opt.sGuiVollbildBpp, false);
  kanvas3d.set3DPeer(canvaspeer);
  mView.addCanvas3D(kanvas3d);

  VirtualUniverse univers = new VirtualUniverse();
  Locale lokal = new Locale();
  univers.addLocale(lokal);
  univers.addView(mView);
  lokal.addBranchGraph(mSceneBg);
} 

Great :), thanks for this. I will try it with my example.
tomcat

having worked out (I think) how to do a first person shooter (thanx Preston) I have realised that I was after something slightly different. I have a car and I want to see my car (all of it not just through the windscreen). I think this is called 2nd or 3rd person perspective (not sure about the name).

I thought a way of doing this is by placing the camera several units behind the car and have it following the car. Any suggestions as what is the best way of doing this?

tomcat