Acces to a skin modifier (ISkin interface)

 
 
 
Posted by:antoine
Data created:18 August 2010

Hi Marsel,

I'm trying to access to the skinning information of a mesh with a skin modifier.

I'm trying to do it that way:

IIDerivedObject theObj = (IIDerivedObject)node.ObjectRef;
for( int m = 0; m < theObj.Modifiers.Count; m++ )
{
    IModifier theModifier = theObj.GetModifier(m);
    if (theModifier.ClassName == "Skin")
    {
       IISkin iskin = (IISkin)theModifier.GetInterface(I_SKIN);
    }
}

but I don't know what to pass as parameter to the GetInterface method...

I_SKIN obviously does not work...

From what I found by searching on google, in C++ it would be :

 theModifier->GetInterface(I_SKIN)

But this doesn't work with max.net...

Thanks by advance, any help will be greatly appreciated.

Antoine.

Hi Antoine,

Sorry for the late reply, somehow I didn't get email notification for this thread. Basically, you have to look up the value for your interface constant inside 3dsmax SDK doc first. For example, it says:

#define  I_SKIN   0x00010000
#define  I_SKINIMPORTDATA   0x00020000
#define  I_SKIN2   0x00030000
#define  I_GIZMO   9815854
#define  I_GIZMO2   9815855
#define  I_GIZMO3   9815856
#define  SKIN_INVALID_NODE_PTR   0
#define  SKIN_OK   1

So I_SKIN is 0x00010000. Then you pass this constant to GetInterface:

IISkin iskin = (IISkin)theModifier.GetInterface((InterfaceID)0x00010000);

I do not think that IISkin is being up-cast is current release, however, so this might return null. If thats the case I will add the upcasting for the next build so that this works for you.

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Hi Marsel,

Thanks for your help, now I understand better how GetInterface works !

And you are right, IISkin is not up-cast.

Please include that in your next release

 

Thanks again,

Antoine.

 

Hi Marsel,

By any chance, have you added the upcasting of IISkin in 1.2.7 ?

Thx,

Antoine

 

Hi Antoine,

Yes, all of the interfaces mentioned previously in this thread should now be upcastable in 1.2.7

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Hi!

Don't know whats going on, but it's still not working for me...

The code i'm using:

IObject obj = node.ObjectRef;
IISkin skin = null;
if (obj is IIDerivedObject)
{
IIDerivedObject derived = obj as IIDerivedObject;
obj = derived.ObjRef;
foreach (IModifier modifier in derived.Modifiers)
{

      object iface = modifier.GetInterface((InterfaceID)0x00010000);
      if (iface is IISkin)
      {
           skin = iface as IISkin;
      }
}
}

The GetInterface method always returns null, no matter what id i try. But 0x00010000 is ISkin, isn't it?

Btw the "Name" property of "modifier" is "Skin", so it is indeed the skin modifier, it just appears to be unable to return its interface...

Thanks in advance.