Ejemplo n.º 1
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.º 2
0
        //
        // 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
        //
        /////////////////////////////////////////////////////////////////////
        //
        // Overrides
        //
        /////////////////////////////////////////////////////////////////////
        public override void getDrawRequests( MDrawInfo info,
            bool objectAndActiveOnly,
            MDrawRequestQueue queue)
        {
            // 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 );
                }
            }
        }
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
        /////////////////////////////////////////////////////////////////////
        //
        // 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);
                }
            }
        }