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

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

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

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. :)