How Objects are Drawn in the Viewport
The following steps describe how a simple object is drawn in the viewport.
- The object's drawing code is in its override
BaseObject::Display()
method. AnINode
and aViewExp
are passed into this method. - The implementation of
BaseObject::Display()
callsINode::GetObjectTM()
. This method returns the matrix that is used to transform the points of the object from object space to world space. - The
BaseObject::Display()
method then takes the matrix returned fromINode::GetObjectTM()
and sets it into the graphics window (usingGraphicsWindow::setTransform()
). In this way, when the object starts drawing points in object space, they will be transformed with this matrix. This puts them into world space as they are drawn.
Below is the code from the SimpleObject
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); // UpdateMesh just calls BuildMesh() if req'd at time t.
gw->setTransform(mat);
mesh.render( gw, inode->Mtls(),
(flags&USE_DAMAGE_RECT) ? &vpt->GetDammageRect() : NULL, COMP_ALL,
inode->NumMtls());
return(0);
}