Simple question: Is there a way to find which direction the camera is facing?

This is probably such a n00b question, but is there a simple way?

What I want to do is throw a ball (very much like shooting a gun) in the direction the user is currently facing (1st person view).

The first way that came to mind was set the user’s initial viewing direction and then keep track of it using my own movement controls. But is there no way to just get which direction the user is facing if using KeyboardNavigatorBehavior? Or even better (for mouse looking), OrbitBehavior?

Many thanks.

Normally you store and calculate those angles yourself, and use them to apply the view-transformation.

Without calculating those angles yourself, how would you know where to move and where you are.

If Java3D has abstracted away this info from you, you might not want to use Java3D’s behaviour-class for it, but roll your own.

I understand how to create my own behaviour class for navigation and it shouldn’t be much of a problem. Only thing is I’m a little short on time and would prefer to use Java3d’s built in classes for navigation, if possible.

So using KeyboardNavigatorBehavior and OrbitBehavior I would move about… Is there no Java3d feature or function or something that returns the direction the user is facing in the scene?

I need to know what direction the player is facing to be able to set the initial velocity (including direction and vertical angle) of the ball that they throw. So perhaps they would move about, stop, and then press space bar to shoot the ball in the direction they were looking.

Thanks.

I think this chapter contains the information your searching for.

http://fivedots.coe.psu.ac.th/~ad/jg/ch15/index.html

BTW: I think this guy does a good job in his book describing how to develop J3D apps. You might think about purchasing this book or his newest one.

I actually already have that book - it’s proved very useful. But anyway, I’ve just decided to put together my own controls and keep track of the user’s position and view. I thought this would be the best way once I start to get into networked multplaying too.

Thanks for the help guys.