Hey Sweenie... How's The Irrlicht Wrapper Coming..

Community Forums/Showcase/Hey Sweenie... How's The Irrlicht Wrapper Coming..

Red Ocktober(Posted 2005) [#1]
... along?

if you got a free second, could you give us an update...

also, a question or two...

1- since the thing is object oriented, how are you approaching it... exposing functions to create new instances of objects at the BMax level???

from what i understand, the different Irrlicht classes cannot be used in 'Max...

2- is that the main reason why you are wrapping it, or is it because there is no external interface to it for "max to link up with...

thx

--Mike


Sweenie(Posted 2005) [#2]
It's slowly coming along.
About 250 of about 600 functions are done.
The rest of the functions are "converted" but requires a bit more work to...um, work :)

Trying to answer your questions...

Let's say I have a C++ Api which expose a class called SceneManager.
This class contains three methods called BeginScene, RenderScene and EndScene.

A c++ user could easily create an instance of this class by simply writing...

SceneManager mySmgr;

and call it's methods by writing...

mySmgr->BeginScene()
mySmgr->RenderScene()
mySmgr->EndScene()


Now if I want to do the same thing i Bmax I get trouble because the only thing I can use from the API(dll) is ordinary functions, not classes.
The methods in the class are "ordinary" functions but they are hidden inside the class and beyond my reach.

What I can do though is to create a wrapper dll which creates and call class-methods for me.

So to reach the methods above I create four functions in my wrapper.
Smgr_CreateSceneManager()
Smgr_BeginScene()
Smgr_RenderScene()
Smgr_EndScene()


Smgr_CreateSceneManager() will create a SceneManager Instance and return it's pointer.

Smgr_BeginScene(),Smgr_RenderScene() and Smgr_EndScene() will take the pointer to the class that I provide and call the corresponding method inside it.

So doing the same as the C++ code above but in Bmax would look like this...
Local MySmgr = Smgr_CreateSceneManager()
Smgr_BeginScene(MySmgr)
Smgr_RenderScene(MySmgr)
Smgr_EndScene(MySmgr)


Now, this doesn't have a very objectoriented feel to it so why not put it inside a couple of types?
Like this...

Type SceneManager
 Field ClassInstance:Int

 Method BeginScene()
  Smgr_BeginScene(ClassInstance)
 End Method

 Method RenderScene()
  Smgr_RenderScene(ClassInstance)
 End Method

 Method EndScene()
  Smgr_EndScene(ClassInstance)
 End Method

 Function Create:SceneManager()
  NewInstance:SceneManager = New SceneManager
  NewInstance.ClassInstance = Smgr_CreateSceneManager()
 Return NewInstance
 End Function



Then the bmax code could look like this instead...


Local MySmgr = SceneManager.Create()
MySmgr.BeginScene()
MySmgr.RenderScene()
MySmgr.EndScene()



Now, it is a bit more objectoriented a more like the C++ code.

I have to mention though that this is how I solve this problem using my current knowledge of Bmax and C++.
There probably exists a much smarter and easier solution.
So if anyone knows a better way of solving this with Bmax, please let me know. :)


Red Ocktober(Posted 2005) [#3]
ahhhhhh.... yes, that explains it quite well...

BIG THANKS.... and good luck with this...

i was playing around with OGRE the other day and was thinking of embarking on a similar trek... i'm so outta touch with coding lately... one of the real reasons i'm gonna license 'MAX...

i think it'll draw me back into c++ and basic coding...

hey, thanks again...

one more thing... are you planning on wrapping just the renderer functions, or pretty much everything?

--Mike


teamonkey(Posted 2005) [#4]
Sweenie: That's the approach we're currently using for the ODE module. ODE has a C API but for the collision detection you need to create a structure and access its member fields directly, so for that we've got a couple of C wrapper functions. We're now busy wrapping it all up into some more user-friendly Max classes.

If you do find a better way of doing things, let me know :)


Sweenie(Posted 2005) [#5]
@Red Ocktober
I have done several attempts to wrap Ogre but then I barely can compile a simple tutorial, wrapping it is even harder.
If you got VS C++ 6.0 it seems to work somewhat fine but anything else than that and your'e in for several hours of compiler fiddling. :(
Ogre have a pretty clean interface and is powerful but I think it's too much work just to get it up and running, at least for a newbie.

Now regarding Irrlicht.
I will wrap the video and scenemanager classes first.

@teamonkey
If you do find a better way of doing things, let me know :)

Will do... :)


Red Ocktober(Posted 2005) [#6]
yeah... i'm cursin' my arse off here trying to get this damn thing to compile on the mac... the damn project is set up for xcode, which only osx 10.3.x has...

... and wouldn't ya know it, i'm running 10.2.8 with the dec dev tools.... arrrrrrrrrgggghhhh!!!

getting irrlicht up and running is like dating a girl scout compared to this...

... but have you ran the Ogre demos yet... the water and the fresnel demos... hot stuff.

i'm gonna try one more thing before i give up...

hey, is there an irrlicht port for osx???

--Mike


Xip(Posted 2005) [#7]
@swennie:

ja det är lite intresant hur han använder -> operator på "icke pekare till objekt"...
fast som psuedo exempel spelar det kanske inte så stor roll :P

uhhhhga, så otroligt skönt att kunna skriva svenska, o slippa missförstånd och att ständigt bli behandlad som en minder-årig eller nåt, o andra sidan så blir man väll jagad av alla andra som inte förstår svenska nu :P

sorry for the swedish, but you proberbly whodent anderstand it bether on english :P