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::TiltDown()
{
	Matrix44 rotMat;
	rotMat.SetRotationX(DegreeToRadian(-1));
	WorldPoint4 positionBack = mCameraMatrix[3];
	mCameraMatrix[3] = WorldPoint3::ZERO;
	mCameraMatrix = mCameraMatrix*rotMat;
	mCameraMatrix[3] = positionBack;
}
Example #4
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 #5
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 #6
0
//-------------------------------
//
//-------------------------------
void Vector3::RotateX( float fAngle )
{
	matRot.SetRotationX( fAngle );
	*this *= matRot;
} //Vector3::RotateX
Example #7
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 #8
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 );
}