Google

wrappers

Discussion regarding the Managed .Net Wrapper for Ogre, MOGRE (http://sourceforge.net/projects/mogre)

Moderators: OGRE Team, MOGRE Moderators

wrappers

Postby remz » Thu Mar 06, 2008 10:23 am

hello,

Since there are quite a few nice ogre addon that I'd like to see exposed to MOGRE I tought I'd try myself at some wrapper writting (for Paged Geometry at first, and maybe later for NxOgre).

so I was wondering you guys had any good link/book name about wrapper writting doc.

thank you.


remz
remz
Gnoblar
 
Posts: 10
Kudos: 0
Joined: 26 Mar 2007

Postby kerozcak » Wed Mar 19, 2008 9:52 am

I don't know any :(
But i would love to see Paged Geometry for MOGRE :)
Have you made any progress with it?
kerozcak
Gnoblar
 
Posts: 11
Kudos: 0
Joined: 25 Jan 2008

Postby remz » Wed Mar 19, 2008 12:53 pm

kerozcak wrote:I don't know any :(
But i would love to see Paged Geometry for MOGRE :)
Have you made any progress with it?


not yet, but it's definitely something that would be awesome for mogre. Unfortunately I don't have much time to dig blindly into the internet. I don't even know where to start. I was thinking that maybe that cpp2java used by mogre could help but that's as far as I got.
remz
Gnoblar
 
Posts: 10
Kudos: 0
Joined: 26 Mar 2007

Postby Marioko » Wed Mar 19, 2008 3:03 pm

the best and easy way to make wrappers for MOGRE is using C++/CLI. Currently the mogre Autowrapper cannot be used for Addons, but Cpp2java is a good starting point to generate a XML with all C++ classes descriptions you could use it if you want some automatic build.

Other way is creating the wrapper manually like EditableTerrain mogre wrapper.

This is a free bonus chapter (44 pages) for a good C++/CLI book that explain how to build managed wrappers with C++/CLI:
http://courseptr.cengage.com/downloads/ ... usCh02.pdf

Books about C++/CLI are recommended reading. I was reading C++/CLI In Action, very nice book..

Basically you need to code a Managed C++/CLI class with C++ native pointers inside.. for example



Code: Select all
//C++/CLI demo wrapper class for something
public ref class MyWrapper{
   private:
            NativeClass *myNativeObj;
    public:
          MyWrapper(){
                myNativeObj = new NativeClass();
          }
         
         public System::String^ GetSomeNativeString(){
                    std::str* = myNativeObj->getString();
                    System::String^  result = youNeedParseStringYourSelf(str);
                   return result;
        }
}

In C# for example you can use MyWrapper class.

MyClass myManagedObj = new MyClass();
string str = myManagedObj.GetSomeNativeString();
//Wrapper ready


Its will be nice if you or everybody could learn C++/CLI a make Addons wrapper. REMEMBER you dont need a full wrapper (all class) only user classes will need a wrapper.

Currently i am working in a big project and i dont have time to build`em, and update MOGRE again to last OGRE version.. sorry for that :D

[EDIT]
Also remember that many MOGRE classes have a cast operator defined to get native references. For example in C++/CLI you can do this:

Code: Select all
public void InitAddons(Mogre::SceneManager^ managedScnMgr){
         Ogre::SceneManager* nativeSceneMgr = (Ogre::SceneManager*)managedScnMgr;     
         addon->init(nativeSceneMgr);
 }
Image
User avatar
Marioko
Goblin
 
Posts: 235
Kudos: 0
Joined: 14 Jul 2006
Location: Colombia

Postby remz » Thu Mar 20, 2008 12:39 am

thanks a lot for that reply!

well, earlier today I decided to order that very same book (C++/CLI in Action) since manning usualy publishes very good books. I'll get started as soon as I get it!
remz
Gnoblar
 
Posts: 10
Kudos: 0
Joined: 26 Mar 2007

Postby Marioko » Thu Mar 20, 2008 1:31 am

nice.. i hope that you can help us.. :D
Image
User avatar
Marioko
Goblin
 
Posts: 235
Kudos: 0
Joined: 14 Jul 2006
Location: Colombia

Postby Xavier » Wed May 28, 2008 12:30 am

Marioko wrote:Also remember that many MOGRE classes have a cast operator defined to get native references. For example in C++/CLI you can do this:

Code: Select all
public void InitAddons(Mogre::SceneManager^ managedScnMgr){
         Ogre::SceneManager* nativeSceneMgr = (Ogre::SceneManager*)managedScnMgr;     
         addon->init(nativeSceneMgr);
 }


The problem we're finding is that MOGRE's wrapping somehow eliminates the vtable pointers from the wrapped class, so that using those cast operators does no good if you intend actually to work with data members of the class (for instance, trying to get at the vertexData or indexData members of the native SubMesh class). This screws up the offsets into the data space of the class instance, making it entirely unusable for anything other than calling methods on the class. In our case, we're using a MOGRE app to manipulate some meshes, and then passing those meshes to native code which then manipulates the submeshes and vertex/index data some more -- but we can't seem to overcome this issue with the data offset. I'll keep looking but I just wanted to inform on this one. ;)
Xavier
Gnoblar
 
Posts: 14
Kudos: 0
Joined: 09 Feb 2006

Postby Bekas » Wed May 28, 2008 7:31 am

It seems to me that your native code is not compiled against modified Ogre's sources.
Most of native Ogre objects returned by Mogre have an additional data member (void* actually), so if your native code is compiled against "original" Ogre, it will receive an object with different data layout than it expects.
Bekas
OGRE Expert User
 
Posts: 513
Kudos: 1
Joined: 27 Feb 2006

Postby RichTufty » Wed May 28, 2008 9:56 am

I'd like to see Hydrax wrapped !!! :lol: :lol:
RichTufty
Halfling
 
Posts: 61
Kudos: 0
Joined: 16 Feb 2007

Postby Marioko » Wed May 28, 2008 1:52 pm

yeah me too.. i going to start working on that, it will be my firts mogre wrapper..
Image
User avatar
Marioko
Goblin
 
Posts: 235
Kudos: 0
Joined: 14 Jul 2006
Location: Colombia

Postby RichTufty » Wed May 28, 2008 2:01 pm

Awesome, can you let me / us know when yer done :lol:
Can't wait!
RichTufty
Halfling
 
Posts: 61
Kudos: 0
Joined: 16 Feb 2007

Postby Marioko » Wed May 28, 2008 2:13 pm

sure, i will trying to keep you update :D
Image
User avatar
Marioko
Goblin
 
Posts: 235
Kudos: 0
Joined: 14 Jul 2006
Location: Colombia

Postby Beauty » Sun Aug 17, 2008 12:20 pm

It would be nice, if you Marioko would finish and pubish the wrapper tutorial.
I could need it for a partially MogreNewt update :wink:
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
IRC chat ... Mogre: irc://freenode/#mogre ... Ogre: irc://freenode/#ogre3d
User avatar
Beauty
OGRE Community Helper
 
Posts: 1645
Kudos: 37
Joined: 09 May 2007
Location: Germany


Return to MOGRE

Who is online

Users browsing this forum: No registered users and 1 guest