Example #1
0
void CDlgCalc4x4::OnEnChangeEditAngle2()
{
	UpdateData();

	SECOND_VARIABLE second = (SECOND_VARIABLE)m_ComboSecond.GetCurSel();
	CommonDataInterface *secondData = dynamic_cast<CommonDataInterface *>(m_Second[ m_ComboSecond.GetCurSel()]);
	if (!secondData)
		return;

	m_Second[ m_ComboSecond.GetCurSel()]->UpdateData();

	Matrix44 mat;
	switch (second)
	{
	case VAR2_MAT_ROTATEX:
		mat.SetRotationX(m_Angle2);
		break;

	case VAR2_MAT_ROTATEY:
		mat.SetRotationY(m_Angle2);
		break;

	case VAR2_MAT_ROTATEZ:
		mat.SetRotationZ(m_Angle2);
		break;

	case VAR2_MAT_SCALE:
		mat.SetScale(Vector3(m_Angle2, m_Angle2, m_Angle2));
		break;
	}

	secondData->SetMatrix(mat);
}
Example #2
0
void CDlgCalc4x4::OnEnChangeEditAngle1()
{
	UpdateData();

	FIRST_VARIABLE first = (FIRST_VARIABLE)m_ComboFirst.GetCurSel();
	CommonDataInterface *firstData = dynamic_cast<CommonDataInterface *>(m_First[ m_ComboFirst.GetCurSel()]);
	if (!firstData)
		return;

	m_First[ m_ComboFirst.GetCurSel()]->UpdateData();

	Matrix44 mat;
	switch (first)
	{
	case VAR1_MAT_ROTATEX:
		mat.SetRotationX(m_Angle1);
		break;

	case VAR1_MAT_ROTATEY:
		mat.SetRotationY(m_Angle1);
		break;

	case VAR1_MAT_ROTATEZ:
		mat.SetRotationZ(m_Angle1);
		break;

	case VAR1_MAT_SCALE:
		mat.SetScale(Vector3(m_Angle1, m_Angle1, m_Angle1));
		break;
	}

	firstData->SetMatrix(mat);
}
Example #3
0
void Camera::TurnRight(Real degree )
{
	Matrix44 rotMat;
	rotMat.SetRotationY(DegreeToRadian(degree));
	WorldPoint4 positionBack = mCameraMatrix[3];
	mCameraMatrix[3] = WorldPoint3::ZERO;
	mCameraMatrix = rotMat*mCameraMatrix;
	mCameraMatrix[3] = positionBack;
}
Example #4
0
/**
 @brief 
 */
void	MainLoop(int elapse_time)
{
	Matrix44 mat;
	mat.SetRotationY(elapse_time*0.0002f);
	g_matLocal1 *= mat;

	// Render
	Render(g_hWnd);
	::InvalidateRect(g_hWnd, NULL, TRUE);
}
Example #5
0
void GCL::Node::SetOrientation( Real x,Real y,Real z )
{
	const WorldPoint4 backupPosition = mTransform[3];
	Matrix44 xRot;
	xRot.SetRotationX(x);
	Matrix44 yRot;
	yRot.SetRotationY(y);
	Matrix44 zRot;
	zRot.SetRotationZ(z);
	mTransform = xRot * yRot * zRot;

	mTransform.SetPosition(backupPosition);
}
Example #6
0
//---------------------------
//
//---------------------------
Matrix44 Matrix44::GetBillboardX() const
{
	static Matrix44	matWorld;
	static Vector3	vDir;

	vDir.x = _13;
	vDir.y = _23;
	vDir.z = _33;

	if( vDir.x == 0.0F )
	{
		matWorld.SetIdentity();
	}
	else	if( vDir.x > 0.0F )
	{
		matWorld.SetRotationY( -atanf( vDir.z / vDir.x ) + MATH_PI / 2 );
	}
	else
	{
		matWorld.SetRotationY( -atanf( vDir.z / vDir.x ) - MATH_PI / 2 );
	} //if..else if..else..

	return matWorld;
} //Matrix44::GetBillboardX
Example #7
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(255, 255, 255),			//컬러버퍼를 청소하고 채워질 색상( 0xAARRGGBB )
		1.0f,				//깊이버퍼를 청소할값 ( 0 ~ 1 0 이 카메라에서 제일가까운 1 이 카메라에서 제일 먼 )
		0					//스텐실 버퍼를 채울값
		)))
	{
		//화면 청소가 성공적으로 이루어 졌다면... 랜더링 시작
		g_pDevice->BeginScene();

		static float y = 0;
		y += timeDelta / 1000.f;
		// 각도가 2*PI 에 이르면 0으로 초기화한다.
		if (y >= 6.28f)
			y = 0;

		Matrix44 rx, ry, r;
		rx.SetRotationX(MATH_PI/4.f); 	// x축으로 45도 회전시킨다.
		ry.SetRotationY(y); // y축으로 회전
		r = rx*ry;
		g_pDevice->SetTransform(D3DTS_WORLD, (D3DXMATRIX*)&r);


		Matrix44 rry;
		rry.SetRotationY(-y); // y축으로 회전
		Vector3 dir = global->lightDir * rry;
		global->light.Direction = *(D3DXVECTOR3*)&dir;
		g_pDevice->SetLight(0, &global->light); // 광원 설정.


		g_pDevice->SetMaterial(&global->mtrl);
		g_pDevice->SetStreamSource( 0, global->vb, 0, sizeof(Vertex) );
		g_pDevice->SetIndices(global->ib);
		g_pDevice->SetFVF( Vertex::FVF );
		g_pDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, global->vtxSize, 0, global->faceSize);

		//랜더링 끝
		g_pDevice->EndScene();
		//랜더링이 끝났으면 랜더링된 내용 화면으로 전송
		g_pDevice->Present( NULL, NULL, NULL, NULL );
	}
}
Example #8
0
void cStage_IngameEnd::Update(const float elapseTime)
{
	graphic::cCharacter* pMe = m_user == 1 ? character1 : character2;

//	if( m_camDirOriginal.DotProduct(pMe->GetCamera()->GetDirection()) < 1 )
//		pMe->GetCamera()-

	if( m_nextStage )
	{
		m_tick += elapseTime;

		if( m_tick >= 5.f )
		{
			m_tick = 0.f;
			GetStageMgr()->SetStage( GetStageMgr()->ENDING );
			GetStageMgr()->GetStage()->Init();
		}
	}

//	bool bAniState1 = character1->Move(elapseTime);
//	bool bAniState2 = character2->Move(elapseTime);
	bool bAniState = pMe->Move(elapseTime);

//	if( bAniState1 == false && bAniState2 == false )
	if( bAniState == false )
	{
		m_nextStage = true;

//		character1->GetBoneMgr()->SetAniLoop(true);
//		character1->SetAnimation( "..\\media\\ani\\valle\\valle1_normal.ani" );
//		character2->GetBoneMgr()->SetAniLoop(true);
//		character2->SetAnimation( "..\\media\\ani\\valle\\valle1_normal.ani" );
		pMe->GetBoneMgr()->SetAniLoop(true);
		pMe->SetAnimation( "..\\media\\ani\\valle\\valle1_normal.ani" );

		Matrix44 matR;
		matR.SetRotationY( MATH_PI );
//		character1->SetTM( matR * character1->GetTM() );
//		character2->SetTM( matR * character2->GetTM() );
		pMe->SetTM( matR * pMe->GetTM() );
	}
}
Example #9
0
//
// 윈도우 프로시져 함수 ( 메시지 큐에서 받아온 메시지를 처리한다 )
//
LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
	switch (msg)
	{
	case WM_KEYDOWN:
		if (wParam == VK_ESCAPE)
			::DestroyWindow(hWnd);
		else if (wParam == VK_TAB)
		{
			static bool flag = false;
			g_pDevice->SetRenderState(D3DRS_CULLMODE, flag);
			g_pDevice->SetRenderState(D3DRS_FILLMODE, flag? D3DFILL_SOLID : D3DFILL_WIREFRAME);
			flag = !flag;
		}
		else if (wParam == VK_SPACE)
		{
		}
		break;

	case WM_LBUTTONDOWN:
		{
			g_LButtonDown = true;
			g_CurPos.x = LOWORD(lParam);
			g_CurPos.y = HIWORD(lParam);
			Pick(g_CurPos.x, g_CurPos.y);
		}
		break;

	case WM_RBUTTONDOWN:
		{
			g_RButtonDown = true;
			g_CurPos.x = LOWORD(lParam);
			g_CurPos.y = HIWORD(lParam);
		}
		break;

	case WM_LBUTTONUP:
		g_LButtonDown = false;
		break;

	case WM_RBUTTONUP:
		g_RButtonDown = false;
		break;

	case WM_MOUSEMOVE:
		if (g_LButtonDown)
		{
			POINT pos;
			pos.x = LOWORD(lParam);
			pos.y = HIWORD(lParam);

			const int x = pos.x - g_CurPos.x;
			const int y = pos.y - g_CurPos.y;
			g_CurPos = pos;

			//Matrix44 mat1;
			//mat1.SetRotationY( -x * 0.01f );
			//Matrix44 mat2;
			//mat2.SetRotationX( -y * 0.01f );
			//g_LocalTm *= (mat1 * mat2);
			Pick(pos.x, pos.y);
		}
		if (g_RButtonDown)
		{
			POINT pos;
			pos.x = LOWORD(lParam);
			pos.y = HIWORD(lParam);

			const int x = pos.x - g_CurPos.x;
			const int y = pos.y - g_CurPos.y;
			g_CurPos = pos;

			Matrix44 rx;
			rx.SetRotationY( x * 0.005f );

			Matrix44 ry;
			ry.SetRotationX( y * 0.005f );

			Matrix44 m = rx * ry;
			g_camPos *= m;

			UpdateCamera();
		}	
		else
		{
			g_CurPos.x = LOWORD(lParam);
			g_CurPos.y = HIWORD(lParam);
		}
		break;

	case WM_MOUSEWHEEL:
		{
			const int fwKeys = GET_KEYSTATE_WPARAM(wParam);
			const int zDelta = GET_WHEEL_DELTA_WPARAM(wParam);

			Vector3 dir = g_lookAtPos - g_camPos;
			dir.Normalize();
			g_camPos += (zDelta < 0)? dir * -50 : dir*50;
			UpdateCamera();
		}
		break;

	case WM_DESTROY: //윈도우가 파괴된다면..
		PostQuitMessage(0);	//프로그램 종료 요청 ( 메시지 루프를 빠져나가게 된다 )
		break;
	}
	return DefWindowProc( hWnd, msg, wParam, lParam );
}
Example #10
0
//-------------------------------
//
//-------------------------------
void Vector3::RotateY( float fAngle )
{
	matRot.SetRotationY( fAngle );
	*this *= matRot;
} //Vector3::RotateY
Example #11
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;

	switch (message)
	{
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		switch (wmId)
		{
		case IDM_ABOUT:
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		Paint(hWnd, hdc);
		EndPaint(hWnd, &ps);
		break;
	case WM_ERASEBKGND:
		return 1;

	case WM_KEYDOWN:
		switch (wParam)
		{
		case VK_TAB:
			g_WireFrame = !g_WireFrame;
			break;

		case VK_UP:
		case VK_DOWN:
			{
				Matrix44 mat;
				mat.SetRotationX((wParam==VK_UP)? 0.1f : -0.1f);
				g_matLocal *= mat;
			}
			break;

		case VK_LEFT:
		case VK_RIGHT:
			{
				Matrix44 mat;
				mat.SetRotationY((wParam==VK_LEFT)? 0.1f : -0.1f);
				g_matLocal *= mat;
			}
			break;

		case 'W':
		case 'S':
			{
				Vector3 dir = g_cameraLookat - g_cameraPos;
				dir.Normalize();
				const bool isForward = 'W' == wParam;
				g_cameraPos += dir * (isForward? 10.f : -10.f);
				g_cameraLookat += dir * (isForward? 10.f : -10.f);

				Vector3 dir2 = g_cameraLookat - g_cameraPos;
				dir2.Normalize();
				g_matView.SetView(g_cameraPos, dir2, Vector3(0,1,0));
			}
			break;

		case 'A':
		case 'D':
			{
				Vector3 dir = g_cameraLookat - g_cameraPos;
				dir.Normalize();
				Vector3 right = Vector3(0,1,0).CrossProduct(dir);
				right.Normalize();
				const bool isRight = 'A' == wParam;
				g_cameraPos += right * (isRight? 10.f : -10.f);
				g_cameraLookat += right * (isRight? 10.f : -10.f);

				Vector3 dir2 = g_cameraLookat - g_cameraPos;
				dir2.Normalize();
				g_matView.SetView(g_cameraPos, dir2, Vector3(0,1,0));
			}
			break;

		case 'E':
		case 'C':
			{
				Matrix44 mat;
				mat.SetRotationY((wParam=='E')? 0.1f : -0.1f);
				g_cameraPos = g_cameraPos * mat;

				Vector3 dir2 = g_cameraLookat - g_cameraPos;
				dir2.Normalize();
				g_matView.SetView(g_cameraPos, dir2, Vector3(0,1,0));
			}
			break;

		case VK_ESCAPE:
			DestroyWindow(hWnd);
		}
		break;

	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Example #12
0
//
// 윈도우 프로시져 함수 ( 메시지 큐에서 받아온 메시지를 처리한다 )
//
LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
	PAINTSTRUCT ps;
	HDC hdc;

	switch (msg)
	{
	case WM_ERASEBKGND:
		return 0;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		Paint(hWnd, hdc);
		EndPaint(hWnd, &ps);
		break;

	case WM_KEYDOWN:
		switch (wParam)
		{
		case VK_ESCAPE:
			::DestroyWindow(hWnd);
			break;

		case 'D':
		case 'A':
			{
				g_cameraPos.x += (wParam=='D')? 100.f : -100.f;
				Vector3 dir = g_cameraLookat - g_cameraPos;
				dir.Normalize();
				g_matView.SetView(g_cameraPos, dir, Vector3(0,1,0));
			}
			break;

		case 'W':
		case 'S':
			{
				g_cameraPos.z += (wParam=='W')? 100.f : -100.f;
				Vector3 dir = g_cameraLookat - g_cameraPos;
				dir.Normalize();
				g_matView.SetView(g_cameraPos, dir, Vector3(0,1,0));
			}
			break;

		case VK_UP:
		case VK_DOWN:
			{
				Matrix44 mat;
				mat.SetRotationX((wParam==VK_UP)? 0.1f : -0.1f);
				g_matLocal1 *= mat;
			}
			break;

		case VK_LEFT:
		case VK_RIGHT:
			{
				Matrix44 mat;
				mat.SetRotationY((wParam==VK_LEFT)? 0.1f : -0.1f);
				g_matLocal1 *= mat;
			}
			break;
		}
		break;
	case WM_DESTROY: //윈도우가 파괴된다면..
		PostQuitMessage(0);	//프로그램 종료 요청 ( 메시지 루프를 빠져나가게 된다 )
		break;
	}
	return DefWindowProc( hWnd, msg, wParam, lParam );
}