Custom camera movement procedures

Howdy!



Using a SimpleApplication we can see, that the default camera is declared in Application as

Code:
protected Camera cam;
which is then used to make a FlyByCamera in SimpleApplication using the code as
Code:
protected FlyByCamera flyCam; flyCam = new FlyByCamera(cam);
. All the code responsible for processing analog signals from mouse movement is stored in the FlyByCamera class.

I need to modify the moveCamera(float value, boolean sideways) method so that it do not move the camera by certain vector and set new camera location, but stay always at the same place and store the delta vector (here delta mean the difference between camera's position in the previous frame and current frame) somewhere else for future needs. The only problem is that I cannot directly modify FlyByCamera's class code, or, should I say, modifying it looks like to be very painful.

I bet there could be a better solution. Of course I could just make a copy of the FlyByCamera class, change some code there to suit my needs (or just extend it, making some overrides), but that way I will also need to change the SimpleApplication's class code so that it uses my camera class, instead of FlyByCamera's..

So, any ideas?

You might consider extending and capturing the camera’s location on each frame on the update method.



Edit: after rereading, you really want to make a functionally different controller. In this case I would recommend duplicating the class and modifying it to fit your needs

@sbook said:
Edit: after rereading, you really want to make a functionally different controller. In this case I would recommend duplicating the class and modifying it to fit your needs

I feared that this would be the solution.. :( oh well, the painful-way it is :)

Copy-Paste is painful? :wink:

Replacing the other camera is not painful. Just flyCam.setEnabled(false) and then do whatever you want with your own. No need to modify SimpleApplication.

@sbook said:
Copy-Paste is painful? ;)

Naah, of course not, just thought that a couple of overrides would do the trick :)