本文整理汇总了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;
}
示例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);
}