Notifications
Clear all

[Closed] [SDK] Very simple morpher – update problem

Hi
I’m trying to create a very simple morpher-like modifier. For now it’s pretty much what the 3ds Max plugin wizard created + one additional parameter of TYPE_INODE + Custom pickbutton to pick the node. I want to copy the target verts to my mesh, as simple as that.
For now it works only with Meshes:

void aVertMorph::ModifyObject(TimeValue t, ModContext& mc, ObjectState* os, INode* node) 
{
   INode* targetNode = NULL;
   pblock->GetValue(pb_targetnode, t, targetNode, FOREVER);
   if (targetNode)
   {
      BOOL deleteIt;
      TriObject* targetTriObj = GetTriObjectFromNode(targetNode, deleteIt, t);
      if (targetTriObj)
      {
         TriObject *myTriObj = (TriObject*)os->obj;
         if (myTriObj)
         {
            for (int v=0; v<myTriObj->mesh.numVerts; v++)
            {
               myTriObj->mesh.verts[v] = targetTriObj->GetMesh().verts[v];
            }
         }
      }
      if (deleteIt) targetTriObj->DeleteMe();
   }
}

And it usually works, but not always. When I add an animated noise mod to the target node and some other modifiers like edit_mesh (nothing thath turns it into poly) it sometimes (rather rarely, most of the time it works) stops updating in the viewport while moving the time slider – the ModifyObject method is not called at all. What can be the problem?

2 Replies

Could be caused by a variety of factors, most likely related to your modifier’s validity interval. Are you setting that properly and returning it in your GetValidity function? And when your target node changes (due to animation or whatever), are you getting proper ‘ref changed’ messages in your NotifyRefChanged function?

That was the problem indeed, NotifyRefChanged wasn’t even called. I’ve implemented the GetValidity function and everything works now, thanks for the hint