wrappers

remz

06-03-2008 09:23:11

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

kerozcak

19-03-2008 08:52:24

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

remz

19-03-2008 11:53:30

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.

Marioko

19-03-2008 14:03:06

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




//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:


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

remz

19-03-2008 23:39:28

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!

Marioko

20-03-2008 00:31:09

nice.. i hope that you can help us.. :D

Xavier

28-05-2008 00:30:28


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


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

Bekas

28-05-2008 07:31:55

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.

RichTufty

28-05-2008 09:56:54

I'd like to see Hydrax wrapped !!! :lol: :lol:

Marioko

28-05-2008 13:52:40

yeah me too.. i going to start working on that, it will be my firts mogre wrapper..

RichTufty

28-05-2008 14:01:31

Awesome, can you let me / us know when yer done :lol:
Can't wait!

Marioko

28-05-2008 14:13:19

sure, i will trying to keep you update :D

Beauty

17-08-2008 12:20:55

It would be nice, if you Marioko would finish and pubish the wrapper tutorial.
I could need it for a partially [u]MogreNewt update[/u] :wink: