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


C++ PVRTVec3::lenSqr方法代码示例

本文整理汇总了C++中PVRTVec3::lenSqr方法的典型用法代码示例。如果您正苦于以下问题:C++ PVRTVec3::lenSqr方法的具体用法?C++ PVRTVec3::lenSqr怎么用?C++ PVRTVec3::lenSqr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PVRTVec3的用法示例。


在下文中一共展示了PVRTVec3::lenSqr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FlyState

void BulletNode::FlyState()
{
	 mBulletPos += mDir * mSpeed;
	 mBulletPos.y -= mGravity;
	 mSpeed -= mFriction;
	
	 if (mHit)
	 {
		mState = state_hit;
		return;
	 }

	 if (mSpeed < 0.0f || mBulletPos.y < 0.0f)
	 {
		 mState = state_missed;
	 }
	 else
	 {
		PVRTVec3 fromStart = mBulletPos - mBulletStartingPos;
		float fromStartDist = fromStart.lenSqr();
		if (fromStartDist > MM(mRange))
		{
			mState = state_missed;
		}
	 }
}
开发者ID:dovalec,项目名称:3D,代码行数:26,代码来源:BulletNode.cpp

示例2: updatePosition

	void SimpleCamera::updatePosition()
	{	
	// Most of this stuff is to try and smooth movement when controlled by the primitive keyboard input available

		PVRTVec3 vDec = m_vVelocity * f2vt(TimeController::inst().getDeltaTime()) * m_fMoveSpeed * f2vt(0.1f);

		while(vDec.lenSqr()>m_vVelocity.lenSqr())
		{
			vDec /= f2vt(2.0f);
		}

		m_vVelocity -= vDec;

		if(m_vVelocity.lenSqr()>m_fMoveSpeed*m_fMoveSpeed)
		{
			m_vVelocity = m_vVelocity.normalized()*m_fMoveSpeed;
		}
 		m_vPosition += m_vVelocity * f2vt((float)TimeController::inst().getDeltaTime());
	}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例3: Update

void SceneManager::Update()
{
	RenderLayerManager & renderManager = RenderLayerManager::GetRenderLayerManager();
	const PVRTVec3 center = renderManager.GetCenter();
	float occlusionRadius = renderManager.GetOcclusionRadius();


    PVRTVec4 vecA( mLookMtx->f[12], 0.0f,  mLookMtx->f[14], 1);
	PVRTVec4 vecB( GLOBAL_SCALE *  FRUSTUM_W, 0.0f,  GLOBAL_SCALE * FRUSTUM_D, 1);
	PVRTVec4 vecC( GLOBAL_SCALE * -FRUSTUM_W, 0.0f,  GLOBAL_SCALE * FRUSTUM_D, 1);
	
    vecB = *mLookMtx * vecB;
    vecC = *mLookMtx * vecC;

	PVRTVec2 A(vecA.x, vecA.z);
	PVRTVec2 B(vecB.x, vecB.z);
	PVRTVec2 C(vecC.x, vecC.z);



	mToApplyCount = 0;

	if (mQuadTree)
	{
		static QuadNode * quadNodes[256]={0}; 
		int quadNodeCount = 0;

		//mQuadTree->GetQuads(center.x, center.z, occlusionRadius, quadNodes, quadNodeCount);
		mQuadTree->GetQuadsCameraFrustum(quadNodes, quadNodeCount,  mLookMtx);
		quadNodeCount--;

		bool useFrustumCulling = true; //!!!!!!!!!!!!!!!!!!!!!

		for (int quad = quadNodeCount ; quad >=0 ; quad--)
		{
			QuadNode * pQuadNode = quadNodes[quad];

			List & dataList = pQuadNode->GetDataList();
			ListIterator listIter(dataList);
			while( Node * pRootNode = (Node*)listIter.GetPtr() )	
			{			
				if (!pRootNode->IsVisible())
					continue;

				//pRootNode->UpdateWithoutChildren();
				bool useOcclusionRadius  = pRootNode->GetUseOcclusionCulling();
				PVRTVec3 worldPos = pRootNode->GetWorldTranslation();

				if (!useFrustumCulling && useOcclusionRadius)
				{
					PVRTVec3 distVec = worldPos - center;

					if ( distVec.lenSqr() < MM(occlusionRadius) ) 
					{
						pRootNode->SetInFrustum(true);
						pRootNode->Update();
						mToApply[mToApplyCount] = pRootNode;
						mToApplyCount++;
					}
					else
					{
						pRootNode->SetInFrustum(false);
					}
				}
				else if (useFrustumCulling)
				{
					PVRTVec2 P(worldPos.x, worldPos.z);

					PVRTVec2 v0 = C - A;
					PVRTVec2 v1 = B - A;
					PVRTVec2 v2 = P - A;

					// Compute dot products
					float dot00 = v0.dot(v0);
					float dot01 = v0.dot(v1);
					float dot02 = v0.dot(v2);
					float dot11 = v1.dot(v1);
					float dot12 = v1.dot(v2);

					// Compute barycentric coordinates
					float invDenom = 1.0f / (dot00 * dot11 - dot01 * dot01);
					float u = (dot11 * dot02 - dot01 * dot12) * invDenom;
					float v = (dot00 * dot12 - dot01 * dot02) * invDenom;

					bool addToList = false;
					// Check if point is in triangle
					//PVRTVec3 distVec = worldPos - center;
					//if ( distVec.lenSqr() < MM(occlusionRadius) ) 
					{
						if ( (u > 0) && (v > 0) && (u + v < 1))
						{
							addToList = true;
						}
						else if ( Collision::CircleTriangleEdgeIntersection(A,B,P, pRootNode->GetRadius() ) )
						{
							addToList = true;
						}
						else if ( Collision::CircleTriangleEdgeIntersection(A,C,P, pRootNode->GetRadius() ))
						{
							addToList = true;
//.........这里部分代码省略.........
开发者ID:dovalec,项目名称:3D,代码行数:101,代码来源:SceneManager.cpp


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