void arrowLocator::getRotationAngle (arrowLocatorData * data){ // Retrieve value of the angle attribute from the node MStatus status ; MObject node = thisMObject(); MPlug wdPlug(node, windDirection); MAngle angle; wdPlug.getValue(angle); data->rotateAngle = angle; }
//- This method draw this locator in current scene by calling openGL functions // view -- 3D view that is being drawn into // path -- path to this locator in the DAG // style -- style to draw object in // status -- selection status of object // void arrowLocator::draw(M3dView &view,const MDagPath & path,M3dView::DisplayStyle style, M3dView::DisplayStatus status) { MObject thisNode = thisMObject(); //- We're in the draw routine, not the compute method //- therefore it is safe to grab plugs in the following way and //- get/set values. You would never do something like this in //- the compute method because it might start a cycle in the //- graph. Here we just need the value of our winddirection //- plug so that we can draw our arrow pointing the right way. MPlug wdPlug(thisNode, windDirection); MAngle angle; wdPlug.getValue(angle); //- Start drawing by OpenGL view.beginGL(); //- If the drawing style is shaded, set color and draw opaque shape if ( ( style == M3dView::kFlatShaded ) || ( style == M3dView::kGouraudShaded ) ) { //- Push to save current color settings glPushAttrib( GL_CURRENT_BIT ); if ( status == M3dView::kActive ) { view.setDrawColor( 13, M3dView::kActiveColors ); } else { view.setDrawColor( 13, M3dView::kDormantColors ); } //- Push the old matrix on the stack, rotate the current one, //- draw the shape, then pop the old matrix off the stack for //- maya to use again. glPushMatrix(); glRotated(-angle.asDegrees(), 0.0, 1.0, 0.0); glBegin( GL_TRIANGLE_FAN ); glVertex3f(arrow[0][0],arrow[0][1],arrow[0][2]); glVertex3f(arrow[1][0],arrow[1][1],arrow[1][2]); glVertex3f(arrow[2][0],arrow[2][1],arrow[2][2]); glEnd(); glBegin( GL_TRIANGLE_FAN ); glVertex3f(arrow[2][0],arrow[2][1],arrow[2][2]); glVertex3f(arrow[3][0],arrow[3][1],arrow[3][2]); glVertex3f(arrow[0][0],arrow[0][1],arrow[0][2]); glEnd(); glPopMatrix(); glPopAttrib(); } //- Draw the outline of the arrow shape glPushMatrix(); glRotated(-angle.asDegrees(), 0.0, 1.0, 0.0); glBegin( GL_LINE_STRIP); glVertex3f(arrow[0][0],arrow[0][1],arrow[0][2]); glVertex3f(arrow[1][0],arrow[1][1],arrow[1][2]); glVertex3f(arrow[2][0],arrow[2][1],arrow[2][2]); glEnd(); glBegin( GL_LINE_STRIP ); glVertex3f(arrow[2][0],arrow[2][1],arrow[2][2]); glVertex3f(arrow[3][0],arrow[3][1],arrow[3][2]); glVertex3f(arrow[0][0],arrow[0][1],arrow[0][2]); glEnd(); glPopMatrix(); view.endGL(); }