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


C++ CNode::getPosition方法代码示例

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


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

示例1: toolsSetType

void CEditorEngine::toolsSetType(const EEditorTool &type, int centralPointX, int centralPointY)
{
	CNode *node;

	if(m_selectedNodes.size() > 0)
	{
		node = m_selectedNodes.front();

		if(m_tool == EET_NONE)
		{
			m_tempPosition = node->getPosition();
			m_tempRotation = node->getRotation();
			m_centralPoint = glm::ivec2(centralPointX, centralPointY);
			m_translatePlane.fromOrigin(m_tempPosition, m_currentEditorScene->getActiveCamera()->getForwardVector());
		}
		else
		{
			node->setPosition(m_tempPosition);
			node->setRotation(m_tempRotation);
		}
	}

	m_tool = type;
}
开发者ID:creepydragon,项目名称:revision1,代码行数:24,代码来源:CEditorEngine.cpp

示例2: update

void CEditorEngine::update(double step, double interpolation)
{
	if(m_selectedNodes.size() > 0)
	{
		CNode *node = m_selectedNodes.front();
		glm::ivec2 rel = m_centralPoint - m_window->getCursorPosition();

		if(m_tool == EET_GRAB)
		{
			if(node->isPositionLocked() == false)
			{
				CCameraLogicNode *activeCamera = m_currentEditorScene->getActiveCamera();

				glm::vec3 newPosition = m_tempPosition;

				m_translatePlane.intersectRay(activeCamera->getPosition(),
											  m_currentEditorScene->getRay(m_window->getCursorPosition()),
											  newPosition);

				if(m_modifier != ETM_NONE)
				{
					newPosition.x = (m_modifier == ETM_ONLY_X_AXIS) ? newPosition.x : m_tempPosition.x;
					newPosition.y = (m_modifier == ETM_ONLY_Y_AXIS) ? newPosition.y : m_tempPosition.y;
					newPosition.z = (m_modifier == ETM_ONLY_Z_AXIS) ? newPosition.z : m_tempPosition.z;
				}

				node->setPosition(newPosition);
			}
		}
		else if(m_tool == EET_ROTATE)
		{
			if(node->isRotationLocked() == false)
			{
				glm::vec3 rot = glm::vec3(rel.x, rel.x, rel.x);
				if(m_modifier != ETM_NONE)
				{
					rot.x *= m_modifier == ETM_ONLY_X_AXIS;
					rot.y *= m_modifier == ETM_ONLY_Y_AXIS;
					rot.z *= m_modifier == ETM_ONLY_Z_AXIS;
				}
				node->setRotation(glm::radians(m_tempRotation + rot));
			}
		}
		else if(m_tool == EET_LOOKAT)
		{
			if(node->isRotationLocked() == false)
			{
				CCameraLogicNode *activeCamera = m_currentEditorScene->getActiveCamera();

				glm::vec3 newPosition = m_tempPosition;

				m_translatePlane.intersectRay(activeCamera->getPosition(),
											  m_currentEditorScene->getRay(m_window->getCursorPosition()),
											  newPosition);

				glm::mat4 matrix = glm::translate(glm::mat4(1.0f), node->getPosition());
				matrix *= glm::lookAt(m_tempPosition, newPosition, glm::vec3(0.0f, 1.0f, 0.0f)) * matrix;

				node->setModelMatrix(matrix);
			}
		}
	}

	CEngine::update(step, interpolation);
}
开发者ID:creepydragon,项目名称:revision1,代码行数:65,代码来源:CEditorEngine.cpp


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