Пример #1
0
void Robot::DrawRobot(float xPos, float yPos, float zPos)
{
	glPushMatrix();	
		glTranslatef(xPos, yPos, zPos);	// draw robot at desired coordinates

		// draw head and torso parts
		DrawHead(1.0f, 2.0f, 0.0f);		
		DrawTorso(1.5f, 0.0f, 0.0f);

		// move the left arm away from the torso and rotate it to give "walking" effect
		glPushMatrix();
			glTranslatef(0.0f, -0.5f, 0.0f);
			glRotatef(armAngles[LEFT], 1.0f, 0.0f, 0.0f);
			DrawArm(2.5f, 0.0f, -0.5f);
		glPopMatrix();

		// move the right arm away from the torso and rotate it to give "walking" effect
		glPushMatrix();
			glTranslatef(0.0f, -0.5f, 0.0f);
			glRotatef(armAngles[RIGHT], 1.0f, 0.0f, 0.0f);
			DrawArm(-1.5f, 0.0f, -0.5f);
		glPopMatrix();

		// move the left leg away from the torso and rotate it to give "walking" effect
		glPushMatrix();					
			glTranslatef(0.0f, -0.5f, 0.0f);
			glRotatef(legAngles[LEFT], 1.0f, 0.0f, 0.0f);
			DrawLeg(-0.5f, -5.0f, -0.5f);
		glPopMatrix();

		// move the right leg away from the torso and rotate it to give "walking" effect
		glPushMatrix();
			glTranslatef(0.0f, -0.5f, 0.0f);
			glRotatef(legAngles[RIGHT], 1.0f, 0.0f, 0.0f);
			DrawLeg(1.5f, -5.0f, -0.5f);
		glPopMatrix();

	glPopMatrix();	// pop back to original coordinate system
}
Пример #2
0
void TuxDraw::DrawJacket(const TuxPts *pTuxedo,
	ID2D1SolidColorBrush* pSuiteColor,
	ID2D1SolidColorBrush* pShirtColor,
	ID2D1HwndRenderTarget*  pRenderTarget)
{

	//ID2D1Mesh* pMesh;
	//ID2D1TessellationSink *pSink;
	//pMesh->Open(&pSink);
	//pSink->AddTriangles();
	//pRenderTarget->CreateMesh(&pMesh);
	//pRenderTarget->Cre

	//pRenderTarget->FillGeometry(, pSuiteColor);
	int strokeWidth = 3;
	FLOAT hipSpan = (pTuxedo->pts[JointType_HipRight].x - pTuxedo->pts[JointType_HipLeft].x) / 2.0f;
	FLOAT shoulderSpan = pTuxedo->pts[JointType_ShoulderRight].x - pTuxedo->pts[JointType_ShoulderLeft].x;
	shoulderSpan = shoulderSpan < 0.1 ? 1 : shoulderSpan;

	int shirtWidth = (int)hipSpan;
	int deltaShirtX = 0;
	D2D1_POINT_2F suitPtTop = pTuxedo->pts[JointType_SpineShoulder];
	D2D1_POINT_2F suitPtBottom = pTuxedo->pts[JointType_SpineBase];

	int deltaSuitX = shirtWidth;
	int suitWidth = (int)(shoulderSpan / 2);
	D2D1_POINT_2F suiteTop = pTuxedo->pts[JointType_SpineShoulder];
	D2D1_POINT_2F suiteBottom = pTuxedo->pts[JointType_SpineBase];

	bool drawSuit = true;
	bool drawShirt = true;

	while (drawShirt || drawSuit)
	{
		//draw the shirt
		drawShirt = deltaShirtX < shirtWidth;
		drawSuit = deltaSuitX < suitWidth;
		if (drawShirt)
		{
			suitPtTop.x += deltaShirtX;
			pRenderTarget->DrawLine(suitPtTop, suitPtBottom, pShirtColor,  strokeWidth);

			suitPtTop.x += -2 * deltaShirtX;
			pRenderTarget->DrawLine(suitPtTop, suitPtBottom, pShirtColor, strokeWidth);
			suitPtTop.x = suitPtTop.x +deltaShirtX;
		}

		if (drawSuit)
		{
			suitPtTop.x += deltaSuitX;
			suitPtBottom.x += deltaShirtX;
			pRenderTarget->DrawLine(suitPtTop, suitPtBottom, pSuiteColor, strokeWidth);

			suitPtTop.x -= 2 * deltaSuitX;
			suitPtBottom.x -= 2 * deltaShirtX;
			pRenderTarget->DrawLine(suitPtTop, suitPtBottom, pSuiteColor, strokeWidth);

			suitPtTop.x += deltaSuitX;
			suitPtBottom.x += deltaShirtX;
		}

		deltaSuitX++;
		deltaShirtX++;
	}
	
	DrawArm(pTuxedo->pts[JointType_ShoulderLeft], pTuxedo->pts[JointType_ElbowLeft], pTuxedo->pts[JointType_WristLeft],
		pSuiteColor, pRenderTarget);
	DrawArm(pTuxedo->pts[JointType_ShoulderRight], pTuxedo->pts[JointType_ElbowRight], pTuxedo->pts[JointType_WristRight],
		pSuiteColor, pRenderTarget);
		
	
}