void BasicLocator::draw( M3dView & view, const MDagPath & path, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { view.beginGL(); glPushAttrib( GL_CURRENT_BIT ); MPointArray pts; getCirclePoints( pts ); glBegin(GL_LINE_STRIP); for( unsigned int i=0; i < pts.length(); i++ ) glVertex3f( float(pts[i].x), float(pts[i].y), float(pts[i].z) ); glEnd(); glBegin(GL_LINES); glVertex3f( -0.5f, 0.0f, 0.0f ); glVertex3f( 0.5f, 0.0f, 0.0f ); glVertex3f( 0.0f, 0.0f, -0.5f ); glVertex3f( 0.0f, 0.0f, 0.5f ); glEnd(); glPopAttrib(); view.endGL(); }
void kgLocator::draw( M3dView & view, const MDagPath & path, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { MStatus stat; //First get the value of the height attribute //of the assocuated locator MObject thisNode = thisMObject(); MFnDagNode dagFn( thisNode ); MPlug heightPlug = dagFn.findPlug( height, &stat ); float heightValue; heightPlug.getValue( heightValue ); view.beginGL(); glPushAttrib( GL_CURRENT_BIT ); glBegin( GL_LINES ); //Draw a cross for(unsigned int i=0; i < pts.length(); i+= 2 ) { glVertex3f(pts[i].x, pts[i].y, pts[i].z ); glVertex3f(pts[i+1].x, pts[i+1].y, pts[i+1].z ); } //And a vertical spindle //of the same height as //the height attribute glVertex3f( 0.0f, 0.0f, 0.0f ); glVertex3f( 0.0f, heightValue, 0.0f ); glEnd(); glPopAttrib(); view.endGL(); }
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(); }
// Load the vertexProgram and fill in the necessary constants used in the vertex program. // void hwRefractReflectShader_NV20::loadVertexProgramGL( M3dView& view ) { view.beginGL(); { // Don't load/initialize the vertex program more than once. // if (vertex_program_id == 0) initVertexProgram(vertexProgramString, &vertex_program_id); // Set up the constant values. // // CONSTANTS: // 0- 3 4x4 ModelView-Projection composite matrix // 4- 7 4x4 ModelView inverseTranspose matrix // 8- 11 4x4 ModelView matrix // 12-15 4x4 Texture matrix // glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 0, GL_MODELVIEW_PROJECTION_NV, GL_IDENTITY_NV); glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 4, GL_MODELVIEW, GL_INVERSE_TRANSPOSE_NV); glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 8, GL_MODELVIEW, GL_IDENTITY_NV); glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 12, GL_TEXTURE, GL_IDENTITY_NV); float rIdx = fRefractionIndex; glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 58, rIdx, rIdx*rIdx, 0.0, 0.0); // refraction index glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 59, 0.0, 0.0, 0.0, 1.0); // eye position glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 64, 0.0, 1.0, 2.0, 3.0); // misc constants } view.endGL(); }
void octreeVizNode::draw( M3dView & view, const MDagPath & /*path*/, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { MDagPath camera; view = M3dView::active3dView(); view.getCamera(camera); MATRIX44F mat; double clipNear, clipFar, fov; int ispersp; parseCamera(camera, mat, clipNear, clipFar, fov, ispersp); view.beginGL(); glPushAttrib(GL_ALL_ATTRIB_BITS); glShadeModel(GL_SMOOTH); glPointSize(3); if(m_pTex) { XYZ ori(0,0,0); m_pTex->setProjection(mat, fov, ispersp); int port[4]; glGetIntegerv(GL_VIEWPORT, port); m_pTex->setPortWidth(port[2]); m_pTex->drawCube(); m_pTex->testRaster(ori); } glPopAttrib(); view.endGL(); }
void fishVizNode::draw( M3dView & view, const MDagPath & /*path*/, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { view.beginGL(); glPushAttrib(GL_ALL_ATTRIB_BITS); unsigned num_ptc = ptc_positions.length(); glBegin(GL_LINES); glColor3f(0,0,1); for(unsigned i=0; i<num_ptc; i++) { glVertex3f(ptc_positions[i].x, ptc_positions[i].y, ptc_positions[i].z); glVertex3f(ptc_positions[i].x+ptc_velocities[i].x, ptc_positions[i].y+ptc_velocities[i].y, ptc_positions[i].z+ptc_velocities[i].z); } //glColor3f(0,1,0); //for(unsigned i=0; i<num_ptc; i++) //{ // glVertex3f(ptc_positions[i].x, ptc_positions[i].y, ptc_positions[i].z); // glVertex3f(ptc_positions[i].x+ptc_ups[i].x*m_fish_length, ptc_positions[i].y+ptc_ups[i].y*m_fish_length, ptc_positions[i].z+ptc_ups[i].z*m_fish_length); //} glColor3f(1,0,0); for(unsigned i=0; i<num_ptc; i++) { glVertex3f(ptc_positions[i].x, ptc_positions[i].y, ptc_positions[i].z); glVertex3f(ptc_positions[i].x-ptc_views[i].x*m_fish_length, ptc_positions[i].y-ptc_views[i].y*m_fish_length, ptc_positions[i].z-ptc_views[i].z*m_fish_length); } glEnd(); glPopAttrib(); view.endGL(); }
void MannequinMoveManipulator::draw(M3dView &view, const MDagPath &path, M3dView::DisplayStyle style, M3dView::DisplayStatus status) { static MGLFunctionTable *gGLFT = 0; if (0 == gGLFT) { gGLFT = MHardwareRenderer::theRenderer()->glFunctionTable(); } recalcMetrics(); float size = _manipScale * MFnManip3D::globalSize(); float handleSize = MFnManip3D::handleSize() / 100.0f; // Probably on [0, 100]. float handleHeight = size * handleSize * 0.5f; float handleOfs = size - handleHeight; float handleRadius = handleHeight * 0.25f; float origin[4]; _origin.get(origin); float x[4], y[4], z[4]; (_origin + (_x * size)).get(x); (_origin + (_y * size)).get(y); (_origin + (_z * size)).get(z); view.beginGL(); GLUquadricObj* quadric = gluNewQuadric(); gluQuadricNormals(quadric, GLU_SMOOTH); gluQuadricTexture(quadric, true); gluQuadricDrawStyle(quadric, GLU_FILL); colorAndName(view, _glPickableItem + 0, true, xColor()); gGLFT->glBegin(MGL_LINES); gGLFT->glVertex3fv(origin); gGLFT->glVertex3fv(x); gGLFT->glEnd(); glDrawCone(quadric, _origin + (_x * handleOfs), _x, handleHeight, handleRadius); colorAndName(view, _glPickableItem + 1, true, yColor()); gGLFT->glBegin(MGL_LINES); gGLFT->glVertex3fv(origin); gGLFT->glVertex3fv(y); gGLFT->glEnd(); glDrawCone(quadric, _origin + (_y * handleOfs), _y, handleHeight, handleRadius); colorAndName(view, _glPickableItem + 2, true, zColor()); gGLFT->glBegin(MGL_LINES); gGLFT->glVertex3fv(origin); gGLFT->glVertex3fv(z); gGLFT->glEnd(); glDrawCone(quadric, _origin + (_z * handleOfs), _z, handleHeight, handleRadius); gluDeleteQuadric(quadric); view.endGL(); }
void retargetLocator::draw( M3dView& view, const MDagPath& DAGPath, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { view.beginGL(); glPushAttrib( GL_CURRENT_BIT ); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glDepthMask( GL_FALSE ); if ( status == M3dView::kActive ) viewMode = 0; else if ( status == M3dView::kLead ) viewMode = 1; else viewMode = 2; glDepthFunc( GL_ALWAYS ); drawDiscAll( discLineAlpha*0.5f, discFillAlpha*0.5f ); for( int i =0; i<lineAlpha.length(); i++ ) { drawArrowAll( lineAlpha[i]*0.5f, fillAlpha[i]*0.5f, i ); } glDepthFunc( GL_LESS ); drawDiscAll( discLineAlpha, discFillAlpha ); for( int i =0; i<lineAlpha.length(); i++ ) { drawArrowAll( lineAlpha[i], fillAlpha[i], i ); } glDepthMask( GL_TRUE ); glDisable( GL_BLEND ); glPopAttrib(); view.endGL(); }
void curvedArrows::draw( M3dView & view, const MDagPath & /*path*/, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { // Get the size // MObject thisNode = thisMObject(); MPlug tPlug = MPlug( thisNode, aTransparency ); MPlug cPlug = MPlug( thisNode, aTheColor ); float r, g, b, a; MObject color; cPlug.getValue( color ); MFnNumericData data( color ); data.getData( r, g, b ); tPlug.getValue( a ); view.beginGL(); if( (style == M3dView::kFlatShaded) || (style == M3dView::kGouraudShaded) ) { // Push the color settings // glPushAttrib( GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT | GL_ENABLE_BIT | GL_PIXEL_MODE_BIT ); if ( a < 1.0f ) { glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); } glColor4f( r, g, b, a ); glBegin( GL_TRIANGLES ); unsigned int i; for ( i = 0; i < fsFaceListSize; i ++ ) { unsigned int *vid = fsFaceList[i]; unsigned int *nid = fsFaceVertexNormalList[i]; for ( unsigned int j = 0; j < 3; j ++ ) { glNormal3d( fsNormalList[nid[j]-1][0], fsNormalList[nid[j]-1][1], fsNormalList[nid[j]-1][2] ); glVertex3d( fsVertexList[vid[j]-1][0], fsVertexList[vid[j]-1][1], fsVertexList[vid[j]-1][2] ); } } glEnd(); glPopAttrib(); drawEdgeLoop( view, status ); } else { drawEdgeLoop( view, status ); } view.endGL(); }
void VmIslandNode::draw( M3dView& i_view, const MDagPath& i_path, M3dView::DisplayStyle i_style, M3dView::DisplayStatus i_status ) { //fprintf( stderr, "VmIslandNode::Draw()\n" ); //Start OpenGL i_view.beginGL(); // Get all the values we need from the plugs. // // Note that for the oa_update plug, we don't actually // care about the value we get from it. But we do ask // for it to be computed, since that computation process // will get the internal structures up to date. But, the // drawStyle() plug we do care about the value of. At the // same time though, in the compute() method, nothing // needs to be computed for it. MPlug updatePlug( thisMObject(), VmIslandNode::oa_update ); const bool updateOK = updatePlug.asBool(); if( updateOK == false) { MGlobal::displayError( "VmIslandNode::draw() - update failed\n" ); } MPlug drawStylePlug( thisMObject(), VmIslandNode::ia_drawStyle ); const int drawStyle = drawStylePlug.asInt(); //Check plugs if (drawStyle == 0){ drawBB(); } else if (drawStyle == 1){ drawSubBB(); } else if ( drawStyle == 2 ){ drawPlane(); } else if( drawStyle == 3) { drawPlane(); drawTerrainNormals(); }else if (drawStyle == 4 ) { drawPlane(); drawInstances(); } else if (drawStyle == 5 ) { drawPlane(); drawInstances(); drawWindVelocities(); } else if (drawStyle == 6 ) { drawPlane(); drawBB(); drawSubBB(); drawInstances(); drawTerrainNormals(); drawWindVelocities(); } //Close OpenGL i_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 bruiseMapNode::draw( M3dView & view, const MDagPath & /*path*/, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { view.beginGL(); glPointSize(2); if(m_base->hasBase()) m_base->draw(); view.endGL(); }
// Load the textures, update the necessary variable values, initialize register combiners, // save and load the matrices with the proper values // MStatus hwRefractReflectShader_NV20::preDraw(const MDrawRequest& request, M3dView& view) { MStatus stat = loadTextures( request, view); if( MS::kSuccess != stat ) return stat; // get the reflectivity value // MPlug tPlug(thisMObject(), reflectivity); if( tPlug.getValue( fReflectivity ) ) { if( fReflectivity < 0.01f ) fReflectivity = 0.01f; if( fReflectivity > 1.0f ) fReflectivity = 1.0f; } else fReflectivity = 0.5f; // get the refraction index value // MPlug rPlug(thisMObject(), refractionIndex); if( rPlug.getValue( fRefractionIndex ) ) { if ( fRefractionIndex < 1.0f ) fRefractionIndex = 1.0f; if ( fRefractionIndex > 2.0f ) fRefractionIndex = 2.0f; } else fRefractionIndex = 1.0f; initCombiners( request, view ); // Compute the camera rotation angle and axis // MDagPath cameraPath; MStatus status = view.getCamera( cameraPath ); MMatrix mmatrix = cameraPath.inclusiveMatrix( &status ); MTransformationMatrix tmatrix( mmatrix ); MQuaternion camRotation = tmatrix.rotation(); MVector camAxis; double camTheta; camRotation.getAxisAngle( camAxis, camTheta ); // Convert to degrees from radians camTheta *= 57.295779513082320876798154814105; // == (180 / M_PI) view.beginGL(); glMatrixMode( GL_TEXTURE ); glPushMatrix(); glLoadIdentity(); glScalef(1.0, -1.0, 1.0); glRotated( camTheta, camAxis[0], camAxis[1], camAxis[2]); glMatrixMode( GL_MODELVIEW ); view.endGL(); return stat; }
/* virtual */ MStatus hwUnlitShader::unbind(const MDrawRequest& request, M3dView& view) { view.beginGL(); glPopClientAttrib(); glPopAttrib(); view.endGL(); return MS::kSuccess; }
void sixdofConstraintNode::draw( M3dView & view, const MDagPath &path, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { // std::cout << "sixdofConstraintNode::draw" << std::endl; update(); view.beginGL(); glPushAttrib( GL_ALL_ATTRIB_BITS ); // glPushMatrix(); glDisable(GL_LIGHTING); if( !(status == M3dView::kActive || status == M3dView::kLead || status == M3dView::kHilite || ( style != M3dView::kGouraudShaded && style != M3dView::kFlatShaded )) ) { glColor3f(1.0, 1.0, 0.0); } vec3f posA; vec3f posB; if (m_constraint) { vec3f world; m_constraint->get_world(world); quatf rotA; m_constraint->rigid_bodyA()->get_transform(posA, rotA); posA = posA - world; quatf rotB; m_constraint->rigid_bodyB()->get_transform(posB, rotB); posB = posB - world; } // glLoadIdentity(); glBegin(GL_LINES); glVertex3f(posA[0], posA[1], posA[2]); glVertex3f(posB[0], posB[1], posB[2]); glVertex3f(-1.0, 0.0, 0.0); glVertex3f(1.0, 0.0, 0.0); glVertex3f(0.0, -1.0, 0.0); glVertex3f(0.0, 1.0, 0.0); glVertex3f(0.0, 0.0, -1.0); glVertex3f(0.0, 0.0, 1.0); glEnd(); // glPopMatrix(); glPopAttrib(); view.endGL(); }
void rigidBodyNode::draw( M3dView & view, const MDagPath &path, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { // std::cout << "rigidBodyNode::draw" << std::endl; MObject thisObject(thisMObject()); update(); view.beginGL(); glPushAttrib( GL_ALL_ATTRIB_BITS ); if(m_rigid_body) { //remove the scale, since it's already included in the node transform vec3f scale; m_rigid_body->collision_shape()->get_scale(scale); glPushMatrix(); glScalef(1/scale[0], 1/scale[1], 1/scale[2]); if(style == M3dView::kFlatShaded || style == M3dView::kGouraudShaded) { glEnable(GL_LIGHTING); MPlug plug(thisObject, rigidBodyNode::ia_mass); float mass; plug.getValue(mass); if (mass) { float material[] = { 0.2f, 1.0f, 0.2f, 1.0f }; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, material); } else { float material[] = { 1.0f, 0.3f, 0.1f, 1.0f }; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, material); } //glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, material); m_rigid_body->collision_shape()->gl_draw(collision_shape_t::kDSSolid); } if( status == M3dView::kActive || status == M3dView::kLead || status == M3dView::kHilite || ( style != M3dView::kGouraudShaded && style != M3dView::kFlatShaded ) ) { glDisable(GL_LIGHTING); m_rigid_body->collision_shape()->gl_draw(collision_shape_t::kDSWireframe); } glPopMatrix(); } glPopAttrib(); view.endGL(); }
void DrawableHolderUI::draw( const MDrawRequest &request, M3dView &view ) const { MDrawData drawData = request.drawData(); DrawableHolder *drawableHolder = (DrawableHolder *)drawData.geometry(); assert( drawableHolder ); IECoreGL::ConstScenePtr s = drawableHolder->scene(); if( !s ) { return; } view.beginGL(); // maya can sometimes leave an error from it's own code, // and we don't want that to confuse us in our drawing code. while( glGetError()!=GL_NO_ERROR ) { } // if we're being drawn as part of a selection operation we need // to make sure there's a name on the name stack, as the IECoreGL::NameStateComponent // expects to be able to load a name into it (it fails with an invalid operation if // there's no name slot to load into). if( view.selectMode() ) { view.pushName( 0 ); } try { // do the main render s->render( m_displayStyle.baseState( request.displayStyle() ) ); // do a wireframe render over the top if we're selected and we just did a solid // draw. bool selected = request.displayStatus()==M3dView::kActive || request.displayStatus()==M3dView::kLead; bool solid = request.displayStyle()==M3dView::kFlatShaded || request.displayStyle()==M3dView::kGouraudShaded; if( selected && solid ) { s->render( m_displayStyle.baseState( M3dView::kWireFrame ) ); } } catch( std::exception &e ) { IECore::msg( IECore::Msg::Error, "DrawableHolderUI::draw", e.what() ); } view.endGL(); }
void swissArmyLocatorManip::draw(M3dView & view, const MDagPath &path, M3dView::DisplayStyle style, M3dView::DisplayStatus status) { MPxManipContainer::draw(view, path, style, status); view.beginGL(); MPoint textPos = nodeTranslation(); char str[100]; sprintf(str, "Swiss Army Manipulator"); MString distanceText(str); view.drawText(distanceText, textPos, M3dView::kLeft); view.endGL(); }
void wingVizNode::draw( M3dView & view, const MDagPath & /*path*/, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { view.beginGL(); //glPushAttrib( GL_POLYGON_BIT ); //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); //glFrontFace(GL_CW); //glEnable(GL_CULL_FACE); //if(i_show_v) m_base->drawVelocity(); m_base->draw(); //glPopAttrib(); view.endGL(); }
/* virtual */ MStatus pnTriangles::unbind(const MDrawRequest& request, M3dView& view) // // Description: // // { view.beginGL(); // Disable vertex shader if (fTestVertexProgram) { glDisable(GL_VERTEX_SHADER_EXT); } // Disable fragment shader else if (fTestFragmentProgram) { glDisable(GL_FRAGMENT_SHADER_ATI); } // Disable regular material state else { glDisable( GL_TEXTURE_2D ); glDisable(GL_COLOR_MATERIAL); if (fInTexturedMode) { glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL_MODELVIEW); } } // Disable PN triangles extension if needed // if (fExtensionSupported[kPNTriangesEXT] || (fSubdivisions == 0)) { if (fSubdivisions != 0) glDisable( GL_PN_TRIANGLES_ATI ); } glPopClientAttrib(); glPopAttrib(); view.endGL(); return MS::kSuccess; }
//------------------------------------------------------------------------------ // void RasterSelect::end() { M3dView view = fSelectInfo.view(); unsigned int sxl, syl, sw, sh; fSelectInfo.selectRect(sxl, syl, sw, sh); unsigned int vxl, vyl, vw, vh; view.viewport(vxl, vyl, vw, vh); const unsigned int width = (MAX_RASTER_SELECT_RENDER_SIZE < sw) ? MAX_RASTER_SELECT_RENDER_SIZE : sw; const unsigned int height = (MAX_RASTER_SELECT_RENDER_SIZE < sh) ? MAX_RASTER_SELECT_RENDER_SIZE : sh; float* selDepth = new float[MAX_RASTER_SELECT_RENDER_SIZE* MAX_RASTER_SELECT_RENDER_SIZE]; GLint buffer; ::glGetIntegerv( GL_READ_BUFFER, &buffer ); ::glReadBuffer( GL_BACK ); ::glReadPixels(vxl, vyl, width, height, GL_DEPTH_COMPONENT, GL_FLOAT, (void *)selDepth); ::glReadBuffer( buffer ); for (unsigned int j=0; j<height; ++j) { for (unsigned int i=0; i<width; ++i) { const GLfloat depth = selDepth[j*width + i]; if (depth < 1.0f) { fMinZ = std::min(fMinZ, depth); } } } ::glMatrixMode(GL_PROJECTION); ::glPopMatrix(); ::glMatrixMode(GL_MODELVIEW); ::glDisable(GL_SCISSOR_TEST); if (!fWasDepthTestEnabled) { ::glDisable(GL_DEPTH_TEST); } view.endGL(); }
void mpBox::draw( M3dView & view, const MDagPath & path, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { float xsize, ysize, zsize; MObject thisNode = thisMObject(); float r, g, b, a; float rotx, roty, rotz, ba; int lw, dt; MObject color; MObject rotate; _COMMON_ATTR_READ_; //zsize MPlug xsPlug = MPlug( thisNode, aXsize ); xsPlug.getValue( xsize ); //ysize MPlug ysPlug = MPlug( thisNode, aYsize ); ysPlug.getValue( ysize ); //zsize MPlug zsPlug = MPlug( thisNode, aZsize ); zsPlug.getValue( zsize ); //drawType MPlug drPlug = MPlug( thisNode, aDrawType ); drPlug.getValue( dt ); view.beginGL(); glPushMatrix(); glRotatef(rotx ,1.0,0.0,0.0); glRotatef(roty ,0.0,1.0,0.0); glRotatef(rotz ,0.0,0.0,1.0); glPushAttrib(GL_ALL_ATTRIB_BITS); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); //draw Infront glDepthFunc(GL_LESS); glColor4f( r, g, b, a ); drawStyle(style, dt, lw); drawCube(xsize, ysize, zsize); //draw Behind glDepthFunc(GL_GREATER); glColor4f( r, g, b, ba ); drawStyle(style, dt, lw); drawCube(xsize, ysize, zsize); glPopAttrib(); glPopMatrix(); view.endGL(); }
void BCIViz::draw( M3dView & view, const MDagPath & path, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { MObject thisNode = thisMObject(); view.beginGL(); glPushAttrib (GL_CURRENT_BIT); glDisable(GL_DEPTH_TEST); drawDriver(); drawTargets(); drawNeighbours(); drawWeights(); glEnable(GL_DEPTH_TEST); glPopAttrib(); view.endGL(); }
/* virtual */ MStatus hwDecalBumpShader_NV20::unbind(const MDrawRequest& request, M3dView& view) { view.beginGL(); glDisable(GL_REGISTER_COMBINERS_NV); glDisable(GL_TEXTURE_SHADER_NV); glActiveTextureARB( GL_TEXTURE0_ARB ); glPopClientAttrib(); glPopAttrib(); view.endGL(); return MS::kSuccess; }
void hwPhongShader::releaseEverything() { if (phong_map_id != 0) { M3dView view = M3dView::active3dView(); // The M3dView class doesn't return the correct status if there isn't // an active 3D view, so we rely on the success of beginGL() which // will make the context current. // if (view.beginGL()) { glDeleteTextures( 1, &phong_map_id ); phong_map_id = 0; } view.endGL(); } }
/* virtual */ MStatus hwUnlitShader::geometry( const MDrawRequest& request, M3dView& view, int prim, unsigned int writable, int indexCount, const unsigned int * indexArray, int vertexCount, const int * vertexIDs, const float * vertexArray, int normalCount, const float ** normalArrays, int colorCount, const float ** colorArrays, int texCoordCount, const float ** texCoordArrays) { view.beginGL(); glVertexPointer(3, GL_FLOAT, 0, vertexArray); glEnableClientState(GL_VERTEX_ARRAY); if (normalCount > 0) { // Technically, we don't need the normals for this example. But // most of the 3rd party plug-ins will probably want the normal, // which is why the following lines were kept. glNormalPointer(GL_FLOAT, 0, normalArrays[0]); glEnableClientState(GL_NORMAL_ARRAY); } if (texCoordCount > 0) { glTexCoordPointer(2, GL_FLOAT, 0, texCoordArrays[0]); glEnableClientState(GL_TEXTURE_COORD_ARRAY); } glDrawElements(prim, indexCount, GL_UNSIGNED_INT, indexArray); view.endGL(); return MS::kSuccess; }
// Initialize the register combiners setting // void hwRefractReflectShader_NV20::initCombiners(const MDrawRequest& request, M3dView& view) { view.beginGL(); { // Use only the 1st stage of the register combiner stages // glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 1); { float refractivity[4], reflectivity[4]; refractivity[0] = refractivity[1] = refractivity[2] = refractivity[3] = 1.0f - fReflectivity; reflectivity[0] = reflectivity[1] = reflectivity[2] = reflectivity[3] = fReflectivity; glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, refractivity); glCombinerParameterfvNV(GL_CONSTANT_COLOR1_NV, reflectivity); } // combiner 0 // a*b+c*d // a is from the refractive color // c is from the refrlective texture glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB); glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_CONSTANT_COLOR0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB); glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV, GL_TEXTURE1_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB); glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV, GL_CONSTANT_COLOR1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB); // output: // (stage, portion, abOutput, cdOutput, sumOutput, scale, bias, abDotProduct, cdDotProduct, muxSum) glCombinerOutputNV(GL_COMBINER0_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_SPARE0_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE); // final combiner // output: Frgb = A*B + (1-A)*C + D // (variable, input, mapping, componentUsage); // Just pass through the D variable // glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB); glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB); glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB); glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB); } view.endGL(); }
void sgBLocator_fromGeo::draw( M3dView& view, const MDagPath& dagPath, M3dView::DisplayStyle displayStyle, M3dView::DisplayStatus status ) { view.beginGL(); glPushAttrib( GL_CURRENT_BIT ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glDepthMask( GL_FALSE ); glDisable ( GL_LIGHTING ); if ( status == M3dView::kActive ) { glColor3f( m_colorActive.r, m_colorActive.g, m_colorActive.b ); } else if ( status == M3dView::kLead ) { glColor3f( m_colorLead.r, m_colorLead.g, m_colorLead.b ); } else { glColor3f( m_colorDefault.r, m_colorDefault.g, m_colorDefault.b ); } glLineWidth( m_lineWidth ); glBegin( GL_LINES ); glVertex3f( m_pointArr[0].x, m_pointArr[0].y, m_pointArr[0].z ); glVertex3f( m_pointArr[1].x, m_pointArr[1].y, m_pointArr[1].z ); glVertex3f( m_pointArr[2].x, m_pointArr[2].y, m_pointArr[2].z ); glVertex3f( m_pointArr[3].x, m_pointArr[3].y, m_pointArr[3].z ); glVertex3f( m_pointArr[4].x, m_pointArr[4].y, m_pointArr[4].z ); glVertex3f( m_pointArr[5].x, m_pointArr[5].y, m_pointArr[5].z ); glEnd(); glLineWidth( 1 ); glDepthMask( GL_TRUE ); glPopAttrib(); view.endGL(); }
// Retore the openGL matrices and the openGL texture objects states // MStatus hwRefractReflectShader_NV20::postDraw( const MDrawRequest& request, M3dView& view ) { view.beginGL(); { glMatrixMode( GL_TEXTURE ); glPopMatrix(); glMatrixMode( GL_MODELVIEW ); glActiveTextureARB( GL_TEXTURE1_ARB ); glBindTexture( GL_TEXTURE_CUBE_MAP_ARB, 0 ); glDisable(GL_TEXTURE_CUBE_MAP_ARB); glActiveTextureARB( GL_TEXTURE0_ARB ); glBindTexture( GL_TEXTURE_CUBE_MAP_ARB, 0 ); glDisable(GL_TEXTURE_CUBE_MAP_ARB); } view.endGL(); return MS::kSuccess; }