Example #1
0
MBoundingBox footPrint::boundingBox() const
{
	// Get the size
	//
	MObject thisNode = thisMObject();
	MPlug plug( thisNode, size );
	MDistance sizeVal;
	plug.getValue( sizeVal );

	double multiplier = sizeVal.asCentimeters();

	MPoint corner1( -0.17, 0.0, -0.7 );
	MPoint corner2( 0.17, 0.0, 0.3 );

	corner1 = corner1 * multiplier;
	corner2 = corner2 * multiplier;

	return MBoundingBox( corner1, corner2 );
}
Example #2
0
MBoundingBox swissArmyLocator::boundingBox() const
{   
	// Get the size
	//
	MObject thisNode = thisMObject();
	MPlug plug(thisNode, aSize);
	MDistance sizeVal;
	plug.getValue(sizeVal);

	double multiplier = sizeVal.asCentimeters();
 
	MPoint corner1(-1.1, 0.0, -1.1);
	MPoint corner2(1.1, 0.0, 1.1);

	corner1 = corner1 * multiplier;
	corner2 = corner2 * multiplier;

	return MBoundingBox(corner1, corner2);
}
Example #3
0
float FootPrintDrawOverride::getMultiplier(const MDagPath& objPath) const
{
	// Retrieve value of the size attribute from the node
	MStatus status;
	MObject footprintNode = objPath.node(&status);
	if (status)
	{
		MPlug plug(footprintNode, footPrint::size);
		if (!plug.isNull())
		{
			MDistance sizeVal;
			if (plug.getValue(sizeVal))
			{
				return (float)sizeVal.asCentimeters();
			}
		}
	}

	return 1.0f;
}
Example #4
0
float convert( const MDistance &from )
{
	return from.asCentimeters();
}
Example #5
0
// called by legacy default viewport
void footPrint::draw( M3dView & view, const MDagPath & /*path*/,
							 M3dView::DisplayStyle style,
							 M3dView::DisplayStatus status )
{
	// Get the size
	//
	MObject thisNode = thisMObject();
	MPlug plug( thisNode, size );
	MDistance sizeVal;
	plug.getValue( sizeVal );

	float multiplier = (float) sizeVal.asCentimeters();

	view.beginGL();


	if ( ( style == M3dView::kFlatShaded ) ||
		 ( style == M3dView::kGouraudShaded ) )
	{ 
		// Push the color settings
		//
		glPushAttrib( GL_CURRENT_BIT );

		if ( status == M3dView::kActive ) {
			view.setDrawColor( 13, M3dView::kActiveColors );
		} else {
			view.setDrawColor( 13, M3dView::kDormantColors );
		}

		glBegin( GL_TRIANGLE_FAN );
	        int i;
			int last = soleCount - 1;
			for ( i = 0; i < last; ++i ) {
				glVertex3f( sole[i][0] * multiplier,
							sole[i][1] * multiplier,
							sole[i][2] * multiplier );
			}
		glEnd();
		glBegin( GL_TRIANGLE_FAN );
			last = heelCount - 1;
			for ( i = 0; i < last; ++i ) {
				glVertex3f( heel[i][0] * multiplier,
							heel[i][1] * multiplier,
							heel[i][2] * multiplier );
			}
		glEnd();

		glPopAttrib();
	}

	// Draw the outline of the foot
	//
	glBegin( GL_LINES );
	    int i;
	    int last = soleCount - 1;
	    for ( i = 0; i < last; ++i ) {
			glVertex3f( sole[i][0] * multiplier,
						sole[i][1] * multiplier,
						sole[i][2] * multiplier );
			glVertex3f( sole[i+1][0] * multiplier,
						sole[i+1][1] * multiplier,
						sole[i+1][2] * multiplier );
		}
		last = heelCount - 1;
	    for ( i = 0; i < last; ++i ) {
			glVertex3f( heel[i][0] * multiplier,
						heel[i][1] * multiplier,
						heel[i][2] * multiplier );
			glVertex3f( heel[i+1][0] * multiplier,
						heel[i+1][1] * multiplier,
						heel[i+1][2] * multiplier );
		}
	glEnd();


	view.endGL();

	// Draw the name of the footPrint
	view.setDrawColor( MColor( 0.1f, 0.8f, 0.8f, 1.0f ) );
	view.drawText( MString("Footprint"), MPoint( 0.0, 0.0, 0.0 ), M3dView::kCenter );
}
Example #6
0
void swissArmyLocator::draw(M3dView &view, const MDagPath &/*path*/, 
							M3dView::DisplayStyle style,
							M3dView::DisplayStatus status)
{ 
	// Get the size
	//
	MObject thisNode = thisMObject();

	MPlug plug(thisNode, aSize);
	MDistance sizeVal;
	plug.getValue(sizeVal);

	MPlug arrow1AnglePlug(thisNode, aArrow1Angle);
	MAngle arrow1Angle;
	arrow1AnglePlug.getValue(arrow1Angle);
	double angle1 = -arrow1Angle.asRadians() - 3.1415927/2.0;

	MPlug arrow3AnglePlug(thisNode, aArrow3Angle);
	MAngle arrow3Angle;
	arrow3AnglePlug.getValue(arrow3Angle);
	double angle3 = arrow3Angle.asRadians();

	MPlug statePlug(thisNode, aState);
	int state;
	statePlug.getValue(state);

	MPlug togglePlug(thisNode, aToggle);
	bool toggle;
	togglePlug.getValue(toggle);

	MPlug directionXPlug(thisNode, aArrow2DirectionX);
	MPlug directionYPlug(thisNode, aArrow2DirectionY);
	MPlug directionZPlug(thisNode, aArrow2DirectionZ);
	double dirX;
	double dirY;
	double dirZ;
	directionXPlug.getValue(dirX);
	directionYPlug.getValue(dirY);
	directionZPlug.getValue(dirZ);
	double angle2 = atan2(dirZ,dirX);
	angle2 += 3.1415927;

	float multiplier = (float) sizeVal.asCentimeters();

	view.beginGL(); 

	if ((style == M3dView::kFlatShaded) || 
		(style == M3dView::kGouraudShaded)) 
	{  
		// Push the color settings
		// 
		glPushAttrib(GL_CURRENT_BIT);

		if (status == M3dView::kActive) {
			view.setDrawColor(13, M3dView::kActiveColors);
		} else {
			view.setDrawColor(13, M3dView::kDormantColors);
		}  

		int i;
		int last;

		if (toggle) {
		if (status == M3dView::kActive)
			view.setDrawColor(15, M3dView::kActiveColors);
		else
			view.setDrawColor(15, M3dView::kDormantColors);
		glBegin(GL_TRIANGLE_FAN);
			last = centreCount - 1;
			for (i = 0; i < last; ++i) {
				glVertex3f(centre[i][0] * multiplier,
						   centre[i][1] * multiplier,
						   centre[i][2] * multiplier);
			}
		glEnd();
		}

		if (state == 0) {
		if (status == M3dView::kActive)
			view.setDrawColor(19, M3dView::kActiveColors);
		else
			view.setDrawColor(19, M3dView::kDormantColors);
		glBegin(GL_TRIANGLE_FAN);
			last = state1Count - 1;
			for (i = 0; i < last; ++i) {
				glVertex3f(state1[i][0] * multiplier,
						   state1[i][1] * multiplier,
						   state1[i][2] * multiplier);
			}
		glEnd();
		}

		if (state == 1) {
		if (status == M3dView::kActive)
			view.setDrawColor(21, M3dView::kActiveColors);
		else
			view.setDrawColor(21, M3dView::kDormantColors);
		glBegin(GL_TRIANGLE_FAN);
			last = state2Count - 1;
			for (i = 0; i < last; ++i) {
				glVertex3f(state2[i][0] * multiplier,
						   state2[i][1] * multiplier,
						   state2[i][2] * multiplier);
			}
		glEnd();
		}

		if (state == 2) {
		if (status == M3dView::kActive)
			view.setDrawColor(18, M3dView::kActiveColors);
		else
			view.setDrawColor(18, M3dView::kDormantColors);
		glBegin(GL_TRIANGLE_FAN);
			last = state3Count - 1;
			for (i = 0; i < last; ++i) {
				glVertex3f(state3[i][0] * multiplier,
						   state3[i][1] * multiplier,
						   state3[i][2] * multiplier);
			}
		glEnd();
		}

		if (state == 3) {
		if (status == M3dView::kActive)
			view.setDrawColor(17, M3dView::kActiveColors);
		else
			view.setDrawColor(17, M3dView::kDormantColors);
		glBegin(GL_TRIANGLE_FAN);
			last = state4Count - 1;
			for (i = 0; i < last; ++i) {
				glVertex3f(state4[i][0] * multiplier,
						   state4[i][1] * multiplier,
						   state4[i][2] * multiplier);
			}
		glEnd();
		}

		if (status == M3dView::kActive)
			view.setDrawColor(12, M3dView::kActiveColors);
		else
			view.setDrawColor(12, M3dView::kDormantColors);
		glBegin(GL_TRIANGLE_FAN);
			last = arrow1Count - 1;
			for (i = 0; i < last; ++i) {
				glVertex3f( (float) (- arrow1[i][0] * multiplier * cos(angle1) 
						   - arrow1[i][2] * multiplier * sin(angle1)),
						   (float) (arrow1[i][1] * multiplier + delta1),
						   (float) (arrow1[i][2] * multiplier * cos(angle1) -
						   arrow1[i][0] * multiplier * sin(angle1)));
			}
		glEnd();

		if (status == M3dView::kActive)
			view.setDrawColor(16, M3dView::kActiveColors);
		else
			view.setDrawColor(16, M3dView::kDormantColors);
		glBegin(GL_TRIANGLE_FAN);
			last = arrow2Count - 1;
			for (i = 0; i < last; ++i) {
				glVertex3f( (float) (- arrow2[i][0] * multiplier * cos(angle2) 
						   - arrow2[i][2] * multiplier * sin(angle2)),
						   (float) (arrow2[i][1] * multiplier + delta2),
						   (float) (arrow2[i][2] * multiplier * cos(angle2) -
						   arrow2[i][0] * multiplier * sin(angle2)));
			}
		glEnd();

		if (status == M3dView::kActive)
			view.setDrawColor(13, M3dView::kActiveColors);
		else
			view.setDrawColor(13, M3dView::kDormantColors);
		glBegin(GL_TRIANGLE_FAN);
			last = arrow3Count - 1;
			for (i = 0; i < last; ++i) {
				glVertex3f( (float) (- arrow3[i][0] * multiplier * cos(angle3) 
						   - arrow3[i][2] * multiplier * sin(angle3)),
						   (float) (arrow3[i][1] * multiplier + delta3),
						   (float) (arrow3[i][2] * multiplier * cos(angle3) -
						   arrow3[i][0] * multiplier * sin(angle3)));
			}
		glEnd();

		if (status == M3dView::kActive)
			view.setDrawColor(5, M3dView::kActiveColors);
		else
			view.setDrawColor(5, M3dView::kDormantColors);
		glBegin(GL_TRIANGLE_FAN);
			last = arrow4Count - 1;
			for (i = 0; i < last; ++i) {
				glVertex3f((float) (arrow4[i][0] * multiplier),
						   (float) (arrow4[i][1] * multiplier + delta4),
						   (float) (arrow4[i][2] * multiplier));
			}
		glEnd();

		glPopAttrib();
	}

	// Draw the outline of the locator
	//
	glBegin(GL_LINES);
	    int i;
		int last;

		if (toggle) {
		last = centreCount - 1;
	    for (i = 0; i < last; ++i) { 
			glVertex3f(centre[i][0] * multiplier, 
					   centre[i][1] * multiplier, 
					   centre[i][2] * multiplier);
			glVertex3f(centre[i+1][0] * multiplier, 
					   centre[i+1][1] * multiplier, 
					   centre[i+1][2] * multiplier);
		}
		}

		if (state == 0) {
		last = state1Count - 1;
	    for (i = 0; i < last; ++i) { 
			glVertex3f(state1[i][0] * multiplier, 
					   state1[i][1] * multiplier, 
					   state1[i][2] * multiplier);
			glVertex3f(state1[i+1][0] * multiplier, 
					   state1[i+1][1] * multiplier, 
					   state1[i+1][2] * multiplier);
		}
		}

		if (state == 1) {
		last = state2Count - 1;
	    for (i = 0; i < last; ++i) { 
			glVertex3f(state2[i][0] * multiplier, 
					   state2[i][1] * multiplier, 
					   state2[i][2] * multiplier);
			glVertex3f(state2[i+1][0] * multiplier, 
					   state2[i+1][1] * multiplier, 
					   state2[i+1][2] * multiplier);
		}
		}

		if (state == 2) {
		last = state3Count - 1;
	    for (i = 0; i < last; ++i) { 
			glVertex3f(state3[i][0] * multiplier, 
					   state3[i][1] * multiplier, 
					   state3[i][2] * multiplier);
			glVertex3f(state3[i+1][0] * multiplier, 
					   state3[i+1][1] * multiplier, 
					   state3[i+1][2] * multiplier);
		}
		}

		if (state == 3) {
		last = state4Count - 1;
	    for (i = 0; i < last; ++i) { 
			glVertex3f(state4[i][0] * multiplier, 
					   state4[i][1] * multiplier, 
					   state4[i][2] * multiplier);
			glVertex3f(state4[i+1][0] * multiplier, 
					   state4[i+1][1] * multiplier, 
					   state4[i+1][2] * multiplier);
		}
		}

		last = arrow1Count - 1;
	    for (i = 0; i < last; ++i) { 
			glVertex3f((float) (- arrow1[i][0] * multiplier * cos(angle1) 
					   - arrow1[i][2] * multiplier * sin(angle1)),
					   (float) (arrow1[i][1] * multiplier + delta1),
					   (float) (arrow1[i][2] * multiplier * cos(angle1) -
					   arrow1[i][0] * multiplier * sin(angle1)));
			glVertex3f((float) (- arrow1[i+1][0] * multiplier * cos(angle1) 
					   - arrow1[i+1][2] * multiplier * sin(angle1)),
					   (float) (arrow1[i+1][1] * multiplier + delta1),
					   (float) (arrow1[i+1][2] * multiplier * cos(angle1) -
					   arrow1[i+1][0] * multiplier * sin(angle1)));
		}

		last = arrow2Count - 1;
	    for (i = 0; i < last; ++i) { 
			glVertex3f((float) (- arrow2[i][0] * multiplier * cos(angle2) 
					   - arrow2[i][2] * multiplier * sin(angle2)),
					   (float) (arrow2[i][1] * multiplier + delta2),
					   (float) (arrow2[i][2] * multiplier * cos(angle2) -
					   arrow2[i][0] * multiplier * sin(angle2)));
			glVertex3f((float) (- arrow2[i+1][0] * multiplier * cos(angle2) 
					   - arrow2[i+1][2] * multiplier * sin(angle2)),
					   (float) (arrow2[i+1][1] * multiplier + delta2),
					   (float) (arrow2[i+1][2] * multiplier * cos(angle2) -
					   arrow2[i+1][0] * multiplier * sin(angle2)));
		}

		last = arrow3Count - 1;
	    for (i = 0; i < last; ++i) { 
			glVertex3f((float) (- arrow3[i][0] * multiplier * cos(angle3) 
					   - arrow3[i][2] * multiplier * sin(angle3)),
					   (float) (arrow3[i][1] * multiplier + delta3),
					   (float) (arrow3[i][2] * multiplier * cos(angle3) -
					   arrow3[i][0] * multiplier * sin(angle3)));
			glVertex3f((float) (- arrow3[i+1][0] * multiplier * cos(angle3) 
					   - arrow3[i+1][2] * multiplier * sin(angle3)),
					   (float) (arrow3[i+1][1] * multiplier + delta3),
					   (float) (arrow3[i+1][2] * multiplier * cos(angle3) -
					   arrow3[i+1][0] * multiplier * sin(angle3)));
		}

		last = arrow4Count - 1;
	    for (i = 0; i < last; ++i) { 
			glVertex3f((float) (arrow4[i][0] * multiplier), 
					   (float) (arrow4[i][1] * multiplier + delta4), 
					   (float) (arrow4[i][2] * multiplier));
			glVertex3f((float) (arrow4[i+1][0] * multiplier), 
					   (float) (arrow4[i+1][1] * multiplier + delta4), 
					   (float) (arrow4[i+1][2] * multiplier));
		}

		last = perimeterCount - 1;
	    for (i = 0; i < last; ++i) { 
			glVertex3f(perimeter[i][0] * multiplier, 
					   perimeter[i][1] * multiplier, 
					   perimeter[i][2] * multiplier);
			glVertex3f(perimeter[i+1][0] * multiplier, 
					   perimeter[i+1][1] * multiplier, 
					   perimeter[i+1][2] * multiplier);
		}

	glEnd();

	view.endGL();
}