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


C++ Stack::GetNumOfElements方法代码示例

本文整理汇总了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;
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:51,代码来源:SNMRotationTarget.cpp

示例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;
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:46,代码来源:SNMMeshJoint.cpp


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