The following steps describe how a simple object is drawn in the viewport.
BaseObject::Display()
method. An INode
and a ViewExp
are passed into this method.BaseObject::Display()
calls INode::GetObjectTM()
. This method returns the matrix that is used to transform the points of the object from object space to world space.BaseObject::Display()
method then takes the matrix returned from INode::GetObjectTM()
and sets it into the graphics window (using GraphicsWindow::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);
}