smernesto
06-01-2008 21:18:28
Hi.
Well many of us don´t want to port the C++ code for some project to C# and Mogre because it takes much time and if the C++ code change we have to update the C# again. I have ported some code like the OSM loader and some other code but is really tedious.
Bekas made some wrappers with C++/CLI for newton and anothers.
How we can port existing project for Ogre using C++/CLI? For example some plugins and project like OgreAL.
Marioko heard from you that you are working in something like this?
Thanks
Ernesto
dodongoxp
07-01-2008 05:10:13
marioko is working on something like an addon version of the autowrapp of mogre...
but for the moment you can just use C++/CLI references to mogre where in normal C++ refers to normal ogre.. its tediuos and complex.. but for the moment is a way... not the only way.. but a valid way to port existing addons
Marioko
07-01-2008 05:19:55
first of all:
Port = Rewrite everything in new language, MogreNewton is a port, and because Bekas use C++/CLI and ogreNewton is a small library was relative easy port this addon to mogre. I am working in a solution that will use the same autowrapper for Mogre but with Addons.
Another way to use ogre addons with Mogre is creating little c++/cli bridge, this is a class writed in C++/CLI (compiled to an .NET assembly) that use C++ addon code and mogre code, for example for use NxOGRE u can do something like this:
public ref class NxOgreBridge{
private: World *mWorld;
public:
void CreateWorld(Mogre::SceneManager ^mogreScnMgr){
Ogre::SceneManager scnMgr = (Ogre::SceneManager)mogreScnMgr;
mWorld = new World(scnMgr,"paramters");
}
void UpdateWorld(float time){
mWorld->update(time);
}
}
Important: NxOGRE (the Addon) shoul be compiled with Ogre .h headers file in Mogre SDK.
If u need pass a .NET String to Ogre::String u can use the Marshall.h and Marshall.cpp files. These files can be downloaded from mogre SVN souce code. And do something like:
include Marshall.h;
void CreateOgreObject(System::String ^str){ // .net string
DECLARE_NATIVE_STRING(ogreString, str);
//ogreString object is automaticaly created in DECLARE_NATIVE_STRING, u dont need create a pointer XD
ogreScneManager->createEntity(ogreString,....);
}
Kerion
08-01-2008 23:53:22
I am glad I found this, because I need to do this very thing.
So I can cast Mogre::Root to Ogre:Root in my C++/CLI code? I need to wrap Editable Terrain Manager, but I frankly don't want to do the auto-wrapping like MOGRE, I can just hand-wrap it easy enough...I just need to be able to get at the raw OGRE objects to pass to ETM in the wrapper code.
So I could do something like:
public ref class MyETMBridge {
public:
void initialize(Mogre::Root^ root) {
Ogre::Root root = (Ogre::Root)root;
}
}
Obviously I need to compile the C++/CLI with the MOGRE headers so it has the proper decorations on the class definitions.
Marioko
09-01-2008 00:17:25
a lot of Mogre class define a implicit cast operator, you can use the assembly explorer and look if Mogre::Root define this operator. If yes, then in c++/cli class u can:
Ogre::Root *root = (Ogre::Root)mogreRoot;
Kerion
09-01-2008 00:27:27
Hmmm, Root does not. That seems very strange. Would it possible to have Root given the same operator?
I guess in reality, it doesn't matter, I could just call Ogre::Root::getSingletonPtr() to get the same thing, but that forces my wrapper in to a single root situation, rather than allowing the wrapper consumer to tell me which OGRE root to use.
Almost seems like an oversight though, that Root doesn't define that operator.