Hikari Wrapper for MOGRE         Create a GUI using Flash

Wrapper for Hikari - With this you can embedd Adobe Flash to a Mogre application, e.g. to show a GUI.

Details in this forum thread.

Download


The last version is available here : HikariWrapper for Mogre 1.7.1 . vs2008 only at the moment.
The source code is available here : source code at bitbucket

Prerequisite


You must have the flash.ocx plugin in folder of your exe. it's included in the hikariwrapper zip file.

Setting up Hikari


use this code to set up hikari :

HikariManager _HikariManager = new HikariManager("path\\to\\flashfiles");



For creating a new flash control, use this code :

FlashControl _FpsControl = _HikariManager.CreateFlashOverlay("Fps", viewport, 130, 91, RelativePosition.TopLeft, 0, 0);
_FpsControl.Load("fps.swf");


Alternatively, if you want to create a flash material without adding it on an overlay, use this code instead

FlashControl _FpsControl = _HikariManager.CreateFlashMaterial("Fps", 130, 91);


this will create internaly a new ogre material, containing your flash control, you can then assign this material to an entity, using SetMaterialName, for example:

_MyEntity.SetMaterialName("FpsMaterial");


Finally, don't forget to add a call to the Update function of your hikari manager in a framelistener, for example :

bool Main_FrameStarted(FrameEvent evt)
{
 _HikariManager.Update();
}

Calling an actionscript function from csharp


You need to add the specific line of code in the actionscript code of your flash control, like in this exemple :

function testflash()
{
	
}

//here, the first parameter is the name of your function outside of flash, the second is the reference to our function
ExternalInterface.addCallback("testflash",testflash);


next, you need to use the csharp flash control object to call the function :

//args is the array of parameters passed to the actionscript function
object[] args = new object[0];
_MyFlashControl.CallFunction("testflash",args);


Calling a csharp function from actionscript


let say we have a csharp function we want to call from flash.

//the function signature must always be like this
public void testCsharp(object[] args)
{

}


first, create a new callbackhandler delegate :

CallbackHandler _testcsharp;


next, bind it to a our csharp function

_testcsharp = this.testCsharp;


then bind it to our flashcontrol

//the first param is the name of our function in action script, the second is the reference to our delegate
_MyFlashControl.Bind("testCsharp",_testcsharp);


finally, call the function from actionscript like this :

//add parameter for our csharp function after the first one
ExternalInterface.call("testCsharp");


known issues

  • memory leak : like hikari, hikariwrapper suffer from memory leak. however, a cross platform, memoryleak free version of hikari, named akarui exist. but it haven't be integrated with ogre, and thus haven't be implemented with hikariwrapper for now. The code is still available, so if you want to give it a shot, just send a pm to gantz

  • flashcontrol.materialname : the materialname property of flashcontrol is buggy, and don't return the correct material name. instead, use ControlIDMaterial where ControlID is the name of your flashcontrol

  • Flash 10 : last time i tested it, flash 10 make hikariwrapper crash. it safer to ignore this version for now, and only use flash9. the activex components (flash9.ocx) is included in the hikariwrapper zip

  • Perfomance concern : try to avoid using a lot of animated flash in your gui. things like tweener still acceptable performance wise, but full screen animation usually perform badly.

  • video playback : you can playback video by integrating directly your flv video in your flash control. streaming won't work (mainly because of the offline nature of hikari)

Todo: Copy screenshot from forum to this page.

Call to undefined function mb_split()Call to undefined function mb_split()Call to undefined function mb_split()Call to undefined function mb_split()