Example #1
0
//-----------------------------------------------------------------------------//
// 구의 좌표를 업데이트한다.
//-----------------------------------------------------------------------------//
void CCharacter::UpdateCollisionBox()
{
	Matrix44 *pmat = m_pModel[ BODY]->GetWorldTM();
	m_Sphere.SetCenter( &pmat->GetPosition() );
	m_MinSphere.SetCenter( &pmat->GetPosition() );

	m_pModel[ BODY]->UpdateCollisionBox();
	m_pModel[ WEAPON]->UpdateCollisionBox();
}
Example #2
0
//랜더
void Render(int timeDelta)
{
	//화면 청소
	if (SUCCEEDED(g_pDevice->Clear( 
		0,			//청소할 영역의 D3DRECT 배열 갯수		( 전체 클리어 0 )
		NULL,		//청소할 영역의 D3DRECT 배열 포인터		( 전체 클리어 NULL )
		D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL,	//청소될 버퍼 플레그 ( D3DCLEAR_TARGET 컬러버퍼, D3DCLEAR_ZBUFFER 깊이버퍼, D3DCLEAR_STENCIL 스텐실버퍼
		D3DCOLOR_XRGB(150, 150, 150),			//컬러버퍼를 청소하고 채워질 색상( 0xAARRGGBB )
		1.0f,				//깊이버퍼를 청소할값 ( 0 ~ 1 0 이 카메라에서 제일가까운 1 이 카메라에서 제일 먼 )
		0					//스텐실 버퍼를 채울값
		)))
	{
		//화면 청소가 성공적으로 이루어 졌다면... 랜더링 시작
		g_pDevice->BeginScene();

		//fps출력
		static WORD frameCnt = 0;
		static DWORD ntimeDelay = 0;
		static float fps = 0.f;
				
		frameCnt++;
		ntimeDelay += timeDelta;
		if( ntimeDelay >= 1000 )
		{	
			fps = (float)frameCnt;
			frameCnt = 0;
			ntimeDelay -= ntimeDelay;
		}		
		string outputFps = format( "%0.3f", fps );
		RECT rc;
		SetRect( &rc, 150, 100, 0, 0 );  //다이렉트 생성할때의 화면 크기의 좌표로 적용됨
		global->font->DrawTextA( NULL,   //A : 아스키코드
//			"global->font->DrawText", 
			outputFps.c_str(),
			-1, 
			&rc, 
			DT_NOCLIP,  //다 출력하겠다라는 의미(화면 크기 연연하지 않겠다인듯??)
			D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f) );
				

		//쿼터니언 응용	
		/*
		Quaternion quat;
		quat.SetRotationArc(Vector3(0,1,0),Vector3(0,0,1));  //첫번째 인자방향 기준으로 두번째 인자 방향으로
		Matrix44 qt = quat.GetMatrix();
		*/
		static float ftheta = 0.f;
		ftheta += 0.0005f;
		const float fradian = ftheta / MATH_PI;
		if( ftheta >= 360.f )
			ftheta = 0.f;
		Matrix44 mat;
		mat.SetTranslate(Vector3(5, sin(fradian) * 10.f, -490));  //sin(fradian) : 각도에 따른 +-변화  //10.f 곱하기는 범위
//		Matrix44 m = global->localTm * mat;
//		g_pDevice->SetTransform(D3DTS_WORLD, (D3DXMATRIX*)&m);  //마우스 회전 잠금
		g_pDevice->SetTransform(D3DTS_WORLD, (D3DXMATRIX*)&mat);
		global->mesh3DText->DrawSubset( 0 );
				
		Vector3 mainPos(-10, 0, -490);
		Vector3 targetLook = mat.GetPosition() - mainPos;  //대상물체와 메인물체와의 거리 판단
		targetLook.Normalize();
		Quaternion quat;
//		mainPos.Normalize();
//		quat.SetRotationArc(mainPos, targetLook);   //첫번째 인자를 물체의 위치로 하니 회전하는 방향이 생각과는 다르게 표현된다...역시 고정된 방향이어야 되나보다...
		quat.SetRotationArc(Vector3(1,0,0), targetLook);  //양의 x축방향으로 대상물체를 바라본다
		Matrix44 qm = quat.GetMatrix();
		mat.SetTranslate(mainPos);
		qm *= mat;
		g_pDevice->SetTransform(D3DTS_WORLD, (D3DXMATRIX*)&qm);
		global->mesh3DText->DrawSubset( 0 );
		
		//랜더링 끝
		g_pDevice->EndScene();
		//랜더링이 끝났으면 랜더링된 내용 화면으로 전송
		g_pDevice->Present( NULL, NULL, NULL, NULL );
	}
}