Maya API How-To #07 | ||
| ||
How do I use MPxLocatorNode::draw() to draw in static world-space independent of the parent locator's transformation?When the MPxLocator::draw() method is initiated the OpenGL
To draw in world-space, find the Maya Camera represented by the
current view and determine the inverse of this Camera's transformation
matrix. Load this inverted matrix into the OpenGL void myMPxLocator::draw( M3dView & view, const MDagPath & dagPath, M3dView::DisplayStyle style, M3dView::DisplayStatus displayStatus ) { MStatus status; MDagPath thisCameraView; // the dagPath for this modelPanel's Camera MMatrix cameraInverseMatrix; // inverse matrix for the modelPanel's Camera double dMatrix[4][4]; // the 4Ч4 array for the OpenGL matrix // Get the Maya Camera associated with this view view.getCamera( thisCameraView ); // Load inverse of the Camera's Matrix cameraInverseMatrix = (thisCameraView.inclusiveMatrix()).inverse(); // Get 4Ч4 array to represent matrix (required for glLoadMatrix) cameraInverseMatrix.get( dMatrix ); // Initialize Maya's GL view.beginGL(); glMatrixMode( GL_MODELVIEW ); glPushMatrix(); // Load the inverse of the Camera's matrix into the Model View. // This places the render origin at Maya's world center. glLoadMatrixd( (GLdouble *)dMatrix ); // Now draw your OpenGL using world-coordinates for the vertices glBegin( GL_LINES ) /* ... render here ... */ glEnd(); glPopMatrix(); view.endGL(); } | ||
Copyright ©2005 by Bryan Ewert, maya@ewertb.com Maya is a Registered Trademark of Alias |