Ejemplo n.º 1
0
        // for userInteraction example code
        //
        public void drawRedPointAtCenter(MDrawRequest request, M3dView view)
        //
        // Description:
        //
        //     Simple very fast draw routine
        //
        // Arguments:
        //
        //     request - request to be drawn
        //     view    - view to draw into
        //
        {
            // Draw point
            //
            view.beginGL();

            // save state
            //
            OpenGL.glPushAttrib(OpenGL.GL_CURRENT_BIT | OpenGL.GL_POINT_BIT);
            OpenGL.glPointSize(20.0f);
            OpenGL.glBegin(OpenGL.GL_POINTS);
            OpenGL.glColor3f(1.0f, 0.0f, 0.0f);
            OpenGL.glVertex3f(0.0f, 0.0f, 0.0f);
            OpenGL.glEnd();

            // restore state
            //
            OpenGL.glPopAttrib();
            view.endGL();
        }
Ejemplo n.º 2
0
        public void getDrawRequestsWireframe(MDrawRequest request,
                                             MDrawInfo info)
        {
            request.token = (int)DrawShapeStyle.kDrawWireframe;

            M3dView.DisplayStatus displayStatus     = info.displayStatus;
            M3dView.ColorTable    activeColorTable  = M3dView.ColorTable.kActiveColors;
            M3dView.ColorTable    dormantColorTable = M3dView.ColorTable.kDormantColors;
            switch (displayStatus)
            {
            case M3dView.DisplayStatus.kLead:
                request.setColor(LEAD_COLOR, (int)activeColorTable);
                break;

            case M3dView.DisplayStatus.kActive:
                request.setColor(ACTIVE_COLOR, (int)activeColorTable);
                break;

            case M3dView.DisplayStatus.kActiveAffected:
                request.setColor(ACTIVE_AFFECTED_COLOR, (int)activeColorTable);
                break;

            case M3dView.DisplayStatus.kDormant:
                request.setColor(DORMANT_COLOR, (int)dormantColorTable);
                break;

            case M3dView.DisplayStatus.kHilite:
                request.setColor(HILITE_COLOR, (int)activeColorTable);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 3
0
        public override void getDrawRequests(MDrawInfo info,
                                             bool objectAndActiveOnly,
                                             MDrawRequestQueue queue)
        {
            quadricShape shapeNode = surfaceShape as quadricShape;

            if (shapeNode == null)
            {
                return;
            }

            // The following line will be removed when all the .net assemblies will be merged into one
            // We would then be able to call info.getPrototype(this)

            MDrawRequest request = info.getPrototype(this);

            quadricGeom geom = shapeNode.geometry();

            MDrawData data;

            getDrawData(geom, out data);
            request.setDrawData(data);

            // Are we displaying meshes?
            if (!info.objectDisplayStatus(M3dView.DisplayObjects.kDisplayMeshes))
            {
                return;
            }

            // Use display status to determine what color to draw the object
            //
            switch (info.displayStyle)
            {
            case M3dView.DisplayStyle.kWireFrame:
                getDrawRequestsWireframe(request, info);
                queue.add(request);
                break;

            case M3dView.DisplayStyle.kGouraudShaded:
                request.token = (int)DrawShapeStyle.kDrawSmoothShaded;
                getDrawRequestsShaded(request, info, queue, data);
                queue.add(request);
                break;

            case M3dView.DisplayStyle.kFlatShaded:
                request.token = (int)DrawShapeStyle.kDrawFlatShaded;
                getDrawRequestsShaded(request, info, queue, data);
                queue.add(request);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 4
0
        public void getDrawRequestsShaded(MDrawRequest request,
                                          MDrawInfo info,
                                          MDrawRequestQueue queue,
                                          MDrawData data)
        {
            // Need to get the material info
            //
            MDagPath  path     = info.multiPath; // path to your dag object
            M3dView   view     = info.view;      // view to draw to
            MMaterial material = base.material(path);

            M3dView.DisplayStatus displayStatus = info.displayStatus;

            // Evaluate the material and if necessary, the texture.
            //
            material.evaluateMaterial(view, path);

            bool drawTexture = true;

            if (drawTexture && material.materialIsTextured)
            {
                material.evaluateTexture(data);
            }

            request.material = material;

            bool materialTransparent = false;

            material.getHasTransparency(ref materialTransparent);
            if (materialTransparent)
            {
                request.isTransparent = true;
            }

            // create a draw request for wireframe on shaded if
            // necessary.
            //
            if ((displayStatus == M3dView.DisplayStatus.kActive) ||
                (displayStatus == M3dView.DisplayStatus.kLead) ||
                (displayStatus == M3dView.DisplayStatus.kHilite))
            {
                MDrawRequest wireRequest = info.getPrototype(this);
                wireRequest.setDrawData(data);
                getDrawRequestsWireframe(wireRequest, info);
                wireRequest.token        = (int)DrawShapeStyle.kDrawWireframeOnShaded;
                wireRequest.displayStyle = M3dView.DisplayStyle.kWireFrame;
                queue.add(wireRequest);
            }
        }
Ejemplo n.º 5
0
        // Main draw routine. Gets called by Maya with draw requests.
        //
        public override void draw(MDrawRequest request, M3dView view)
        //
        // Description:
        //
        //     Main (OpenGL) draw routine
        //
        // Arguments:
        //
        //     request - request to be drawn
        //     view    - view to draw into
        //
        {
            // Get the token from the draw request.
            // The token specifies what needs to be drawn.
            //
            int token = request.token;

            switch (token)
            {
            case (int)DrawToken.kDrawWireframe:
            case (int)DrawToken.kDrawWireframeOnShaded:
                drawWireframe(request, view);
                break;

            case (int)DrawToken.kDrawSmoothShaded:
                drawShaded(request, view);
                break;

            case (int)DrawToken.kDrawFlatShaded:                     // Not implemented
                break;

            case (int)DrawToken.kDrawVertices:
                drawVertices(request, view);
                break;

            case (int)DrawToken.kDrawBoundingBox:
                drawBoundingBox(request, view);
                break;

            // for userChangingViewContext example code
            //
            case (int)DrawToken.kDrawRedPointAtCenter:
                drawRedPointAtCenter(request, view);
                break;
            }
        }
Ejemplo n.º 6
0
        // Main draw routine. Gets called by maya with draw requests.
        //
        public override void draw(MDrawRequest request, M3dView view)
        {
            // Get the token from the draw request.
            // The token specifies what needs to be drawn.
            //
            DrawShapeStyle token = (DrawShapeStyle)request.token;
            switch (token)
            {
                case DrawShapeStyle.kDrawWireframe:
                case DrawShapeStyle.kDrawWireframeOnShaded:
                case DrawShapeStyle.kDrawVertices:
                    drawVertices(request, view);
                    break;

                case DrawShapeStyle.kDrawSmoothShaded:
                    break;          // Not implemented, left as exercise

                case DrawShapeStyle.kDrawFlatShaded: // Not implemented, left as exercise
                    break;
            }
        }
Ejemplo n.º 7
0
        // Main draw routine. Gets called by maya with draw requests.
        //
        public override void draw(MDrawRequest request, M3dView view)
        {
            // Get the token from the draw request.
            // The token specifies what needs to be drawn.
            //
            DrawShapeStyle token = (DrawShapeStyle)request.token;

            switch (token)
            {
            case DrawShapeStyle.kDrawWireframe:
            case DrawShapeStyle.kDrawWireframeOnShaded:
            case DrawShapeStyle.kDrawVertices:
                drawVertices(request, view);
                break;

            case DrawShapeStyle.kDrawSmoothShaded:
                break;                           // Not implemented, left as exercise

            case DrawShapeStyle.kDrawFlatShaded: // Not implemented, left as exercise
                break;
            }
        }
Ejemplo n.º 8
0
        public void getDrawRequestsWireframe(MDrawRequest request,
            MDrawInfo info)
        {
            request.token = (int)DrawShapeStyle.kDrawWireframe;

            M3dView.DisplayStatus displayStatus = info.displayStatus;
            M3dView.ColorTable activeColorTable = M3dView.ColorTable.kActiveColors;
            M3dView.ColorTable dormantColorTable = M3dView.ColorTable.kDormantColors;
            switch (displayStatus)
            {
                case M3dView.DisplayStatus.kLead:
                    request.setColor(LEAD_COLOR, (int)activeColorTable);
                    break;
                case M3dView.DisplayStatus.kActive:
                    request.setColor(ACTIVE_COLOR, (int)activeColorTable);
                    break;
                case M3dView.DisplayStatus.kActiveAffected:
                    request.setColor(ACTIVE_AFFECTED_COLOR, (int)activeColorTable);
                    break;
                case M3dView.DisplayStatus.kDormant:
                    request.setColor(DORMANT_COLOR, (int)dormantColorTable);
                    break;
                case M3dView.DisplayStatus.kHilite:
                    request.setColor(HILITE_COLOR, (int)activeColorTable);
                    break;
                default:
                    break;
            }
        }
Ejemplo n.º 9
0
        public void getDrawRequestsShaded(MDrawRequest request,
            MDrawInfo info,
            MDrawRequestQueue queue,
            MDrawData data)
        {
            // Need to get the material info
            //
            MDagPath path = info.multiPath;	// path to your dag object
            M3dView view = info.view; 		// view to draw to
            MMaterial material = base.material(path);
            M3dView.DisplayStatus displayStatus = info.displayStatus;

            // Evaluate the material and if necessary, the texture.
            //
            material.evaluateMaterial(view, path);

            bool drawTexture = true;
            if (drawTexture && material.materialIsTextured)
            {
                material.evaluateTexture(data);
            }

            request.material = material;

            bool materialTransparent = false;
            material.getHasTransparency( ref materialTransparent);
            if ( materialTransparent ) {
                request.isTransparent = true;
            }

            // create a draw request for wireframe on shaded if
            // necessary.
            //
            if ((displayStatus == M3dView.DisplayStatus.kActive) ||
                 (displayStatus == M3dView.DisplayStatus.kLead) ||
                 (displayStatus == M3dView.DisplayStatus.kHilite))
            {
                MDrawRequest wireRequest = info.getPrototype(this);
                wireRequest.setDrawData(data);
                getDrawRequestsWireframe(wireRequest, info);
                wireRequest.token = (int)DrawShapeStyle.kDrawWireframeOnShaded;
                wireRequest.displayStyle = M3dView.DisplayStyle.kWireFrame;
                queue.add(wireRequest);
            }
        }
Ejemplo n.º 10
0
        //
        // From the given draw request, get the draw data and determine
        // which quadric to draw and with what values.
        //
        public override void draw(MDrawRequest request, M3dView view)
        {
            MDrawData data = request.drawData();

            quadricGeom geom = data.geometry() as quadricGeom;

            DrawShapeStyle token = (DrawShapeStyle)request.token;
            bool drawTexture = false;

            view.beginGL();

            if ((token == DrawShapeStyle.kDrawSmoothShaded) || (token == DrawShapeStyle.kDrawFlatShaded))
            {
                OpenGL.glEnable((uint)OpenGL.GL_POLYGON_OFFSET_FILL);

                // Set up the material
                //
                MMaterial material = request.material;
                material.setMaterial(request.multiPath, request.isTransparent);

                // Enable texturing
                //
                drawTexture = material.materialIsTextured;
                if (drawTexture) OpenGL.glEnable((uint)OpenGL.GL_TEXTURE_2D);

                // Apply the texture to the current view
                //
                if (drawTexture)
                {
                    material.applyTexture(view, data);
                }
            }

            IntPtr qobj = GLUFunctionInvoker.gluNewQuadric();

            switch (token)
            {
                case DrawShapeStyle.kDrawWireframe:
                case DrawShapeStyle.kDrawWireframeOnShaded:
                    GLUFunctionInvoker.gluQuadricDrawStyle(qobj, GLU_LINE);
                    break;

                case DrawShapeStyle.kDrawSmoothShaded:
                    GLUFunctionInvoker.gluQuadricNormals(qobj, GLU_SMOOTH);
                    GLUFunctionInvoker.gluQuadricTexture(qobj, GLtrue);
                    GLUFunctionInvoker.gluQuadricDrawStyle(qobj, GLU_FILL);
                    break;

                case DrawShapeStyle.kDrawFlatShaded:
                    GLUFunctionInvoker.gluQuadricNormals(qobj, GLU_FLAT);
                    GLUFunctionInvoker.gluQuadricTexture(qobj, GLtrue);
                    GLUFunctionInvoker.gluQuadricDrawStyle(qobj, GLU_FILL);
                    break;
            }

            switch (geom.shapeType)
            {
                case (short)DrawShapeType.kDrawCylinder:
                    GLUFunctionInvoker.gluCylinder(qobj, geom.radius1, geom.radius2, geom.height,
                                 geom.slices, geom.stacks);
                    break;
                case (short)DrawShapeType.kDrawDisk:
                    GLUFunctionInvoker.gluDisk(qobj, geom.radius1, geom.radius2, geom.slices, geom.loops);
                    break;
                case (short)DrawShapeType.kDrawPartialDisk:
                    GLUFunctionInvoker.gluPartialDisk(qobj, geom.radius1, geom.radius2, geom.slices,
                                    geom.loops, geom.startAngle, geom.sweepAngle);
                    break;
                case (short)DrawShapeType.kDrawSphere:
                default:
                    GLUFunctionInvoker.gluSphere(qobj, geom.radius1, geom.slices, geom.stacks);
                    break;
            }

            // Turn off texture mode
            //
            if (drawTexture) OpenGL.glDisable((uint)OpenGL.GL_TEXTURE_2D);

            view.endGL();
        }
Ejemplo n.º 11
0
        //
        // Description:
        //
        //     Main (OpenGL) draw routine
        //
        // Arguments:
        //
        //     request - request to be drawn
        //     view    - view to draw into
        //
        // Main draw routine. Gets called by Maya with draw requests.
        //
        public override void draw( MDrawRequest request, M3dView view )
        {
            // Get the token from the draw request.
            // The token specifies what needs to be drawn.
            //
            int token = request.token;

            switch( token )
            {
                case (int)DrawToken.kDrawWireframe:
                case (int)DrawToken.kDrawWireframeOnShaded:
                    drawWireframe( request, view );
                    break;

                case (int)DrawToken.kDrawSmoothShaded:
                    drawShaded( request, view );
                    break;

                case (int)DrawToken.kDrawFlatShaded: // Not implemented
                    break;

                case (int)DrawToken.kDrawVertices:
                    drawVertices( request, view );
                    break;

                case (int)DrawToken.kDrawBoundingBox:
                    drawBoundingBox( request, view );
                    break;
                // for userChangingViewContext example code
                //
                case (int)DrawToken.kDrawRedPointAtCenter:
                    drawRedPointAtCenter( request, view );
                    break;
            }
        }
Ejemplo n.º 12
0
        //
        // Description:
        //
        //     Wireframe drawing routine
        //
        // Arguments:
        //
        //     request - request to be drawn
        //     view    - view to draw into
        //
        /////////////////////////////////////////////////////////////////////
        //
        // Helper routines
        //
        /////////////////////////////////////////////////////////////////////
        public void drawWireframe( MDrawRequest request, M3dView view )
        {
            MDrawData data = request.drawData();
            apiMeshGeom geom = (apiMeshGeom)data.geometry();
            if (geom == null) return;

            int token = request.token;

            bool wireFrameOnShaded = false;
            if ((int)DrawToken.kDrawWireframeOnShaded == token)
            {
                wireFrameOnShaded = true;
            }

            view.beginGL();

            // Query current state so it can be restored
            //
            bool lightingWasOn = OpenGL.glIsEnabled(OpenGL.GL_LIGHTING) != 0;
            if ( lightingWasOn ) {
                OpenGL.glDisable(OpenGL.GL_LIGHTING);
            }

            if ( wireFrameOnShaded ) {
                OpenGL.glDepthMask(0);
            }

            // Draw the wireframe mesh
            //
            int vid = 0;
            for ( int i=0; i<geom.faceCount; i++ )
            {
                OpenGL.glBegin(OpenGL.GL_LINE_LOOP);
                for ( int v=0; v<geom.face_counts[i]; v++ )
                {
                    MPoint vertex = geom.vertices[ geom.face_connects[vid++] ];
                    OpenGL.glVertex3f((float)vertex[0], (float)vertex[1], (float)vertex[2]);
                }
                OpenGL.glEnd();
            }

            // Restore the state
            //
            if ( lightingWasOn ) {
                OpenGL.glEnable(OpenGL.GL_LIGHTING);
            }
            if ( wireFrameOnShaded ) {
                OpenGL.glDepthMask(1);
            }

            view.endGL();
        }
Ejemplo n.º 13
0
        /////////////////////////////////////////////////////////////////////
        //
        // Helper routines
        //
        /////////////////////////////////////////////////////////////////////

        public void drawWireframe(MDrawRequest request, M3dView view)
        //
        // Description:
        //
        //     Wireframe drawing routine
        //
        // Arguments:
        //
        //     request - request to be drawn
        //     view    - view to draw into
        //
        {
            MDrawData   data = request.drawData();
            apiMeshGeom geom = (apiMeshGeom)data.geometry();

            if (geom == null)
            {
                return;
            }

            int token = request.token;

            bool wireFrameOnShaded = false;

            if ((int)DrawToken.kDrawWireframeOnShaded == token)
            {
                wireFrameOnShaded = true;
            }

            view.beginGL();

            // Query current state so it can be restored
            //
            bool lightingWasOn = OpenGL.glIsEnabled(OpenGL.GL_LIGHTING) != 0;

            if (lightingWasOn)
            {
                OpenGL.glDisable(OpenGL.GL_LIGHTING);
            }

            if (wireFrameOnShaded)
            {
                OpenGL.glDepthMask(0);
            }

            // Draw the wireframe mesh
            //
            int vid = 0;

            for (int i = 0; i < geom.faceCount; i++)
            {
                OpenGL.glBegin(OpenGL.GL_LINE_LOOP);
                for (int v = 0; v < geom.face_counts[i]; v++)
                {
                    MPoint vertex = geom.vertices[geom.face_connects[vid++]];
                    OpenGL.glVertex3f((float)vertex[0], (float)vertex[1], (float)vertex[2]);
                }
                OpenGL.glEnd();
            }

            // Restore the state
            //
            if (lightingWasOn)
            {
                OpenGL.glEnable(OpenGL.GL_LIGHTING);
            }
            if (wireFrameOnShaded)
            {
                OpenGL.glDepthMask(1);
            }

            view.endGL();
        }
Ejemplo n.º 14
0
		// for userInteraction example code
		//
		public void drawRedPointAtCenter( MDrawRequest request, M3dView view )
		//
		// Description:
		//
		//     Simple very fast draw routine
		//
		// Arguments:
		//
		//     request - request to be drawn
		//     view    - view to draw into
		//
		{
			// Draw point
			// 
			view.beginGL();
		
			// save state
			//
			OpenGL.glPushAttrib(OpenGL.GL_CURRENT_BIT | OpenGL.GL_POINT_BIT);
			OpenGL.glPointSize(20.0f);
			OpenGL.glBegin(OpenGL.GL_POINTS);
			OpenGL.glColor3f(1.0f, 0.0f, 0.0f);
			OpenGL.glVertex3f(0.0f, 0.0f, 0.0f);
			OpenGL.glEnd();
							
			// restore state
			//
			OpenGL.glPopAttrib();
			view.endGL();

		}
Ejemplo n.º 15
0
        //
        // Description:
        //
        //     Simple very fast draw routine
        //
        // Arguments:
        //
        //     request - request to be drawn
        //     view    - view to draw into
        //
        // for userInteraction example code
        //
        public void drawRedPointAtCenter( MDrawRequest request, M3dView view )
        {
            // Draw point
            //
            view.beginGL();

            // save state
            //
            OpenGL.glPushAttrib(OpenGL.GL_CURRENT_BIT | OpenGL.GL_POINT_BIT);
            OpenGL.glPointSize(20.0f);
            OpenGL.glBegin(OpenGL.GL_POINTS);
            OpenGL.glColor3f(1.0f, 0.0f, 0.0f);
            OpenGL.glVertex3f(0.0f, 0.0f, 0.0f);
            OpenGL.glEnd();

            // restore state
            //
            OpenGL.glPopAttrib();
            view.endGL();
        }
Ejemplo n.º 16
0
        public override void getDrawRequests(MDrawInfo info,
                                             bool objectAndActiveOnly,
                                             MDrawRequestQueue queue)
        {
            apiSimpleShape shapeNode = surfaceShape as apiSimpleShape;

            if (shapeNode == null)
            {
                return;
            }

            // This call creates a prototype draw request that we can fill
            // in and then add to the draw queue.
            //
            MDrawRequest request = info.getPrototype(this);


            MDrawData    data;
            MVectorArray geomPtr = shapeNode.controlPoints;

            // Stuff our data into the draw request, it'll be used when the drawing
            // actually happens
            getDrawData(geomPtr, out data);

            request.setDrawData(data);

            // Decode the draw info and determine what needs to be drawn
            //

            M3dView.DisplayStyle  appearance    = info.displayStyle;
            M3dView.DisplayStatus displayStatus = info.displayStatus;

            switch (appearance)
            {
            case M3dView.DisplayStyle.kWireFrame:
            {
                request.token = (int)DrawShapeStyle.kDrawWireframe;

                M3dView.ColorTable activeColorTable  = M3dView.ColorTable.kActiveColors;
                M3dView.ColorTable dormantColorTable = M3dView.ColorTable.kDormantColors;

                switch (displayStatus)
                {
                case M3dView.DisplayStatus.kLead:
                    request.setColor(LEAD_COLOR, (int)activeColorTable);
                    break;

                case M3dView.DisplayStatus.kActive:
                    request.setColor(ACTIVE_COLOR, (int)activeColorTable);
                    break;

                case M3dView.DisplayStatus.kActiveAffected:
                    request.setColor(ACTIVE_AFFECTED_COLOR, (int)activeColorTable);
                    break;

                case M3dView.DisplayStatus.kDormant:
                    request.setColor(DORMANT_COLOR, (int)dormantColorTable);
                    break;

                case M3dView.DisplayStatus.kHilite:
                    request.setColor(HILITE_COLOR, (int)activeColorTable);
                    break;

                default:
                    break;
                }

                queue.add(request);

                break;
            }

            case M3dView.DisplayStyle.kGouraudShaded:
            {
                // Create the smooth shaded draw request
                //
                request.token = (int)DrawShapeStyle.kDrawSmoothShaded;

                // Need to get the material info
                //
                MDagPath  path     = info.multiPath;     // path to your dag object
                M3dView   view     = info.view;          // view to draw to
                MMaterial material = base.material(path);

                // Evaluate the material and if necessary, the texture.
                //
                material.evaluateMaterial(view, path);

                bool drawTexture = true;
                if (drawTexture && material.materialIsTextured)
                {
                    material.evaluateTexture(data);
                }

                request.material = material;

                bool materialTransparent = false;
                material.getHasTransparency(ref materialTransparent);
                if (materialTransparent)
                {
                    request.isTransparent = true;
                }

                queue.add(request);

                // create a draw request for wireframe on shaded if
                // necessary.
                //
                if ((displayStatus == M3dView.DisplayStatus.kActive) ||
                    (displayStatus == M3dView.DisplayStatus.kLead) ||
                    (displayStatus == M3dView.DisplayStatus.kHilite))
                {
                    MDrawRequest wireRequest = request;
                    wireRequest.setDrawData(data);
                    wireRequest.token        = (int)DrawShapeStyle.kDrawWireframeOnShaded;
                    wireRequest.displayStyle = M3dView.DisplayStyle.kWireFrame;

                    M3dView.ColorTable activeColorTable = M3dView.ColorTable.kActiveColors;

                    switch (displayStatus)
                    {
                    case M3dView.DisplayStatus.kLead:
                        wireRequest.setColor(LEAD_COLOR, (int)activeColorTable);
                        break;

                    case M3dView.DisplayStatus.kActive:
                        wireRequest.setColor(ACTIVE_COLOR, (int)activeColorTable);
                        break;

                    case M3dView.DisplayStatus.kHilite:
                        wireRequest.setColor(HILITE_COLOR, (int)activeColorTable);
                        break;

                    default:
                        break;
                    }

                    queue.add(wireRequest);
                }

                break;
            }

            case M3dView.DisplayStyle.kFlatShaded:
                request.token = (int)DrawShapeStyle.kDrawFlatShaded;
                break;

            default:
                break;
            }

            // Add draw requests for components
            //
            if (!objectAndActiveOnly)
            {
                // Inactive components
                //
                if ((appearance == M3dView.DisplayStyle.kPoints) ||
                    (displayStatus == M3dView.DisplayStatus.kHilite))
                {
                    MDrawRequest vertexRequest = request;
                    vertexRequest.setDrawData(data);
                    vertexRequest.token = (int)DrawShapeStyle.kDrawVertices;
                    vertexRequest.setColor(DORMANT_VERTEX_COLOR, (int)M3dView.ColorTable.kActiveColors);

                    queue.add(vertexRequest);
                }

                // Active components
                //
                if (shapeNode.hasActiveComponents)
                {
                    MDrawRequest activeVertexRequest = request;
                    activeVertexRequest.setDrawData(data);
                    activeVertexRequest.token = (int)DrawShapeStyle.kDrawVertices;
                    activeVertexRequest.setColor(ACTIVE_VERTEX_COLOR, (int)M3dView.ColorTable.kActiveColors);

                    MObjectArray clist           = shapeNode.activeComponents;
                    MObject      vertexComponent = clist[0]; // Should filter list
                    activeVertexRequest.component = vertexComponent;

                    queue.add(activeVertexRequest);
                }
            }
        }
Ejemplo n.º 17
0
        public void drawVertices(MDrawRequest request, M3dView view)
        {
            MDrawData data = request.drawData();
            MVectorArray geom = data.geometry() as MVectorArray;

            view.beginGL();

            // Query current state so it can be restored
            //
            bool lightingWasOn = OpenGL.glIsEnabled(OpenGL.GL_LIGHTING) != 0 ? true : false;
            if (lightingWasOn)
            {
                OpenGL.glDisable(OpenGL.GL_LIGHTING);
            }
            float lastPointSize;
            getLastPointSize(out lastPointSize);

            // Set the point size of the vertices
            //
            OpenGL.glPointSize(POINT_SIZE);

            // If there is a component specified by the draw request
            // then loop over comp (using an MFnComponent class) and draw the
            // active vertices, otherwise draw all vertices.
            //
            MObject comp = request.component;
            if (!comp.isNull)
            {
                MFnSingleIndexedComponent fnComponent = new MFnSingleIndexedComponent(comp);
                for (int i = 0; i < fnComponent.elementCount; i++)
                {
                    int index = fnComponent.element(i);
                    OpenGL.glBegin(OpenGL.GL_POINTS);
                    MVector point = geom[index];
                    OpenGL.glVertex3f((float)point[0],
                                (float)point[1],
                                (float)point[2]);
                    OpenGL.glEnd();

                    MPoint mp = new MPoint(point);
                    view.drawText(String.Format("{0}", index), mp);
                }
            }
            else
            {
                for (int i = 0; i < geom.length; i++)
                {
                    OpenGL.glBegin(OpenGL.GL_POINTS);
                    MVector point = geom[i];
                    OpenGL.glVertex3f((float)point[0], (float)point[1], (float)point[2]);
                    OpenGL.glEnd();
                }
            }

            // Restore the state
            //
            if (lightingWasOn)
            {
                OpenGL.glEnable(OpenGL.GL_LIGHTING);
            }
            OpenGL.glPointSize(lastPointSize);

            view.endGL();
        }
Ejemplo n.º 18
0
        public void drawBoundingBox(MDrawRequest request, M3dView view)
        //
        // Description:
        //
        //     Bounding box drawing routine
        //
        // Arguments:
        //
        //     request - request to be drawn
        //     view    - view to draw into
        //
        {
            // Get the surface shape
            MPxSurfaceShape shape = (MPxSurfaceShape)surfaceShape;

            if (shape == null)
            {
                return;
            }

            // Get the bounding box
            MBoundingBox box = shape.boundingBox();
            float        w   = (float)box.width;
            float        h   = (float)box.height;
            float        d   = (float)box.depth;

            view.beginGL();

            // Below we just two sides and then connect
            // the edges together

            MPoint minVertex = box.min;

            // Draw first side
            OpenGL.glBegin(OpenGL.GL_LINE_LOOP);
            MPoint vertex = minVertex;

            OpenGL.glVertex3f((float)vertex[0], (float)vertex[1], (float)vertex[2]);
            OpenGL.glVertex3f((float)vertex[0] + w, (float)vertex[1], (float)vertex[2]);
            OpenGL.glVertex3f((float)vertex[0] + w, (float)vertex[1] + h, (float)vertex[2]);
            OpenGL.glVertex3f((float)vertex[0], (float)vertex[1] + h, (float)vertex[2]);
            OpenGL.glVertex3f((float)vertex[0], (float)vertex[1], (float)vertex[2]);
            OpenGL.glEnd();

            // Draw second side
            MVector sideFactor = new MVector(0, 0, d);
            MPoint  vertex2    = minVertex.plus(sideFactor);

            OpenGL.glBegin(OpenGL.GL_LINE_LOOP);
            OpenGL.glVertex3f((float)vertex2[0], (float)vertex2[1], (float)vertex2[2]);
            OpenGL.glVertex3f((float)vertex2[0] + w, (float)vertex2[1], (float)vertex2[2]);
            OpenGL.glVertex3f((float)vertex2[0] + w, (float)vertex2[1] + h, (float)vertex2[2]);
            OpenGL.glVertex3f((float)vertex2[0], (float)vertex2[1] + h, (float)vertex2[2]);
            OpenGL.glVertex3f((float)vertex2[0], (float)vertex2[1], (float)vertex2[2]);
            OpenGL.glEnd();

            // Connect the edges together
            OpenGL.glBegin(OpenGL.GL_LINES);
            OpenGL.glVertex3f((float)vertex2[0], (float)vertex2[1], (float)vertex2[2]);
            OpenGL.glVertex3f((float)vertex[0], (float)vertex[1], (float)vertex[2]);

            OpenGL.glVertex3f((float)vertex2[0] + w, (float)vertex2[1], (float)vertex2[2]);
            OpenGL.glVertex3f((float)vertex[0] + w, (float)vertex[1], (float)vertex[2]);

            OpenGL.glVertex3f((float)vertex2[0] + w, (float)vertex2[1] + h, (float)vertex2[2]);
            OpenGL.glVertex3f((float)vertex[0] + w, (float)vertex[1] + h, (float)vertex[2]);

            OpenGL.glVertex3f((float)vertex2[0], (float)vertex2[1] + h, (float)vertex2[2]);
            OpenGL.glVertex3f((float)vertex[0], (float)vertex[1] + h, (float)vertex[2]);
            OpenGL.glEnd();

            view.endGL();
        }
Ejemplo n.º 19
0
        public void drawVertices(MDrawRequest request, M3dView view)
        //
        // Description:
        //
        //     Component (vertex) drawing routine
        //
        // Arguments:
        //
        //     request - request to be drawn
        //     view    - view to draw into
        //
        {
            MDrawData   data = request.drawData();
            apiMeshGeom geom = (apiMeshGeom)data.geometry();

            if (geom == null)
            {
                return;
            }

            view.beginGL();

            // Query current state so it can be restored
            //
            bool lightingWasOn = OpenGL.glIsEnabled(OpenGL.GL_LIGHTING) != 0;

            if (lightingWasOn)
            {
                OpenGL.glDisable(OpenGL.GL_LIGHTING);
            }
            float[] lastPointSize = new float[1];
            OpenGL.glGetFloatv(OpenGL.GL_POINT_SIZE, lastPointSize);

            // Set the point size of the vertices
            //
            OpenGL.glPointSize(POINT_SIZE);

            // If there is a component specified by the draw request
            // then loop over comp (using an MFnComponent class) and draw the
            // active vertices, otherwise draw all vertices.
            //
            MObject comp = request.component;

            if (!comp.isNull)
            {
                MFnSingleIndexedComponent fnComponent = new MFnSingleIndexedComponent(comp);
                for (int i = 0; i < fnComponent.elementCount; i++)
                {
                    int index = fnComponent.element(i);
                    OpenGL.glBegin(OpenGL.GL_POINTS);
                    MPoint vertex = geom.vertices[index];
                    OpenGL.glVertex3f((float)vertex[0],
                                      (float)vertex[1],
                                      (float)vertex[2]);
                    OpenGL.glEnd();

                    string annotation = index.ToString();
                    view.drawText(annotation, vertex);
                }
            }
            else
            {
                int vid = 0;
                for (int i = 0; i < geom.faceCount; i++)
                {
                    OpenGL.glBegin(OpenGL.GL_POINTS);
                    for (int v = 0; v < geom.face_counts[i]; v++)
                    {
                        MPoint vertex = geom.vertices[geom.face_connects[vid++]];
                        OpenGL.glVertex3f((float)vertex[0],
                                          (float)vertex[1],
                                          (float)vertex[2]);
                    }
                    OpenGL.glEnd();
                }
            }

            // Restore the state
            //
            if (lightingWasOn)
            {
                OpenGL.glEnable(OpenGL.GL_LIGHTING);
            }
            OpenGL.glPointSize(lastPointSize[0]);

            view.endGL();
        }
Ejemplo n.º 20
0
        public void drawShaded(MDrawRequest request, M3dView view)
        //
        // Description:
        //
        //     Shaded drawing routine
        //
        // Arguments:
        //
        //     request - request to be drawn
        //     view    - view to draw into
        //
        {
            MDrawData   data = request.drawData();
            apiMeshGeom geom = (apiMeshGeom)data.geometry();

            if (geom == null)
            {
                return;
            }

            view.beginGL();

            OpenGL.glEnable(OpenGL.GL_POLYGON_OFFSET_FILL);

            // Set up the material
            //
            MMaterial material = request.material;

            material.setMaterial(request.multiPath, request.isTransparent);

            // Enable texturing ...
            //
            // Note, Maya does not enable texturing if useDefaultMaterial is enabled.
            // However, you can choose to ignore this in your draw routine.
            //
            bool drawTexture = material.materialIsTextured && !view.usingDefaultMaterial;

            if (drawTexture)
            {
                OpenGL.glEnable(OpenGL.GL_TEXTURE_2D);
            }

            // Apply the texture to the current view
            //
            if (drawTexture)
            {
                material.applyTexture(view, data);
            }

            // Draw the polygons
            //
            int  vid    = 0;
            uint uv_len = geom.uvcoords.uvcount();

            for (int i = 0; i < geom.faceCount; i++)
            {
                OpenGL.glBegin(OpenGL.GL_POLYGON);
                for (int v = 0; v < geom.face_counts[i]; v++)
                {
                    MPoint  vertex = geom.vertices[geom.face_connects[vid]];
                    MVector normal = geom.normals[geom.face_connects[vid]];
                    if (uv_len > 0)
                    {
                        // If we are drawing the texture, make sure the coord
                        // arrays are in bounds.
                        if (drawTexture)
                        {
                            int uvId1 = geom.uvcoords.uvId(vid);
                            if (uvId1 < uv_len)
                            {
                                float tu = 0.0f;
                                float tv = 0.0f;
                                geom.uvcoords.getUV(uvId1, ref tu, ref tv);
                                OpenGL.glTexCoord2f(tu, tv);
                            }
                        }
                    }

                    OpenGL.glNormal3f((float)normal[0], (float)normal[1], (float)normal[2]);
                    OpenGL.glVertex3f((float)vertex[0], (float)vertex[1], (float)vertex[2]);
                    vid++;
                }
                OpenGL.glEnd();
            }

            // Turn off texture mode
            //
            if (drawTexture)
            {
                OpenGL.glDisable(OpenGL.GL_TEXTURE_2D);
            }

            view.endGL();
        }
Ejemplo n.º 21
0
        public void drawVertices(MDrawRequest request, M3dView view)
        {
            MDrawData    data = request.drawData();
            MVectorArray geom = data.geometry() as MVectorArray;

            view.beginGL();

            // Query current state so it can be restored
            //
            bool lightingWasOn = OpenGL.glIsEnabled(OpenGL.GL_LIGHTING) != 0 ? true : false;

            if (lightingWasOn)
            {
                OpenGL.glDisable(OpenGL.GL_LIGHTING);
            }
            float lastPointSize;

            getLastPointSize(out lastPointSize);

            // Set the point size of the vertices
            //
            OpenGL.glPointSize(POINT_SIZE);

            // If there is a component specified by the draw request
            // then loop over comp (using an MFnComponent class) and draw the
            // active vertices, otherwise draw all vertices.
            //
            MObject comp = request.component;

            if (!comp.isNull)
            {
                MFnSingleIndexedComponent fnComponent = new MFnSingleIndexedComponent(comp);
                for (int i = 0; i < fnComponent.elementCount; i++)
                {
                    int index = fnComponent.element(i);
                    OpenGL.glBegin(OpenGL.GL_POINTS);
                    MVector point = geom[index];
                    OpenGL.glVertex3f((float)point[0],
                                      (float)point[1],
                                      (float)point[2]);
                    OpenGL.glEnd();

                    MPoint mp = new MPoint(point);
                    view.drawText(String.Format("{0}", index), mp);
                }
            }
            else
            {
                for (int i = 0; i < geom.length; i++)
                {
                    OpenGL.glBegin(OpenGL.GL_POINTS);
                    MVector point = geom[i];
                    OpenGL.glVertex3f((float)point[0], (float)point[1], (float)point[2]);
                    OpenGL.glEnd();
                }
            }

            // Restore the state
            //
            if (lightingWasOn)
            {
                OpenGL.glEnable(OpenGL.GL_LIGHTING);
            }
            OpenGL.glPointSize(lastPointSize);

            view.endGL();
        }
Ejemplo n.º 22
0
        //
        // Description:
        //
        //     Shaded drawing routine
        //
        // Arguments:
        //
        //     request - request to be drawn
        //     view    - view to draw into
        //
        public void drawShaded( MDrawRequest request, M3dView view )
        {
            MDrawData data = request.drawData();
            apiMeshGeom geom = (apiMeshGeom)data.geometry();
            if (geom == null) return;

            view.beginGL();

            OpenGL.glEnable(OpenGL.GL_POLYGON_OFFSET_FILL);

            // Set up the material
            //
            MMaterial material = request.material;
            material.setMaterial( request.multiPath, request.isTransparent );

            // Enable texturing ...
            //
            // Note, Maya does not enable texturing if useDefaultMaterial is enabled.
            // However, you can choose to ignore this in your draw routine.
            //
            bool drawTexture = material.materialIsTextured && !view.usingDefaultMaterial;

            if (drawTexture)
            {
                OpenGL.glEnable(OpenGL.GL_TEXTURE_2D);
            }

            // Apply the texture to the current view
            //
            if ( drawTexture )
            {
                material.applyTexture( view, data );
            }

            // Draw the polygons
            //
            int vid = 0;
            uint uv_len = geom.uvcoords.uvcount();
            for ( int i=0; i<geom.faceCount; i++ )
            {
                OpenGL.glBegin(OpenGL.GL_POLYGON);
                for ( int v=0; v < geom.face_counts[i]; v++ )
                {
                    MPoint vertex = geom.vertices[ geom.face_connects[vid] ];
                    MVector normal = geom.normals[ geom.face_connects[vid] ];
                    if (uv_len > 0)
                    {
                        // If we are drawing the texture, make sure the coord
                        // arrays are in bounds.
                        if ( drawTexture ) {
                            int uvId1 = geom.uvcoords.uvId(vid);
                            if ( uvId1 < uv_len )
                            {
                                float tu = 0.0f;
                                float tv = 0.0f;
                                geom.uvcoords.getUV( uvId1, ref tu, ref tv );
                                OpenGL.glTexCoord2f( tu, tv );
                            }
                        }
                    }

                    OpenGL.glNormal3f((float)normal[0], (float)normal[1], (float)normal[2]);
                    OpenGL.glVertex3f((float)vertex[0], (float)vertex[1], (float)vertex[2]);
                    vid++;
                }
                OpenGL.glEnd();
            }

            // Turn off texture mode
            //
            if (drawTexture)
            {
                OpenGL.glDisable(OpenGL.GL_TEXTURE_2D);
            }

            view.endGL();
        }
Ejemplo n.º 23
0
        public override void draw(MDrawRequest request, M3dView view)
        //
        // From the given draw request, get the draw data and determine
        // which quadric to draw and with what values.
        //
        {
            MDrawData data = request.drawData();

            quadricGeom geom = data.geometry() as quadricGeom;

            DrawShapeStyle token       = (DrawShapeStyle)request.token;
            bool           drawTexture = false;

            view.beginGL();

            if ((token == DrawShapeStyle.kDrawSmoothShaded) || (token == DrawShapeStyle.kDrawFlatShaded))
            {
                OpenGL.glEnable((uint)OpenGL.GL_POLYGON_OFFSET_FILL);

                // Set up the material
                //
                MMaterial material = request.material;
                material.setMaterial(request.multiPath, request.isTransparent);

                // Enable texturing
                //
                drawTexture = material.materialIsTextured;
                if (drawTexture)
                {
                    OpenGL.glEnable((uint)OpenGL.GL_TEXTURE_2D);
                }

                // Apply the texture to the current view
                //
                if (drawTexture)
                {
                    material.applyTexture(view, data);
                }
            }

            IntPtr qobj = GLUFunctionInvoker.gluNewQuadric();

            switch (token)
            {
            case DrawShapeStyle.kDrawWireframe:
            case DrawShapeStyle.kDrawWireframeOnShaded:
                GLUFunctionInvoker.gluQuadricDrawStyle(qobj, GLU_LINE);
                break;

            case DrawShapeStyle.kDrawSmoothShaded:
                GLUFunctionInvoker.gluQuadricNormals(qobj, GLU_SMOOTH);
                GLUFunctionInvoker.gluQuadricTexture(qobj, GLtrue);
                GLUFunctionInvoker.gluQuadricDrawStyle(qobj, GLU_FILL);
                break;

            case DrawShapeStyle.kDrawFlatShaded:
                GLUFunctionInvoker.gluQuadricNormals(qobj, GLU_FLAT);
                GLUFunctionInvoker.gluQuadricTexture(qobj, GLtrue);
                GLUFunctionInvoker.gluQuadricDrawStyle(qobj, GLU_FILL);
                break;
            }

            switch (geom.shapeType)
            {
            case (short)DrawShapeType.kDrawCylinder:
                GLUFunctionInvoker.gluCylinder(qobj, geom.radius1, geom.radius2, geom.height,
                                               geom.slices, geom.stacks);
                break;

            case (short)DrawShapeType.kDrawDisk:
                GLUFunctionInvoker.gluDisk(qobj, geom.radius1, geom.radius2, geom.slices, geom.loops);
                break;

            case (short)DrawShapeType.kDrawPartialDisk:
                GLUFunctionInvoker.gluPartialDisk(qobj, geom.radius1, geom.radius2, geom.slices,
                                                  geom.loops, geom.startAngle, geom.sweepAngle);
                break;

            case (short)DrawShapeType.kDrawSphere:
            default:
                GLUFunctionInvoker.gluSphere(qobj, geom.radius1, geom.slices, geom.stacks);
                break;
            }

            // Turn off texture mode
            //
            if (drawTexture)
            {
                OpenGL.glDisable((uint)OpenGL.GL_TEXTURE_2D);
            }

            view.endGL();
        }
Ejemplo n.º 24
0
        //
        // Description:
        //
        //     Component (vertex) drawing routine
        //
        // Arguments:
        //
        //     request - request to be drawn
        //     view    - view to draw into
        //
        public void drawVertices( MDrawRequest request, M3dView view )
        {
            MDrawData data = request.drawData();
            apiMeshGeom geom = (apiMeshGeom)data.geometry();
            if (geom == null) return;

            view.beginGL();

            // Query current state so it can be restored
            //
            bool lightingWasOn = OpenGL.glIsEnabled(OpenGL.GL_LIGHTING) != 0;
            if ( lightingWasOn ) {
                OpenGL.glDisable(OpenGL.GL_LIGHTING);
            }
            float[] lastPointSize = new float[1];
            OpenGL.glGetFloatv(OpenGL.GL_POINT_SIZE, lastPointSize);

            // Set the point size of the vertices
            //
            OpenGL.glPointSize(POINT_SIZE);

            // If there is a component specified by the draw request
            // then loop over comp (using an MFnComponent class) and draw the
            // active vertices, otherwise draw all vertices.
            //
            MObject comp = request.component;
            if ( ! comp.isNull ) {
                MFnSingleIndexedComponent fnComponent = new MFnSingleIndexedComponent( comp );
                for ( int i=0; i<fnComponent.elementCount; i++ )
                {
                    int index = fnComponent.element( i );
                    OpenGL.glBegin(OpenGL.GL_POINTS);
                    MPoint vertex = geom.vertices[ index ];
                    OpenGL.glVertex3f((float)vertex[0],
                                (float)vertex[1],
                                (float)vertex[2] );
                    OpenGL.glEnd();

                    string annotation = index.ToString();
                    view.drawText( annotation, vertex );
                }
            }
            else {
                int vid = 0;
                for ( int i=0; i<geom.faceCount; i++ )
                {
                    OpenGL.glBegin(OpenGL.GL_POINTS);
                    for ( int v=0; v<geom.face_counts[i]; v++ )
                    {
                        MPoint vertex = geom.vertices[ geom.face_connects[vid++] ];
                        OpenGL.glVertex3f((float)vertex[0],
                                    (float)vertex[1],
                                    (float)vertex[2] );
                    }
                    OpenGL.glEnd();
                }
            }

            // Restore the state
            //
            if ( lightingWasOn ) {
                OpenGL.glEnable(OpenGL.GL_LIGHTING);
            }
            OpenGL.glPointSize(lastPointSize[0]);

            view.endGL();
        }
Ejemplo n.º 25
0
        //
        // Description:
        //
        //     Bounding box drawing routine
        //
        // Arguments:
        //
        //     request - request to be drawn
        //     view    - view to draw into
        //
        public void drawBoundingBox( MDrawRequest request, M3dView view )
        {
            // Get the surface shape
            MPxSurfaceShape shape = (MPxSurfaceShape)surfaceShape;
            if ( shape == null )
                return;

            // Get the bounding box
            MBoundingBox box = shape.boundingBox();
            float w = (float) box.width;
            float h = (float) box.height;
            float d = (float) box.depth;
            view.beginGL();

            // Below we just two sides and then connect
            // the edges together

            MPoint minVertex = box.min;

            // Draw first side
            OpenGL.glBegin(OpenGL.GL_LINE_LOOP);
            MPoint vertex = minVertex;
            OpenGL.glVertex3f((float)vertex[0], (float)vertex[1], (float)vertex[2]);
            OpenGL.glVertex3f((float)vertex[0] + w, (float)vertex[1], (float)vertex[2]);
            OpenGL.glVertex3f((float)vertex[0] + w, (float)vertex[1] + h, (float)vertex[2]);
            OpenGL.glVertex3f((float)vertex[0], (float)vertex[1] + h, (float)vertex[2]);
            OpenGL.glVertex3f((float)vertex[0], (float)vertex[1], (float)vertex[2]);
            OpenGL.glEnd();

            // Draw second side
            MVector sideFactor = new MVector(0, 0, d);
            MPoint vertex2 = minVertex.plus( sideFactor );
            OpenGL.glBegin(OpenGL.GL_LINE_LOOP);
            OpenGL.glVertex3f((float)vertex2[0], (float)vertex2[1], (float)vertex2[2]);
            OpenGL.glVertex3f((float)vertex2[0] + w, (float)vertex2[1], (float)vertex2[2]);
            OpenGL.glVertex3f((float)vertex2[0] + w, (float)vertex2[1] + h, (float)vertex2[2]);
            OpenGL.glVertex3f((float)vertex2[0], (float)vertex2[1] + h, (float)vertex2[2]);
            OpenGL.glVertex3f((float)vertex2[0], (float)vertex2[1], (float)vertex2[2]);
            OpenGL.glEnd();

            // Connect the edges together
            OpenGL.glBegin(OpenGL.GL_LINES);
            OpenGL.glVertex3f((float)vertex2[0], (float)vertex2[1], (float)vertex2[2]);
            OpenGL.glVertex3f((float)vertex[0], (float)vertex[1], (float)vertex[2]);

            OpenGL.glVertex3f((float)vertex2[0] + w, (float)vertex2[1], (float)vertex2[2]);
            OpenGL.glVertex3f((float)vertex[0] + w, (float)vertex[1], (float)vertex[2]);

            OpenGL.glVertex3f((float)vertex2[0] + w, (float)vertex2[1] + h, (float)vertex2[2]);
            OpenGL.glVertex3f((float)vertex[0] + w, (float)vertex[1] + h, (float)vertex[2]);

            OpenGL.glVertex3f((float)vertex2[0], (float)vertex2[1] + h, (float)vertex2[2]);
            OpenGL.glVertex3f((float)vertex[0], (float)vertex[1] + h, (float)vertex[2]);
            OpenGL.glEnd();

            view.endGL();
        }
Ejemplo n.º 26
0
        /////////////////////////////////////////////////////////////////////
        //
        // Overrides
        //
        /////////////////////////////////////////////////////////////////////

        public override void getDrawRequests(MDrawInfo info,
                                             bool objectAndActiveOnly,
                                             MDrawRequestQueue queue)
        //
        // Description:
        //
        //     Add draw requests to the draw queue
        //
        // Arguments:
        //
        //     info                 - current drawing state
        //     objectsAndActiveOnly - no components if true
        //     queue                - queue of draw requests to add to
        //
        {
            // Get the data necessary to draw the shape
            //
            MDrawData   data     = new MDrawData();
            apiMesh     meshNode = (apiMesh)surfaceShape;
            apiMeshGeom geom     = meshNode.meshGeom();

            if ((null == geom) || (0 == geom.faceCount))
            {
                MGlobal.displayInfo("NO DrawRequest for apiMesh");
                return;
            }

            // This call creates a prototype draw request that we can fill
            // in and then add to the draw queue.
            //
            MDrawRequest request = getDrawRequest(info);             // info.getPrototype(this);

            getDrawData(geom, out data);
            request.setDrawData(data);

            // Decode the draw info and determine what needs to be drawn
            //

            M3dView.DisplayStyle  appearance    = info.displayStyle;
            M3dView.DisplayStatus displayStatus = info.displayStatus;

            // Are we displaying meshes?
            if (!info.objectDisplayStatus(M3dView.DisplayObjects.kDisplayMeshes))
            {
                return;
            }

            // Use this code to help speed up drawing.
            // inUserInteraction() is true for any interaction with
            // the viewport, including object or component TRS and camera changes.
            // userChangingViewContext() is true only when the user is using view
            // context tools (tumble, dolly, track, etc.)
            //
            if (info.inUserInteraction || info.userChangingViewContext)
            {
                // User is using view context tools so
                // request fast draw and get out
                //
                request.token = (int)DrawToken.kDrawRedPointAtCenter;
                queue.add(request);
                return;
            }

            switch (appearance)
            {
            case M3dView.DisplayStyle.kWireFrame:
            {
                request.token = (int)DrawToken.kDrawWireframe;

                int activeColorTable  = (int)M3dView.ColorTable.kActiveColors;
                int dormantColorTable = (int)M3dView.ColorTable.kDormantColors;

                switch (displayStatus)
                {
                case M3dView.DisplayStatus.kLead:
                    request.setColor(LEAD_COLOR, activeColorTable);
                    break;

                case M3dView.DisplayStatus.kActive:
                    request.setColor(ACTIVE_COLOR, activeColorTable);
                    break;

                case M3dView.DisplayStatus.kActiveAffected:
                    request.setColor(ACTIVE_AFFECTED_COLOR, activeColorTable);
                    break;

                case M3dView.DisplayStatus.kDormant:
                    request.setColor(DORMANT_COLOR, dormantColorTable);
                    break;

                case M3dView.DisplayStatus.kHilite:
                    request.setColor(HILITE_COLOR, activeColorTable);
                    break;

                default:
                    break;
                }

                queue.add(request);

                break;
            }

            case M3dView.DisplayStyle.kGouraudShaded:
            {
                // Create the smooth shaded draw request
                //
                request.token = (int)DrawToken.kDrawSmoothShaded;

                // Need to get the material info
                //
                MDagPath  path     = info.multiPath;                    // path to your dag object
                M3dView   view     = info.view;                         // view to draw to
                MMaterial material = base.material(path);

                // If the user currently has the default material enabled on the
                // view then use the default material for shading.
                //
                if (view.usingDefaultMaterial)
                {
                    material = MMaterial.defaultMaterial;
                }

                // Evaluate the material and if necessary, the texture.
                //
                material.evaluateMaterial(view, path);

                bool drawTexture = true;
                if (drawTexture && material.materialIsTextured)
                {
                    material.evaluateTexture(data);
                }

                request.material = material;

                // request.setDisplayStyle( appearance );

                bool materialTransparent = false;
                material.getHasTransparency(ref materialTransparent);
                if (materialTransparent)
                {
                    request.isTransparent = true;
                }

                queue.add(request);

                // create a draw request for wireframe on shaded if
                // necessary.
                //
                if ((displayStatus == M3dView.DisplayStatus.kActive) ||
                    (displayStatus == M3dView.DisplayStatus.kLead) ||
                    (displayStatus == M3dView.DisplayStatus.kHilite))
                {
                    MDrawRequest wireRequest = getDrawRequest(info);                             // info.getPrototype(this);
                    wireRequest.setDrawData(data);
                    wireRequest.token        = (int)DrawToken.kDrawWireframeOnShaded;
                    wireRequest.displayStyle = M3dView.DisplayStyle.kWireFrame;

                    int activeColorTable = (int)M3dView.ColorTable.kActiveColors;

                    switch (displayStatus)
                    {
                    case M3dView.DisplayStatus.kLead:
                        wireRequest.setColor(LEAD_COLOR, activeColorTable);
                        break;

                    case M3dView.DisplayStatus.kActive:
                        wireRequest.setColor(ACTIVE_COLOR, activeColorTable);
                        break;

                    case M3dView.DisplayStatus.kHilite:
                        wireRequest.setColor(HILITE_COLOR, activeColorTable);
                        break;

                    default:
                        break;
                    }

                    queue.add(wireRequest);
                }

                break;
            }

            case M3dView.DisplayStyle.kFlatShaded:
                request.token = (int)DrawToken.kDrawFlatShaded;
                queue.add(request);
                break;

            case M3dView.DisplayStyle.kBoundingBox:
                request.token = (int)DrawToken.kDrawBoundingBox;
                queue.add(request);
                break;

            default:
                break;
            }

            // Add draw requests for components
            //
            if (!objectAndActiveOnly)
            {
                // Inactive components
                //
                if ((appearance == M3dView.DisplayStyle.kPoints) ||
                    (displayStatus == M3dView.DisplayStatus.kHilite))
                {
                    MDrawRequest vertexRequest = getDrawRequest(info);                     // info.getPrototype(this);
                    vertexRequest.setDrawData(data);
                    vertexRequest.token = (int)DrawToken.kDrawVertices;
                    vertexRequest.setColor(DORMANT_VERTEX_COLOR,
                                           (int)M3dView.ColorTable.kActiveColors);

                    queue.add(vertexRequest);
                }

                // Active components
                //
                if (((MPxSurfaceShape)surfaceShape).hasActiveComponents)
                {
                    MDrawRequest activeVertexRequest = getDrawRequest(info);                     // info.getPrototype(this);
                    activeVertexRequest.setDrawData(data);
                    activeVertexRequest.token = (int)DrawToken.kDrawVertices;
                    activeVertexRequest.setColor(ACTIVE_VERTEX_COLOR,
                                                 (int)M3dView.ColorTable.kActiveColors);

                    MObjectArray clist           = ((MPxSurfaceShape)surfaceShape).activeComponents;
                    MObject      vertexComponent = clist[0];                // Should filter list
                    activeVertexRequest.component = vertexComponent;

                    queue.add(activeVertexRequest);
                }
            }
        }