本文整理汇总了C++中Frame::GetUp方法的典型用法代码示例。如果您正苦于以下问题:C++ Frame::GetUp方法的具体用法?C++ Frame::GetUp怎么用?C++ Frame::GetUp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Frame
的用法示例。
在下文中一共展示了Frame::GetUp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void FollowPathComponent::Update(float time)
{
if(m_delayed)
{
// If delayed, increment current delay time. Then check if it's ready to go on to the next
// node. If it is, get the next node.
m_currentDelayTime += time;
if(m_currentDelayTime > m_nodes[m_nextNode].delay)
{
m_currentDelayTime = 0.0f;
m_delayed = false;
GetNextNode(); // Now get the next destination.
}
return;
}
if(m_nodes.size() > m_nextNode)
{
m_t += time;
float t = m_t / m_nodes[m_nextNode].timeToReach;
glm::vec3 nextPoint;
glm::vec3 refPoint;
if(m_reverse)
{
nextPoint = CalculateBezierPoint(t,
m_nodes[m_nextNode+3].position, // p0
m_nodes[m_nextNode+2].position, // p1
m_nodes[m_nextNode+1].position, // p2
m_nodes[m_nextNode].position); // p3
refPoint = CalculateBezierPoint(t+0.05f,
m_nodes[m_nextNode+3].position, // p0
m_nodes[m_nextNode+2].position, // p1
m_nodes[m_nextNode+1].position, // p2
m_nodes[m_nextNode].position); // p3
}
else
{
nextPoint = CalculateBezierPoint(t,
m_nodes[m_nextNode-3].position, // p0
m_nodes[m_nextNode-2].position, // p1
m_nodes[m_nextNode-1].position, // p2
m_nodes[m_nextNode].position); // p3
refPoint = CalculateBezierPoint(t+0.05f,
m_nodes[m_nextNode-3].position, // p0
m_nodes[m_nextNode-2].position, // p1
m_nodes[m_nextNode-1].position, // p2
m_nodes[m_nextNode].position); // p3
}
glm::vec3 a = GetParent().GetTransform().GetForward();
glm::vec3 b = refPoint - GetParent().GetPos();
float cosX = glm::dot(a, b);
cosX = cosX / (glm::length(a) * glm::length(b));
float x = glm::acos(glm::max(glm::min(cosX, 1.0f), -1.0f)); // Not sure if need to convert cosX to radians.
x = x * 10.0f;
glm::vec3 rotationAxis = glm::normalize(glm::cross(a, b));
Frame transform = GetParent().GetTransform();
glm::vec3 currUp = glm::normalize(transform.GetUp());
glm::vec3 currForward = glm::normalize(transform.GetForward());
glm::vec3 newForward = glm::rotate(currForward, x, rotationAxis);
transform.SetForward(glm::normalize(newForward));
glm::vec3 newUp = glm::rotate(currUp, x, rotationAxis);
transform.SetUp(glm::normalize(newUp));
GetParent().SetTransform(transform);
GetParent().SetPos(nextPoint);
if(t >= 1.0f)
{
// Arrived at node. Now check if there is a delay on it before getting next destination.
if(m_nodes[m_nextNode].delay > 0.0001f)
{
m_delayed = true;
m_currentDelayTime = 0.0f;
}
else
{
GetNextNode();
}
m_t = 0.0f;
}
}
}