Exemplo n.º 1
0
static void DrawObjectiveInfo(const Objective *o, const Vec2i pos)
{
	const CharacterStore *store = &gCampaign.Setting.characters;

	switch (o->Type)
	{
	case OBJECTIVE_KILL:
		{
			const Character *cd = CArrayGet(
				&store->OtherChars, CharacterStoreGetSpecialId(store, 0));
			DrawHead(cd, DIRECTION_DOWN, STATE_IDLE, pos);
		}
		break;
	case OBJECTIVE_RESCUE:
		{
			const Character *cd = CArrayGet(
				&store->OtherChars, CharacterStoreGetPrisonerId(store, 0));
			DrawHead(cd, DIRECTION_DOWN, STATE_IDLE, pos);
		}
		break;
	case OBJECTIVE_COLLECT:
		{
			const Pic *p = o->u.Pickup->Pic;
			Blit(&gGraphicsDevice, p,
				Vec2iMinus(pos, Vec2iScaleDiv(p->size, 2)));
		}
		break;
	case OBJECTIVE_DESTROY:
		{
			Vec2i picOffset;
			const Pic *p =
				MapObjectGetPic(o->u.MapObject, &picOffset, false);
			Blit(&gGraphicsDevice, p, Vec2iAdd(pos, picOffset));
		}
		break;
	case OBJECTIVE_INVESTIGATE:
		// Don't draw
		return;
	default:
		CASSERT(false, "Unknown objective type");
		return;
	}
}
Exemplo n.º 2
0
/*
안드로이드 전체 모습을 그리는 함수
*/
void DrawAndroid(){
	DrawBody(0, 0, 0, 0); // 몸통 함수 호출
	Drawneck(); // 목함수 호출
	DrawHead(); // 머리 호출
	DrawR_Arm(R_Arm_x, 1, 0, 0);//우측팔뚝
	if (key == ROCKET) DrawR_HandRocket(); // 로켓모드일때 우측로켓호출
	else DrawR_Hand(R_Arm_y, 1, 0, 0);  //우측팔호출
	DrawL_Arm(L_Arm_x, 1, 0, 0);   //좌측팔뚝
	if (key == ROCKET) DrawL_HandRocket(); // 로켓모드일때 우측로켓호출
	else DrawL_Hand(L_Arm_y, 1, 0, 0);//좌측손호출
	DrawL_Legs(L_Leg_x, 1, 0, 0);  //좌측다리
	DrawL_foot(L_Leg_y, 1, 0, 0);  //좌측발		 
	DrawR_Legs(R_Leg_x, 1, 0, 0);  //우측다리
	DrawR_foot(R_Leg_y, 1, 0, 0);  //우측발	
}
Exemplo n.º 3
0
void Person::Draw(ModelviewStack* ms)
{
	useLighting(1);

	setColour(1.0, 0.0, 0.0);
	ms->Push();
	{
		ms->Translate(_transform.position);
		
		DrawBody(ms);
		//DrawNeck(ms);
		DrawHead(ms);
		DrawArms(ms);
		DrawLegs(ms);
	}
	ms->Pop();
}
Exemplo n.º 4
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
}
Exemplo n.º 5
0
/// <summary>
/// Handle new body data
/// <param name="nTime">timestamp of frame</param>
/// <param name="nBodyCount">body data count</param>
/// <param name="ppBodies">body data in frame</param>
/// </summary>
void CBodyBasics::ProcessBody(INT64 nTime, int nBodyCount, IBody** ppBodies)
{
    if (m_hWnd)
    {
        HRESULT hr = EnsureDirect2DResources();

        DetectionResult nEngaged[6] = { DetectionResult_Unknown };

        int width = 0;
        int height = 0;
        if (SUCCEEDED(hr) && m_pRenderTarget && m_pCoordinateMapper)
        {
            m_pRenderTarget->BeginDraw();
            m_pRenderTarget->Clear();

            RECT rct;
            GetClientRect(GetDlgItem(m_hWnd, IDC_VIDEOVIEW), &rct);
            width = rct.right;
            height = rct.bottom;

            for (int i = 0; i < nBodyCount; ++i)
            {
                nEngaged[i] = DetectionResult_Maybe;

                IBody* pBody = ppBodies[i];
                if (pBody)
                {
                    BOOLEAN bTracked = false;
                    hr = pBody->get_IsTracked(&bTracked);

                    // Engaged()は使えるみたい。これは、視野に入ってきた人を認識するものだろう。
                    hr = pBody->get_Engaged( &nEngaged[i] );
                    // 以下はまだ使えないようだ
                    //hr = pBody->GetAppearanceDetectionResults((UINT)i, &nEngaged[i]);

                    if (SUCCEEDED(hr) && bTracked)
                    {
                        Joint joints[JointType_Count];
                        D2D1_POINT_2F jointPoints[JointType_Count];
                        HandState leftHandState = HandState_Unknown;
                        HandState rightHandState = HandState_Unknown;

                        pBody->get_HandLeftState(&leftHandState);
                        pBody->get_HandRightState(&rightHandState);

                        hr = pBody->GetJoints(_countof(joints), joints);
                        if (SUCCEEDED(hr))
                        {
                            for (int j = 0; j < _countof(joints); ++j)
                            {
                                jointPoints[j] = BodyToScreen(joints[j].Position, width, height);
                            }

                            DrawBody(joints, jointPoints);

                            // ここに頭部に丸を描いて、ボディ番号を表示
                            DrawHead(jointPoints[JointType_Head], i, nEngaged[i]);

                            DrawHand(leftHandState, jointPoints[JointType_HandLeft]);
                            DrawHand(rightHandState, jointPoints[JointType_HandRight]);
                        }
                    }
                }
            }

            hr = m_pRenderTarget->EndDraw();

            // Device lost, need to recreate the render target
            // We'll dispose it now and retry drawing
            if (D2DERR_RECREATE_TARGET == hr)
            {
                hr = S_OK;
                DiscardDirect2DResources();
            }
        }

        if (!m_nStartTime)
        {
            m_nStartTime = nTime;
        }

        double fps = 0.0;

        LARGE_INTEGER qpcNow = {0};
        if (m_fFreq)
        {
            if (QueryPerformanceCounter(&qpcNow))
            {
                if (m_nLastCounter)
                {
                    m_nFramesSinceUpdate++;
                    fps = m_fFreq * m_nFramesSinceUpdate / double(qpcNow.QuadPart - m_nLastCounter);
                }
            }
        }

        WCHAR szStatusMessage[128] ;
        StringCchPrintf( szStatusMessage, _countof(szStatusMessage),
                         L" FPS = %0.2f  Time = %I64d width:%d height:%d",
                         fps, (nTime - m_nStartTime), width, height);

        if (SetStatusMessage(szStatusMessage, 1000, false))
        {
            m_nLastCounter = qpcNow.QuadPart;
            m_nFramesSinceUpdate = 0;
        }
    }
}
Exemplo n.º 6
0
void Castle::Draw()
{
	glEnable(GL_LIGHTING);      

	glColor3ub(0, 100, 0);
	glPushMatrix();
	{
		glTranslated(position[0],position[1]+4,position[2]);
		glScaled(20, 10, 20);
		DrawWall();

		glColor3ub(0, 100, 0);
		for(float i = -0.5; i <= 0.5; i += 0.5)
		{
			glPushMatrix();
			{
				glTranslated(i, 1, 1);
				glScaled(0.2, 0.15, 0.05);
				Draw3DBrick(1);
			}
			glPopMatrix();
		}

		for(float i = -0.5; i <= 0.5; i += 0.5)
		{
			glPushMatrix();
			{
				glTranslated(i, 1, -1);
				glScaled(0.2, 0.15, 0.05);
				Draw3DBrick(1);
			}
			glPopMatrix();
		}

		for(float i = -0.5; i <= 0.5; i += 0.5)
		{
			glPushMatrix();
			{
				glTranslated(1, 1, i);
				glRotatef(90,0,1,0);
				glScaled(0.2, 0.15, 0.05);
				Draw3DBrick(1);
			}
			glPopMatrix();
		}

		for(float i = -0.5; i <= 0.5; i += 0.5)
		{
			glPushMatrix();
			{
				glTranslated(-1, 1, i);
				glRotatef(90,0,1,0);
				glScaled(0.2, 0.15, 0.05);
				Draw3DBrick(1);
			}
			glPopMatrix();
		}

		//DrawClous();
		glPushMatrix();
		{
			glTranslated(0, 4, 1);
			DrawClouds();
		}
		glPopMatrix();

		glPushMatrix();
		{
			glTranslated(-0.9, 1.4, 0.9);
			glScaled(0.2, 1, 0.2);
			DrawHead();
		}
		glPopMatrix();

		glPushMatrix();
		{
			glTranslated(0.9, 1.4, 0.9);
			glScaled(0.2, 1, 0.2);
			DrawHead();
		}
		glPopMatrix();

		glPushMatrix();
		{
			glTranslated(-0.9, 1.4, -0.9);
			glScaled(0.2, 1, 0.2);
			DrawHead();
		}
		glPopMatrix();

		glPushMatrix();
		{
			glTranslated(0.9, 1.4, -0.9);
			glScaled(0.2, 1, 0.2);
			DrawHead();
		}
		glPopMatrix();

		glTranslated(0, 1, 0);

		glPushMatrix();
		{
			glScaled(1, 0.01, 1);
			Draw3DBrick(2);
		}
		glPopMatrix();

		glTranslated(0, 0.3, 0.5);

		glPushMatrix();
		{
			glTranslated(0, 0.2, 0.0);
			glScaled(0.7, 1.1, 0.7);
			DrawMainHead();
		}
		glPopMatrix();

		glTranslated(0, 1.4, 0);

		DrawFlage();

	}
	glPopMatrix();


	glDisable(GL_LIGHTING);
}
Exemplo n.º 7
0
/*
김연아 선수의 모션을 취하는 함수
*/
void Show()
{
	sndPlaySound(TEXT("C:\\sample4.wav"), SND_ASYNC | SND_NOSTOP);
	glLoadIdentity(); //CTM 초기화

	/*
	로봇의 기본적인 관절의 움직임 범위를 제한하는 곳
	*/
	L_Arm_x = (-40) + sin(time2) * 60;//왼쪽 어깨의 각도시작은 -40상태에서 sin()함수를 사용하여 주기적인 움직임 설정
	R_Arm_x = (-80) - L_Arm_x;       //우측 어깨의 각도시작은 -80상태에서 왼쪽어깨 움직임의 반대로 설정
	R_Arm_y = -abs(cos(time2) * 10);  //우측팔뚝 각도조절(팔을 뻗는 움직임표현을위하여 어깨의 sin()함수와 반대인 cos()함수 사용)
	L_Arm_y = -abs(-cos(time2) * 10); //좌측팔뚝 각도조절(팔을 뻗는 움직임표현을위하여 어깨의 sin()함수와 반대인 cos()함수 사용)

	R_Leg_y = abs(-sin(time) * 30 - 30); //우측종아리 각도조절(abs절대값을 줌으로써 종아리가 앞으로 꺾이지 않는 한계점을 설정)
	L_Leg_y = abs(sin(time) * 30 - 30);  //좌측종아리 각도조절(abs절대값을 줌으로써 종아리가 앞으로 꺾이지 않는 한계점을 설정)
	R_Leg_x = sin(time) * 60;          //우측다리는 60도 각도까지 움직이되 sin()함수를 사용하여 주기적인 움직임 설정
	L_Leg_x = -R_Leg_x;             //좌측다리는 우측다리반대로 60도 각도까지 움직이되 sin()함수를 사용하여 주기적인 움직임 설정

	////////////////display////////////////

	cyl = gluNewQuadric(); //실린더 객체 생성
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //초기화
	glMatrixMode(GL_MODELVIEW); //모드 설정

	DrawGround(); //지면 호출
	glLoadIdentity(); //CTM 초기화
	glRotatef(-230.0, 0, 1, 0); //y축기준으로 회전

	/*
	로봇이 피겨동작시 몸이 틀어지는 것을 표현
	*/
	glRotatef(sin(time) * 7, 0, 0, 1); //z축기준으로 7도 까지 각도틀어짐 (sin()함수를 사용하여 주기적인 움직임 설정)
	glRotatef(sin(time) * 7, 0, 1, 0); //y축으로 7도 까지 각도틀어짐 (sin()함수를 사용하여 주기적인 움직임 설정)

	//로봇 몸체 각도 조절
	glTranslatef(0.0, 0.18, 0.0); //y축으로 이동
	glRotatef(80, 1, 0, 0);        //x축 기준으로 회전

	glTranslatef(0.0, 0.5, 0.0);//최초 위치 

	glPushMatrix(); // 처음 저장 위치

	DrawBody(0, 0, 0, 0); // 몸통 함수 호출

	glPopMatrix(); // 처음 저장 좌표로 돌아 간다.
	glPushMatrix();// 처음 저장 좌표 다시 저장

	Drawneck(); // 목함수 호출

	glPopMatrix(); // 처음 저장 좌표로 돌아 간다.
	glPushMatrix();// 처음 저장 좌표 다시 저장

	//머리 위치 설정
	glRotatef(-75, 1, 0, 0); //x축기준으로 회전(머리를 위쪽으로 돌리기)
	glTranslatef(0.0, -0.02, 0.0); //y축으로 이동 (머리 시작점)

	DrawHead(); // 머리 호출

	glPopMatrix(); // 처음 저장 좌표로 돌아 간다.
	glPushMatrix();// 처음 저장 좌표 다시 저장

	//우측전체팔 위치 설정


	DrawR_Arm((R_Arm_y + 30), 1, 0, 0);  //우측팔호출
	DrawR_Hand(-(R_Arm_y - 15), 1, 0, 0); //우측팔뚝

	glPopMatrix(); // 처음 저장 좌표로 돌아 간다.
	glPushMatrix();// 처음 저장 좌표 다시 저장

	//좌측전체팔 위치 설정
	glTranslatef(0.0, -0.16, -0.04);//y축,z축으로 이동(좌측팔 시작점)
	glRotatef(40, 0, 0, 1);     //z축 기준으로 회전

	DrawL_Arm((L_Arm_y + 30), 1, 0, 0);   //좌측팔호출	
	DrawL_Hand(-(L_Arm_y - 15), 1, 0, 0);  //좌측팔뚝

	glPopMatrix(); // 처음 저장 좌표로 돌아 간다.
	glPushMatrix();// 처음 저장 좌표 다시 저장

	//좌측전체 다리 위치 설정
	glTranslatef(0.0, -0.45, -0.25);//y축,z축으로 이동(좌측다리 시작점)
	glRotatef(-90, 1, 0, 0);  //x축 기준으로 회전

	DrawL_Legs(-30, 1, 0, 0);  //좌측다리
	DrawL_foot(10, 1, 0, 0);  //좌측종아리		 

	glPopMatrix(); // 처음 저장 좌표로 돌아 간다.
	glPushMatrix();// 처음 저장 좌표 다시 저장

	//우측전체 다리 위치 설정
	glTranslatef(0.0, -0.5, -0.5);//y축,z축으로 이동(우측다리 시작점)
	glRotatef(-90, 1, 0, 0); //x축 기준으로 회전

	DrawR_Legs(160, 1, 0, 0);  //우측다리
	DrawR_foot(R_Leg_y, 1, 0, 0);  //우측종아리		

	glPopMatrix(); // 처음 저장 좌표로 돌아 간다.

	glutSwapBuffers();
}