How to implement Archive, ArchiveFactory in Mogre and c#


22-03-2010 15:33:55

In native Ogre,we can inherit abstract class Archive, ArchiveFactory, DataStreamPtr to implement some function. URLArchive fox example.
In mogre source,I found all object are inheritted from CLRObject.and most of them have a internal filed “CLRObject* _native;” It seem that we must implement function use native c++ and then wrap it as Mogre do.
My question is "Is there any way to extend Archive, ArchiveFactory,DataStreamPtr in Mogre and C#?" :shock:


23-03-2010 04:17:15

No, it's not possible atm, you have to go native.

But, you only need to write a wrapper if you'd add additional public members that need to be accessed by managed code, otherwise a native plugin that registers the factory is sufficent.


23-03-2010 09:42:26

en,it's a way,but will have some trouble if someone like me is not familiar with c++ and C++/cli.
there's a PhysX wrapper for .net,in this wrapper,author (smoove) did some work make us to inherit physX's native c++ interface.
Do we have chance to modify the mogre's source as follow?

(interface for c# user)
public interface class IArchive{
//here we put some Archive's member function
IDataStreamPtr^ Open(String^ filename)
public interface class IArchiveFactory{
//here we put some codes similar to ogre's ArchiveFactory
public interface class IDataStreamPtr{

(internal wrapper class)
public class giArchive: public Archive
gcroot<IArchive^> iface;
giArchive() { }
~giArchive() { this->iface = nullptr; }
DataStreamPtr Open(const String& filename) const
return static_cast<const Ogre::DataStreamPtr *>(iface->Open( ToManagedString(filename)));