Displaying the Object in the Viewport

When deriving from a SimpleObject2, a plug-in only has to build the mesh in its override of the virtual function SimpleObject::BuildMesh(). In other plug-ins that derives from BaseObject, the plug-in must draw itself in the viewport in its implementation of BaseObject::Display() function.

The following code snippet is an example implementation of BaseObject::Display().

int SimpleObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags)
{
   if (!OKtoDisplay(t)) return 0;
   GraphicsWindow *gw = vpt->getGW();
   Matrix3 mat = inode->GetObjectTM(t);  
   UpdateMesh(t);
   gw->setTransform(mat);
   mesh.render(gw, inode->Mtls(),
     (flags&USE_DAMAGE_RECT) ? &vpt->GetDammageRect() : NULL, COMP_ALL, inode->NumMtls());
   return(0);
}

See Also