One ManualObject problem

muyi

21-10-2009 02:23:40

I have a problem when I learn Intermediate Tutorial 4 : Volume Selection and Basic Manual Objects.

The class - SelectionRectangle, is inherited from ManualObject, and VS 2008 give me this message
string cannot covert to CLRObject*.

My Code is
public class SelectionRectangle : ManualObject
{
public SelectionRectangle(string name)
: base(name)
{

}
}
, and the red line is under the base(name).

How can I deal with it? All help will be appreciated.

smiley80

21-10-2009 05:45:05

In Mogre, ManualObject doesn't have a public constructor that takes a string, so you can't easily derive your own class from it*.
In your case, however, you could use extension methods to get the same result.


*There is a pretty hackish (and probably faulty) way to achieve that:

public class SelectionRectangle : ManualObject
{
public unsafe SelectionRectangle(string name) : base(null)
{
using (SceneManagerEnumerator.SceneManagerIterator smi = Root.Singleton.GetSceneManagerIterator())
{
smi.MoveNext();
ManualObject dummyObject = smi.Current.CreateManualObject(name);
typeof(ManualObject).GetField("_native", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(this, (IntPtr)dummyObject.NativePtr);
}
}
}

muyi

22-10-2009 15:40:38

Thanks smiley80 for reply.
I will try it, and hope we can use ManualObject constructor which takes a string parameter in the near future, if it is possible.