3ds Max C++ Modifier not receiving Map Channel data when 2+ modifiers are in the Modifier list

StackOverflow https://stackoverflow.com/questions/23507166

  •  16-07-2023
  •  | 
  •  

سؤال

Having some troubles with a modifier plugin I'm making in C++ for 3ds Max 2015 and I'm running into an issue where I apply 2+ modifiers ( can be any type of modifier it doesn't matter ) to an object then I apply my own modifier ( OpenSubdiv-MPS ) which will run through my code fine on it's 1st pass, but when I update anything for the object the second pass through my code 3ds Max gives me an object w/ a mesh that does not have any Mapping data. This results in a crash for my plugin because I need the Mapping data for it.

Here is the Modifer list from Max:

https://i.stack.imgur.com/l3S2Q.png (Sorry, unable to post images yet )

Everything works fine if I only use 1 modifier before it or no other modifiers. I also can place as many as I want after it. Another weird occurrence I've noticed is if I create my Modifier 1st and then add 2+ Modifiers between it and the object the Mapping data will be returned correctly.

I assume this is related to a Validity / Channel issues that I've ran into before and was able to resolve myself by setting the channel validity myself. However, I've been unable to resolve the issue by this method again.

Here is my code for the ModifyObject function that 3ds Max calls for my Modifier...

void OpenSubdiv_MPS::ModifyObject(TimeValue t, ModContext& mc, ObjectState* os, INode* node) 
{
    Interval valid = GetValidity(t);
    valid &= os->obj->ChannelValidity(t,TOPO_CHAN_NUM);
    valid &= os->obj->ChannelValidity(t,GEOM_CHAN_NUM);

    if (os->obj->IsSubClassOf(polyObjectClassID)) 
    {
            PolyObject *polyOb = (PolyObject*)os->obj;
            ModifyPolyObject(polyOb, t, mc);
    }
    // Convert to a tri mesh if possible
    else if(os->obj->CanConvertToType(polyObjectClassID)) 
    {
            PolyObject  *polyOb = (PolyObject *)os->obj->ConvertToType(t, polyObjectClassID);
            // Now stuff this into the pipeline!
            os->obj = polyOb;

            ModifyPolyObject(polyOb, t, mc, 3);
    }

    os->obj->SetChannelValidity (GEOM_CHAN_NUM, valid);
    os->obj->SetChannelValidity (TOPO_CHAN_NUM, valid);

    os->obj->SetChannelValidity (VERT_COLOR_CHAN_NUM, valid);
    os->obj->SetChannelValidity (TEXMAP_CHAN_NUM, valid );
    os->obj->SetChannelValidity (SELECT_CHAN_NUM, valid);
    os->obj->SetChannelValidity (MTL_CHAN_NUM, valid);
}

Any ideas on what may be causing 3ds Max to give my Mesh no mapping data?

Thanks for the time.

هل كانت مفيدة؟

المحلول

I ended up figuring this out due to replys here....

http://forums.cgsociety.org/showthread.php?p=7816721#post7816721

Without clicking the link I just needed to make sure to update....

ChannelMask ChannelsUsed(); ChannelMask ChannelsChanged();

Originally they were set to their default values of TOPO_CHANNEL |GEOM_CHANNEL and GEOM_CHANNEL respectivly.

Updating ChannelIsChanged() to GEOM_CHANNEL | TOPO_CHANNEL | TEXMAP_CHANNEL | VERTCOLOR_CHANNEL solved the issue.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top