I’m learning JME and want to toggle between different camera options.
I want to have a camera pointing forwards from a location on a geometry, while following that geometry. Picture a camera looking out from a plane’s cockpit.
After some experimentation, the closest approximation I’ve come up with is using a CameraNode like this:
Then affixing that camera to my geometry’s node and setting a translation vector to my desired position:
This gets the camera in the correct place initially, facing forwards, and following the geometry, but I also want to be able to toggle back and forth between this and the default flyCam. If the orientation of the object changes later, the offset will be wrong. I think what I really want is figure out what the forward vector of the geometry is at the point of toggle, and then add a known offset to that. But how do I find the forward vector?
I also tried to use lookAt with various vectors, but didn’t really get anywhere. The camera would usually end up pointing downwards at an angle rather than forwards. I don’t know why.
So I’m looking for a good way of solving this.