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


C++ Quaternion::getPitch方法代码示例

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


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

示例1: mouseReleaseEvent

void  OgreWidget::mouseReleaseEvent(QMouseEvent * e)
{
  if (e->button() == Qt::MiddleButton || e->button() == Qt::LeftButton)
    {
      m_mouseButtonsPressed &= e->buttons();
      m_oldPos = QPoint(InvalidMousePoint);

      if (m_snapeToGrid)
        {
          Ogre::Vector3 pos = m_selectionManager.getPosition();
          int           gridSpace = DataManager::getSingleton()->getGridSpace();

          pos.x = qFloor((pos.x + gridSpace / 2.f) / gridSpace) * gridSpace;
          pos.y = qFloor((pos.y + gridSpace / 2.f) / gridSpace) * gridSpace;
          pos.z = qFloor((pos.z + gridSpace / 2.f) / gridSpace) * gridSpace;
          m_selectionManager.setPosition(pos.x, pos.y, pos.z);
          emit itemMoved();
        }
      if (m_snapeToAngle)
        {
          Ogre::Quaternion  orientation = m_selectionManager.getOrientation();
          int               snapAngle = DataManager::getSingleton()->getSnapAngle();

          if (m_constraintedX)
            {
              m_selectionManager.pitch(-orientation.getPitch());
              m_selectionManager.pitch(Ogre::Degree(qFloor((orientation.getPitch().valueDegrees() + snapAngle / 2.f) / snapAngle) * snapAngle));
            }
          else if (m_constraintedY)
            {
              m_selectionManager.yaw(-orientation.getYaw());
              m_selectionManager.yaw(Ogre::Degree(qFloor((orientation.getYaw().valueDegrees() + snapAngle / 2.f) / snapAngle) * snapAngle));
            }
          else if (m_constraintedZ)
            {
              m_selectionManager.roll(-orientation.getRoll());
              m_selectionManager.roll(Ogre::Degree(qFloor((orientation.getRoll().valueDegrees() + snapAngle / 2.f) / snapAngle) * snapAngle));
            }
          emit itemMoved();
        }
      update();
      e->accept();
    }
  else
    {
      e->ignore();
    }
}
开发者ID:ShrademnThill,项目名称:ogre-construction-set,代码行数:48,代码来源:OgreWidget.cpp

示例2: approach

void EnemyController::approach(void)
{
	EnemyPlane* enemy = static_cast<EnemyPlane*>(IDManager::getPointer(_enemyName, ACTOR));
	Ogre::Vector3 temp = FCKnowledge::getSingleton().getPlayerPosition() - enemy->getPosition();
	Ogre::Vector3 direction = temp * enemy->getAxis();
	//std::cout<<direction.x<<" "<<direction.y<<" "<<direction.z<<std::endl;
	if(direction.angleBetween(Ogre::Vector3::NEGATIVE_UNIT_Z) >= Ogre::Radian(Ogre::Degree(1)))
	{
		Ogre::Quaternion test = direction.getRotationTo(Ogre::Vector3::NEGATIVE_UNIT_Z);
		Ogre::Degree angle = enemy->getRotateLimit();
		
		double yawNum = test.getYaw().valueDegrees()/(angle*WORLD_UPDATE_INTERVAL).valueDegrees();
		yawNum = Ogre::Math::Clamp(yawNum, -1.0, 1.0);
		enemy->yaw(yawNum);

		double pitchNum = test.getPitch().valueDegrees()/(angle*WORLD_UPDATE_INTERVAL).valueDegrees();
		pitchNum = Ogre::Math::Clamp(pitchNum, -1.0, 1.0);
		enemy->pitch(pitchNum);
		
		double rollNum = test.getRoll().valueDegrees()/(angle*WORLD_UPDATE_INTERVAL).valueDegrees();
		rollNum = Ogre::Math::Clamp(rollNum, -1.0, 1.0);
		enemy->roll(rollNum);
		
	}
	else
	{
		enemy->yaw(0);
		enemy->pitch(0);
		enemy->roll(0);
	}
}
开发者ID:utah2013zyd,项目名称:Game,代码行数:31,代码来源:EnemyController.cpp

示例3: doPhysics

    void PhysicsSystem::doPhysics(float dt, const std::vector<std::pair<std::string, Ogre::Vector3> >& actors)
    {
        //set the DebugRenderingMode. To disable it,set it to 0
        //eng->setDebugRenderingMode(1);

        //set the walkdirection to 0 (no movement) for every actor)
        for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++)
        {
            OEngine::Physic::PhysicActor* act = it->second;
            act->setWalkDirection(btVector3(0,0,0));
        }
		playerMove::playercmd& pm_ref = playerphysics->cmd;

        pm_ref.rightmove = 0;
        pm_ref.forwardmove = 0;
        pm_ref.upmove = 0;

		//playerphysics->ps.move_type = PM_NOCLIP;
        for (std::vector<std::pair<std::string, Ogre::Vector3> >::const_iterator iter (actors.begin());
            iter!=actors.end(); ++iter)
        {
            //dirty stuff to get the camera orientation. Must be changed!

            Ogre::SceneNode *sceneNode = mRender.getScene()->getSceneNode (iter->first);
            Ogre::Vector3 dir;
            Ogre::Node* yawNode = sceneNode->getChildIterator().getNext();
            Ogre::Node* pitchNode = yawNode->getChildIterator().getNext();
			Ogre::Quaternion yawQuat = yawNode->getOrientation();
            Ogre::Quaternion pitchQuat = pitchNode->getOrientation();



            playerphysics->ps.viewangles.x = pitchQuat.getPitch().valueDegrees();

			playerphysics->ps.viewangles.y = yawQuat.getYaw().valueDegrees() *-1 + 90;


                Ogre::Quaternion quat = yawNode->getOrientation();
                Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y);

				pm_ref.rightmove = -iter->second.x;
				pm_ref.forwardmove = -iter->second.y;
				pm_ref.upmove = iter->second.z;



            }





        mEngine->stepSimulation(dt);
    }
开发者ID:DeejStar,项目名称:openmw,代码行数:54,代码来源:physicssystem.cpp

示例4: updateLogic

void Application::updateLogic( const float elapsedSeconds )
{
	const float TURN_DEGREES_PER_SECOND = 360;
	const float MOVEMENT_UNITS_PER_SECOND = 4;

	m_movingDirection = 0;

	if ( m_keyboard->isKeyDown( OIS::KC_LEFT ) )
	{
		m_sceneNode->yaw( Ogre::Degree( -TURN_DEGREES_PER_SECOND * elapsedSeconds ) );

		Ogre::Quaternion nodeOri = m_sceneNode->getOrientation();
		m_cameraController->addOrientation(nodeOri.getYaw().valueDegrees(), nodeOri.getPitch().valueDegrees());
	}

	if ( m_keyboard->isKeyDown( OIS::KC_RIGHT ) )
	{
		m_sceneNode->yaw( Ogre::Degree( -TURN_DEGREES_PER_SECOND * elapsedSeconds ) );
		
		Ogre::Quaternion nodeOri = m_sceneNode->getOrientation();
		m_cameraController->addOrientation(nodeOri.getYaw().valueDegrees(), nodeOri.getPitch().valueDegrees());
	}

	if ( m_keyboard->isKeyDown( OIS::KC_UP ) )
	{
		m_sceneNode->translate( Ogre::Vector3::UNIT_Z * MOVEMENT_UNITS_PER_SECOND * elapsedSeconds, Ogre::Node::TS_LOCAL );
		m_movingDirection++;

		Ogre::Vector3 nodePos = m_sceneNode->getPosition();
		m_cameraController->setLookAtPosition(nodePos.x, nodePos.y, nodePos.z);
	}

	if ( m_keyboard->isKeyDown( OIS::KC_DOWN ) )
	{
		m_sceneNode->translate( Ogre::Vector3::NEGATIVE_UNIT_Z * MOVEMENT_UNITS_PER_SECOND * elapsedSeconds, Ogre::Node::TS_LOCAL );
		m_movingDirection--;		
	
		Ogre::Vector3 nodePos = m_sceneNode->getPosition();
		m_cameraController->setLookAtPosition(nodePos.x, nodePos.y, nodePos.z);
	}
}
开发者ID:juanjmostazo,项目名称:ouan-tests,代码行数:41,代码来源:Application.cpp

示例5: setOrientation

void CameraManager::setOrientation(Ogre::Quaternion ori){

	mNodeYaw = ori.getYaw();
	mNodePitch = ori.getPitch();
	mNodeRoll = ori.getRoll();

	if(mCameraMode == OCULUS)
		mOculusCamera->setOrientation(ori);
	else
		mSimpleCamera->setOrientation(ori);

}
开发者ID:Target6,项目名称:pairOculus,代码行数:12,代码来源:CameraManager.cpp

示例6: updateStats

void Application::updateStats()
{
	static Ogre::String currFps = "Current FPS: ";
	static Ogre::String avgFps = "Average FPS: ";
	static Ogre::String bestFps = "Best FPS: ";
	static Ogre::String worstFps = "Worst FPS: ";
	static Ogre::String tris = "Triangle Count: ";
	static Ogre::String batches = "Batch Count: ";

	// update stats when necessary
	try {
		Ogre::OverlayElement* guiAvg = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/AverageFps");
		Ogre::OverlayElement* guiCurr = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/CurrFps");
		Ogre::OverlayElement* guiBest = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/BestFps");
		Ogre::OverlayElement* guiWorst = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/WorstFps");

		const Ogre::RenderTarget::FrameStats& stats = m_window->getStatistics();
		guiAvg->setCaption(avgFps + Ogre::StringConverter::toString(stats.avgFPS));
		guiCurr->setCaption(currFps + Ogre::StringConverter::toString(stats.lastFPS));
		guiBest->setCaption(bestFps + Ogre::StringConverter::toString(stats.bestFPS)
			+" "+Ogre::StringConverter::toString(stats.bestFrameTime)+" ms");
		guiWorst->setCaption(worstFps + Ogre::StringConverter::toString(stats.worstFPS)
			+" "+Ogre::StringConverter::toString(stats.worstFrameTime)+" ms");

		Ogre::OverlayElement* guiTris = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/NumTris");
		guiTris->setCaption(tris + Ogre::StringConverter::toString(stats.triangleCount));

		Ogre::OverlayElement* guiBatches = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/NumBatches");
		guiBatches->setCaption(batches + Ogre::StringConverter::toString(stats.batchCount));

		/////////////////////////
		
		Ogre::Vector3 camPos = m_camera->getPosition();
		Ogre::Quaternion camOri = m_camera->getOrientation();
		Ogre::Vector3 freddyPos = m_sceneNode->getPosition();
		Ogre::Quaternion freddyOri = m_sceneNode->getOrientation();
		
		Ogre::OverlayElement* guiDbg = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/DebugText");
		guiDbg->setTop(0);

		Ogre::String message = 
			"Camera Position: x: "+Ogre::StringConverter::toString(camPos.x)+", y: "+Ogre::StringConverter::toString(camPos.y)+", z:"+Ogre::StringConverter::toString(camPos.z) + "\n" + 
			"Camera orientation: yaw: "+Ogre::StringConverter::toString(camOri.getYaw())+", pitch: "+Ogre::StringConverter::toString(camOri.getPitch())+", roll:"+Ogre::StringConverter::toString(camOri.getRoll()) + "\n" + 
			"Freddy position: x: "+Ogre::StringConverter::toString(freddyPos.x)+", y: "+Ogre::StringConverter::toString(freddyPos.y)+", z:"+Ogre::StringConverter::toString(freddyPos.z) + "\n" + 
			"Freddy orientation: yaw: "+Ogre::StringConverter::toString(freddyOri.getYaw())+", pitch: "+Ogre::StringConverter::toString(freddyOri.getPitch())+", roll:"+Ogre::StringConverter::toString(freddyOri.getRoll());
		
		guiDbg->setCaption(message);
		debugWindow->setText("This is a demo!");
	}
	catch(...) { /* ignore */ }
}
开发者ID:juanjmostazo,项目名称:ouan-tests,代码行数:51,代码来源:Application.cpp

示例7: Vector

/**
 * @brief Returns the rotation Vector
 *
 * @param mode
 */
Vector Transform::getRotation	()
{
	Ogre::Quaternion rot = m_4x4.extractQuaternion();
	return Vector(	rot.getYaw().valueRadians(), rot.getPitch().valueRadians(),	rot.getRoll().valueRadians() );
}
开发者ID:jamessqr,项目名称:Cing,代码行数:10,代码来源:Transform.cpp

示例8: position

  void
  CovarianceVisual::setMessage
  (const geometry_msgs::PoseWithCovariance& msg)
  {
    // Construct pose position and orientation.
    const geometry_msgs::Point& p = msg.pose.position;
    Ogre::Vector3 position (p.x, p.y, p.z);
    Ogre::Quaternion orientation
      (msg.pose.orientation.w,
       msg.pose.orientation.x,
       msg.pose.orientation.y,
       msg.pose.orientation.z);

    // Set position and orientation for axes scene node.
    if(!position.isNaN())
      axes_->setPosition (position);
    else
      ROS_WARN_STREAM_THROTTLE(1, "position contains NaN: " << position);
    if(!orientation.isNaN())
      axes_->setOrientation (orientation);
    else
      ROS_WARN_STREAM_THROTTLE(1, "orientation contains NaN: " << orientation);

    // check for NaN in covariance
    for (unsigned i = 0; i < 3; ++i) {
      if(isnan(msg.covariance[i])) {
        ROS_WARN_THROTTLE(1, "covariance contains NaN");
        return;
      }
    }

    // Compute eigen values and vectors for both shapes.
    std::pair<Eigen::Matrix3d, Eigen::Vector3d>
      positionEigenVectorsAndValues
      (computeEigenValuesAndVectors (msg, 0));
    std::pair<Eigen::Matrix3d, Eigen::Vector3d>
      orientationEigenVectorsAndValues
      (computeEigenValuesAndVectors (msg, 3));

    Ogre::Quaternion positionQuaternion
      (computeRotation (msg, positionEigenVectorsAndValues));
    Ogre::Quaternion orientationQuaternion
      (computeRotation (msg, orientationEigenVectorsAndValues));

    positionNode_->setOrientation (positionQuaternion);
    orientationNode_->setOrientation (orientationQuaternion);

    // Compute scaling.
    Ogre::Vector3 positionScaling
      (std::sqrt (positionEigenVectorsAndValues.second[0]),
       std::sqrt (positionEigenVectorsAndValues.second[1]),
       std::sqrt (positionEigenVectorsAndValues.second[2]));
    positionScaling *= scaleFactor_;

    Ogre::Vector3 orientationScaling
      (std::sqrt (orientationEigenVectorsAndValues.second[0]),
       std::sqrt (orientationEigenVectorsAndValues.second[1]),
       std::sqrt (orientationEigenVectorsAndValues.second[2]));
    orientationScaling *= scaleFactor_;

    // Set the scaling.
    if(!positionScaling.isNaN())
      positionNode_->setScale (positionScaling);
    else
      ROS_WARN_STREAM("positionScaling contains NaN: " << positionScaling);

    if(!orientationScaling.isNaN())
      orientationNode_->setScale (orientationScaling);
    else
      ROS_WARN_STREAM("orientationScaling contains NaN: " << orientationScaling);

    // Debugging.
    ROS_DEBUG_STREAM_THROTTLE
      (1.,
       "Position:\n"
       << position << "\n"
       << "Positional part 3x3 eigen values:\n"
       << positionEigenVectorsAndValues.second << "\n"
       << "Positional part 3x3 eigen vectors:\n"
       << positionEigenVectorsAndValues.first << "\n"
       << "Sphere orientation:\n"
       << positionQuaternion << "\n"
       << positionQuaternion.getRoll () << " "
       << positionQuaternion.getPitch () << " "
       << positionQuaternion.getYaw () << "\n"
       << "Sphere scaling:\n"
       << positionScaling << "\n"
       << "Rotational part 3x3 eigen values:\n"
       << orientationEigenVectorsAndValues.second << "\n"
       << "Rotational part 3x3 eigen vectors:\n"
       << orientationEigenVectorsAndValues.first << "\n"
       << "Cone orientation:\n"
       << orientationQuaternion << "\n"
       << orientationQuaternion.getRoll () << " "
       << orientationQuaternion.getPitch () << " "
       << orientationQuaternion.getYaw () << "\n"
       << "Cone scaling:\n"
       << orientationScaling
       );
  }
开发者ID:carlosmccosta,项目名称:rviz_plugin_covariance,代码行数:100,代码来源:covariance_visual.cpp

示例9: frameRenderingQueued


//.........这里部分代码省略.........
		if (mKeyboard->isKeyDown(OIS::KC_V)) // Left - or roll
		{
		if(mKeyboard->isKeyDown( OIS::KC_LSHIFT ))
			{
				transVectorCamera.y -= mMove;
			} 
		else
			{
			transVectorCamera.y += mMove; 
			}
		}
		if (mKeyboard->isKeyDown(OIS::KC_B)) // Left - or roll
		{
		if(mKeyboard->isKeyDown( OIS::KC_LSHIFT ))
			{
				transVectorCamera.z -= mMove;
			} 
		else
			{
				transVectorCamera.z += mMove; 
			}
		}

		mSceneMgr->getSceneNode("cameraInsertion")->translate(transVectorInsertion * evt.timeSinceLastFrame, Ogre::Node::TS_LOCAL);
		mSceneMgr->getSceneNode("cameraNode")->translate(transVectorCamera * evt.timeSinceLastFrame, Ogre::Node::TS_LOCAL);

		//-------------------mTrayMgr -----------------------------------------------------------------
		mTrayMgr->frameRenderingQueued(evt);
		if (!mTrayMgr->isDialogVisible())
		{
        if (mDetailsPanel->isVisible())// If details panel is visible, then update its contents
        {
			if (mSelectedElement == 1)
			{
				Ogre::Quaternion Quat = mSceneMgr->getSceneNode("cameraNode")->getOrientation();
				mDetailsPanel->setParamValue(0, "Camera");
				mDetailsPanel->setParamValue(1, Ogre::StringConverter::toString(mSceneMgr->getSceneNode("cameraNode")->getPosition().x));
				mDetailsPanel->setParamValue(2, Ogre::StringConverter::toString(mSceneMgr->getSceneNode("cameraNode")->getPosition().y));
				mDetailsPanel->setParamValue(3, Ogre::StringConverter::toString(mSceneMgr->getSceneNode("cameraNode")->getPosition().z));
				//Get scene node values
				mDetailsPanel->setParamValue(6, Ogre::StringConverter::toString(Quat.getPitch()));
				mDetailsPanel->setParamValue(9, Ogre::StringConverter::toString(Quat.getYaw()));
				mDetailsPanel->setParamValue(12, Ogre::StringConverter::toString(Quat.getRoll()));
				mDetailsPanel->setParamValue(15, Ogre::StringConverter::toString(mSceneMgr->getSceneNode("cameraInsertion")->getPosition().z));
				//Get if possible symball values
				if (!mNoSimballConnected)
				{
					mDetailsPanel->setParamValue(5, Ogre::StringConverter::toString(mPitchC));
					mDetailsPanel->setParamValue(8, Ogre::StringConverter::toString(mRotC));
					mDetailsPanel->setParamValue(11, Ogre::StringConverter::toString(mYawC));
					mDetailsPanel->setParamValue(13, Ogre::StringConverter::toString(mInsC));;
				}
			}
			if (mSelectedElement == 2)
			{
				Ogre::Quaternion Quat = mSceneMgr->getSceneNode("LeftNode")->getOrientation();
				mDetailsPanel->setParamValue(0, "Stick left");
				mDetailsPanel->setParamValue(1, Ogre::StringConverter::toString(mSceneMgr->getSceneNode("LeftNode")->getPosition().x));
				mDetailsPanel->setParamValue(2, Ogre::StringConverter::toString(mSceneMgr->getSceneNode("LeftNode")->getPosition().y));
				mDetailsPanel->setParamValue(3, Ogre::StringConverter::toString(mSceneMgr->getSceneNode("LeftNode")->getPosition().z));
				//Get scene node values
				mDetailsPanel->setParamValue(6, Ogre::StringConverter::toString(Quat.getPitch()));
				mDetailsPanel->setParamValue(9, Ogre::StringConverter::toString(Quat.getYaw()));
				mDetailsPanel->setParamValue(12, Ogre::StringConverter::toString(Quat.getRoll()));
				mDetailsPanel->setParamValue(15, Ogre::StringConverter::toString(mSceneMgr->getSceneNode("MoveNodeLeft")->getPosition().x));
				//Get if possible symball values
				if (!mNoSimballConnected)
				{
					mDetailsPanel->setParamValue(5, Ogre::StringConverter::toString(mPitchR));
					mDetailsPanel->setParamValue(8, Ogre::StringConverter::toString(mRotR));
					mDetailsPanel->setParamValue(11, Ogre::StringConverter::toString(mYawR));
					mDetailsPanel->setParamValue(13, Ogre::StringConverter::toString(mInsR));;
				}
			}
			if (mSelectedElement == 3)
			{
				Ogre::Quaternion Quat = mSceneMgr->getSceneNode("RightNode")->getOrientation();
				mDetailsPanel->setParamValue(0, "Stick right");
				mDetailsPanel->setParamValue(1, Ogre::StringConverter::toString(mSceneMgr->getSceneNode("RightNode")->getPosition().x));
				mDetailsPanel->setParamValue(2, Ogre::StringConverter::toString(mSceneMgr->getSceneNode("RightNode")->getPosition().y));
				mDetailsPanel->setParamValue(3, Ogre::StringConverter::toString(mSceneMgr->getSceneNode("RightNode")->getPosition().z));
				//Get scene node values
				mDetailsPanel->setParamValue(6, Ogre::StringConverter::toString(Quat.getPitch()));
				mDetailsPanel->setParamValue(9, Ogre::StringConverter::toString(Quat.getYaw()));
				mDetailsPanel->setParamValue(12, Ogre::StringConverter::toString(Quat.getRoll()));
				mDetailsPanel->setParamValue(15, Ogre::StringConverter::toString(mSceneMgr->getSceneNode("MoveNodeRight")->getPosition().x));
				//Get if possible symball values
				if (!mNoSimballConnected)
				{
					mDetailsPanel->setParamValue(5, Ogre::StringConverter::toString(mPitchL));
					mDetailsPanel->setParamValue(8, Ogre::StringConverter::toString(mRotL));
					mDetailsPanel->setParamValue(11, Ogre::StringConverter::toString(mYawL));
					mDetailsPanel->setParamValue(13, Ogre::StringConverter::toString(mInsL));;
				}
			}

        }
    }
	return ret;
}
开发者ID:sw-eng-2014,项目名称:general_solution,代码行数:101,代码来源:LapTrainer.cpp

示例10: doPhysics

    void PhysicsSystem::doPhysics(float dt, const std::vector<std::pair<std::string, Ogre::Vector3> >& actors)
    {
        //set the DebugRenderingMode. To disable it,set it to 0
        //eng->setDebugRenderingMode(1);

        //set the walkdirection to 0 (no movement) for every actor)
        for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++)
        {
            OEngine::Physic::PhysicActor* act = it->second;
            act->setWalkDirection(btVector3(0,0,0));
        }
		playerMove::playercmd& pm_ref = playerphysics->cmd;

        pm_ref.rightmove = 0;
        pm_ref.forwardmove = 0;
        pm_ref.upmove = 0;

		//playerphysics->ps.move_type = PM_NOCLIP;
        for (std::vector<std::pair<std::string, Ogre::Vector3> >::const_iterator iter (actors.begin());
            iter!=actors.end(); ++iter)
        {
            OEngine::Physic::PhysicActor* act = mEngine->getCharacter(iter->first);
			//if(iter->first == "player")
			//	std::cout << "This is player\n";
            //dirty stuff to get the camera orientation. Must be changed!

            Ogre::SceneNode *sceneNode = mRender.getScene()->getSceneNode (iter->first);
            Ogre::Vector3 dir;
            Ogre::Node* yawNode = sceneNode->getChildIterator().getNext();
            Ogre::Node* pitchNode = yawNode->getChildIterator().getNext();
			Ogre::Quaternion yawQuat = yawNode->getOrientation();
            Ogre::Quaternion pitchQuat = pitchNode->getOrientation();

            // unused
            //Ogre::Quaternion both = yawQuat * pitchQuat;

            playerphysics->ps.viewangles.x = pitchQuat.getPitch().valueDegrees();
            playerphysics->ps.viewangles.z = 0;
			playerphysics->ps.viewangles.y = yawQuat.getYaw().valueDegrees() *-1 + 90;

            if(mFreeFly)
            {
                Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y);

				pm_ref.rightmove = -dir1.x;
				pm_ref.forwardmove = dir1.z;
				pm_ref.upmove = dir1.y;


				//std::cout << "Current angle" << yawQuat.getYaw().valueDegrees() - 90<< "\n";
				//playerphysics->ps.viewangles.x = pitchQuat.getPitch().valueDegrees();
				//std::cout << "Pitch: " << yawQuat.getPitch() << "Yaw:" << yawQuat.getYaw() << "Roll: " << yawQuat.getRoll() << "\n";
                dir = 0.07*(yawQuat*pitchQuat*dir1);
            }
            else
            {

                Ogre::Quaternion quat = yawNode->getOrientation();
                Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y);

				pm_ref.rightmove = -dir1.x;
				pm_ref.forwardmove = dir1.z;
				pm_ref.upmove = dir1.y;



                dir = 0.025*(quat*dir1);
            }


            //set the walk direction
            act->setWalkDirection(btVector3(dir.x,-dir.z,dir.y));
        }
        mEngine->stepSimulation(dt);
    }
开发者ID:SlavaHill,项目名称:openmw,代码行数:75,代码来源:physicssystem.cpp


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