Exemple #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();
}
void sphericalBlendShapeVisualizerDrawOverride::addUIDrawables(
								const MDagPath& objPath,
								MHWRender::MUIDrawManager& drawManager,
								const MHWRender::MFrameContext& frameContext,
								const MUserData* data)
{
	sphericalBlendShapeVisualizerData* pLocatorData = (sphericalBlendShapeVisualizerData*)data;
	if (!pLocatorData)
	{
		return;
	}

	MMatrix spaceMatrix    = pLocatorData->fSpaceMatrix;
	MMatrix spaceInvMatrix = spaceMatrix.inverse();

	short poleAxis      = pLocatorData->fPoleAxis;
	short seamAxis      = pLocatorData->fSeamAxis;

	drawManager.beginDrawable();

	MColor lineColor, vertexColor, poleAxisColor, seamAxisColor;
	lineColor		= MColor(0.7294f, .239216f, 0.2980f, 1.0f);
	vertexColor		= MColor(0.5843f, 0.78824f, .17255f, 1.0f);
	poleAxisColor   = MColor(1.0f, 0.0f, 0.f, 1.0f);
	seamAxisColor   = MColor(0.0f, 1.0f, 0.0f, 1.0f);

	MMatrix identity;
	identity.setToIdentity();

	double radius   = 1.0;
	int numRings    = 20;
	int numSections = 20;

	MPoint sphericalPoint, xyzPoint;
	MPoint startPoint, endPoint, firstPoint;
	MPointArray points;

	drawManager.setDepthPriority(5);

	drawManager.setColor(lineColor);

	bboxPoints.clear();
	bboxPoints.setLength(numRings*numSections);

	for(int ring=0; ring<=numRings; ring++) {
		double azimuth = (double)ring / numRings * M_PI * 2;

		for(int section=0; section<=numSections; section++) {
			double zenith = (double)section / (numSections) * M_PI;

			sphericalPoint.x = radius;
			sphericalPoint.y = zenith;
			sphericalPoint.z = azimuth;
			
			if (section==0) {
				sphericalToCartesian(sphericalPoint, poleAxis, seamAxis, startPoint);
				startPoint = startPoint * spaceMatrix;
				firstPoint = startPoint;
				bboxPoints.append(firstPoint);
				continue;
			} else {
				sphericalToCartesian(sphericalPoint, poleAxis, seamAxis, endPoint);
				endPoint = endPoint * spaceMatrix;
				drawManager.line(startPoint, endPoint);
				bboxPoints.append(endPoint);
				startPoint = endPoint;
			}
		}
	}

	for(int ring=0; ring<=numRings; ring++) {
		double azimuth = (double)ring / numRings * M_PI * 2;

		for(int section=0; section<=numSections; section++) {
			double zenith = (double)section / (numSections) * M_PI;

			sphericalPoint.x = radius;
			sphericalPoint.y = azimuth;
			sphericalPoint.z = zenith;
			
			if (section==0) {
				sphericalToCartesian(sphericalPoint, poleAxis, seamAxis, startPoint);
				startPoint = startPoint * spaceMatrix;
				firstPoint = startPoint;
				continue;
			} else {
				sphericalToCartesian(sphericalPoint, poleAxis, seamAxis, endPoint);
				endPoint = endPoint * spaceMatrix;
				drawManager.line(startPoint, endPoint);
				startPoint = endPoint;
			}
		}
	}

	drawManager.setLineWidth(3.0);
	drawManager.setLineStyle(MHWRender::MUIDrawManager::kDashed);
	
	startPoint = MPoint(0, 0, 0) * spaceMatrix;


	MVector endVector(0, 0, 0);
	setAxis(endVector, poleAxis, radius);
	endPoint = MPoint(endVector) * spaceMatrix;

	drawManager.setColor(poleAxisColor);
	drawManager.line(startPoint, endPoint);

	endVector = MVector(0, 0, 0);
	setAxis(endVector, seamAxis, radius);
	endPoint = MPoint(endVector) * spaceMatrix;

	drawManager.setColor(seamAxisColor);
	drawManager.line(startPoint, endPoint);
	drawManager.endDrawable();
}