.Net Custom Scene Node
Posted: Sun Jul 16, 2006 9:11 pm
One thing that is holding me back from using Irrlicht is that I really prefer to work with a managed language, specifically C#, and using a non-native .Net library can cause a lot of friction.
Part of the reason I'm looking for a native .Net engine is that I'm almost certain I want custom scene nodes, I really prefer C#, and my C++ is a little rusty.
When I looked at Irrlicht before (version 0.12), it seemed to me that I would have to write a custom scene node in C++. Over the last 30 minutes or so, I decided to check this - it couldn't be that hard, right? Well, the Irrlicht.Net.Scene.ISceneNode class is just a wrapper around the C++ version. In fact, the single parameter to the ISceneNode constructor is a irr::scene::ISceneNode* named realSceneNode.
This means in order to have a .Net scene node, you have to have a C++ scene node for it to wrap. This means to have a custom .Net scene node, I would have to create a a DotNetSceneNodeWrapper class in C++ that implements irr::scene::ISceneNode and take a .Net custom scene node in it's constructor.
Sure, I can make it so something like:
sceneManager.AddCustomDotNetSceneNode(new MySceneNode() ) works.
But first, the .Net custom SceneNode would be created, then passed to the scenemanager to be wrapped in a new Irrlicht::Scene::CustomDotNetSceneNodeProxy so it could be added to the scene. Maybe that's not so bad.
Later the SceneManager calls OnPreRender for all the scene nodes.
you'd have irr::scene::ISceneNode overriden by Irrlicht::Scene"::CustomDotNetSceneNodeProxy (written in C++)
CustomDotNetSceneNodeProxy->OnPreRender() would call the underlying CustomDotNetSceneNode (written in C#) OnPreRender code.
That's not as many layers of indirection as I had worried about, but it still seems like it would have to move between managed and unmanaged code far too often.
And it still seems like a bad idea to try to implement a custom scene node in C#.
What do you guys think? Has anyone ever proposed a .Net native port of Irrlicht? I've probably put too much thought into this already without searching the forums.
Part of the reason I'm looking for a native .Net engine is that I'm almost certain I want custom scene nodes, I really prefer C#, and my C++ is a little rusty.
When I looked at Irrlicht before (version 0.12), it seemed to me that I would have to write a custom scene node in C++. Over the last 30 minutes or so, I decided to check this - it couldn't be that hard, right? Well, the Irrlicht.Net.Scene.ISceneNode class is just a wrapper around the C++ version. In fact, the single parameter to the ISceneNode constructor is a irr::scene::ISceneNode* named realSceneNode.
This means in order to have a .Net scene node, you have to have a C++ scene node for it to wrap. This means to have a custom .Net scene node, I would have to create a a DotNetSceneNodeWrapper class in C++ that implements irr::scene::ISceneNode and take a .Net custom scene node in it's constructor.
Sure, I can make it so something like:
sceneManager.AddCustomDotNetSceneNode(new MySceneNode() ) works.
But first, the .Net custom SceneNode would be created, then passed to the scenemanager to be wrapped in a new Irrlicht::Scene::CustomDotNetSceneNodeProxy so it could be added to the scene. Maybe that's not so bad.
Later the SceneManager calls OnPreRender for all the scene nodes.
you'd have irr::scene::ISceneNode overriden by Irrlicht::Scene"::CustomDotNetSceneNodeProxy (written in C++)
CustomDotNetSceneNodeProxy->OnPreRender() would call the underlying CustomDotNetSceneNode (written in C#) OnPreRender code.
That's not as many layers of indirection as I had worried about, but it still seems like it would have to move between managed and unmanaged code far too often.
And it still seems like a bad idea to try to implement a custom scene node in C#.
What do you guys think? Has anyone ever proposed a .Net native port of Irrlicht? I've probably put too much thought into this already without searching the forums.