Example #1
0
void    MG_poseReader::drawText(const MString &text,const double* color, const MPoint &position,M3dView &view){

		glColor4d(color[0],color[1],color[2],1.0f);
		
		view.drawText( text, position, M3dView::kLeft );

}
Example #2
0
// Pre-render callback
//
void refreshCompute::preRenderCB(const MString& panelName, void * data)
{
	refreshCompute *thisCompute = (refreshCompute *) data;
	if (!thisCompute)
		return;

	M3dView view;
	MStatus status = M3dView::getM3dViewFromModelPanel(panelName, view);
	if (status != MS::kSuccess)
		return;

	int width = 0, height = 0;
	width = view.portWidth( &status );
	if (status != MS::kSuccess || (width < 2))
		return;
	height = view.portHeight( &status );
	if (status != MS::kSuccess || (height < 2))
		return;

	unsigned int vx,vy,vwidth,vheight;
	vx = 0;
	vy = 0;
	vwidth = width / 2;
	vheight = height / 2;
	status = view.pushViewport (vx, vy, vwidth, vheight);

	if (thisCompute->mBufferOperation != kDrawDepthBuffer)
	{
		M3dView view;
		MStatus status = M3dView::getM3dViewFromModelPanel(panelName, view);
		MPoint origin;
		status = view.drawText( MString("Pre render callback: ") + panelName, origin );
	}
}
Example #3
0
void ProxyViz::drawBrush(M3dView & view)
{
    const float & radius = selectionRadius();
    MString radstr("radius: ");
    radstr += radius;
    const Vector3F & position = selectionCenter();
    view.drawText(radstr, MPoint(position.x, position.y, position.z) );
	
    DrawForest::drawBrush();
}
Example #4
0
void swissArmyLocatorManip::draw(M3dView & view, 
								 const MDagPath &path, 
								 M3dView::DisplayStyle style,
								 M3dView::DisplayStatus status)
{ 
    MPxManipContainer::draw(view, path, style, status);
    view.beginGL(); 

    MPoint textPos = nodeTranslation();
	char str[100];
    sprintf(str, "Swiss Army Manipulator"); 
    MString distanceText(str);
    view.drawText(distanceText, textPos, M3dView::kLeft);
    view.endGL();
}
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 );
}
MStatus viewRenderUserOperation::execute( const MHWRender::MDrawContext & drawContext )
{
	// Sample code to debug pass information
	static const bool debugPassInformation = false;
	if (debugPassInformation)
	{
		const MHWRender::MPassContext & passCtx = drawContext.getPassContext();
		const MString & passId = passCtx.passIdentifier();
		const MStringArray & passSem = passCtx.passSemantics();
		printf("viewRenderUserOperation: drawing in pass[%s], semantic[", passId.asChar());
		for (unsigned int i=0; i<passSem.length(); i++)
			printf(" %s", passSem[i].asChar());
		printf("\n");
	}

	// Example code to find the active override.
	// This is not necessary if the operations just keep a reference
	// to the override, but this demonstrates how this
	// contextual information can be extracted.
	//
	MHWRender::MRenderer *theRenderer = MHWRender::MRenderer::theRenderer();
	const MHWRender::MRenderOverride *overridePtr = NULL;
	if (theRenderer)
	{
		const MString & overrideName = theRenderer->activeRenderOverride();
		overridePtr = theRenderer->findRenderOverride( overrideName );
	}

	// Some sample code to debug lighting information in the MDrawContext
	//
	if (fDebugLightingInfo)
	{
		viewRenderOverrideUtilities::printDrawContextLightInfo( drawContext );
	}

	// Some sample code to debug other MDrawContext information
	//
	if (fDebugDrawContext)
	{
		MStatus status;
		MMatrix matrix = drawContext.getMatrix(MHWRender::MFrameContext::kWorldMtx, &status);
		double dest[4][4];
		status = matrix.get(dest);
		printf("World matrix is:\n");
		printf("\t%f, %f, %f, %f\n", dest[0][0], dest[0][1], dest[0][2], dest[0][3]);
		printf("\t%f, %f, %f, %f\n", dest[1][0], dest[1][1], dest[1][2], dest[1][3]);
		printf("\t%f, %f, %f, %f\n", dest[2][0], dest[2][1], dest[2][2], dest[2][3]);
		printf("\t%f, %f, %f, %f\n", dest[3][0], dest[3][1], dest[3][2], dest[3][3]);

		MDoubleArray viewDirection = drawContext.getTuple(MHWRender::MFrameContext::kViewDirection, &status);
		printf("Viewdirection is: %f, %f, %f\n", viewDirection[0], viewDirection[1], viewDirection[2]);

		MBoundingBox box = drawContext.getSceneBox(&status);
		printf("Screen box is:\n");
		printf("\twidth=%f, height=%f, depth=%f\n", box.width(), box.height(), box.depth());
		float center[4];
		box.center().get(center);
		printf("\tcenter=(%f, %f, %f, %f)\n", center[0], center[1], center[2], center[3]);


		int originX, originY, width, height;
		status = drawContext.getViewportDimensions(originX, originY, width, height);
		printf("Viewport dimension: center(%d, %d), width=%d, heigh=%d\n", originX, originY, width, height);
	}

	//  Draw some addition things for scene draw
	//
	M3dView mView;
	if (mPanelName.length() &&
		(M3dView::getM3dViewFromModelPanel(mPanelName, mView) == MStatus::kSuccess))
	{
		// Get the current viewport and scale it relative to that
		//
		int targetW, targetH;
		drawContext.getRenderTargetSize( targetW, targetH );

		if (fDrawLabel)
		{
			MString testString("Drawing with override: ");
			testString += overridePtr->name();
			MPoint pos(0.0,0.0,0.0);
			glColor3f( 1.0f, 1.0f, 1.0f );
			mView.drawText( testString, pos);
		}

		// Some user drawing of scene bounding boxes
		//
		if (fDrawBoundingBoxes)
		{
			MDagPath cameraPath;
			mView.getCamera( cameraPath);
			MCustomSceneDraw userDraw;
			userDraw.draw( cameraPath, targetW, targetH );
		}
	}
	return MStatus::kSuccess;
}
Example #7
0
void Point::draw(M3dView& view, const MDagPath& mdag_path, 
				 M3dView::DisplayStyle display_style, 
				 M3dView::DisplayStatus display_status) {
	
	MObject self = thisMObject();
	
	int display = MPlug(self, input_display).asInt();
	if (display == 0) {
		return;
	}

	int use_box = MPlug(self, input_box).asInt();
	int use_cross = MPlug(self, input_cross).asInt();
	int use_tick = MPlug(self, input_tick).asInt();
	int use_axis = MPlug(self, input_axis).asInt();
	int color_index = MPlug(self, input_color).asInt();
	
	float tx = MPlug(self, Point::localPositionX).asFloat();
	float ty = MPlug(self, Point::localPositionY).asFloat();
	float tz = MPlug(self, Point::localPositionZ).asFloat();

	float sx = MPlug(self, Point::localScaleX).asFloat();
	float sy = MPlug(self, Point::localScaleY).asFloat();
	float sz = MPlug(self, Point::localScaleZ).asFloat();
	
	MColor color;
	switch (display_status) {
	case M3dView::kActive:
		color = MColor(1.0f, 1.0f, 1.0f);
		break;
	case M3dView::kLead:
		color = MColor(0.26f, 1.0f, 0.64f);
		break;
	case M3dView::kActiveAffected:
		color = MColor(0.783999979496f, 0.0f, 0.783999979496f);
		break;
	case M3dView::kTemplate:
		color = MColor(0.469999998808f, 0.469999998808f, 0.469999998808f);
		break;
	case M3dView::kActiveTemplate:
		color = MColor(1.0f, 0.689999997616f, 0.689999997616f);
		break;
	default:
		color = colors[color_index];
	}
	
	view.beginGL();
	
	if (use_axis == 1) {
		view.setDrawColor(MColor(1.0, 0, 0));
		view.drawText("x", MPoint(sx + tx, ty, tz), M3dView::kCenter);

		view.setDrawColor(MColor(0, 1.0, 0));
		view.drawText("y", MPoint(tx, sy + ty, tz), M3dView::kCenter);

		view.setDrawColor(MColor(0, 0, 1.0));
		view.drawText("z", MPoint(tx, ty, sz + tz), M3dView::kCenter);
	}

	glPushAttrib(GL_CURRENT_BIT);
	glEnable(GL_BLEND);
	glBegin(GL_LINES);

	if (use_box == 1) {
		glColor3f(color.r, color.g, color.b);

		// Top
		glVertex3f(-sx + tx, sy + ty, -sz + tz);
		glVertex3f(sx + tx, sy + ty, -sz + tz);

		glVertex3f(sx + tx, sy + ty, -sz + tz);
		glVertex3f(sx + tx, sy + ty, sz + tz);

		glVertex3f(sx + tx, sy + ty, sz + tz);
		glVertex3f(-sx + tx, sy + ty, sz + tz);

		glVertex3f(-sx + tx, sy + ty, sz + tz);
		glVertex3f(-sx + tx, sy + ty, -sz + tz);

		// Bottom
		glVertex3f(-sx + tx, -sy + ty, -sz + tz);
		glVertex3f(sx + tx, -sy + ty, -sz + tz);

		glVertex3f(sx + tx, -sy + ty, -sz + tz);
		glVertex3f(sx + tx, -sy + ty, sz + tz);

		glVertex3f(sx + tx, -sy + ty, sz + tz);
		glVertex3f(-sx + tx, -sy + ty, sz + tz);

		glVertex3f(-sx + tx, -sy + ty, sz + tz);
		glVertex3f(-sx + tx, -sy + ty, -sz + tz);

		// Left
		glVertex3f(-sx + tx, -sy + ty, -sz + tz);
		glVertex3f(-sx + tx, sy + ty, -sz + tz);

		glVertex3f(-sx + tx, sy + ty, -sz + tz);
		glVertex3f(-sx + tx, sy + ty, sz + tz);

		glVertex3f(-sx + tx, sy + ty, sz + tz);
		glVertex3f(-sx + tx, -sy + ty, sz + tz);

		glVertex3f(-sx + tx, -sy + ty, sz + tz);
		glVertex3f(-sx + tx, -sy + ty, -sz + tz);

		// Right
		glVertex3f(sx + tx, -sy + ty, -sz + tz);
		glVertex3f(sx + tx, sy + ty, -sz + tz);

		glVertex3f(sx + tx, sy + ty, -sz + tz);
		glVertex3f(sx + tx, sy + ty, sz + tz);

		glVertex3f(sx + tx, sy + ty, sz + tz);
		glVertex3f(sx + tx, -sy + ty, sz + tz);

		glVertex3f(sx + tx, -sy + ty, sz + tz);
		glVertex3f(sx + tx, -sy + ty, -sz + tz);
	}

	if (use_cross == 1) {
		glColor3f(color.r, color.g, color.b);

		glVertex3f(tx, -sy + ty, tz);
		glVertex3f(tx, sy + ty, tz);

		glVertex3f(-sx + tx, ty, tz);
		glVertex3f(sx + tx, ty, tz);

		glVertex3f(tx, ty, -sz + tz);
		glVertex3f(tx, ty, sz + tz);
	}

	if (use_tick == 1) {
		glColor3f(color.r, color.g, color.b);

		glVertex3f((-sx*0.05f) + tx, (sy*0.05f) + ty, tz);
		glVertex3f((sx*0.05f) + tx, (-sy*0.05f) + ty, tz);

		glVertex3f((sx*0.05f) + tx, (sy*0.05f) + ty, tz);
		glVertex3f((-sx*0.05f) + tx, (-sy*0.05f) + ty, tz);

		glVertex3f(tx, (sy*0.05f) + ty, (-sz*0.05f) + tz);
		glVertex3f(tx, (-sy*0.05f) + ty, (sz*0.05f) + tz);

		glVertex3f(tx, (sy*0.05f) + ty, (sz*0.05f) + tz);
		glVertex3f(tx, (-sy*0.05f) + ty, (-sz*0.05f) + tz);

		glVertex3f((sx*0.05f) + tx, ty, (-sz*0.05f) + tz);
		glVertex3f((-sx*0.05f) + tx, ty, (sz*0.05f) + tz);

		glVertex3f((sx*0.05f) + tx, ty, (sz*0.05f) + tz);
		glVertex3f((-sx*0.05f) + tx, ty, (-sz*0.05f) + tz);
	}

	if (use_axis == 1) {
		glColor3f(color.r, color.g, color.b);

		if (display_status == M3dView::kDormant) {
			glColor3f(1.0f, 0.0f, 0.0f);
		}
		glVertex3f(tx, ty, tz);
		glVertex3f(sx + tx, ty, tz);

		if (display_status == M3dView::kDormant) {
			glColor3f(0.0f, 1.0f, 0.0f);
		}
		glVertex3f(tx, ty, tz);
		glVertex3f(tx, sy + ty, tz);

		if (display_status == M3dView::kDormant) {
			glColor3f(0.0f, 0.0f, 1.0f);
		}
		glVertex3f(tx, ty, tz);
		glVertex3f(tx, ty, sz + tz);
	}

	glEnd();
	glDisable(GL_BLEND);
	glPopAttrib();

	view.endGL();
}
Example #8
0
void apiSimpleShapeUI::drawVertices( const MDrawRequest & request,
							  M3dView & view ) const
//
// Description:
//
//     Component (vertex) drawing routine
//
// Arguments:
//
//     request - request to be drawn
//     view    - view to draw into
//
{
	MDrawData data = request.drawData();
	MVectorArray * geom = (MVectorArray*)data.geometry();

	view.beginGL(); 

	// Query current state so it can be restored
	//
	bool lightingWasOn = glIsEnabled( GL_LIGHTING ) ? true : false;
	if ( lightingWasOn ) {
		glDisable( GL_LIGHTING );
	}
	float lastPointSize;
	glGetFloatv( GL_POINT_SIZE, &lastPointSize );

	// Set the point size of the vertices
	//
	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( comp );
		for ( int i=0; i<fnComponent.elementCount(); i++ )
		{
			int index = fnComponent.element( i );
			glBegin( GL_POINTS );
			MVector& point = (*geom)[index];
			glVertex3f( (float)point[0], 
						(float)point[1], 
						(float)point[2] );
			glEnd();

			char annotation[32];
			sprintf( annotation, "%d", index );
			view.drawText( annotation, point );
		}
	}
	else {
		for ( unsigned int i=0; i<geom->length(); i++ )
		{
			glBegin( GL_POINTS );
			MVector point = (*geom)[ i ];
			glVertex3f( (float)point[0], (float)point[1], (float)point[2] );
			glEnd();
		}
	}

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

	view.endGL(); 
}