Firstly , I need to create a gui to display the intro scene. In order to be able to play OGM or OGG movie i need to use the gui controller named GuiTheoraCtrl.
theoraFile attribute used for locating the media file which I am going to use in our intro. Next thing I need to do create some functions to load the introGui and end the playback once the media finishes.I will be adding all these codes in to the intro.Gui
First function which i will be creating is loadIntroGui. As anyone can guess it will be used to load the introGui.
This function will be called from chechStartUpDone function scripted in StartUpGui. Which located at gameDirectory/client/ui
I also need to create a method which stops the playback and load the main menu Gui.
Now there is a problem which we have to look in to. How can we know when to stop the playback? So far , I couldn't find any information regarding to this. Then I thought i could schedule(delay) to this function call based on the time frame of the video. in simple terms, if the video is 6 second long then I could be able to schedule the function call to 6 second. Luckly schedule function already comes with the engine.
Our Intro is done. Now we can move on to cut scene.
Creating CutSceneGui to display cutscene movie
same as above, first thing I need to do is create a GuiTheoraCtrl and functions to load the gui.
Following pic showing the code is a bit long. For clear view just click on the pic.
Now our Gui is done we need to concentrate on how to activate this GUI in game. The simplest way is using the trigger. When the player gets in to the trigger we can call the loadCutSceneGui function. in order to create a trigger, first think I need to do is create a trigger data block and onEnterTrigger function to load the gui.
there are some additional things I have done in onEnterTrigger().
firstly, I stoped the game sound then paused the countdown.
and I eventuallyfreeze the game play by using $timeScale variable. This call absolutely necessary otherwise, while the movie playing the game will still continue under the canvas(game window)
The rest of the code used for loading the gui after we enter in to the trigger.
Placing the movieTrigger in to the game world
We now need to place the movie trigger in to the game. We can modify the mission file or alternatively we can use the world editor in game.
I am going to use world editor so that I can see what I am doing.
- start the game as usual
- once the game starts press on f11 to bring world editor
- choose world editor creator from the window toolbar
- find the trigger sim object from mission object\ mission sim group and click on it.
- Building Object Trigger pop up window will display on screen. choose the movie trigger datablock which we defined. Now we have a movie trigger in game world.
- scale/place it as you prefer.
Converting Avi to OGG/OGV (Additional)
There is a convertor which we can use to convert avi format to ogv format. the program is called ffmep2Theora and its downloadeble from;
http://v2v.cc/~j/ffmpeg2theora/
This program, works only in command prompt.
In order to conver the avi video;
- put the avi in to the directory ffmpeg2theora folder.(in my pc i use "C:\documents and Settings\school
- now in command prompt type the name of the program followed by space, followed by the name of the avi (with its extension). as an example lets say the avi format I am going to convert is named cutscene. So i need to type: ffmeg2theora cutscene.avi
No comments:
Post a Comment