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


C++ Mat4::MakeTranslate方法代码示例

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


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

示例1: _upateState

		void tPlayerController::_upateState(float timeStep)
		{
			Vec3 nextStep = Vec3::Zero;

			if (mState == eOnLand)
			{
				nextStep += mForwordVelocity * mNode->GetDirection();
				nextStep += mSideVelocity * mNode->GetRight();
			}
			else if (mState == eOnFall)
			{
				nextStep += Vec3::UnitY * mGravity;
			}
			else if (mState == eOnJump)
			{
				nextStep += mForwordVelocity * mNode->GetDirection();
				nextStep += mSideVelocity * mNode->GetRight();
				nextStep += mInternalJumpVel * Vec3::UnitY;
			}

			nextStep *= timeStep;

			const Vec3 & worldPos = mNode->GetPosition();
			NewtonWorld * ntWorld = tWorld::Instance()->_getNewtonWorld();

			NewtonWorldConvexCastReturnInfo info[_NT_MAX_CONTACTS];

			Mat4 worldTm;

			worldTm.MakeTranslate(worldPos.x, worldPos.y, worldPos.z);
			 
			Vec3 dest = worldPos + nextStep;
			float hitParam;

			// check on land
			if (mState == eOnJump)
			{
				int contacts = NewtonWorldConvexCast(ntWorld, worldTm[0], &dest.x, mShape->_getNewtonCollision(), &hitParam, this,
													 _convexCastBodyFilter, info, _NT_MAX_CONTACTS, 0);

				if (contacts)
				{
					float bestValue = info[0].m_point[1];
					float lowestValue = info[0].m_point[1];

					for (int i = 1; i < contacts; i ++)
					{
						float value = info[i].m_point[1];

						if (value > bestValue)
							bestValue = value;

						if (value < lowestValue)
							lowestValue = value;
					}

					if (mInternalJumpVel >= 0 && bestValue > mPlayerHeight * mJumpHighLimit)
						mInternalJumpVel = 0;

					/*if (mInternalJumpVel <= 0 && lowestValue < mPlayerHeight * mLandLimit)
					{
						mState = eOnLand;
					}
					*/

					Vec3 Normal, Position;
					if (mInternalJumpVel <= 0 && _checkOnLand(dest, &Normal, &Position))
					{
						mNode->SetPosition(Position);
						mState = eOnLand;
					}
				}

				mNode->SetPosition(dest);

				return ;
			}
			
			Vec3 Normal, Position;
			if (_checkOnLand(dest, &Normal, &Position))
			{
				int contacts = NewtonWorldConvexCast(ntWorld, worldTm[0], &dest.x, mShape->_getNewtonCollision(), &hitParam, this,
													 _convexCastBodyFilter, info, _NT_MAX_CONTACTS, 0);

				float bestValue = info[0].m_point[1];
				float lowestValue = info[0].m_point[1];

				for (int i = 1; i < contacts; i ++)
				{
					float value = info[i].m_point[1];

					if (value > bestValue)
						bestValue = value;

					if (value < lowestValue)
						lowestValue = value;
				}

				if (bestValue < dest.y + mPlayerHeight * mLandLimit)
					mState = eOnLand;
//.........这里部分代码省略.........
开发者ID:ak4hige,项目名称:myway3d,代码行数:101,代码来源:NewtonPlayerController.cpp


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