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;
}
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);
}