当前位置: 首页>>代码示例>>C++>>正文


C++ Entity::GetLocalTransform方法代码示例

本文整理汇总了C++中Entity::GetLocalTransform方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::GetLocalTransform方法的具体用法?C++ Entity::GetLocalTransform怎么用?C++ Entity::GetLocalTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Entity的用法示例。


在下文中一共展示了Entity::GetLocalTransform方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ApplyTransform

void EditorBodyControl::ApplyTransform(float32 x, float32 y, float32 z)
{
	if (!InModificationMode())
		return;

    Entity *selectedNode = scene->GetProxy();
    if(selectedNode)
	{
		Matrix4 modification;
		modification.Identity();

		Matrix4 t1, t2;
		t1.CreateTranslation(-selectedNode->GetWorldTransform().GetTranslationVector());
		t2.CreateTranslation(selectedNode->GetWorldTransform().GetTranslationVector());

		switch (GetModificationMode())
		{
			case ResourceEditor::MODIFY_MOVE:
				modification.CreateTranslation(Vector3(x, y, z));
				break;

			case ResourceEditor::MODIFY_ROTATE:
				modification.CreateRotation(Vector3(1, 0, 0), DegToRad(x));
				modification *= Matrix4::MakeRotation(Vector3(0, 1, 0), DegToRad(y));
				modification *= Matrix4::MakeRotation(Vector3(0, 0, 1), DegToRad(z));

				modification = (t1 * modification) * t2;
				break;

			case ResourceEditor::MODIFY_SCALE:
				modification.CreateScale(Vector3(1, 1, 1) + Vector3(x + y + z, x + y + z, x + y + z) / 100.f);
				modification = (t1 * modification) * t2;
				break;

			default:
				break;
		}

		Matrix4 originalTransform = selectedNode->GetLocalTransform();
		modification = originalTransform * modification;

		if (IsLandscapeRelative())
		{
			modification = modification * GetLandscapeOffset(modification);
		}

		CommandsManager::Instance()->ExecuteAndRelease(new CommandTransformObject(selectedNode,
																				  originalTransform,
																				  modification),
													   scene);
	}
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:52,代码来源:EditorBodyControl.cpp

示例2: ProcessMouse

bool EditorBodyControl::ProcessMouse(UIEvent *event)
{
	Entity * selection = scene->GetProxy();
	//selection with second mouse button
    
	if (event->tid == UIEvent::BUTTON_1)
	{
		if (event->phase == UIEvent::PHASE_BEGAN)
		{
			isDrag = false;
			inTouch = true;
			touchStart = event->point;

			if (selection)
			{
				modifiedNode = selection;
				transformBeforeModification = selection->GetLocalTransform();
			}
		}
		else if (event->phase == UIEvent::PHASE_DRAG)
		{
			if (!isDrag)
			{
				Vector2 d = event->point - touchStart;
				
				if (selection && d.Length() > 5 && InModificationMode())
				{
					ArrowsNode* arrowsNode = GetArrowsNode(false);
					if (arrowsNode && arrowsNode->GetModAxis() != ArrowsNode::AXIS_NONE)
					{
						isDrag = true;
						if (InputSystem::Instance()->GetKeyboard()->IsKeyPressed(DVKEY_SHIFT))
						{
							originalNode = scene->GetProxy();

							//create temporary node to calculate transform
							modifiedNode = originalNode->Clone();
							originalNode->GetParent()->AddNode(modifiedNode);
							SelectNode(modifiedNode);
							selection = modifiedNode;

							//store original transform
							transformBeforeModification = modifiedNode->GetLocalTransform();
						}

						if (selection)
						{
							scene->SetBulletUpdate(selection, false);

							inTouch = true;
							touchStart = event->point;
						
							startTransform = selection->GetLocalTransform();
						
							InitMoving(event->point);
						
							translate1.CreateTranslation(-rotationCenter);
							translate2.CreateTranslation(rotationCenter);
						
							//calculate koefficient for moving
							Camera * cam = scene->GetCurrentCamera();
							const Vector3 & camPos = cam->GetPosition();
							const Matrix4 & wt = selection->GetWorldTransform();
							Vector3 objPos = Vector3(0,0,0) * wt;
							Vector3 dir = objPos - camPos;
							moveKf = (dir.Length() - cam->GetZNear()) * 0.003;
						}
					}
				}
			}
			else
			{
				if (selection && InModificationMode())
				{
                    Landscape *landscape = dynamic_cast<Landscape *>(selection);
                    if(!landscape)
                    {
                        PrepareModMatrix(event->point);

						if (IsLandscapeRelative())
						{
							currTransform = currTransform * GetLandscapeOffset(currTransform);
						}

						selection->SetLocalTransform(currTransform);

                        if(currentGraph)
                        {
                            currentGraph->UpdateMatricesForCurrentNode();
                        }
                    }
				}
			}
		}
		else if (event->phase == UIEvent::PHASE_ENDED)
		{
			inTouch = false;
			if (isDrag)
			{
				// originalNode should be non-zero only when clone node
//.........这里部分代码省略.........
开发者ID:droidenko,项目名称:dava.framework,代码行数:101,代码来源:EditorBodyControl.cpp


注:本文中的Entity::GetLocalTransform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。