Hikari (v0.3)

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
Contact:

Hikari (v0.3)

Postby ajs15822 » Sat Jun 07, 2008 10:31 pm

Howdy again! :D

Image
(Fancy Hikari Logo)

Meet Hikari (hee-kah-ree), a small yet powerful library that makes it easy to use Flash content in Ogre3D. The possible applications include:
  • Create the interface for your game in Flash
  • Play Flash movies as cut-scenes in your game
  • Embed Flash mini-games in your game
  • Combine Flash with 3D to make novel interfaces
  • Use Flash for animated decals on 3D models
And it doesn't stop there! I'm excited to see what other uses people will dream up.


Basic overview of using Hikari:
    Step 1) Design your interface in Flash
    Step 2) Export to SWF files.
    Step 3) Create the HikariManager.
    Step 4) Create a FlashControl for each SWF using the HikariManager.
    Step 5) Load the SWF files into each respective FlashControl.
    Step 6) Bind callbacks in ActionScript and C++.
    Step 7) Inject mouse input into the HikariManager.
    Step 8) Call HikariManager::update from your update loop.

Features:
  • Efficient updating with dirty-rectangling
  • Full transparency support
  • Load the Flash ActiveX control from the registry or a local file
  • Create a FlashControl as a movable overlay or pure material
  • Bind C++ functions to handle function calls from ActionScript
  • Call ActionScript callbacks from C++
  • Support for communication of basic ActionScript types (null, boolean, number, string)
  • International string support
  • Minimal impact on application size

License:
    Hikari is licensed under the Lesser GNU Public License (LGPL) with one stipulation: if you use it, tell me about it! :D


Image
(Screenshot from the v0.2 Demo)


Demo:
    The demo is extremely simple (I began learning Flash about 4 days ago) but is certainly enough to demonstrate the basic implementation. Play with the slider and color-picker and drag around the FlashControls by holding down the right-mouse-button.

    Download the Hikari Demo (v0.2)

Source:

Forums:
    For discussion and support of Hikari, you may wish to visit our forums.

Documentation:
    The API headers are fully documented using Doxygen-compatible comments-- I will generate the online docs later.

    For articles and tutorials about use of Hikari, see the Hikari Wiki.


How is Hikari implemented?
When you create a FlashControl using the HikariManager, here's what happens:
  • The Flash ActiveX control is loaded (either from Flash.ocx in the working directory or from the registry).
  • It is embedded into a Windowless OLE site.
  • An event handler is bound to the OLE object to handle various Flash events.
  • Invalidations are caught, the dirty area is expanded.
  • Mouse input is injected by translating it into native window messages which are then sent directly to the Windowless site.
  • Keyboard input is handled by directing all keyboard messages (using a message hook) to the focused FlashControl. (To accommodate complex keyboard input)
  • During a global update, if a FlashControl is dirty, the dirty area is rendered and merged with an internal buffer, which is then blit to a dynamic texture using Ogre3D's facilities.



Have fun! <3
Last edited by ajs15822 on Mon Aug 25, 2008 6:19 am, edited 6 times in total.
0 x

User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
Contact:

Postby betajaen » Sat Jun 07, 2008 11:03 pm

Well done! We've come along way from BetaGUI and CEGUI and it shows.
0 x

User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1667
Joined: Mon Jan 21, 2008 10:26 pm

Postby madmarx » Sat Jun 07, 2008 11:40 pm

It seems that the fps is quite bigger than Navi's.

Well done!
0 x

Murphy
Greenskin
Posts: 102
Joined: Tue May 10, 2005 11:42 pm
Location: SF, California
Contact:

Postby Murphy » Sun Jun 08, 2008 12:30 am

Yay! Now I have something FUN to do today!
0 x

User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!

Postby Brocan » Sun Jun 08, 2008 1:02 am

That's great !!! Amazing !!! I'll will use it instead CEGUI for my next project :D
0 x

User avatar
metaldev
Orc Shaman
Posts: 761
Joined: Thu Mar 17, 2005 11:56 pm
Location: Boston
Contact:

Postby metaldev » Sun Jun 08, 2008 1:57 am

holy crap ajs. :!: :!: :!: :!: :!: :!: :!:
0 x

User avatar
steven
Gnoll
Posts: 657
Joined: Mon Feb 28, 2005 1:53 pm
Location: Australia - Canberra (ex - Switzerland - Geneva)
Contact:

Postby steven » Sun Jun 08, 2008 2:26 am

Bravo!

Just one question: what is the licensing behind Flash and ActionScript?
Is it lgpl compatible?

I tried to find info but... well I don't have days to read all this:
http://www.adobe.com/products/eulas/ ;)
Last edited by steven on Sun Jun 08, 2008 2:45 am, edited 1 time in total.
0 x

User avatar
Zeal
Ogre Magi
Posts: 1260
Joined: Mon Aug 07, 2006 6:16 am
Location: Colorado Springs, CO USA

Postby Zeal » Sun Jun 08, 2008 2:28 am

I never lost faith sir, I knew one day you would ride down from the heavens on a cloud of glory, and bestow upon us all, FLASH SUPPORT!
0 x

User avatar
Praetor
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3335
Joined: Tue Jun 21, 2005 8:26 pm
Location: Rochester, New York, US
Contact:

Postby Praetor » Sun Jun 08, 2008 2:51 am

This use of Flash is not against any terms of use from Adobe. They are, however, not liable for it. They do not "support" it in any way, so it means we are all on our own.

If you make an app that uses Flash and you want to distribute it (to make sure it is on a users machine, or that they have a correct version) you must apply for a distribution license from Adobe. Or, all you can do it ask the user to download the newest Flash.
0 x

User avatar
steven
Gnoll
Posts: 657
Joined: Mon Feb 28, 2005 1:53 pm
Location: Australia - Canberra (ex - Switzerland - Geneva)
Contact:

Postby steven » Sun Jun 08, 2008 2:55 am

Praetor wrote:If you make an app that uses Flash and you want to distribute it (to make sure it is on a users machine, or that they have a correct version) you must apply for a distribution license from Adobe. Or, all you can do it ask the user to download the newest Flash.

That was the info I needed.
Thanks.
0 x

User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
Contact:

Postby ajs15822 » Sun Jun 08, 2008 3:13 am

Yup, the main restrictions seem to be about the distribution of the player. Hikari doesn't require you to distribute the Flash ActiveX control with your application, it is simply an option for those who wish to ensure compatibility. For those who wish to distribute the Flash ActiveX control and stay legally within bounds, you can apply for a free license by filling out this form.

Praetor wrote:They do not "support" it in any way, so it means we are all on our own.


This lack of support (there is no documentation on embedding the Flash ActiveX control) gave me quite an exercise in OLE while I was writing this thing. In fact, I still can't get the text caret working for text inputs. :?

Zeal wrote:I never lost faith sir, I knew one day you would ride down from the heavens on a cloud of glory, and bestow upon us all, FLASH SUPPORT!


Haha, I was thinking of you when I began this library. :P
0 x

marshmonkey
Goblin
Posts: 251
Joined: Thu May 31, 2007 5:41 am

Postby marshmonkey » Sun Jun 08, 2008 7:53 am

aj, you rock . . . I hope someone ( maybe us! ) uses this to create some awesome GUI masterpieces!
0 x
http://NimbleBit.com <- purveyors of nimble bits
http://myZeroGear.com <- mah indie game

User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
Contact:

Postby Noman » Sun Jun 08, 2008 8:02 am

Wow.

Looks like game over for most of the other GUI libs =)

Congrats!

(Edit : Had compilation problems - missing shlwapi.h. Turns out that you need to install the Web Workshop component of the Platform SDK in order for this to exist)
0 x

handcircus
Halfling
Posts: 43
Joined: Wed Apr 05, 2006 8:00 pm
Contact:

Postby handcircus » Sun Jun 08, 2008 10:09 am

This is fantastic news, thanks!
0 x
HandCircus Game Studio - http://www.handcircus.com - Creators of Rolando and Rolando 2

User avatar
johnhpus
Platinum Sponsor
Platinum Sponsor
Posts: 1186
Joined: Sat Apr 17, 2004 2:49 am

Postby johnhpus » Sun Jun 08, 2008 11:31 am

The demo is very cool, but I noticed a slight lag when dragging the slider back and forth.

Any idea on the cause? In Navi there can be a similar lag when using non-Flash sliders and I think it's because it's copying the entire buffer instead of just the dirty area (not at all sure about that). Are you copying the buffer entirely or concentrating on parts that have changed?
0 x

Gillian_Seed
Kobold
Posts: 29
Joined: Mon Oct 16, 2006 9:55 pm
Contact:

Postby Gillian_Seed » Sun Jun 08, 2008 12:34 pm

Hi,


Hikari seems so cool that I quickly tried it.

First I ran the demo and it worked fine, then I just added the code of the demo to my app,
but I can't have it work :( (please, see the screenshot below for the errors during the compilation).

Do you know what's wrong ?
(I use the latest OgreSDK and I added the relevant path for the ".h" files to my proj,
but I didn't add the path to the ".idb" lib file because CodeBlocks doesn't recognize ".idb" files).

Do I have to compile Hikari from scratch in order to get a ".lib" file and, then, make Hikari work in my app ?


Thank you for your answers, and, of course, thank you, ajs15822, for Hikari ! You've done a very good job !


Image
Image
0 x

Dodzey
Halfling
Posts: 40
Joined: Fri Dec 15, 2006 8:54 pm
Location: England, UK

Postby Dodzey » Sun Jun 08, 2008 1:43 pm

Do I have to compile Hikari from scratch in order to get a ".lib" file and, then, make Hikari work in my app ?


Yes, the errors show that you are not linking to the library
0 x
Dodzey

User avatar
lf3thn4d
Orc
Posts: 478
Joined: Mon Apr 10, 2006 9:12 pm

Postby lf3thn4d » Sun Jun 08, 2008 2:31 pm

Nice work. :-) This might work very well for those who have money for flash IDE. :-P

Noman wrote:Wow.
Looks like game over for most of the other GUI libs =)

Nah.. It only works in windows. And requires a flash IDE to do any good. Unless you want to stick to flex which isn't quite what flash is. :P
0 x

Gillian_Seed
Kobold
Posts: 29
Joined: Mon Oct 16, 2006 9:55 pm
Contact:

Postby Gillian_Seed » Sun Jun 08, 2008 4:01 pm

Dodzey wrote:
Do I have to compile Hikari from scratch in order to get a ".lib" file and, then, make Hikari work in my app ?


Yes, the errors show that you are not linking to the library



Ok, thank you for your reply.


I downloaded Flash9 + MSVC2005, and, then, I tried to compile Hikari using CodeBlocks, but I can't resolve these errors
(please, see the screenshot below).

What do I miss ? Do I need "glib" or something to make the compilation work ?
I ask that because of the 3rd error (see the "sort()" call + the "gnu" stuff)
If yes, will I have to compile glib or is there any pre-made ".lib/.a/.dll/..." file available ? (PS : I use Windows)


Thanks for your answers !


Image
Last edited by Gillian_Seed on Sun Jun 08, 2008 4:05 pm, edited 2 times in total.
0 x

vinhk
Kobold
Posts: 25
Joined: Fri Oct 21, 2005 9:01 am
Location: Far East

Postby vinhk » Sun Jun 08, 2008 4:03 pm

oh my, what a fantastic job ~ ! I think I'll use this for GUI.
0 x

User avatar
DanielSefton
Ogre Magi
Posts: 1235
Joined: Fri Oct 26, 2007 12:36 am
Location: Mountain View, CA
Contact:

Postby DanielSefton » Sun Jun 08, 2008 5:29 pm

O____O I love you.

Effortless GUI's here I come! :D
Last edited by DanielSefton on Sun Jun 08, 2008 5:51 pm, edited 1 time in total.
0 x

User avatar
DanielSefton
Ogre Magi
Posts: 1235
Joined: Fri Oct 26, 2007 12:36 am
Location: Mountain View, CA
Contact:

Postby DanielSefton » Sun Jun 08, 2008 5:50 pm

Uhh... Got the libs, now what? :P

I literally have no idea what I'm doing - Where's this 'HikariManager'? :?

And what ActionScript do you need? An example FLA file would be nice. =]
0 x

User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
Contact:

Postby ajs15822 » Sun Jun 08, 2008 8:55 pm

Noman wrote:Wow.

Looks like game over for most of the other GUI libs =)

Congrats!

(Edit : Had compilation problems - missing shlwapi.h. Turns out that you need to install the Web Workshop component of the Platform SDK in order for this to exist)


Naw, other GUI libs will have their place-- I've just expanded the playing field to allow more Flash talent to get in the game.

As for the shwlapi dependency, it's used for "PathFileExists" to test if a ".swf" file exists before opening it (for debugging purposes, really). If obtaining shwlapi turns out to be an issue, I can always just replace it with the little hack of using ifstream to open the path to test for existence.

Gillian_Seed wrote:Ok, thank you for your reply.

I downloaded Flash9 + MSVC2005, and, then, I tried to compile Hikari using CodeBlocks, but I can't resolve these errors
(please, see the screenshot below).

What do I miss ? Do I need "glib" or something to make the compilation work ?
I ask that because of the 3rd error (see the "sort()" call + the "gnu" stuff)
If yes, will I have to compile glib or is there any pre-made ".lib/.a/.dll/..." file available ? (PS : I use Windows)


You will need to compile the Hikari library with Microsoft Visual C++ 2005 or higher (with the Platform SDK installed) because it uses the #import directive to generate the Flash headers. I don't see this as a major issue because the Express version (which I myself use!) is completely free.

As for the 'sort' issues, I think CodeBlocks just doesn't like my non-standard binary predicate declarations. I could replace that with more compatible code but due to the issue specified above, there's not much of a point.

Daniel Sefton wrote:Uhh... Got the libs, now what? :P

I literally have no idea what I'm doing - Where's this 'HikariManager'? :?
And what ActionScript do you need? An example FLA file would be nice. =]


I apologize for not having the introductory tutorials ready, I'm switching hosting providers right now.

First, compile Hikari from source using MSVC2005 (with the OgreSDK and Flash 9) in both the Debug and Release modes. If successful, it should generate Hikari.lib/Hikari.dll and Hikari_d.lib/Hikari_d.dll in the "Hikari\lib" directory.

Next, create a basic Ogre/OIS application (see the HikariDemo for an example).

For the debug build, you will need to link against the "Hikari_d.lib" you created earlier and copy "Hikari_d.dll" to the directory where you will run the executable.

Similarly, for the release build, you will need to link against the "Hikari.lib" you created earlier and copy "Hikari.dll" to the directory where you will run the executable.

In your application, add the "Hikari/include" path to your project's include directories. In your source, to include the entire Hikari API, simply declare:

Code: Select all

#include "Hikari.h"


I highly recommend reading the documentation within Hikari.h, FlashControl.h, and FlashValue.h.


To instantiate the HikariManager singleton in your application, you will need to "new" it (similar to the Ogre Root singleton):

Code: Select all

using namespace Hikari;

HikariManager* mgr = new HikariManager("myFlashFiles");


Then, after you've created Ogre::Root, camera, viewport, and scenemanager, you can create FlashControl overlays:

Code: Select all

using namespace Hikari;

FlashControl* myControl = mgr->createFlashOverlay("myControl", viewport, 300, 200, Position(Center), 0);

myControl->load("movie.swf");


Then, you need to update the HikariManager in your update loop:

Code: Select all

mgr->update();


And you also need to inject mouse input into the HikariManager, for example, this is how the HikariDemo does it:

Code: Select all

bool HikariDemo::mouseMoved(const OIS::MouseEvent &arg)
{
   return hikariMgr->injectMouseMove(arg.state.X.abs, arg.state.Y.abs);
}

bool HikariDemo::mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id)
{
   return hikariMgr->injectMouseDown(id);
}

bool HikariDemo::mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id)
{
   return hikariMgr->injectMouseUp(id);
}


That's pretty much the basics of getting started (don't forget to delete the HikariManager in your Application's destructor!). If you look over the code of the HikariDemo and the code within the FLA files (in the demo's media folder), you should get a pretty good idea of the callback system. I'll try to find some time to write up a proper tutorial.

johnpus wrote:The demo is very cool, but I noticed a slight lag when dragging the slider back and forth.

Any idea on the cause? In Navi there can be a similar lag when using non-Flash sliders and I think it's because it's copying the entire buffer instead of just the dirty area (not at all sure about that). Are you copying the buffer entirely or concentrating on parts that have changed?


That slider is quite the stress-test because of several factors: it employs "live-dragging" (constantly notifies listeners during the drag), updates a small bit of text below the slider, invalidates the area, and alters the material's opacity with every pixel the slider is dragged.

Hikari definitely employs dirty-rectangling-- during updates, only the dirty area is rendered by Flash. This isn't to say that the dirty-rectangling is perfect: I had several issues getting the HardwarePixelBuffer to lock with arbitrary rectangles and so I instead maintain an internal shadow buffer to handle rectangle merging and then blit the entire shadow buffer to the pixel buffer using simple row-memcpy. The method, though imperfect, is still quite effective because profiling shows that the Flash software renderer is, naturally, the biggest CPU hog in the chain-- comparatively, the memcpy is negligible.

Nevertheless, I'll see if I can't find a compatible way to do dirty-rectangle updates directly in Ogre3D, to squeeze the maximum amount of performance out.
Last edited by ajs15822 on Sun Jun 08, 2008 9:16 pm, edited 1 time in total.
0 x

User avatar
DanielSefton
Ogre Magi
Posts: 1235
Joined: Fri Oct 26, 2007 12:36 am
Location: Mountain View, CA
Contact:

Postby DanielSefton » Sun Jun 08, 2008 9:01 pm

Cheers ajs, I'll give it a go. :)

But it doesn't come with any .fla's... Only .swf's.
0 x

User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
Contact:

Postby ajs15822 » Sun Jun 08, 2008 9:17 pm

DanielSefton wrote:Cheers ajs, I'll give it a go. :)

But it doesn't come with any .fla's... Only .swf's.


Oh, forgot, the FLA's are included with the source release. ;)

By the way, if you're looking for ready-made Flash UI components and have Flash CS3, check it out. (The HikariDemo used Slider, ColorPicker, and Button)
0 x


Return to “Showcase”

Who is online

Users browsing this forum: No registered users and 6 guests