GUI/Video
From TDN
Overview
We're using the excellent Ogg Vorbis and Theora codecs. They're fast, free, and cross-platform. Thank you, Xiph.org! All the decoding and streaming happens in a background thread, rendering via an optimized YUV->RGB converter to an OpenGL texture, so the core functionality can be applied to any GL-rendered object - which for Torque, is everything from GUI to grenades. All of the Ogg codecs are free for use, meaning you don't have to pay any license fees to use them in your game. Theora.org has information about how to encode videos to Theora format.
Setup
Torque now supports playback of the Ogg Theora video codec, by Xiph.org, the fine people who brought us Ogg Vorbis, an excellent audio codec. The size and weight of the video will affect the performance of your menu, so be considerate of older computers.
theoraGoodies
GuiTheoraCtrl
Video playback in a GUI may be accomplished by using the GuiTheoraCtrl - just call setFile on it, passing it the path of the video file, and it will play it. If you're interested in integrating the playback in other areas of the engine, look at the TheoraTexture class - it manages rendering Theora video to a GL texture, which can then be rendered or otherwise used.
So you should have something like this:
new GuiTheoraCtrl(MyVideo) {
profile = "GuiDefaultProfile";
horizSizing = "relative";
vertSizing = "relative";
position = "40 25";
extent = "320 240";
minExtent = "8 2";
visible = "1";
done = "0";
stopOnSleep = "1";
backgroundColor = "0 0 0 255";
};
Go to the Console and use this command:
MyVideo.setFile("starter.fps/data/video/menuvideo.ogg");
Remember that you need to leave off the first "slash" when specifying the path to the file:
MyVideoControl.setFile("game/data/videos/MyOggVideo.ogg");
where the file "MyOggVideo.ogg" is stored in your projects "game/data/videos" directory
or you can use the expandFilename() if using relative paths:
1. MyVideoControl.setFile(expandFilename("~/data/videos/MyOggVideo.ogg"));
2. MyVideoControl.setFile(expandFilename("~/game/data/videos/MyOggVideo.ogg"));
3. MyVideoControl.setFile(expandFilename("./videos/MyOggVideo.ogg"));
To stop the video use, stop() on the GuiTheoraCtrl. You can set this command to be a button.
The next best thing is to script this input to a button or startup. See the demo game data's GUI buttons to see this in action. Full controls have yet to be documented.
Categories: TGE | TGB | GUI



