Exemplo n.º 1
0
void CNodeInfoWindow::OnClickUpdateTransformButton()
{
	EditorScene* scene = EditorScene::getInstance();
	SNodeInfo* info = scene->GetSelectedNodeInfo();
	if (!info)
		return;

	f32 position[3];
	f32 rotation[3];
	f32 scaling[3];

	char text[256];
	for (u32 i = 0; i < 3; i++)
	{
		GetWindowTextA(mPosTextFields[i], text, 256);
		int err = sscanf_s(text, "%f", &position[i]);
		if (err < 1 || err == EOF)
		{
			MessageBoxA(mParentHwnd, "cannot convert position value", "Error", NULL);
			return;
		}
	}

	for (u32 i = 0; i < 3; i++)
	{
		GetWindowTextA(mRotTextFields[i], text, 256);
		int err = sscanf_s(text, "%f", &rotation[i]);
		if (err < 1 || err == EOF)
		{
			MessageBoxA(mParentHwnd, "cannot convert rotation value", "Error", NULL);
			return;
		}
	}

	for (u32 i = 0; i < 3; i++)
	{
		GetWindowTextA(mScaleTextFields[i], text, 256);
		int err = sscanf_s(text, "%f", &scaling[i]);
		if (err < 1 || err == EOF)
		{
			MessageBoxA(mParentHwnd, "cannot convert scale value", "Error", NULL);
			return;
		}
	}

	info->Position.x = position[0];
	info->Position.y = position[1];
	info->Position.z = position[2];

	info->Rotation.x = rotation[0] * XM_PI / 180.0f;
	info->Rotation.y = rotation[1] * XM_PI / 180.0f;
	info->Rotation.z = rotation[2] * XM_PI / 180.0f;

	info->Scaling.x = scaling[0];
	info->Scaling.y = scaling[1];
	info->Scaling.z = scaling[2];

	scene->UpdateNodeInfo(info);
	UpdateShowing(info);
}
Exemplo n.º 2
0
void CMeshNodePanel::MouseMove(int sx, int sy)
{
	EditorScene* scene = EditorScene::getInstance();
	EditorWindow* window = EditorWindow::getInstance();
	if (!scene)
		return;

	E_MOUSE_STATE mouseState = window->GetMouseState();

	if (mouseState == EMS_ADD_OBJECT || mouseState == EMS_ADD_INSTANCE)
	{
		scene->ChangeAddedObjectPosition(sx, sy);
	}
	else if (mouseState == EMS_PICKING)
	{
		scene->PickingObject(sx, sy);
	}
	else if (mouseState == EMS_ROTATION)
	{
		SNodeInfo* info = scene->GetSelectedNodeInfo();
		if (!info)
			return;
		f32 rotation = (mRightMousePressPoint.x - sx) * 0.02f;
		f32 rotY = mOrientationBeforeRotate + rotation;

		info->Rotation.y = mOrientationBeforeRotate + rotation;

		mNodeInfoWindow.UpdateShowing(info);
		scene->UpdateNodeInfo(info);
		scene->PickingObject(sx, sy);
	}
}
Exemplo n.º 3
0
void CNodeInfoWindow::OnClickCancelTransformButton()
{
	EditorScene* scene = EditorScene::getInstance();
	SNodeInfo* info = scene->GetSelectedNodeInfo();
	if (!info)
		return;

	UpdateShowing(info);
}
Exemplo n.º 4
0
void CNodeInfoWindow::OnClickPhysicsCheckBox()
{
	EditorScene* scene = EditorScene::getInstance();
	SNodeInfo* info = scene->GetSelectedNodeInfo();
	if (!info)
		return;

	LRESULT r = SendMessage(mPhysicsCheckBox, BM_GETCHECK, 0, 0);
	if (r == BST_CHECKED)
	{
		info->BoundingPhysics = true;
	}
	else if (r == BST_UNCHECKED)
	{
		info->BoundingPhysics = false;
	}
}
Exemplo n.º 5
0
void CNodeInfoWindow::OnClickShadowCheckBox()
{
	EditorScene* scene = EditorScene::getInstance();
	SNodeInfo* info = scene->GetSelectedNodeInfo();
	if (!info)
		return;

	LRESULT r = SendMessage(mShadowCheckBox, BM_GETCHECK, 0, 0);
	if (r == BST_CHECKED)
	{
		info->ShadowCasting = true;
	}
	else if (r == BST_UNCHECKED)
	{
		info->ShadowCasting = false;
	}

	scene->UpdateNodeInfo(info);
}
Exemplo n.º 6
0
void CMeshNodePanel::MouseRightButtonDown(int sx, int sy)
{
	EditorScene* scene = EditorScene::getInstance();
	EditorWindow* window = EditorWindow::getInstance();
	if (!scene)
		return;

	E_MOUSE_STATE mouseState = window->GetMouseState();

	if (mouseState == EMS_ADD_OBJECT)
	{
		mCreateMeshNodeWindow.EnableControl(IDC_NEW_MODEL_NDOE_BTN, TRUE);
		window->SetMouseState(EMS_PICKING);
		scene->CancelAddingObject();
	}
	if (mouseState == EMS_ADD_INSTANCE)
	{
		mInstanceNodeWindow.EnableControl(IDC_INSTANCE_CREATE_BTN, TRUE);
		window->SetMouseState(EMS_PICKING);
		scene->CancelAddingObject();
	}
	else if (mouseState == EMS_PICKING)
	{
		EditorScene* scene = EditorScene::getInstance();
		if (!scene)
			return;

		SNodeInfo* info = scene->GetSelectedNodeInfo();
		if (!info)
			return;

		window->SetMouseState(EMS_ROTATION);
		mRightMousePressPoint.x = sx;
		mRightMousePressPoint.y = sy;
		mOrientationBeforeRotate = info->Rotation.y;
	}
}
Exemplo n.º 7
0
void CMeshNodePanel::updateSelectedObjectTransform(f32 delta)
{
	EditorScene* scene = EditorScene::getInstance();
	if (!scene)
		return;

	SNodeInfo* info = scene->GetSelectedNodeInfo();
	if (!info)
		return;

	const f32 MOVE_UNIT = 10.0f;
	const f32 SCALING_UNIT = 5.0f;
	
	ICameraNode* camera = scene->GetCamera();
	XMFLOAT3 look = camera->getLookVector();
	XMFLOAT3 up(0, 1.0f, 0);
	XMFLOAT3 right = camera->getRightVector();

	XMVECTOR look_v = XMVectorSet(look.x, 0, look.z, 0);
	look_v = XMVector4Normalize(look_v);

	XMStoreFloat3(&look, look_v);

	XMFLOAT3 movement(0, 0, 0);
	XMFLOAT3 scaling(0, 0, 0);

	if (GetAsyncKeyState('W') & 0x8000)
	{
		movement = math::VectorMultiply(look, delta * MOVE_UNIT);
	}

	if (GetAsyncKeyState('S') & 0x8000)
	{
		movement = math::VectorMultiply(look, -delta * MOVE_UNIT);
	}

	if (GetAsyncKeyState('A') & 0x8000)
	{
		movement = math::VectorMultiply(right, -delta * MOVE_UNIT);
	}

	if (GetAsyncKeyState('D') & 0x8000)
	{
		movement = math::VectorMultiply(right, delta * MOVE_UNIT);
	}

	if (GetAsyncKeyState('R') & 0x8000)
	{
		movement = math::VectorMultiply(up, delta * MOVE_UNIT);
	}

	if (GetAsyncKeyState('F') & 0x8000)
	{
		movement = math::VectorMultiply(up, -delta * MOVE_UNIT);
	}

	if (GetAsyncKeyState(VK_ADD) & 0x8000)
	{
		scaling = XMFLOAT3(1.0f, 1.0f, 1.0f);
	}

	if (GetAsyncKeyState(VK_SUBTRACT) & 0x8000)
	{
		scaling = XMFLOAT3(-1.0f, -1.0f, -1.0f);
	}

	scaling = math::VectorMultiply(scaling, delta * SCALING_UNIT);

	info->Position = math::VectorAdd(info->Position, movement);
	info->Scaling = math::VectorAdd(info->Scaling, scaling);

	scene->UpdateNodeInfo(info);
	ShowNodeInfo(info);
}