Exporting Morph information

 
 
 
Posted by:psaii
Data created:12 August 2010

Another question for you guys,

I plan to work next on exporting morphing information. In the current C++ plugin we have in our pipeline, we had to do tricky stuff to be able to access the information, including recompiling the orginal "Morphr3" (or something similar) plugin, as well as another one depending on it. I know the guys doing the Collada max plugin used dumpbin to generate a .lib & .def file to resolve the issue. Anyways, back to the topic.

I plan to export morph information using the IGame system, but I was wondering if I will be able to get all information I need, or if I'll have to somehow wait that you guys add support to access the MorphR class ?

If you can't offer support for that, is there a way to write managed code that wraps the MorphR class, then having Max.Net working with this new class too ? or do I need the MAX.Net source code to do such extension ?

Thanks,

---
Psaii

I can't seem to find MorphR class in the SDK. Is it somewhere in maxsdk headers? Max.NET only wraps whats there so if its absent it would be tricky. Which SDK classes is Morphr derived from?

There could be a couple of workarounds if you have the proper .h and .lib files for it. One would be to include it in the SDK as part of the wrapper, though it'd be a special build for you since Max.NET is just designed to wrap maxsdk classes.

Another way would be for you to write a custom C++/CLI wrapper for it and reference Autodesk.Max.Wrappers.dlu (which is a .NET assembly) so you can use those wrappers (for example when returning or accepting Max objects to/from your class you can use Max.NET wrappers for those objects to save you a lot of wrapping).

Marsel Khadiyev (Software Developer, EPHERE Inc.)

\maxsdk\samples\modifiers\morpher

The class name is 'MorphR3'.

It's a standard plugin that enables artists to perform morphing by combining different morph targets togetherer with a corresponding weight.

Most of the meat is in wm3.h it seems.

 

I'm looking at what I can achieve via the IGame interface to export (or at least test) morphed geometry.

I've got a question about casting types in Max.Net :

I've got the following C++ code :

    IGameModifier* controller = object->GetIGameModifier(0);
    if (controller->GetModifierType() == IGameModifier::IGAME_MORPHER)
    {
        IGameMorpher * l_pMorpher = (IGameMorpher*)controller;
    }

When transposed to Max.net, I cannot find a way to cast the IIGameModifer to IIGameMorpher. What is the correct way to handle that ? I see a native Handle in the class, maybe there's a way to create a instance of IIGameModifier by specifying a Native Handle or something like that ?

Thanks

---
Michel

\maxsdk\samples\modifiers\morpher

The class name is 'MorphR3'.

Ah, I see. The sample headers are currently no included in Max.NET, just the headers inside maxsdk include directory. Another user is currently trying to get some sample code to work with Max.NET so I might have to consider including some of those classes in next build of Max.NET. Maybe down the line these could be broken off into an expansion of the main wrapper.

When transposed to Max.net, I cannot find a way to cast the IIGameModifer to IIGameMorpher.

IIGameModifier is currently not being upcast to IGameMorpher (or IGameGenMod and IGameSkin) so in this build there is no way. I'll try to set this upcasting up for the next build. Since we're dealing with wrappers the framework needs to know ahead of time which top-level wrapper to use for GetIGameModifier result, that needs to be specified manually (through GetModifierType). Adding it to TODO right now.

Do you guys find IGame interfaces useful and use them quite a bit? I had some discussions with Autodesk people about trimming access to some of these interfaces in Max.NET and they said these weren't widely used.

Marsel Khadiyev (Software Developer, EPHERE Inc.)

After looking a bit, it looks like our legacy plugins use these interface to access easily some information, then fall back to SDK standard classes to extract the information. I guess everything can be accessed without using the IGame interface at all. I'm going to look for alternatives, I'll keep you posted.

Sounds good, I'll still try to do what I mentioned in previous post for next build.

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Ok, I'm trying the regular way (without IGame), it's a bit harder, but possible. Right now, I'm parsing all modifiers for a specific mesh, to look for either a Skin modifier, or a Morph modifier (I know I won't be able to get the values out of it, but anyways).

I'm now getting a bad cast (l_Inode is a MaxNode) :

IObject  l_Object = l_Inode.ObjectRef;
IDerivedObject derivedObject = (IDerivedObject)l_Object;

Bam :
System.InvalidCastException: Unable to cast object of type 'Autodesk.Max.Wrappers.IDerivedObject' to type 'Autodesk.Max.Plugins.IDerivedObject'.

Is there a way to get a DerivedObject ? or getting the 'ith' modifier in a specific MaxNode ?

Thanks,

---
Michel

You seem to be using IDerivedObject pluggable class (not sure why its pluggable anyhow). You need to be using Autodesk.Max.IIDerivedObject, so your code becomes:

IObject  l_Object = l_Inode.ObjectRef;
IIDerivedObject derivedObject = (IIDerivedObject)l_Object;
IModifier myModifier = derivedObject.GetModifier( modifierIndex );

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Makes sense. Trying it now. Fast answer :) tks

Edit : Worked. Tks