void mtmEnvLight::draw( M3dView & view, const MDagPath & /*path*/, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { // Get the size // //MObject thisNode = thisMObject(); //MPlug plug( thisNode, size ); //MDistance sizeVal; //plug.getValue( sizeVal ); //float multiplier = (float) sizeVal.asCentimeters(); view.beginGL(); float size2 = 0.7f * .5f; float scale = 2.0f; if ( ( style == M3dView::kFlatShaded ) || ( style == M3dView::kGouraudShaded ) ) { // Push the color settings // glPushAttrib( GL_CURRENT_BIT ); if ( status == M3dView::kActive ) { view.setDrawColor( 13, M3dView::kActiveColors ); } else { view.setDrawColor( 13, M3dView::kDormantColors ); } glBegin( GL_TRIANGLE_FAN ); int i; int last = mtmCount - 1; for ( i = 0; i < last; ++i ) { glVertex3f( (mtm[i][0] - size2) * scale, (mtm[i][1]) * scale, (mtm[i][2] - .15f) * scale ); } glEnd(); glPopAttrib(); } // Draw the outline of the foot // glBegin( GL_LINES ); int i; int last = mtmCount - 1; for ( i = 0; i < last; ++i ) { glVertex3f( (mtm[i][0] - size2) * scale, (mtm[i][1]), (mtm[i][2] - .15f) * scale ); glVertex3f( (mtm[i+1][0] - size2) * scale, (mtm[i+1][1]), (mtm[i+1][2] - .15f) * scale ); } glEnd(); view.endGL(); }
void areaLightNode::draw(M3dView &view, const MDagPath &path, M3dView::DisplayStyle style, M3dView::DisplayStatus status) { MColor drawColor; drawColor.set(MColor::kRGB,1,1,0,0.5); if (status==M3dView::kDormant) { drawColor.set(MColor::kRGB,1,0,0,0.5); } view.setDrawColor(drawColor); view.beginGL(); glBegin(GL_LINES); //these are useful glVertex3f(-1.0f,-1.0f,0.0f); glVertex3f(-1.0f,1.0f,0.0f); glVertex3f(-1.0f,1.0f,0.0f); glVertex3f(1.0f,1.0f,0.0f); glVertex3f(1.0f,1.0f,0.0f); glVertex3f(1.0f,-1.0f,0.0f); glVertex3f(1.0f,-1.0f,0.0f); glVertex3f(-1.0f,-1.0f,0.0f); glVertex3f(0.0f,0.0f,0.0f); glVertex3f(0.0f,0.0f,-3.0f); glVertex3f(0.0f,0.0f,-3.0f); glVertex3f(0.0f,-0.1f,-2.8f); glVertex3f(0.0f,0.0f,-3.0f); glVertex3f(0.0f,0.1f,-2.8f); //these just for fun...... glVertex3f(-0.3f,0.5f,0.0f); glVertex3f(-0.85f,-0.3f,0.0f); glVertex3f(0.3f,0.5f,0.0f); glVertex3f(0.85f,-0.3f,0.0f); glVertex3f(-0.4f,-1.0f,0.0f); glVertex3f(-0.4f,-0.2f,0.0f); glVertex3f(-0.4f,-0.2f,0.0f); glVertex3f(0.4f,-0.2f,0.0f); glVertex3f(0.4f,-0.2f,0.0f); glVertex3f(0.4f,-1.0f,0.0f); glEnd(); view.endGL(); }
//MStatus pointLightNode::compute(const MPlug &plug, MDataBlock &data) //{ // MStatus stat; // return stat=MStatus::kSuccess; //} void pointLightNode::draw(M3dView &view, const MDagPath &path, M3dView::DisplayStyle style, M3dView::DisplayStatus status) { MColor drawColor; drawColor.set(MColor::kRGB,1,1,0); if (status==M3dView::kDormant) { drawColor.set(MColor::kRGB,1,0,0); } if (status==M3dView::kTemplate) { drawColor.set(MColor::kRGB,0,1,0); } view.setDrawColor(drawColor); view.beginGL(); glBegin(GL_LINES); glVertex3f(0.0f,0.1f,0.0f); glVertex3f(0.1f,0.0f,0.0f); glVertex3f(0.0f,0.1f,0.0f); glVertex3f(-0.1f,0.0f,0.0f); glVertex3f(0.0f,0.1f,0.0f); glVertex3f(0.0f,0.0f,0.1f); glVertex3f(0.0f,0.1f,0.0f); glVertex3f(0.0f,0.0f,-0.1f); glVertex3f(0.0f,-0.1f,0.0f); glVertex3f(0.1f,0.0f,0.0f); glVertex3f(0.0f,-0.1f,0.0f); glVertex3f(-0.1f,0.0f,0.0f); glVertex3f(0.0f,-0.1f,0.0f); glVertex3f(0.0f,0.0f,0.1f); glVertex3f(0.0f,-0.1f,0.0f); glVertex3f(0.0f,0.0f,-0.1f); glVertex3f(-0.1f,0.0f,0.0f); glVertex3f(0.0f,0.0f,0.1f); glVertex3f(0.0f,0.0f,0.1f); glVertex3f(0.1f,0.0f,0.0f); glVertex3f(0.1f,0.0f,0.0f); glVertex3f(0.0f,0.0f,-0.1f); glVertex3f(0.0f,0.0f,-0.1f); glVertex3f(-0.1f,0.0f,0.0f); glEnd(); view.endGL(); }
void curvedArrows::drawEdgeLoop( M3dView &view, M3dView::DisplayStatus status ) { glPushAttrib( GL_CURRENT_BIT ); if ( status == M3dView::kActive ) { view.setDrawColor( 13, M3dView::kActiveColors ); } else { view.setDrawColor( 13, M3dView::kDormantColors ); } glBegin( GL_LINE_LOOP ); unsigned int i; for ( i = 0; i < fsEdgeLoopSize; i ++ ) { glVertex3d( fsVertexList[fsEdgeLoop[i]][0], fsVertexList[fsEdgeLoop[i]][1], fsVertexList[fsEdgeLoop[i]][2]); } glEnd(); glPopAttrib(); }
//- 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(); }
void sphereLightNode::draw(M3dView &view, const MDagPath &path, M3dView::DisplayStyle style, M3dView::DisplayStatus status) { MFnDagNode sphereFn(thisMObject()); MPlug radiusPlug=sphereFn.findPlug(sphereRadius); float radius; radiusPlug.getValue(radius); MColor drawColor; drawColor.set(MColor::kRGB,1,1,0); if (status==M3dView::kDormant) { drawColor.set(MColor::kRGB,1,0,0); } if (status==M3dView::kTemplate) { drawColor.set(MColor::kRGB,0,1,0); } view.setDrawColor(drawColor); MFloatVectorArray points(36); for (int i=0; i<36; i++) { float sphereArc=i*10*PI/180; points[i].x=radius*sin(sphereArc); points[i].y=radius*cos(sphereArc); points[i].z=0.0; } view.beginGL(); glBegin(GL_LINE_LOOP); for(int i=0;i<36;i++) { glVertex3f(points[i].x,points[i].y,0.0); } glEnd(); glBegin(GL_LINE_LOOP); for(int i=0;i<36;i++) { glVertex3f(points[i].x,(points[i].y)*cos(60*PI/180),(points[i].y)*sin(60*PI/180)); } glEnd(); glBegin(GL_LINE_LOOP); for(int i=0;i<36;i++) { glVertex3f(points[i].x,(points[i].y)*cos(60*PI/180),-(points[i].y)*sin(60*PI/180)); } glEnd(); glBegin(GL_LINE_LOOP); for(int i=0;i<36;i++) { glVertex3f((points[i].x)*sin(60*PI/180),points[i].y,(points[i].x)*cos(60*PI/180)); } glBegin(GL_LINE_LOOP); for(int i=0;i<36;i++) { glVertex3f(-(points[i].x)*sin(60*PI/180),points[i].y,(points[i].x)*cos(60*PI/180)); } glEnd(); view.endGL(); }
// called by legacy default viewport void footPrint::draw( M3dView & view, const MDagPath & /*path*/, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { // Get the size // MObject thisNode = thisMObject(); MPlug plug( thisNode, size ); MDistance sizeVal; plug.getValue( sizeVal ); float multiplier = (float) sizeVal.asCentimeters(); view.beginGL(); if ( ( style == M3dView::kFlatShaded ) || ( style == M3dView::kGouraudShaded ) ) { // Push the color settings // glPushAttrib( GL_CURRENT_BIT ); if ( status == M3dView::kActive ) { view.setDrawColor( 13, M3dView::kActiveColors ); } else { view.setDrawColor( 13, M3dView::kDormantColors ); } glBegin( GL_TRIANGLE_FAN ); int i; int last = soleCount - 1; for ( i = 0; i < last; ++i ) { glVertex3f( sole[i][0] * multiplier, sole[i][1] * multiplier, sole[i][2] * multiplier ); } glEnd(); glBegin( GL_TRIANGLE_FAN ); last = heelCount - 1; for ( i = 0; i < last; ++i ) { glVertex3f( heel[i][0] * multiplier, heel[i][1] * multiplier, heel[i][2] * multiplier ); } glEnd(); glPopAttrib(); } // Draw the outline of the foot // glBegin( GL_LINES ); int i; int last = soleCount - 1; for ( i = 0; i < last; ++i ) { glVertex3f( sole[i][0] * multiplier, sole[i][1] * multiplier, sole[i][2] * multiplier ); glVertex3f( sole[i+1][0] * multiplier, sole[i+1][1] * multiplier, sole[i+1][2] * multiplier ); } last = heelCount - 1; for ( i = 0; i < last; ++i ) { glVertex3f( heel[i][0] * multiplier, heel[i][1] * multiplier, heel[i][2] * multiplier ); glVertex3f( heel[i+1][0] * multiplier, heel[i+1][1] * multiplier, heel[i+1][2] * multiplier ); } glEnd(); view.endGL(); // Draw the name of the footPrint view.setDrawColor( MColor( 0.1f, 0.8f, 0.8f, 1.0f ) ); view.drawText( MString("Footprint"), MPoint( 0.0, 0.0, 0.0 ), M3dView::kCenter ); }
void EntityInstanceNode::draw( M3dView & view, const MDagPath & path, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { MStatus stat; // Check whether need to redo points if (s_PointerPoints.length()) { if (s_PointerYUp != MGlobal::isYAxisUp()) { // Store the up axis s_PointerYUp = MGlobal::isYAxisUp(); // Points are for Y-UP float pointerVerts[][4] = { {-200, -100, 0, 1}, {-200, 0, 100, 1}, {-200, 0, 100, 1}, {-200, 100, 0, 1}, {-200, 100, 0, 1}, { 0, 0, 0, 1}, { 0, 0, 0, 1}, {-200, -100, 0, 1}, {-200, 0, 100, 1}, { 0, 0, 0, 1}, {-200, -100, 0, 1}, {-200, 100, 0, 1} }; s_PointerPoints = MPointArray(pointerVerts, 12); // Flip the points if Y-Up if (s_PointerYUp) { for(unsigned i = 0; i < s_PointerPoints.length(); ++i) { MPoint p = s_PointerPoints[i]; s_PointerPoints[i].x = p.y; s_PointerPoints[i].y = p.z; s_PointerPoints[i].z = p.x; } } } } // Go ahead and draw pointer selected if this instance is selected switch (status) { case M3dView::kDormant: { stat = view.setDrawColor(s_DrawColor); MErr(stat, "Unable to do: view.setDrawColor"); break; } case M3dView::kTemplate: { MColor templateColor = view.templateColor(&stat); MErr(stat, "Unable to do: view.templateColor"); stat = view.setDrawColor(templateColor); MErr(stat, "Unable to do: view.setDrawColor"); break; } default: { stat = view.setDrawColor(15, M3dView::kActiveColors); MErr(stat, "Unable to do: view.setDrawColor"); break; } } glPushMatrix(); { glBegin( GL_LINES ); { u32 len = s_PointerPoints.length(); for( unsigned i = 0; i < len; i += 2 ) { glVertex3f((GLfloat)s_PointerPoints[i].x, (GLfloat)s_PointerPoints[i].y, (GLfloat)s_PointerPoints[i].z); glVertex3f((GLfloat)s_PointerPoints[i+1].x, (GLfloat)s_PointerPoints[i+1].y, (GLfloat)s_PointerPoints[i+1].z); } } glEnd(); } glPopMatrix(); }
void Point::draw(M3dView& view, const MDagPath& mdag_path, M3dView::DisplayStyle display_style, M3dView::DisplayStatus display_status) { MObject self = thisMObject(); int display = MPlug(self, input_display).asInt(); if (display == 0) { return; } int use_box = MPlug(self, input_box).asInt(); int use_cross = MPlug(self, input_cross).asInt(); int use_tick = MPlug(self, input_tick).asInt(); int use_axis = MPlug(self, input_axis).asInt(); int color_index = MPlug(self, input_color).asInt(); float tx = MPlug(self, Point::localPositionX).asFloat(); float ty = MPlug(self, Point::localPositionY).asFloat(); float tz = MPlug(self, Point::localPositionZ).asFloat(); float sx = MPlug(self, Point::localScaleX).asFloat(); float sy = MPlug(self, Point::localScaleY).asFloat(); float sz = MPlug(self, Point::localScaleZ).asFloat(); MColor color; switch (display_status) { case M3dView::kActive: color = MColor(1.0f, 1.0f, 1.0f); break; case M3dView::kLead: color = MColor(0.26f, 1.0f, 0.64f); break; case M3dView::kActiveAffected: color = MColor(0.783999979496f, 0.0f, 0.783999979496f); break; case M3dView::kTemplate: color = MColor(0.469999998808f, 0.469999998808f, 0.469999998808f); break; case M3dView::kActiveTemplate: color = MColor(1.0f, 0.689999997616f, 0.689999997616f); break; default: color = colors[color_index]; } view.beginGL(); if (use_axis == 1) { view.setDrawColor(MColor(1.0, 0, 0)); view.drawText("x", MPoint(sx + tx, ty, tz), M3dView::kCenter); view.setDrawColor(MColor(0, 1.0, 0)); view.drawText("y", MPoint(tx, sy + ty, tz), M3dView::kCenter); view.setDrawColor(MColor(0, 0, 1.0)); view.drawText("z", MPoint(tx, ty, sz + tz), M3dView::kCenter); } glPushAttrib(GL_CURRENT_BIT); glEnable(GL_BLEND); glBegin(GL_LINES); if (use_box == 1) { glColor3f(color.r, color.g, color.b); // Top glVertex3f(-sx + tx, sy + ty, -sz + tz); glVertex3f(sx + tx, sy + ty, -sz + tz); glVertex3f(sx + tx, sy + ty, -sz + tz); glVertex3f(sx + tx, sy + ty, sz + tz); glVertex3f(sx + tx, sy + ty, sz + tz); glVertex3f(-sx + tx, sy + ty, sz + tz); glVertex3f(-sx + tx, sy + ty, sz + tz); glVertex3f(-sx + tx, sy + ty, -sz + tz); // Bottom glVertex3f(-sx + tx, -sy + ty, -sz + tz); glVertex3f(sx + tx, -sy + ty, -sz + tz); glVertex3f(sx + tx, -sy + ty, -sz + tz); glVertex3f(sx + tx, -sy + ty, sz + tz); glVertex3f(sx + tx, -sy + ty, sz + tz); glVertex3f(-sx + tx, -sy + ty, sz + tz); glVertex3f(-sx + tx, -sy + ty, sz + tz); glVertex3f(-sx + tx, -sy + ty, -sz + tz); // Left glVertex3f(-sx + tx, -sy + ty, -sz + tz); glVertex3f(-sx + tx, sy + ty, -sz + tz); glVertex3f(-sx + tx, sy + ty, -sz + tz); glVertex3f(-sx + tx, sy + ty, sz + tz); glVertex3f(-sx + tx, sy + ty, sz + tz); glVertex3f(-sx + tx, -sy + ty, sz + tz); glVertex3f(-sx + tx, -sy + ty, sz + tz); glVertex3f(-sx + tx, -sy + ty, -sz + tz); // Right glVertex3f(sx + tx, -sy + ty, -sz + tz); glVertex3f(sx + tx, sy + ty, -sz + tz); glVertex3f(sx + tx, sy + ty, -sz + tz); glVertex3f(sx + tx, sy + ty, sz + tz); glVertex3f(sx + tx, sy + ty, sz + tz); glVertex3f(sx + tx, -sy + ty, sz + tz); glVertex3f(sx + tx, -sy + ty, sz + tz); glVertex3f(sx + tx, -sy + ty, -sz + tz); } if (use_cross == 1) { glColor3f(color.r, color.g, color.b); glVertex3f(tx, -sy + ty, tz); glVertex3f(tx, sy + ty, tz); glVertex3f(-sx + tx, ty, tz); glVertex3f(sx + tx, ty, tz); glVertex3f(tx, ty, -sz + tz); glVertex3f(tx, ty, sz + tz); } if (use_tick == 1) { glColor3f(color.r, color.g, color.b); glVertex3f((-sx*0.05f) + tx, (sy*0.05f) + ty, tz); glVertex3f((sx*0.05f) + tx, (-sy*0.05f) + ty, tz); glVertex3f((sx*0.05f) + tx, (sy*0.05f) + ty, tz); glVertex3f((-sx*0.05f) + tx, (-sy*0.05f) + ty, tz); glVertex3f(tx, (sy*0.05f) + ty, (-sz*0.05f) + tz); glVertex3f(tx, (-sy*0.05f) + ty, (sz*0.05f) + tz); glVertex3f(tx, (sy*0.05f) + ty, (sz*0.05f) + tz); glVertex3f(tx, (-sy*0.05f) + ty, (-sz*0.05f) + tz); glVertex3f((sx*0.05f) + tx, ty, (-sz*0.05f) + tz); glVertex3f((-sx*0.05f) + tx, ty, (sz*0.05f) + tz); glVertex3f((sx*0.05f) + tx, ty, (sz*0.05f) + tz); glVertex3f((-sx*0.05f) + tx, ty, (-sz*0.05f) + tz); } if (use_axis == 1) { glColor3f(color.r, color.g, color.b); if (display_status == M3dView::kDormant) { glColor3f(1.0f, 0.0f, 0.0f); } glVertex3f(tx, ty, tz); glVertex3f(sx + tx, ty, tz); if (display_status == M3dView::kDormant) { glColor3f(0.0f, 1.0f, 0.0f); } glVertex3f(tx, ty, tz); glVertex3f(tx, sy + ty, tz); if (display_status == M3dView::kDormant) { glColor3f(0.0f, 0.0f, 1.0f); } glVertex3f(tx, ty, tz); glVertex3f(tx, ty, sz + tz); } glEnd(); glDisable(GL_BLEND); glPopAttrib(); view.endGL(); }
void cvColor::draw( M3dView & view, const MDagPath & path, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { // cout << "cvColor::draw\n"; MStatus stat; MObject thisNode = thisMObject(); MPlug enPlug( thisNode, drawingEnabled ); bool doDrawing; stat = enPlug.getValue ( doDrawing ); if (!stat) { stat.perror("cvColor::draw get drawingEnabled"); return; } if (!doDrawing) return; MPlug szPlug( thisNode, pointSize ); float ptSize; stat = szPlug.getValue ( ptSize ); if (!stat) { stat.perror("cvColor::draw get pointSize"); ptSize = 4.0; } MPlug cvPlug( thisNode, cvLocations ); MObject cvObject; stat = cvPlug.getValue(cvObject); if (!stat) { stat.perror("cvColor::draw get cvObject"); return; } MFnPointArrayData cvData(cvObject, &stat); if (!stat) { stat.perror("cvColor::draw get point array data"); return; } MPointArray cvs = cvData.array( &stat ); if (!stat) { stat.perror("cvColor::draw get point array"); return; } // Extract the 'worldMatrix' attribute that is inherited from 'dagNode' // MFnDependencyNode fnThisNode( thisNode ); MObject worldSpaceAttribute = fnThisNode.attribute( "worldMatrix" ); MPlug matrixPlug( thisNode, worldSpaceAttribute); // 'worldMatrix' is an array so we must specify which element the plug // refers to matrixPlug = matrixPlug.elementByLogicalIndex (0); // Get the value of the 'worldMatrix' attribute // MObject matObject; stat = matrixPlug.getValue(matObject); if (!stat) { stat.perror("cvColor::draw get matObject"); return; } MFnMatrixData matrixData(matObject, &stat); if (!stat) { stat.perror("cvColor::draw get world matrix data"); return; } MMatrix worldSpace = matrixData.matrix( &stat ); if (!stat) { stat.perror("cvColor::draw get world matrix"); return; } if ( view.isColorIndexMode() ) { cerr << "Can't update cv colors in color index mode\n"; return; } view.beginGL(); // Push the color settings // glPushAttrib( GL_CURRENT_BIT | GL_POINT_BIT ); glPointSize( ptSize ); glDisable ( GL_POINT_SMOOTH ); // Draw square "points" glBegin( GL_POINTS ); int numCVs = cvs.length(); for (int i = 0; i < numCVs; i++) { // cout << "cv[" << i << "]: " << cvs[i] << ": "; MPoint cv( cvs[i] ); MColor cvColor; cv *= worldSpace; if (cv.x < 0 && cv.y < 0) { // cout << "Red"; cvColor.r = 1.0; cvColor.g = 0.0; cvColor.b = 0.0; } else if (cv.x < 0 && cv.y >= 0) { // cout << "Cyan"; cvColor.r = 0.0; cvColor.g = 1.0; cvColor.b = 1.0; } else if (cv.x >= 0 && cv.y < 0) { // cout << "Blue"; cvColor.r = 0.0; cvColor.g = 0.0; cvColor.b = 1.0; } else if (cv.x >= 0 && cv.y >= 0) { // cout << "Yellow"; cvColor.r = 1.0; cvColor.g = 1.0; cvColor.b = 0.0; } // cout << endl; view.setDrawColor ( cvColor ); glVertex3f( (float)cvs[i].x, (float)cvs[i].y, (float)cvs[i].z); } glEnd(); glPopAttrib(); view.endGL(); }
void liqBoundingBoxLocator::draw( M3dView & view, const MDagPath & path, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { MFnDagNode dagFn( thisMObject() ); MFnDagNode transFn( dagFn.parent( 0 ) ); MStatus stat; bool drawBox( 0 ); MPlug plug = dagFn.findPlug( "drawBox", stat ); if ( stat == MS::kSuccess ) plug.getValue( drawBox ); if ( !drawBox ) return; MDoubleArray bb( 6 ); MGlobal::executeCommand( MString( "exactWorldBoundingBox " ) + transFn.fullPathName(), bb ); pts = shared_array< MPoint >( new MPoint[ 8 ] ); pts[0].x = bb[0]; pts[0].y = bb[4]; pts[0].z = bb[2]; pts[1].x = bb[0]; pts[1].y = bb[4]; pts[1].z = bb[5]; pts[2].x = bb[3]; pts[2].y = bb[4]; pts[2].z = bb[5]; pts[3].x = bb[3]; pts[3].y = bb[4]; pts[3].z = bb[2]; pts[4].x = bb[0]; pts[4].y = bb[1]; pts[4].z = bb[2]; pts[5].x = bb[0]; pts[5].y = bb[1]; pts[5].z = bb[5]; pts[6].x = bb[3]; pts[6].y = bb[1]; pts[6].z = bb[5]; pts[7].x = bb[3]; pts[7].y = bb[1]; pts[7].z = bb[2]; MMatrix m( path.inclusiveMatrix() ); for( unsigned i( 0 ); i < 8; i++ ) pts[i] *= m.inverse(); // draw box view.beginGL(); view.setDrawColor( MColor( .57f, 0, .57f ) ); glPushAttrib( GL_CURRENT_BIT ); glBegin(GL_LINE_STRIP); glVertex3f( (float)pts[0].x, (float)pts[0].y, (float)pts[0].z ); glVertex3f( (float)pts[1].x, (float)pts[1].y, (float)pts[1].z ); glVertex3f( (float)pts[2].x, (float)pts[2].y, (float)pts[2].z ); glVertex3f( (float)pts[3].x, (float)pts[3].y, (float)pts[3].z ); glVertex3f( (float)pts[0].x, (float)pts[0].y, (float)pts[0].z ); glEnd(); glBegin(GL_LINE_STRIP); glVertex3f( (float)pts[4].x, (float)pts[4].y, (float)pts[4].z ); glVertex3f( (float)pts[5].x, (float)pts[5].y, (float)pts[5].z ); glVertex3f( (float)pts[6].x, (float)pts[6].y, (float)pts[6].z ); glVertex3f( (float)pts[7].x, (float)pts[7].y, (float)pts[7].z ); glVertex3f( (float)pts[4].x, (float)pts[4].y, (float)pts[4].z ); glEnd(); glBegin(GL_LINE_STRIP); glVertex3f( (float)pts[0].x, (float)pts[0].y, (float)pts[0].z ); glVertex3f( (float)pts[4].x, (float)pts[4].y, (float)pts[4].z ); glEnd(); glBegin(GL_LINE_STRIP); glVertex3f( (float)pts[1].x, (float)pts[1].y, (float)pts[1].z ); glVertex3f( (float)pts[5].x, (float)pts[5].y, (float)pts[5].z ); glEnd(); glBegin(GL_LINE_STRIP); glVertex3f( (float)pts[2].x, (float)pts[2].y, (float)pts[2].z ); glVertex3f( (float)pts[6].x, (float)pts[6].y, (float)pts[6].z ); glEnd(); glBegin(GL_LINE_STRIP); glVertex3f( (float)pts[3].x, (float)pts[3].y, (float)pts[3].z ); glVertex3f( (float)pts[7].x, (float)pts[7].y, (float)pts[7].z ); glEnd(); view.endGL(); }
void swissArmyLocator::draw(M3dView &view, const MDagPath &/*path*/, M3dView::DisplayStyle style, M3dView::DisplayStatus status) { // Get the size // MObject thisNode = thisMObject(); MPlug plug(thisNode, aSize); MDistance sizeVal; plug.getValue(sizeVal); MPlug arrow1AnglePlug(thisNode, aArrow1Angle); MAngle arrow1Angle; arrow1AnglePlug.getValue(arrow1Angle); double angle1 = -arrow1Angle.asRadians() - 3.1415927/2.0; MPlug arrow3AnglePlug(thisNode, aArrow3Angle); MAngle arrow3Angle; arrow3AnglePlug.getValue(arrow3Angle); double angle3 = arrow3Angle.asRadians(); MPlug statePlug(thisNode, aState); int state; statePlug.getValue(state); MPlug togglePlug(thisNode, aToggle); bool toggle; togglePlug.getValue(toggle); MPlug directionXPlug(thisNode, aArrow2DirectionX); MPlug directionYPlug(thisNode, aArrow2DirectionY); MPlug directionZPlug(thisNode, aArrow2DirectionZ); double dirX; double dirY; double dirZ; directionXPlug.getValue(dirX); directionYPlug.getValue(dirY); directionZPlug.getValue(dirZ); double angle2 = atan2(dirZ,dirX); angle2 += 3.1415927; float multiplier = (float) sizeVal.asCentimeters(); view.beginGL(); if ((style == M3dView::kFlatShaded) || (style == M3dView::kGouraudShaded)) { // Push the color settings // glPushAttrib(GL_CURRENT_BIT); if (status == M3dView::kActive) { view.setDrawColor(13, M3dView::kActiveColors); } else { view.setDrawColor(13, M3dView::kDormantColors); } int i; int last; if (toggle) { if (status == M3dView::kActive) view.setDrawColor(15, M3dView::kActiveColors); else view.setDrawColor(15, M3dView::kDormantColors); glBegin(GL_TRIANGLE_FAN); last = centreCount - 1; for (i = 0; i < last; ++i) { glVertex3f(centre[i][0] * multiplier, centre[i][1] * multiplier, centre[i][2] * multiplier); } glEnd(); } if (state == 0) { if (status == M3dView::kActive) view.setDrawColor(19, M3dView::kActiveColors); else view.setDrawColor(19, M3dView::kDormantColors); glBegin(GL_TRIANGLE_FAN); last = state1Count - 1; for (i = 0; i < last; ++i) { glVertex3f(state1[i][0] * multiplier, state1[i][1] * multiplier, state1[i][2] * multiplier); } glEnd(); } if (state == 1) { if (status == M3dView::kActive) view.setDrawColor(21, M3dView::kActiveColors); else view.setDrawColor(21, M3dView::kDormantColors); glBegin(GL_TRIANGLE_FAN); last = state2Count - 1; for (i = 0; i < last; ++i) { glVertex3f(state2[i][0] * multiplier, state2[i][1] * multiplier, state2[i][2] * multiplier); } glEnd(); } if (state == 2) { if (status == M3dView::kActive) view.setDrawColor(18, M3dView::kActiveColors); else view.setDrawColor(18, M3dView::kDormantColors); glBegin(GL_TRIANGLE_FAN); last = state3Count - 1; for (i = 0; i < last; ++i) { glVertex3f(state3[i][0] * multiplier, state3[i][1] * multiplier, state3[i][2] * multiplier); } glEnd(); } if (state == 3) { if (status == M3dView::kActive) view.setDrawColor(17, M3dView::kActiveColors); else view.setDrawColor(17, M3dView::kDormantColors); glBegin(GL_TRIANGLE_FAN); last = state4Count - 1; for (i = 0; i < last; ++i) { glVertex3f(state4[i][0] * multiplier, state4[i][1] * multiplier, state4[i][2] * multiplier); } glEnd(); } if (status == M3dView::kActive) view.setDrawColor(12, M3dView::kActiveColors); else view.setDrawColor(12, M3dView::kDormantColors); glBegin(GL_TRIANGLE_FAN); last = arrow1Count - 1; for (i = 0; i < last; ++i) { glVertex3f( (float) (- arrow1[i][0] * multiplier * cos(angle1) - arrow1[i][2] * multiplier * sin(angle1)), (float) (arrow1[i][1] * multiplier + delta1), (float) (arrow1[i][2] * multiplier * cos(angle1) - arrow1[i][0] * multiplier * sin(angle1))); } glEnd(); if (status == M3dView::kActive) view.setDrawColor(16, M3dView::kActiveColors); else view.setDrawColor(16, M3dView::kDormantColors); glBegin(GL_TRIANGLE_FAN); last = arrow2Count - 1; for (i = 0; i < last; ++i) { glVertex3f( (float) (- arrow2[i][0] * multiplier * cos(angle2) - arrow2[i][2] * multiplier * sin(angle2)), (float) (arrow2[i][1] * multiplier + delta2), (float) (arrow2[i][2] * multiplier * cos(angle2) - arrow2[i][0] * multiplier * sin(angle2))); } glEnd(); if (status == M3dView::kActive) view.setDrawColor(13, M3dView::kActiveColors); else view.setDrawColor(13, M3dView::kDormantColors); glBegin(GL_TRIANGLE_FAN); last = arrow3Count - 1; for (i = 0; i < last; ++i) { glVertex3f( (float) (- arrow3[i][0] * multiplier * cos(angle3) - arrow3[i][2] * multiplier * sin(angle3)), (float) (arrow3[i][1] * multiplier + delta3), (float) (arrow3[i][2] * multiplier * cos(angle3) - arrow3[i][0] * multiplier * sin(angle3))); } glEnd(); if (status == M3dView::kActive) view.setDrawColor(5, M3dView::kActiveColors); else view.setDrawColor(5, M3dView::kDormantColors); glBegin(GL_TRIANGLE_FAN); last = arrow4Count - 1; for (i = 0; i < last; ++i) { glVertex3f((float) (arrow4[i][0] * multiplier), (float) (arrow4[i][1] * multiplier + delta4), (float) (arrow4[i][2] * multiplier)); } glEnd(); glPopAttrib(); } // Draw the outline of the locator // glBegin(GL_LINES); int i; int last; if (toggle) { last = centreCount - 1; for (i = 0; i < last; ++i) { glVertex3f(centre[i][0] * multiplier, centre[i][1] * multiplier, centre[i][2] * multiplier); glVertex3f(centre[i+1][0] * multiplier, centre[i+1][1] * multiplier, centre[i+1][2] * multiplier); } } if (state == 0) { last = state1Count - 1; for (i = 0; i < last; ++i) { glVertex3f(state1[i][0] * multiplier, state1[i][1] * multiplier, state1[i][2] * multiplier); glVertex3f(state1[i+1][0] * multiplier, state1[i+1][1] * multiplier, state1[i+1][2] * multiplier); } } if (state == 1) { last = state2Count - 1; for (i = 0; i < last; ++i) { glVertex3f(state2[i][0] * multiplier, state2[i][1] * multiplier, state2[i][2] * multiplier); glVertex3f(state2[i+1][0] * multiplier, state2[i+1][1] * multiplier, state2[i+1][2] * multiplier); } } if (state == 2) { last = state3Count - 1; for (i = 0; i < last; ++i) { glVertex3f(state3[i][0] * multiplier, state3[i][1] * multiplier, state3[i][2] * multiplier); glVertex3f(state3[i+1][0] * multiplier, state3[i+1][1] * multiplier, state3[i+1][2] * multiplier); } } if (state == 3) { last = state4Count - 1; for (i = 0; i < last; ++i) { glVertex3f(state4[i][0] * multiplier, state4[i][1] * multiplier, state4[i][2] * multiplier); glVertex3f(state4[i+1][0] * multiplier, state4[i+1][1] * multiplier, state4[i+1][2] * multiplier); } } last = arrow1Count - 1; for (i = 0; i < last; ++i) { glVertex3f((float) (- arrow1[i][0] * multiplier * cos(angle1) - arrow1[i][2] * multiplier * sin(angle1)), (float) (arrow1[i][1] * multiplier + delta1), (float) (arrow1[i][2] * multiplier * cos(angle1) - arrow1[i][0] * multiplier * sin(angle1))); glVertex3f((float) (- arrow1[i+1][0] * multiplier * cos(angle1) - arrow1[i+1][2] * multiplier * sin(angle1)), (float) (arrow1[i+1][1] * multiplier + delta1), (float) (arrow1[i+1][2] * multiplier * cos(angle1) - arrow1[i+1][0] * multiplier * sin(angle1))); } last = arrow2Count - 1; for (i = 0; i < last; ++i) { glVertex3f((float) (- arrow2[i][0] * multiplier * cos(angle2) - arrow2[i][2] * multiplier * sin(angle2)), (float) (arrow2[i][1] * multiplier + delta2), (float) (arrow2[i][2] * multiplier * cos(angle2) - arrow2[i][0] * multiplier * sin(angle2))); glVertex3f((float) (- arrow2[i+1][0] * multiplier * cos(angle2) - arrow2[i+1][2] * multiplier * sin(angle2)), (float) (arrow2[i+1][1] * multiplier + delta2), (float) (arrow2[i+1][2] * multiplier * cos(angle2) - arrow2[i+1][0] * multiplier * sin(angle2))); } last = arrow3Count - 1; for (i = 0; i < last; ++i) { glVertex3f((float) (- arrow3[i][0] * multiplier * cos(angle3) - arrow3[i][2] * multiplier * sin(angle3)), (float) (arrow3[i][1] * multiplier + delta3), (float) (arrow3[i][2] * multiplier * cos(angle3) - arrow3[i][0] * multiplier * sin(angle3))); glVertex3f((float) (- arrow3[i+1][0] * multiplier * cos(angle3) - arrow3[i+1][2] * multiplier * sin(angle3)), (float) (arrow3[i+1][1] * multiplier + delta3), (float) (arrow3[i+1][2] * multiplier * cos(angle3) - arrow3[i+1][0] * multiplier * sin(angle3))); } last = arrow4Count - 1; for (i = 0; i < last; ++i) { glVertex3f((float) (arrow4[i][0] * multiplier), (float) (arrow4[i][1] * multiplier + delta4), (float) (arrow4[i][2] * multiplier)); glVertex3f((float) (arrow4[i+1][0] * multiplier), (float) (arrow4[i+1][1] * multiplier + delta4), (float) (arrow4[i+1][2] * multiplier)); } last = perimeterCount - 1; for (i = 0; i < last; ++i) { glVertex3f(perimeter[i][0] * multiplier, perimeter[i][1] * multiplier, perimeter[i][2] * multiplier); glVertex3f(perimeter[i+1][0] * multiplier, perimeter[i+1][1] * multiplier, perimeter[i+1][2] * multiplier); } glEnd(); view.endGL(); }