Пример #1
0
// addUIDrawables() provides access to the MUIDrawManager, which can be used
// to queue up operations for drawing simple UI elements such as lines, circles and
// text. To enable addUIDrawables(), override hasUIDrawables() and make it return true.
void FootPrintDrawOverride::addUIDrawables(
		const MDagPath& objPath,
		MHWRender::MUIDrawManager& drawManager,
		const MHWRender::MFrameContext& frameContext,
		const MUserData* data)
{
	// Get data cached by prepareForDraw() for each drawable instance, then MUIDrawManager 
	// can draw simple UI by these data.
	FootPrintData* pLocatorData = (FootPrintData*)data;
	if (!pLocatorData)
	{
		return;
	}

	drawManager.beginDrawable();

	// Draw the foot print solid/wireframe
	drawManager.setColor( pLocatorData->fColor );
	drawManager.setDepthPriority(5);

	if (frameContext.getDisplayStyle() & MHWRender::MFrameContext::kGouraudShaded) {
		drawManager.mesh(MHWRender::MUIDrawManager::kTriangles, pLocatorData->fSoleTriangleList);
		drawManager.mesh(MHWRender::MUIDrawManager::kTriangles, pLocatorData->fHeelTriangleList);
	}

	drawManager.mesh(MHWRender::MUIDrawManager::kClosedLine, pLocatorData->fSoleLineList);
	drawManager.mesh(MHWRender::MUIDrawManager::kClosedLine, pLocatorData->fHeelLineList);

	// Draw a text "Foot"
	MPoint pos( 0.0, 0.0, 0.0 ); // Position of the text
	MColor textColor( 0.1f, 0.8f, 0.8f, 1.0f ); // Text color

	drawManager.setColor( textColor );
	drawManager.setFontSize( MHWRender::MUIDrawManager::kSmallFontSize );
	drawManager.text( pos,  MString("Footprint"), MHWRender::MUIDrawManager::kCenter );

	drawManager.endDrawable();
}
Пример #2
0
MStatus SGToolContext::doPtrMoved(MEvent& evt, MHWRender::MUIDrawManager& drawManager, const MHWRender::MFrameContext& frameContext ) {
	sgPrintf( "context class name : %s", frameContext.className() );

	return MS::kSuccess;
}
Пример #3
0
void UsdMayaGLHdRenderer::GenerateDefaultVp2DrawRequests(
    const MDagPath& objPath,
    const MHWRender::MFrameContext& frameContext,
    const MBoundingBox& bounds,
    UsdMayaGLHdRenderer::RequestDataArray *requestArray
    )
{
    if(requestArray == NULL) {
        return;
    }
    M3dView viewHelper = M3dView::active3dView();

    const MHWRender::DisplayStatus displayStatus =
        MHWRender::MGeometryUtilities::displayStatus(objPath);

    const bool isSelected =
            (displayStatus == MHWRender::kActive) ||
            (displayStatus == MHWRender::kLead)   ||
            (displayStatus == MHWRender::kHilite);

    const MColor mayaWireframeColor =
        MHWRender::MGeometryUtilities::wireframeColor(objPath);
    const GfVec4f wireframeColor(mayaWireframeColor.r,
                                 mayaWireframeColor.g,
                                 mayaWireframeColor.b,
                                 mayaWireframeColor.a);


    requestArray->clear();

    if( !(frameContext.getDisplayStyle() & MHWRender::MFrameContext::DisplayStyle::kWireFrame) &&
        !(frameContext.getDisplayStyle() & MHWRender::MFrameContext::DisplayStyle::kBoundingBox) )
    {
        UsdMayaGLHdRenderer::RequestData shadedRequest;
        shadedRequest.fWireframeColor = wireframeColor;
        shadedRequest.bounds = bounds;
// Maya 2015 lacks MHWRender::MFrameContext::DisplayStyle::kFlatShaded for whatever reason...
#if MAYA_API_VERSION >= 201600
        if( frameContext.getDisplayStyle() & MHWRender::MFrameContext::DisplayStyle::kFlatShaded )
        {
            shadedRequest.drawRequest.setToken( UsdMayaGLHdRenderer::DRAW_SHADED_FLAT );
            shadedRequest.drawRequest.setDisplayStyle(M3dView::kFlatShaded);
        }
        else
#endif
        {
            shadedRequest.drawRequest.setToken( UsdMayaGLHdRenderer::DRAW_SHADED_SMOOTH );
            shadedRequest.drawRequest.setDisplayStyle(M3dView::kGouraudShaded);
        }

        requestArray->push_back( shadedRequest );
    }

    if(isSelected || (frameContext.getDisplayStyle() & MHWRender::MFrameContext::DisplayStyle::kWireFrame) )
    {
        UsdMayaGLHdRenderer::RequestData wireRequest;
        wireRequest.bounds = bounds;
        wireRequest.drawRequest.setToken( UsdMayaGLHdRenderer::DRAW_WIREFRAME);
        wireRequest.drawRequest.setDisplayStyle(M3dView::kWireFrame);
        wireRequest.fWireframeColor = wireframeColor;
        requestArray->push_back( wireRequest );
    }
}