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


C++ NxVec3::z方法代码示例

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


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

示例1: update

	void QCharacterController::update(float delta)
	{
		mAccumulation += delta;

		while(mAccumulation>=mTimeStep)
		{
			btVector3 upVectorFinal = QVector3Nx(mPhysicsManager->getLocalGravity(Vector3(NxVector3(mController->getPosition()))));//gmgr->gvmgr->getGravityLocalCCT(NxVector3(mController->getPosition()));
			NxVec3 GravityVector = upVectorFinal;
			upVectorFinal.normalize();
			upVectorFinal*=-1;

			bool testing = false;

			NxVec3 opo = NxVec3(0,0,0);
			NxVec3 fpo = NxVec3(0,0,0);

			float abbc = mPhysicsManager->getLocalGravity(NxVector3(mController->getPosition()+mController->getUpVector())).length();//gmgr->gvmgr->getGravityLocalCCT(NxVector3(mController->getPosition()+mController->getUpVector())).magnitude();
			q_1 = q_2;

			if(mController->getUpVector()!=upVectorFinal&&Ogre::Degree(NxVector3(mController->getUpVector()).angleBetween(NxVector3(upVectorFinal)))>Ogre::Degree(0.075f)&&abbc>0.2f)
			{
				testing = true;

				Ogre::Vector3 up1 = NxVector3(mController->getUpVector());

				//std::cout<<"pos1: "<<mController->cctp[0]->getPosition().x()<<"\n";
				mController->setUpVector(upVectorFinal,mTimeStep);
				//std::cout<<"pos2: "<<mController->cctp[0]->getPosition().x()<<"\n";

				Ogre::Vector3 up2 = NxVector3(mController->getUpVector());
				Ogre::Quaternion q2 = up1.getRotationTo(up2,Ogre::Vector3::UNIT_X);
				q_2 = Quaternion(q2*q_1.toOgre());
			}

			//dnode02->setOrientation(Ogre::Quaternion::IDENTITY);
			//dnode02->setDirection(NxVector3(mController->getUpVector()),Ogre::SceneNode::TS_LOCAL,Ogre::Vector3::UNIT_Y);

			opo = mController->position;

			bool mMidair = false;// = inAir();
			float playerSpeed = 0;

			if(mController->move_)
			{
				Ogre::Vector3 v3 = Ogre::Vector3(moveV.x,moveV.y,moveV.z);
				Ogre::Plane pln = Ogre::Plane(NxVector3(mController->getUpVector()),0);
				pln.projectVector(v3);
				v3.normalise();
				moveV = Ogre::Vector3(moveV.x,moveV.y,moveV.z);
				/// run = 6.225
				/// walk = 2.225
				float spdd = mPlayerSpeedStart*(1-mPlayerSpeedInterpolation)+mPlayerSpeedTop*(mPlayerSpeedInterpolation);//7.0f;//2.225f*(1-runTimer) + 6.225*runTimer

				if(abbc<0.2)
				{
					mController->move(NxVec3(moveV.x,moveV.y,moveV.z)*mTimeStep*spdd,true,mTimeStep,true);
				}
				else
				{
					//std::cout<<"Try move....\n";
					mController->move(NxVec3(moveV.x,moveV.y,moveV.z)*mTimeStep*spdd,true,mTimeStep);
				}
				fpo = mController->position;
				playerSpeed = Ogre::Math::Abs((fpo-opo).length());
				//playerMotionDir = NxVector3(fpo-opo);
				//std::cout<<"Speed: "<<playerSpeed/(gmgr->tmgr->getTimeSpeed()/60.0f)<<"\n";
			}
			else
			{
				playerSpeed = 0;
				//playerMotionDir = Ogre::Vector3(0,0,0);
			}

			mMidair = inAir();

			float lastSpeed = mPlayerSpeedLast;
			mPlayerSpeedLast = playerSpeed;

			if(mPlayerSpeedLast>lastSpeed)
			{
				mPlayerSpeedInterpolation+=(mTimeStep/mPlayerSpeedAccel);
				mGracePeriod = 0;
			}
			else if((mPlayerSpeedLast<mPlayerSpeedStart*mTimeStep||mHittingGround)&&!mMidair)
			{
				// we give a little bit of padding so if a gravity issue ir something stops it for a frame
				// it doesn't slow abruptly.
				++mGracePeriod;
				if(mGracePeriod>=2)
				{
					mPlayerSpeedInterpolation=0;
				}
			}
			else
			{
				mGracePeriod = 0;
			}

			if(mMidair)
			{
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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