If you haven't done so already, be sure to visit the Wiki Portal to read about how the wiki works. Especially the Ogre Wiki Overview page.
Guidelines for converting Ogre C++ code to Mogre C# code
Table of contents
.NET naming conventions
- Methods use pascal case instead of camel case.
- Properties instead of get/set methods. Ogre methods that get transformed to properties are:
- get/setXXXX methods
- getXXXX methods
- bool isXXXX methods
Example:
OGRE
mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5)); SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
MOGRE
mSceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f); SceneNode node = mSceneMgr.RootSceneNode.CreateChildSceneNode();
Note: If you see a property that starts with a lower case letter, it means that the property is not a conversion of get/set methods but a direct wrapper of a class field variable (i.e Mesh.sharedVertexData
)
.NET Events
Ogre uses Listener classes to provide notifications of various events. The pattern involves subclassing an abstract Listener class (that gets the notifications), and subscribing to a notifier using a addListener method. .NET provides Events for this mechanism, so in Mogre there are no add/removeListener methods. Instead, the notifier exposes one event for each function defined in the Ogre's abstract Listener class.
Example:
OGRE
mFrameListener = new SkeletalAnimationFrameListener(mWindow, mCamera); mRoot->addFrameListener(mFrameListener); class RefractionTextureListener : public RenderTargetListener { public: void preRenderTargetUpdate(const RenderTargetEvent& evt) { ........ } }; RenderTarget *rttTex = mTexture->getBuffer()->getRenderTarget(); rttTex->addListener(&mRefractionListener);
MOGRE
mRoot.FrameStarted += new FrameListener.FrameStartedHandler(Skeletal_FrameStarted); RenderTarget rttTex = mTexture.GetBuffer().GetRenderTarget(); rttTex.PreRenderTargetUpdate += new RenderTargetListener.PreRenderTargetUpdateHandler(rttTex_PreRenderTargetUpdate); void rttTex_PreRenderTargetUpdate(RenderTargetEvent_NativePtr evt) { ... }
See also
- In a short Mogre porting example you can see how to port by means of a complete snipit.
- How to port functions with void* parameter - look to this thread
Contributors to this page: jacmoe
and
OgreWikiBot
.
Page last modified on Sunday 27 of December, 2009 18:29:55 UTC by jacmoe
.
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.

