void PropertyFieldQuaternion::OnOK(const MGUI::ClickEvent * e)
	{
		mLayout->SetVisible(false);

		String x_text, y_text, z_text;
		x_text.FromUnicode(mEditBoxX->GetCaption().c_str());
		y_text.FromUnicode(mEditBoxY->GetCaption().c_str());
		z_text.FromUnicode(mEditBoxZ->GetCaption().c_str());

		Float3 val;
		val.x = x_text.ToFloat();
		val.y = y_text.ToFloat();
		val.z = z_text.ToFloat();

		Quat q;
		q.FromEulerAngle(val);
		mObject->SetPropertyData(mProperty, &q);

		String text = 
			f2str(val.x, true) + " " +
			f2str(val.y, true) + " " +
			f2str(val.z, true);

		mButton->SetCaption(text.c_wstr());
	}
Exemple #2
0
void GizmoBar::OnTextChanged(const MGUI::FocusEvent * e)
{
	Node * n = Editor::Instance()->GetSelectNode();
	if (n == NULL)
		return ;

	String x_str, y_str, z_str;
	x_str.FromUnicode(mEditBox_X->GetCaption().c_str());
	y_str.FromUnicode(mEditBox_Y->GetCaption().c_str());
	z_str.FromUnicode(mEditBox_Z->GetCaption().c_str());

	Float3 v;
	v.x = x_str.ToFloat();
	v.y = y_str.ToFloat();
	v.z = z_str.ToFloat();


	switch (Gizmo::Instance()->GetOperator())
	{
	case Gizmo::OP_MOVE:
		{
			UndoRedoManager::Instance()->Push(new UndoRedo_Move(n->GetUID(), n->GetPosition(), v));

			n->SetPosition(v);

			Editor::Instance()->E_NodePositionChanged();
		}
		break;

	case Gizmo::OP_ROTATE:
		{
			Quat q;
			q.FromEulerAngle(v);

			UndoRedoManager::Instance()->Push(new UndoRedo_Rotate(n->GetUID(), n->GetRotation(), q));

			n->SetRotation(q);

			Editor::Instance()->E_NodeRotationChanged();
		}
		break;

	case Gizmo::OP_SCALE:
		{
			UndoRedoManager::Instance()->Push(new UndoRedo_Scale(n->GetUID(), n->GetScale(), v));

			n->SetScale(v);

			Editor::Instance()->E_NodeScaleChanged();
		}
		break;
	}
}