Game Development Community

guiAviBitmapCtrl Windows ONLY fix

by Richard O · in Torque Game Engine · 07/03/2002 (6:43 pm) · 78 replies

A little disclaimer before I get into the code. This is a quick and dirty fix to the guiAviBitmapCtrl module to get it to play AVI's under Windows only (i.e. it will not compile/work on Linux or Mac). All of the below code changes are based upon the current HEAD version:

[b]In engine\gui\guiAviBitmapCtrl.h[/b]

Change the below line (11) from:

	#if !ENABLE_AVI_GUI || !ENABLE_MPG_GUI

to

	#if !ENABLE_AVI_GUI && !ENABLE_MPG_GUI
[b]In engine\gui\guiAviBitmapCtrl.cc[/b]

Change the below line (23) from:

	#define  ENABLE_AVI_GUI    0

to

	#define  ENABLE_AVI_GUI    1

Change the below line (46) from:

	#if !ENABLE_AVI_GUI || !ENABLE_MPG_GUI

to

	#if !ENABLE_AVI_GUI && !ENABLE_MPG_GUI

Replace the entire function GuiAviBitmapCtrl::sndOpen() (lines 101-117) with the below code:

bool GuiAviBitmapCtrl::sndOpen()
{
   char               fileBuffer[1024];
   Audio::Description desc;

   // Build the audio description
   desc.mVolume    = 1.0f;
   desc.mIsLooping = false;
   desc.mIs3D      = false;
   desc.mType      = 0;

   // Create the audio source
   dSprintf(fileBuffer, sizeof(fileBuffer), "%s", mWavFilename);
   mWavHandle = alxCreateSource(&desc, fileBuffer, 0);

   return (mWavHandle != NULL_AUDIOHANDLE);
}
In order to test the above changes I created a directory under fps called AVI. I then created the below script (avitest.cs) in that directory. Here is the source code to the script:
// Issue the below command at the console:
   //
   //    exec("fps/AVI/avitest.cs");
   //

   new GuiControlProfile (IntroProfile)
      {
      opaque      = false;
      fillColor   = "0 0 0";
      fillColorHL = "0 0 0";
      fillColorNA = "0 0 0";
      tab         = true;
      canKeyFocus = true;
      };

   // Create the GuiAviBitmapCtrl
   new GuiAviBitmapCtrl(IntroGui)
      {
      profile = "IntroProfile";
      horizSizing = "width";
      vertSizing = "height";
      position = "0 0";
      extent = "640 480";
      minExtent = "8 8";
      visible = "1";
      variable = "";
      helpTag = "0";
      useVariable = "1";
      aviFileName = "fps/AVI/test.avi";
      wavFileName = "fps/AVI/test.wav";
      setFirstResponder = "1";
      letterBox = true;
//      letterBox = false;
      swapRB = true;
      };

   Canvas.pushDialog(IntroGui);
   Canvas.hideCursor();
   IntroGui.play();
   schedule(100, 0, checkIntroDone);

//-----------------------------------------------------------------------------
function checkIntroDone()
{
   if (IntroGui.done)
      {
      Canvas.popDialog(IntroGui);
      Canvas.showCursor();
      IntroGui.delete();
      IntroProfile.delete();
      }
   else
      schedule(100, 0, checkIntroDone);
}
You will need to create a test AVI (test.avi) and WAV (test.wav) file and place them in the fps/AVI directory prior to executing the above script. To test the AVI control, open the console from the main menu and issue the command:

exec("fps/AVI/avitest.cs");

As far as a Linux and Mac solution, it is on my to do list (no estimate of availability at this time). The above coding changes where done to validate that the existing Windows code was functional.

Rich
Page«First 1 2 3 4 Next»
#61
07/14/2006 (11:18 am)
@Tim

Yep, you're right. Since the Fraps captured files are so huge, I've been assuming that they were uncompressed video. Of course I never bothered to verify it. :( Thanks for the correction.

@Robert

I'm not sure what you mean by "after action review". Are you wanting your players to be able to watch what they just did in the game, or is this something they would record and then distribute to others to watch. Could the Torque demo recording system provide what you need?

It allows players to record what happens in a game session, not in a video format, but in a movement or instructions capture format (I hope that made sense). So, if I'm understanding your needs correctly, your players can hit F3 to start recording their gameplay session and F4 to end it. Then they can go to the main menu screen, locate, and play the demo that was just recorded.
#62
07/14/2006 (12:08 pm)
Aaron, this was my first plan but the powers that be wanted voice comms with it when it plays back and currently my only option for voice communication is with TeamSpeak and the like. If only I could play the voices back with Torque's build in system I'd be cooking with grease ! Unfortunately that's why I'm using FRAPS.... because it captures every thing coming in from TeamSpeak as well as Torque. Any suggestions on how to fix that issue ?
#63
07/14/2006 (12:17 pm)
Ah. I see. That could be a tough one. Recently, I read that Open AL now has audio capture support -- so you might look into that as an option. But considering your requirements, I can see why you've gone with a true video recorder. Distributing Fraps, and staying legal might be difficult though.
#64
07/14/2006 (12:30 pm)
I'll check the AL stuff but thanks again.
#65
05/18/2008 (4:49 pm)
So...does anyone know how to get videos to play in 1.5.2? Been hitting my head on the desk for a few months now
#66
05/18/2008 (5:24 pm)
I would recommend using Theora if you do not wish to work with the AVI code.
#67
05/18/2008 (5:47 pm)
I found a forum on how to convert files into Theora, but how to I place them in game to use? Thanks
#68
05/18/2008 (7:31 pm)
You would make a gui to play them on.

Here's an example of a splash screen I use:

//--- OBJECT WRITE BEGIN ---
new GuiTheoraCtrl(Startup3Gui) {
   canSaveDynamicFields = "0";
   Profile = "GuiDefaultProfile";
   HorizSizing = "right";
   VertSizing = "bottom";
   position = "0 0";
   Extent = "640 480";
   MinExtent = "8 2";
   canSave = "1";
   Visible = "1";
   hovertime = "1000";
   theoraFile = "./exploreIntro.ogg";
   done = "0";
   stopOnSleep = "1";
   backgroundColor = "0 0 0 255";
};
//--- OBJECT WRITE END ---

function loadStartup3()
{
   StartupGui.done = false;
   Canvas.setContent( Startup3Gui );
   schedule(100, 0, checkStartup3Done );
}
   

//-------------------------------------
function Startup3Gui::click()
{
   StartupGui.done = true;

}


//-------------------------------------
function checkStartup3Done()
{
   if (Startup3Gui.done)
   {

   	  echo ("*** Load Main Menu");
      loadMainMenu();

   }
   else
      schedule(100, 0, checkStartup3Done );
}
It works.
#69
05/18/2008 (10:32 pm)
Does it work in just a standard build or do I need to modify anything. I tried it and just got a window that showed a black screen with my mouse trails.

All I did was switch my StartUp.gui with this and then modified the .ogg file name
#70
05/19/2008 (1:58 am)
It works fine in 1.5.2. That's the same engine I use. I don't know why you would get a black screen unless there is a problem with the ogg.
#71
05/19/2008 (5:13 am)
That's probably it, the converter made my .avi into a .ogV
I'll surf around to try and find a .ogg that I know works to test it
Thanks

Edit: Just renamed the .ogv to .ogg
works great
#72
05/19/2008 (11:23 am)
It works, outstanding. I forgot to change all the names from Startup3 to just Startup
#73
05/19/2008 (11:24 am)
Now how would I call a GuiTheoraCtrl with a trigger? and then once the movie is playing go back to the game?
#74
05/20/2008 (2:50 pm)
You would write a function to do that work.

Something like:

function loadStartup(){ 
  StartupGui.done = false; 
  Canvas.setContent( StartupGui );
   schedule(100, 0, checkStartupDone );}
function checkStartupDone(){
   if (StartupGui.done)
   {
    loadMyGame();
   }
   else      schedule(100, 0, checkStartup3Done );}
function loadMyGame()
{
loading stuff here........
}
You would probably have this load over the top of your playGui with a pushDialog, and delete it when the movie was finished.
The above code is just a hack job I did on the function to move from one gui to another, but should give you a little direction. Someone here with more experience can probably help you better if this doesn't work
#75
01/05/2009 (7:20 pm)
Hey Mike, I know this is an old thread but I am having major problems with a Theora I am playing that is several minutes long, it keeps for some reason changing the .done to true even though the file is not finished, any ideas?
#76
01/05/2009 (7:32 pm)
I need to put a 2 minute+ video at the end of the game and it is giving me a world of headaches. All other videos were short several second clips that had no problems with the schedule, but what I desperately need is the syntax on how to make a command execute as soon as and only when the video is done playing. Please let me know if you know of a way to make this possible. Thanks
#77
01/05/2009 (9:30 pm)
I am a step closer, now it senses when it is done, but now it crashes with a debug error when I exit.
I commented out the theoraFile = "./cutscenes/anthem.ogg"; in the GuiTheoraCtrl
and then added
Startup3Gui.setFile("starter.fps/server/scripts/cutscenes/anthem.ogg");
in the loadStartup3 function
#78
01/05/2009 (11:03 pm)
Ok I figured out the crashing problem (not how to fix it but what the problem is) it doesn't have to do with the video but has to do with exiting the game to the main menu.
Page«First 1 2 3 4 Next»