本文整理汇总了C++中Stack::GetNumOfElements方法的典型用法代码示例。如果您正苦于以下问题:C++ Stack::GetNumOfElements方法的具体用法?C++ Stack::GetNumOfElements怎么用?C++ Stack::GetNumOfElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stack
的用法示例。
在下文中一共展示了Stack::GetNumOfElements方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTargetPosition
/**
* @brief
* Returns the target position within the container space of the owner node
*/
bool SNMRotationTarget::GetTargetPosition(Vector3 &vPos) const
{
// Target scene node given?
if (Target.Get().GetLength()) {
// Get the target scene node
const SceneNode *pTarget;
if (GetSceneNode().GetContainer())
pTarget = GetSceneNode().GetContainer()->GetByName(Target.Get());
else {
// This must be the root :()
pTarget = static_cast<const SceneContainer&>(GetSceneNode()).GetByName(Target.Get());
}
if (pTarget) {
// Set the position of the attached node
vPos = pTarget->GetTransform().GetPosition();
// Are we in luck and the target is within the same container as the owner node?
if (GetSceneNode().GetContainer() != pTarget->GetContainer()) {
// Nope, we have to translate the position into the correct space :(
SceneContainer *pContainer = pTarget->GetContainer();
while (pContainer) {
vPos *= pContainer->GetTransform().GetMatrix();
pContainer = pContainer->GetContainer();
}
// To container space of the owner node
pContainer = GetSceneNode().GetContainer();
Stack<SceneContainer*> lstStack;
while (pContainer) {
lstStack.Push(pContainer);
pContainer = pContainer->GetContainer();
}
while (lstStack.GetNumOfElements()) {
pContainer = lstStack.Top();
lstStack.Pop();
vPos *= pContainer->GetTransform().GetInverseMatrix();
}
}
// Done
return true;
}
}
// Error - no valid target scene node, no target rotation :(
return false;
}
示例2: GetTargetRotation
/**
* @brief
* Returns the target rotation within the container space of the owner node
*/
bool SNMMeshJoint::GetTargetRotation(Quaternion &qRot) const
{
// Get the target scene node
const SceneNode *pTarget;
if (GetSceneNode().GetContainer())
pTarget = GetSceneNode().GetContainer()->GetByName(RotationFrom.Get());
else {
// This must be the root :()
pTarget = static_cast<const SceneContainer&>(GetSceneNode()).GetByName(RotationFrom.Get());
}
if (!pTarget)
return false; // Error - no valid target scene node, no target rotation :(
// Set the rotation of the attached node
qRot = pTarget->GetTransform().GetRotation();
// Are we in luck and the target is within the same container as the owner node?
if (GetSceneNode().GetContainer() != pTarget->GetContainer()) {
// Nope, we have to translate the rotation into the correct space :(
const SceneContainer *pContainer = pTarget->GetContainer();
while (pContainer) {
qRot *= pContainer->GetTransform().GetRotation();
pContainer = pContainer->GetContainer();
}
// To container space of the owner node
pContainer = GetSceneNode().GetContainer();
Stack<const SceneContainer*> lstStack;
while (pContainer) {
lstStack.Push(pContainer);
pContainer = pContainer->GetContainer();
}
while (lstStack.GetNumOfElements()) {
pContainer = lstStack.Top();
lstStack.Pop();
qRot *= pContainer->GetTransform().GetRotation().GetUnitInverted();
}
}
// Done
return true;
}