Horde3D
http://www.horde3d.org/forums/

GameCallbackComponent
http://www.horde3d.org/forums/viewtopic.php?f=6&t=1592
Page 1 of 1

Author:  AcidFaucet [ 10.11.2011, 05:25 ]
Post subject:  GameCallbackComponent

Attached are the source files for a callback component for the game engine. Basically you can attach an arbitrary number of callbacks to any event which will be called for both checkEvent() and executeEvent().

The callback is:
Code:
typedef bool (*CALLBACK_FUNC)(bool aIsCheckEvent, GameEvent&);

You can also register a factory function of:
Code:
typedef CALLBACK_FUNC (*FACTORY_FUNC)(const char*);

That loadFromXml() can use to get a function ptr from a string in the XML.

The EventRegistry.zip is a few files that add a PITA string to EventID class that's part of modules. If you're okay with just using integral eventIds then you don't need it and can just change the loadFromXml() of the component to translate an int to an EventID.

Basically on construction the event registry mirrors the EventID enum in that it calls a REGISTER_EVENT() macro passing in the EventID and the comment originally attached to it. I'd really like to write a preprocessor that does the work of keeping this guy up to date rather than fussing with maintaining two places.

Warning: only very lightly tested ... but feel free to yell at me for mess-ups.

Attachments:
EventRegistry.zip [8.3 KiB]
Downloaded 1175 times
GameCallbackComponent.zip [5.44 KiB]
Downloaded 1198 times

Author:  Volker [ 10.11.2011, 07:12 ]
Post subject:  Re: GameCallbackComponent

Thanks for your contribution. Unfortunately I can't add this currently to the community branch, because I currently don't use the GameEngine myself anymore and I don't know if the guys at the university have the time to integrate the patch. Because a lot of projects at the lab are based on the GameEngine, I don't want to commit something I haven't tested myself.

Kind regards,
Volker

Author:  AcidFaucet [ 10.11.2011, 07:54 ]
Post subject:  Re: GameCallbackComponent

No problem. Unless my prior login write rights to the community branch were stripped, I could have put it there myself along with the VS projects but opted not to due to having been out of the loop for a while, as well as preferring the opportunity of peer commentary before such things.

Nonetheless, it's here attached for any that would be interested. I was rather impressed with the "AAA" demo out there.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/