OGRE-MOGRE interconnection        
Print

Normally a wrapper (like OgreDotNet, which uses SWIG) will create a new .NET object each time you need access to a native object, and the class type of the .NET object will be that of the method's return type (the wrapper cannot know which subclass the native object actually is). To address this issue the OGRE's source is modified and the OGRE classes are interconnected to the MOGRE classes. Instead of MOGRE creating a new .NET object each time you need to access an OGRE object, the OGRE object itself creates the appropriate .NET object the first time it is requested and returns it in subsequent requests.

This allows for checking equality of objects (example code is in C#):

Camera cam1 = sceneMgr.CreateCamera("PlayerCam");
 Camera cam2 = sceneMgr.GetCamera("PlayerCam");
 bool areEqual = (cam1 == cam2);  //areEqual is true

And returning the correct subclass:

MovableObject object = sceneNode.GetAttachedObject(0);
 if (object is Entity)
 {
    ...
 }
 else if (object is Camera)
 {
    ...
 }
 else
 {
    ...
 }

 
Because of the modifications to OGRE's source, in order to use a native plugin with MOGRE (like the Paging Scene Manager) you have to recompile it using the modified OGRE's include files.


Contributors to this page: Beauty14565 points  and jacmoe180265 points  .
Page last modified on Friday 24 of September, 2010 18:33:56 UTC by Beauty14565 points .


The content on this page is licensed under the terms of the Creative Commons Attribution-ShareAlike License.
As an exception, any source code contributed within the content is released into the Public Domain.