Cinematic Camera RotationTrack

I’m trying to give the recoil effect which happens when you pull the trigger of a shotgun or similar. I want to bind this effect to the camera later, and for now I’m using a external object to see the movements. Basically when you leftclick, first this box rotates his face up, and after begin to come down slowly. It works, but I have only the cinematic animation when the box is turning from up to down and not the viceversa: In effect, now the box is immediatly rotated upward of 10° more respect before the shot, and after that, the cinematicEvent starts and interpolates the gun downward progressively.

I want to have also the opposite movements [from down to up]. But since I cannot modify the angle value in the RotationTrack during the runtime [new RotationTrack(cubeNode, currentCamAngle+10°inRadiants, duration)], I think it left me only to use a completly separated cinematic object. Isn’t it? Or should I extend an AbstractCineticEvent Class?

Ps: The stop() is used to permit to pull the trigger, even if the gun hasn’t reached the horizontal position yet [and completed a single animation]: If you click fast, you can turn upward, until 90°, without have to wait.


private void setupRecoil() {

q = new Quaternion();

q.fromAngleAxis(ANGLE_RADIANT, Vector3f.UNIT_Z);


private void recoil() {

if (cubeNode.getWorldRotation().getZ() < FastMath.sin((MAX_ANGLE-ANGLE_RADIANT)/2)) {




private void initInputs() {

inputManager.addMapping(“shoot”, new MouseButtonTrigger(mouseInput.BUTTON_LEFT));

ActionListener acl = new ActionListener() {

public void onAction(String name, boolean keyPressed, float tpf) {

if (name.equals(“shoot”) && keyPressed) {






inputManager.addListener(acl, “shoot”);


private void setupCinematic() {

float duration = 2f;

cinematic = new Cinematic(cubeNode, duration);


float[] zero = {0, 0, 0};

cinematic.addCinematicEvent(0, new RotationTrack(cubeNode, zero, duration));



The RotationTrack is pretty basic. You should indeed make your own CinematicEvent, there is an example in the TestCinematic test case.

You should indeed make your own CinematicEvent

Do you mean, I have to extend the AbstractCinematicEvent class?
Because my problem resides in the fact that RotationTrack, is built with a fixed angle. So each time I click, the max angle is the same. I would like to have a playMethod which reads the cam.rotation() each time that I invoke it, and adds to it a fixed angle. So if you can click fast, the direction increases.
Have I to modify the rotationTrack? Or extend a AbstraCE? How [not the code, only suggestions]?

Thanks in advance, nehon
cardoppler said:
Do you mean, I have to extend the AbstractCinematicEvent class?

I can't see what else to say, look at the TestCinematic, I implement my own AbstractCinematicEvent to trigger a fade filter.
you'll have a onPlay, onPause,onStop, and onUpdate method, and you can do absolutely what you want in these methods.

I’m sorry, I was at a PC without JMP when I posted. Anyway I’ve done it.

The issue was the impossibility to pass an argument to the onPlay() method, so as you suggested to me, I’ve created a new CinematicEvent extending the AbstractCinematicEvent.

This new class is pretty the same as the deafult RotationTrack [in effect I was looking for a little change], except for a new method, which i called “setIncrement()”. This method, invoked just a little before cinemtic.Play(), gives me the possibility to change the finalAngle, the angle which will be reached at the end of the animation.

So at each click, it is possibile to update the finalAngle, and subsequently I’ll call the cinematic event to show all the animation.

If I may, I think it will be usefull to add this kind of tool to the default RotationTrack:


void setIncrement(Quaternion actualObjectRotation, Quaternion increment) {

temp = actualCubeRotation.clone();





Thanks again, nehon!


Implemented Track are here to do very basic things, your use case is the one for creating custom events