How to implement Archive, ArchiveFactory in Mogre and c#

issingle

22-03-2010 15:33:55

In native Ogre,we can inherit abstract class Archive, ArchiveFactory, DataStreamPtr to implement some function. URLArchivehttp://www.ogre3d.org/wiki/index.php/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:

smiley80

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.

issingle

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 http://eyecm-physx.sourceforge.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?

c++/cli:
(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
{
public:
gcroot<IArchive^> iface;
public:
giArchive() { }
~giArchive() { this->iface = nullptr; }
private:
DataStreamPtr Open(const String& filename) const
{
return static_cast<const Ogre::DataStreamPtr *>(iface->Open( ToManagedString(filename)));
}
.....
}