Cinematics system for JME3

Hi monkeys, for the last weeks, I’ve been working on a cinematics system for JME3.

It’s not complete yet, but the basics are now set, and it’s ready to be tested by little monkeys :wink:



It’s been built with the idea of plugging it later with a graphic editor in JMP, but I tried to keep it simple to use by code for Eclipse users.



A Cinematic is an appstate. It needs a scene (a Node) containing everything that’s gonna take part in the cinematic.

The cinematic is a set of CinematicEvents, that are going to be triggered at a given time.

Here is the usage (pseudo code)



Cinematic cinematic = new Cinematic(sceneNode, duration);

cinematic.addCinematicEvent(triggerTime, cinematicEvent);



sceneNode is the node containing the scene

duration is the duration of the cinematic

triggerTime is the time in seconds since the beginning of the cinematic when the cinematic event will start

cinematicEvent is the cinematic event.



There are several kind of implemented cinematic events:

  • PositionTrack : allow you to change the position of a spatial over time. It will move the spatial to destination in a given amount of time by linearly interpolating the position.


  • RotationTrack : same as position but for rotation


  • ScaleTrack : same as position and rotation but for scale.


  • SoundTrack : allow to play a sound at a given time for the given duration


  • GuiTrack : Displays a nifty gui at a given time for the given duration. To use it you first need to bind the nifty xml to the cinematic like that



    cinematic.bindUi(“path/to/nifty/file.xml”);



    In the example I created a SubtitleTrack that extends GuiTrack that displays a subtitle in a nifty panel.


  • AnimationTrack : Allow to start a model animation at a given time (a character walking animation for example)


  • MotionTrack : Close to PositionTrack, but allow the use of MotionPath for non linear movements.

    A motionPath is a list of several waypoints. A path is interpolated using Catmull-rom splines between the waypoints.

    The Motion track allow a spatial to move along a MotionPath in a given duration.



    There will be more track implemention, but of course, you can make your own CinematicEvent by extending AbstractCinematicEvent.

    It implements the CinematicEvent interface and provides duration, time, speed, etc… management.

    In the example I demonstrate how to use it for a fadeIn/fadeOut effect in combination with the FadeFilter.



    The camera management is handle as follow :

    you need to bind the camera to the cinematic like that



    CameraNode camNode = cinematic.bindCamera(“topView”, cam);



    You can then position the camNode anywhere and when calling for example



    cinematic.activateCamera(6, “topView”);



    The Cinematic will give the control of the camera to this node, seeing the scene from its point of view (here at 6 seconds from the beginning).

    Of course, you can attach this camNode to a MotionTrack to make any traveling you want.



    There is an example of everything i’ve just describe in the test repo (TestCinematics). I recommend to look at it.



    For now physics are not managed by the cinematic, but first i’d like you monkeys to test the basics :smiley:



    Go test!!

    Like usual any feedback/idea/request is very welcome.



    Nehon
6 Likes

Cool! For physics stuff I guess its quite specific to the users implementation, some thing that can apply forces etc. should be enough.

Nehon, great work! Volunteer as test subject!

Keep up the good work!

Thanks for this great job , when the cinematic is over i have an attention message : " Attention Screen[] is not found " what does it mean ?



About that , when the cinematic is over we can’t have control back to the camera i put to True the flycam to test it and i couldn’t have the control.

the “Screen not found” is thrown by nifty. It’s just a warning

To close the screen i just call nifty.gotoScreen(""); the screen “” does not exists indeed, but that’s intended.

maybe there is a better way to close a screen.



For the second question, maybe i should implement some kind of listener so you could restore back the camera control when the cinematic is finished.

nehon said:
the "Screen not found" is thrown by nifty. It's just a warning
To close the screen i just call nifty.gotoScreen(""); the screen "" does not exists indeed, but that's intended.
maybe there is a better way to close a screen.

For the second question, maybe i should implement some kind of listener so you could restore back the camera control when the cinematic is finished.


Ok , yes i'm pretty sure you should do it because after a cinematics in game we want the camera back to have the game continuing , thanks a lot for everything !

By the way i tried a new version by nighty build sources and i got a lot of errors here ;

import com.jme3.cinematic.GuiTrack;

import com.jme3.cinematic.MotionTrack;

import com.jme3.cinematic.SoundTrack;



cannot be resolved , but they are in the events directory and when i replace by the event directory in the imports i have another error :

Contructor Guitrack MotionTrack and Soundtrack are not defined …



Anybody else has this error ?

Yeah that changed a bit 2 weeks ago (before i posted the announcement btw)

This is for that kind of reason I told you to not use it before the announcement, the API changed…

re-organize your imports, for sound track and motion track look at the new constructors, you should find what you need

I added support for CinematicEventListener on CinematicEvents

In that listener you have a onPlay, onPause, onStop method

You just have to add one to you cinematic

nehon said:
re-organize your imports, for sound track and motion track look at the new constructors, you should find what you need

Can you be more specific ? i updated everything and i still have thoses errors
(i download the last nightly build , then i replace everything in Programfiles>JmonkeyPlateform>Jmonkeyplateform>libs , i'm not sure that it's the right thing to do i'm using Eclipse .

nehon said:
I added support for CinematicEventListener on CinematicEvents
In that listener you have a onPlay, onPause, onStop method
You just have to add one to you cinematic


So fast ! You're great thank you !

Well…organize your imports is ctrl+shit+O with eclipse ctrl+shit+i with netbeans.

Then the constructors have changed, so you have to look into the code the one that fits your needs.

but basically SoundTrack(“Path/to/your/audiofile.wav”); should work.

For the motion track MotionTrack(spatial,motionpath); should work

Thanks a lot , it’s working now

I have another question , if i want to have an order of some Waypoint ( for example i’m filming an object by his left side , then by his right side but without any interpolation , just a changing plan like in cinema ) , is that possible to have something like this :

[java]

cinematic.addCinematicEvent(X,leftSide()); // with leftside a cameramotion with some waypoint and X the frame number

cinematic.addCinematicEvent(X+1,Rightside());

[/java]



if yes , is that the only way to do this ?

Bind 2 camNodes to the cinematic.



CameraNode camLeft = cinematic.bindCamera(“leftView”, cam);

CameraNode camRight = cinematic.bindCamera(“rightView”, cam);



place the right node where you want it to be

then create the motion path for the left side.

and create a motion track with the leftcam and the path





MotionTrack cameraLeftTrack = new MotionTrack(camLeft , path);





you start your cameraLeftTrack at X, then activate any camera at x+1, X+2 etc…



cinematic.activateCamera(X, “camLeft”);

cinematic.addCinematicEvent(X, cameraLeftTrack );

cinematic.activateCamera(X+1, “camRight”);





this is what you need i think.

Thanks a lot Nehon !

nehon said:
In the example I demonstrate how to use it for a fadeIn/fadeOut effect in combination with the FadeFilter.


I didn't see that on the example , did you changed it ?

Is that possible to change the duration only between 2 path ?

nope I didn’t change it see :

http://code.google.com/p/jmonkeyengine/source/browse/branches/jme3/src/test/jme3test/animation/TestCinematic.java?r=6299#103

and

http://code.google.com/p/jmonkeyengine/source/browse/branches/jme3/src/test/jme3test/animation/TestCinematic.java?r=6299#144


danath said:
Is that possible to change the duration only between 2 path ?

What do you mean...? you mean between 2 waypoints?
If that's what you want you should try to play with the speed attribute.
Look at the TestCameraMotionPath, i showed how to use a MotionPathListener, that triggers an event each time the target reaches a waypoint. The motionTrack and the index of the waypoint are passed so you can increase speed at a certain waipoint and decrease back at the next waypoint.

Thank you i’ll try that tonight ! About speed and time feature , what will happen if the game is on a low configuration ? Will the speed and time reduce to let the cinematic loading ? or does the cinematic will be offbeat ?



Thanks

?

There is no loading it’s real time…

The cinematics are made to not be frame rate dependent, but if the hardware cannot display it at an interactive frame rate…there will be slowdowns…like in the actual game.



We discussed once with Normen a way to save the cinematic to video…maybe we’ll add this feature, but that will be a JMP feature, not really a JME3 feature.

nehon said:
?
There is no loading it's real time...
The cinematics are made to not be frame rate dependent, but if the hardware cannot display it at an interactive frame rate...there will be slowdowns...like in the actual game.

We discussed once with Normen a way to save the cinematic to video...maybe we'll add this feature, but that will be a JMP feature, not really a JME3 feature.


The problem here is that a lot of people doesn't have good computer and i think that if cinematics are not frame rate based that would be a problem with a lot of offbeat , i saw a tpf variable , doesn't this var synchronised with the cpu on simpleupdate ? ( still new on JME sorry if my question is absolutely wrong )

How do they do in most game if the computer doesn't specify to the game ? are they doing real time too ?