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


C++ Camera::getPosition方法代码示例

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


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

示例1:

void			Player::_handleCamera()
{
  Ogre::Camera *cam = indie::GameManager::getCamera();

  cam->setPosition(gameObject->getPosition().x,
		   cam->getPosition().y,
		   gameObject->getPosition().z + 300);
}
开发者ID:Unreality3D,项目名称:Unreality3D,代码行数:8,代码来源:Player.cpp

示例2: camera_get_position

void camera_get_position(CameraHandle handle, coiVector3* result)
{
    Ogre::Camera* camera = static_cast<Ogre::Camera*>(handle);
    const Ogre::Vector3& pos = camera->getPosition();
    result->x = pos.x;
    result->y = pos.y;
    result->z = pos.z;
}
开发者ID:holocronweaver,项目名称:llcoi,代码行数:8,代码来源:camera_bind.cpp

示例3: processCamera

void DotSceneLoader::processCamera(rapidxml::xml_node<>* XMLNode,
		Ogre::SceneNode *pParent) {
	// Process attributes
	Ogre::String name = getAttrib(XMLNode, "name");
	Ogre::String id = getAttrib(XMLNode, "id");
// Ogre::Real fov = getAttribReal(XMLNode, "fov", 45);
// Ogre::Real aspectRatio = getAttribReal(XMLNode, "aspectRatio", 1.3333);
	Ogre::String projectionType = getAttrib(XMLNode, "projectionType",
			"perspective");

	// Create the camera
	Ogre::Camera *pCamera = mSceneMgr->createCamera(name);

	// Set the projection type
	if (projectionType == "perspective")
		pCamera->setProjectionType(Ogre::PT_PERSPECTIVE);
	else if (projectionType == "orthographic")
		pCamera->setProjectionType(Ogre::PT_ORTHOGRAPHIC);

	rapidxml::xml_node<>* pElement;

	// Process clipping (?)
	pElement = XMLNode->first_node("clipping");
	if (pElement) {
		Ogre::Real nearDist = getAttribReal(pElement, "near");
		if (nearDist > 0)
		  pCamera->setNearClipDistance(nearDist);

		Ogre::Real farDist = getAttribReal(pElement, "far");
		pCamera->setFarClipDistance(farDist);
	}

	// Process position (?)
	pElement = XMLNode->first_node("position");
	if (pElement)
		pCamera->setPosition(parseVector3(pElement));

	// Process rotation (?)
	pElement = XMLNode->first_node("rotation");
	if (pElement)
		pCamera->setOrientation(parseQuaternion(pElement));

	// construct a scenenode is no parent
	if (!pParent) {
		Ogre::SceneNode* pNode = mAttachNode->createChildSceneNode(name);
		pNode->setPosition(pCamera->getPosition());
		pNode->setOrientation(pCamera->getOrientation());
		pNode->scale(1, 1, 1);
	}
}
开发者ID:lubosz,项目名称:Collage,代码行数:50,代码来源:DotSceneLoader.cpp

示例4: EnableFreeCamera

void World::EnableFreeCamera( bool bEnable )
{
	assert(m_pRenderSystem->m_pMainCamera && m_cameraMan);

	if(!bEnable)
	{
		Ogre::Camera* cam = m_pRenderSystem->m_pMainCamera;
		const Ogre::Vector3 pos = cam->getPosition();
		cam->setPosition(0, 24, 0);
		cam->lookAt(0, 0, 8);
	}

	m_bFreeCamMode = bEnable;
}
开发者ID:wangxun159123,项目名称:MiniCraft,代码行数:14,代码来源:World.cpp

示例5: SaveSettingCamera

//---------------------------------------------------------------------------------------------
void TEditorMapLogic::SaveSettingCamera()
{
  Ogre::Camera* pCamera = TModuleLogic::Get()->GetC()->pGraphicEngine->GetGE()->GetCamera();
  const Ogre::Vector3& pos = pCamera->getPosition();
  const Ogre::Quaternion& dir = pCamera->getOrientation();

  GetSettings()->BeginGroup( "SettingCamera" );

  GetSettings()->WriteEntry( "pos_x", pos.x );
  GetSettings()->WriteEntry( "pos_y", pos.y );
  GetSettings()->WriteEntry( "pos_z", pos.z );

  GetSettings()->WriteEntry( "dir_x", dir.x );
  GetSettings()->WriteEntry( "dir_y", dir.y );
  GetSettings()->WriteEntry( "dir_z", dir.z );
  GetSettings()->WriteEntry( "dir_w", dir.w );
}
开发者ID:retrydev,项目名称:MMO-Framework,代码行数:18,代码来源:EditorMapLogic.cpp

示例6: updateReflectionCamera

void OgrePlanarReflectionMaterial::updateReflectionCamera(const Ogre::MovablePlane& plane)
{
    Ogre::Camera* sofaCamera = mSceneMgr->getCamera("sofaCamera");
    assert(sofaCamera);

    //mCamera->setNearClipDistance(sofaCamera->getNearClipDistance());
    mCamera->setFarClipDistance(sofaCamera->getFarClipDistance());
    mCamera->setAspectRatio(sofaCamera->getViewport()->getActualWidth() /
            sofaCamera->getViewport()->getActualHeight());
    mCamera->setFOVy(sofaCamera->getFOVy());
    mCamera->setOrientation(sofaCamera->getOrientation());
    mCamera->setPosition(sofaCamera->getPosition());

    mCamera->enableReflection(&plane);
    mCamera->enableCustomNearClipPlane(&plane);

}
开发者ID:david-cazier,项目名称:sofa,代码行数:17,代码来源:OgrePlanarReflectionMaterial.cpp

示例7: CheckObjectTransparent

// 检测是否要透明
void CEngineInterface::CheckObjectTransparent()
{
	if(!m_pFairySystem)
		return ;

	CObjectManager* objMng = CObjectManager::GetMe();
	fVector3 fvPos;
	
	if( objMng->GetMySelf()->GetRenderInterface() )
	{
		objMng->GetMySelf()->GetRenderInterface()->Actor_GetLocator( GetCharaLocatorName(LOCATOR_CHAR_ATTACK), fvPos );		// 取人物绑定点的位置, 判断起来比较合理	"人物身体受击点"
	}

	Axis_Trans(tGfxSystem::AX_GAME, fvPos, tGfxSystem::AX_GFX, fvPos);

	Ogre::Camera* pOgreCamera = m_pFairySystem->getCamera();
	Ogre::Vector3 origin = pOgreCamera->getPosition();

	// 屏掉下边这句了by czg 200911-30
	m_pFairySystem->makeObjectTransparent(origin, Ogre::Vector3(fvPos.x, fvPos.y, fvPos.z), 0.8, 1, NULL);
}
开发者ID:jjiezheng,项目名称:pap_full,代码行数:22,代码来源:EngineInterface.cpp

示例8: moveRel

    // Move the player relative to her own position and
    // orientation. After the call, the new position is returned.
    void moveRel(float &relX, float &relY, float &relZ)
    {
        using namespace Ogre;

        // Move camera relative to its own direction
        camera->moveRelative(Vector3(relX,0,relZ));

        // Up/down movement is always done relative the world axis.
        camera->move(Vector3(0,relY,0));

        // Get new camera position, converting back to MW coords.
        Vector3 pos = camera->getPosition();
        relX = pos[0];
        relY = -pos[2];
        relZ = pos[1];

        // TODO: Collision detection must be used to find the REAL new
        // position.

        // Set the position
        setPos(relX, relY, relZ);
    }
开发者ID:Twinzero,项目名称:openmw,代码行数:24,代码来源:playerpos.hpp

示例9: Translate


//.........这里部分代码省略.........

/*
	//IF NOT LEFT OR RIGHT IDLE OR TURNING
	if(!left && !right){
		a_ninjaStealth->setEnabled(false);
		a_ninjaWalk->setEnabled(false);
		a_ninjaIdle1->setEnabled(true);
		
		a_ninjaIdle1->addTime(evt.timeSinceLastFrame);
		
	}
	else
		a_ninjaIdle1->setEnabled(false);
	



	//const Ogre::FrameEvent evt; TODO: how to setup timer???
	//TODO: DONT LEAVE TRANSLATION UPDATE HERE!!
	sceneMgr->getSceneNode("Ninja1")->translate(transVector * evt.timeSinceLastFrame, Ogre::Node::TS_WORLD);
	
	
	//sceneMgr->getSceneNode("Ninja1")->yaw(Ogre::Degree(m_degreeFacing));
	if(m_directionFacing == RIGHT && m_angleFacing < 90  && m_keepTurning == true){
		float turnSpeed = 240 * evt.timeSinceLastFrame;
		sceneMgr->getSceneNode("Ninja1")->yaw(Ogre::Degree(turnSpeed));
		m_angleFacing += turnSpeed;
		if(m_angleFacing > 90)
			m_keepTurning = false;
	}

	if(m_directionFacing == LEFT && m_angleFacing > -90 && m_keepTurning == true){
		float turnSpeed = -240 * evt.timeSinceLastFrame;
		sceneMgr->getSceneNode("Ninja1")->yaw(Ogre::Degree(turnSpeed));
		m_angleFacing += turnSpeed;
		if(m_angleFacing < -90)
			m_keepTurning = false;
	}

	if(space){
		//make a function that sets everything to false
		a_ninjaWalk->setEnabled(false);
		a_ninjaStealth->setEnabled(false);
		a_ninjaIdle1->setEnabled(false);
		a_ninjaAttack1->setEnabled(true);
		a_ninjaAttack1->addTime(evt.timeSinceLastFrame);
	}
	
	
	//This will test collision for a falling ninja
	if(key_a)
		sceneMgr->getSceneNode("Ninja1")->setPosition(0, 300,-100);

	


	

	//REAL INPUTS HERE todo: clean up above but save for reference
	//GUI STUFF
#if(GUI_ON)
	if(key_grave)
		CEGUI::System::getSingleton().getGUISheet()->show();//shows GUI. User must click close to exit
#endif


	*/

	float speed = 30;
	Ogre::Vector3 movement = Ogre::Vector3::ZERO;

	if(up)
		movement.z = -speed;

	if(down)
		movement.z = speed;

	if(left)
		movement.x = -speed;

	if(right)
		movement.x = speed;

	if(mouseWheelUp)
		movement.y = speed;

	if(mouseWheelDown)
		movement.y = -speed;

	

	Ogre::Camera* cam = sceneMgr->getCamera("PlayerCam");
	cam->setPosition(cam->getPosition() + movement);



	//reset mouse wheel movement (CEGUI IS lame about it)
	mouseWheelDown = false;
	mouseWheelUp = false;
}
开发者ID:Cephas1982,项目名称:ZeldaClone3D,代码行数:101,代码来源:Input.cpp

示例10: processCamera

void DotSceneLoader::processCamera(rapidxml::xml_node<>* XMLNode, Ogre::SceneNode *pParent)
{
	// Process attributes
	Ogre::String name = getAttrib(XMLNode, "name");
	Ogre::String id = getAttrib(XMLNode, "id");
	Ogre::Real fov = getAttribReal(XMLNode, "fov", 45);
	Ogre::Real aspectRatio = getAttribReal(XMLNode, "aspectRatio", 1.3333);
	Ogre::String projectionType = getAttrib(XMLNode, "projectionType", "perspective");

	// Create the camera
	Ogre::Camera *pCamera = mSceneMgr->createCamera(name);

	//TODO: make a flag or attribute indicating whether or not the camera should be attached to any parent node.
	//if(pParent)
	//    pParent->attachObject(pCamera);

	// Set the field-of-view
	//! @todo Is this always in degrees?
	//pCamera->setFOVy(Ogre::Degree(fov));

	// Set the aspect ratio
	//pCamera->setAspectRatio(aspectRatio);

	// Set the projection type
	if (projectionType == "perspective")
		pCamera->setProjectionType(Ogre::PT_PERSPECTIVE);
	else if (projectionType == "orthographic")
		pCamera->setProjectionType(Ogre::PT_ORTHOGRAPHIC);

	rapidxml::xml_node<>* pElement;

	// Process clipping (?)
	pElement = XMLNode->first_node("clipping");
	if (pElement)
	{
		Ogre::Real nearDist = getAttribReal(pElement, "near");
		pCamera->setNearClipDistance(nearDist);

		Ogre::Real farDist = getAttribReal(pElement, "far");
		pCamera->setFarClipDistance(farDist);
	}

	// Process position (?)
	pElement = XMLNode->first_node("position");
	if (pElement)
		pCamera->setPosition(parseVector3(pElement));

	// Process rotation (?)
	pElement = XMLNode->first_node("rotation");
	if (pElement)
		pCamera->setOrientation(parseQuaternion(pElement));

	// Process normal (?)
	pElement = XMLNode->first_node("normal");
	if (pElement)
		;//!< @todo What to do with this element?

	// Process lookTarget (?)
	pElement = XMLNode->first_node("lookTarget");
	if (pElement)
		;//!< @todo Implement the camera look target

	// Process trackTarget (?)
	pElement = XMLNode->first_node("trackTarget");
	if (pElement)
		;//!< @todo Implement the camera track target

	// Process userDataReference (?)
	pElement = XMLNode->first_node("userDataReference");
	if (pElement)
		;//!< @todo Implement the camera user data reference

	// construct a scenenode is no parent
	if (!pParent)
	{
		Ogre::SceneNode* pNode = mAttachNode->createChildSceneNode(name);
		pNode->setPosition(pCamera->getPosition());
		pNode->setOrientation(pCamera->getOrientation());
		pNode->scale(1, 1, 1);
	}
}
开发者ID:GameMakersUnion,项目名称:hastySketch,代码行数:81,代码来源:DotSceneLoader.cpp

示例11: OnMouseMove

void ActorSceneCanvas::OnMouseMove(wxMouseEvent& e)
{

	ShowPos(e.GetX(), e.GetY());

    if (!GetSceneManipulator())
        return;

    if (m_pCameraManip)
    {
        wxASSERT(mDragButton != wxMOUSE_BTN_NONE);
        m_pCameraManip->onMotion(e.GetX(), e.GetY());
    }

	if (mDragStarted  && e.LeftIsDown())
	{
		mDragCurrent =Ogre::Vector2(e.GetX(), e.GetY()) ;
		mDragDelta = mDragCurrent - mDragOrigin;
		mDragOrigin = mDragCurrent;

		if (Fairy::CDataManipulator::GetDataManipulator() && mCanManipulateAxis)
		{	
			Ogre::Camera* camera = GetSceneManipulator()->getCamera();
			assert (camera);
			Ogre::Vector3 oldPos = camera->getPosition();
			Fairy::LogicModel* pModel = GetDataManipulator()->m_pObjTemplate;
			if (pModel)
			{
				Ogre::Vector3 objPos = pModel->getPosition();
				Ogre::Real distance = oldPos.distance(objPos);
				Ogre::Real factor = distance*0.1/150.0;

				Ogre::Vector3 pos=Fairy::CDataManipulator::m_baseNode->getPosition();
				Ogre::Vector3 fdeltaxi = Ogre::Vector3::ZERO;
				Ogre::Quaternion qRot = Fairy::CDataManipulator::m_baseNode->getOrientation();
				//david-<<
				 if(mXax)
					 fdeltaxi = /*qRot**/(mDragDelta.x*0.1*Ogre::Vector3::UNIT_X);
				 if(mYax)
					 fdeltaxi = /*qRot**/(mDragDelta.x*0.1*Ogre::Vector3::UNIT_Y);
				 if(mZax)
					 fdeltaxi = /*qRot**/(mDragDelta.x*0.1*Ogre::Vector3::UNIT_Z);
				 //david->>

				Fairy::CDataManipulator::GetDataManipulator()->_updateCurLocatorTrans(fdeltaxi,Ogre::Quaternion::IDENTITY,true);
			}			
		}	
	}

	if(mDragRightStarted &&  e.RightIsDown())
	{
	
		mDragCurrent =Ogre::Vector2(e.GetX(), e.GetY()) ;
		mDragDelta = mDragCurrent - mDragOrigin;
		mDragOrigin = mDragCurrent;

// 		Ogre::Radian x = Ogre::Degree(mDragDelta.val[0]);
// 		Ogre::Radian y = Ogre::Degree(mDragDelta.val[1]);
// 		Fairy::CDataManipulator::m_axex->yaw(y);
// 		Fairy::CDataManipulator::m_axex->pitch(x);

		if ( Fairy::CDataManipulator::GetDataManipulator() &&(mXax || mYax || mZax) && mCanManipulateAxis)
		{			
			Ogre::Vector3 fBaseAxis = Ogre::Vector3::ZERO;
			Ogre::Quaternion fBaseRot = Fairy::CDataManipulator::m_baseNode->getOrientation();

			if(mXax)
				fBaseAxis =/* fBaseRot**/Ogre::Vector3::UNIT_X;
			if(mYax)
				fBaseAxis =/* fBaseRot**/Ogre::Vector3::UNIT_Y;
			if(mZax)
				fBaseAxis =/* fBaseRot**/Ogre::Vector3::UNIT_Z;

			//david-<<
			Ogre::Radian angle = Ogre::Degree(mDragDelta.y);
			//david->>

			Ogre::Quaternion rot(angle, fBaseAxis);			

			if(mRotFirst)
			{
				Fairy::CDataManipulator::GetDataManipulator()->_updateCurLocatorTrans(Ogre::Vector3::ZERO, rot, false);	
			}
			else
			{
				Fairy::CDataManipulator::GetDataManipulator()->_updateCurLocatorRot(rot);	
			}				
		}
	}



    if (GetActiveAction())
    {
        //GetActiveAction()->onMotion(e.GetX(), e.GetY());
		if (e.ControlDown())
		{
			GetActiveAction()->setParameter("FUNC_KEY", "CTRL");
		}
		
//.........这里部分代码省略.........
开发者ID:jjiezheng,项目名称:pap_full,代码行数:101,代码来源:WXSceneCanvas.cpp

示例12: OnKeyDown

void ActorSceneCanvas::OnKeyDown(wxKeyEvent& e)
{
	switch(e.GetKeyCode())
	{
	case 'w':
	case 'W':
		{
			Ogre::Camera* camera = GetSceneManipulator()->getCamera();
			assert (camera);

			Ogre::Vector3 oldPos = camera->getPosition();

			Ogre::Vector3 offsetPos = camera->getDirection() * GetSceneManipulator()->getMoveSpeed();

			Ogre::Vector3 newPos = oldPos;
            newPos.x += offsetPos.x;
            newPos.z += offsetPos.z;

			GetSceneManipulator()->setCameraPosition(newPos);
			e.Skip(false);
		}
		break;
	case 's':
	case 'S':
		{
			Ogre::Camera* camera = GetSceneManipulator()->getCamera();
			assert (camera);

			Ogre::Vector3 oldPos = camera->getPosition();

			Ogre::Vector3 offsetPos = camera->getDirection() * -(GetSceneManipulator()->getMoveSpeed());

			Ogre::Vector3 newPos = oldPos;
            newPos.x += offsetPos.x;
            newPos.z += offsetPos.z;

			GetSceneManipulator()->setCameraPosition(newPos);
			e.Skip(false);
		}
		break;
	case 'a':
	case 'A':
		{
			Ogre::Camera* camera = GetSceneManipulator()->getCamera();
			assert (camera);

			Ogre::Radian yawAngle( GetSceneManipulator()->getRotateSpeed() / 360.0f );

			camera->yaw(yawAngle);
			e.Skip(false);
		}
		break;
	case 'd':
	case 'D':
		{
			Ogre::Camera* camera = GetSceneManipulator()->getCamera();
			assert (camera);

			Ogre::Radian yawAngle( -(GetSceneManipulator()->getRotateSpeed() / 360.0f) );

			camera->yaw(yawAngle);
			e.Skip(false);
		}
		break;
	case 'h':
	case 'H':
		{
			mHideAxis = !mHideAxis;
			Fairy::CDataManipulator::m_baseNode->setVisible(!mHideAxis);
			Fairy::CDataManipulator::mAxisNode_x->setVisible(!mHideAxis);
			Fairy::CDataManipulator::mAxisNode_y->setVisible(!mHideAxis);
			Fairy::CDataManipulator::mAxisNode_z->setVisible(!mHideAxis);
		}
		break;
 	case 'b':
	case 'B':
		{
			GetDataManipulator()->switchBoundingBox(true);
		}
		break;
	case 't':
	case 'T':
		{
			GetSceneManipulator()->setTerrainVisible(!GetSceneManipulator()->getTerrainVisible());
		}
		break;
	case 'g':
	case 'G':
		{
			GetSceneManipulator()->setGridVisible(!GetSceneManipulator()->getGridVisible());
		}
		break;
	case 'r':
	case 'R':
		{
			mRotFirst = !mRotFirst;
		}
		break;
	//case 'C':
 //	case 'c':
//.........这里部分代码省略.........
开发者ID:jjiezheng,项目名称:pap_full,代码行数:101,代码来源:WXSceneCanvas.cpp

示例13: frameStarted

bool SoundEditDialog::frameStarted(const Ogre::FrameEvent& evt)
{
    if (!mPlaySound)
        return true;

    if (/*mPlaySoundInGame*/0)
    {
        Ogre::Camera* camera = mSceneManipulator->getCamera();
        const Ogre::Vector3& camPos = camera->getPosition();

        Fairy::TerrainData* terrainData = mSceneManipulator->getTerrainData();

        std::pair<int, int> camGrid = terrainData->getGrid(camPos.x, camPos.z);

        for (size_t i=0; i<mSoundItems.size(); ++i)
        {
            SoundItem* workingItem = mSoundItems[i];

            if (workingItem->mRepeatTime != 0)
            {
                FLOAT deltaTime = evt.timeSinceLastFrame * 1000;

                // 如果当前的播放次数已达到重复播放次数,就累加时间,直到达到下次播放的时间,就播放
                if (workingItem->mCurrentRepeatTime == workingItem->mRepeatTime)
                {
                    workingItem->mCurrentPlayIntervalTime += (INT)deltaTime;

                    if (workingItem->mCurrentPlayIntervalTime >= workingItem->mNextRepeatTime)
                    {
                        workingItem->mCurrentRepeatTime = 0;
                        workingItem->mCurrentPlayIntervalTime = 0;

                        SoundNames::iterator it = mSoundNames.find(workingItem->mSoundID);

                        if (it != mSoundNames.end())
                        {
                            workingItem->mSoundHandle = _PlaySound(it->second, workingItem->mSoundHandle, false);
                        }

                        ++workingItem->mCurrentRepeatTime;
                    }
                }
                else
                {
                    // 累加重复播放之间的间隔时间
                    workingItem->mCurrentRepeatIntervalTime += (INT)deltaTime;

                    if (workingItem->mCurrentRepeatIntervalTime >= workingItem->mRepeatIntervalTime)
                    {
                        workingItem->mCurrentRepeatIntervalTime = 0;

                        SoundNames::iterator it = mSoundNames.find(workingItem->mSoundID);

                        if (it != mSoundNames.end())
                        {
                            workingItem->mSoundHandle = _PlaySound(it->second, workingItem->mSoundHandle, false);
                        }

                        ++workingItem->mCurrentRepeatTime;
                    }
                }
            }
            else
            {
                if (workingItem->mSoundHandle == -1)
                {
                    SoundNames::iterator it = mSoundNames.find(workingItem->mSoundID);

                    if (it != mSoundNames.end())
                    {
                        workingItem->mSoundHandle = _PlaySound(it->second, workingItem->mSoundHandle, false);
                    }

                    workingItem->mSoundHandle = _PlaySound(it->second, workingItem->mSoundHandle, true);
                }
            }

            if (workingItem->mRadius > 0)
            {
                float dis = Ogre::Math::Sqrt( (camGrid.first - workingItem->mXPos) * (camGrid.first - workingItem->mXPos) +
                    (camGrid.second - workingItem->mZPos) * (camGrid.second - workingItem->mZPos) );

                float volume = 0;

                if(dis <= workingItem->mRadius) 
                    volume = 1.0f-(dis/workingItem->mRadius);

                _SetSoundVolume(workingItem->mSoundHandle, volume);
            }
        }
    }
    else
    {
        if (mPlaySound && mCurrentSoundItem && mCurrentSoundItem->mRepeatTime != 0)
        {
            FLOAT deltaTime = evt.timeSinceLastFrame * 1000;

            // 如果当前的播放次数已达到重复播放次数,就累加时间,直到达到下次播放的时间,就播放
            if (mCurrentRepeatTime == mCurrentSoundItem->mRepeatTime)
            {
//.........这里部分代码省略.........
开发者ID:gitrider,项目名称:wxsj2,代码行数:101,代码来源:SoundEditDlg.cpp

示例14: while

//!
//! Clones an Ogre::MovableObject.
//!
//! Is needed because OGRE does not provide clone functions for cameras and
//! lights.
//!
//! \param movableObject The object to clone.
//! \param name The name to use for the object.
//! \param sceneManager The scene manager to use for creating the object.
//! \return The cloned object.
//!
Ogre::MovableObject * OgreTools::cloneMovableObject ( Ogre::MovableObject *movableObject, const QString &name, Ogre::SceneManager *sceneManager /* =  0 */ )
{
    // make sure the given object is valid
    if (!movableObject) {
        Log::error("The given movable object is invalid.", "OgreTools::cloneMovableObject");
        return 0;
    }

    // make sure a valid scene manager is available
    if (!sceneManager)
        sceneManager = movableObject->_getManager();
    if (!sceneManager) {
        Log::error("No valid scene manager available.", "OgreTools::cloneMovableObject");
        return 0;
    }

    Ogre::MovableObject *result = 0;
    Ogre::String typeName = movableObject->getMovableType();
    if (typeName == "Entity") {
        // clone entity
        Ogre::Entity *entity = dynamic_cast<Ogre::Entity *>(movableObject);
        //movableObjectCopy = entity->clone(name.toStdString());
        Ogre::Entity *entityCopy = sceneManager->createEntity(name.toStdString(), entity->getMesh()->getName());
        Ogre::AnimationStateSet *animationStateSet = entity->getAllAnimationStates();
        Ogre::AnimationStateSet *animationStateSetCopy  = entityCopy->getAllAnimationStates();
        // set the same blend mode on entity copy
        if (entity && entityCopy) {
            if (entity->hasSkeleton() && entityCopy->hasSkeleton()) {
                Ogre::Skeleton *skeleton = entity->getSkeleton();
                Ogre::Skeleton *skeletonCopy = entityCopy->getSkeleton();
                skeletonCopy->setBlendMode(skeleton->getBlendMode());
            }
        }
        // copy all animation states
        if (animationStateSet && animationStateSetCopy) {
            Ogre::AnimationStateIterator animationStateIter = animationStateSet->getAnimationStateIterator();
            Ogre::AnimationStateIterator animationStateCopyIter = animationStateSetCopy->getAnimationStateIterator();
            while (animationStateIter.hasMoreElements()) {
                if (!animationStateCopyIter.hasMoreElements())
                    break;
                Ogre::AnimationState *animationState = animationStateIter.getNext();
                Ogre::AnimationState *animationStateCopy = animationStateCopyIter.getNext();
                animationStateCopy->setLoop(animationState->getLoop());
                //bool enabled = animationState->getEnabled();
                //animationStateCopy->setEnabled(animationState->getEnabled());
                animationStateCopy->setEnabled(true);
                animationStateCopy->setTimePosition(animationState->getTimePosition());
            }
        }

        // create a new container for the cloned entity
        OgreContainer *entityCopyContainer = new OgreContainer(entityCopy);
        entityCopy->setUserAny(Ogre::Any(entityCopyContainer));
        if (!entity->getUserAny().isEmpty()) {
            OgreContainer *entityContainer = Ogre::any_cast<OgreContainer *>(entity->getUserAny());
			if (entityContainer) {
                QObject::connect(entityContainer, SIGNAL(animationStateUpdated(const QString &, double)), entityCopyContainer, SLOT(updateAnimationState(const QString &, double)));
				QObject::connect(entityContainer, SIGNAL(boneTransformUpdated(const QString &, double, double, double, double, double, double)), entityCopyContainer, SLOT(updateBoneTransform(const QString &, double, double, double, double, double, double)));
			}
        }
        result = dynamic_cast<Ogre::MovableObject *>(entityCopy);
    } else if (typeName == "Light") {
        // clone light
        Ogre::Light *light = dynamic_cast<Ogre::Light *>(movableObject);
        Ogre::Light *lightCopy = sceneManager->createLight(name.toStdString());
        lightCopy->setType(light->getType());
        lightCopy->setDiffuseColour(light->getDiffuseColour());
        lightCopy->setSpecularColour(light->getSpecularColour());
        lightCopy->setAttenuation(light->getAttenuationRange(), light->getAttenuationConstant(), light->getAttenuationLinear(), light->getAttenuationQuadric());
        lightCopy->setPosition(light->getPosition());
        lightCopy->setDirection(light->getDirection());
        if (lightCopy->getType() == Ogre::Light::LT_SPOTLIGHT)
            lightCopy->setSpotlightRange(light->getSpotlightInnerAngle(), light->getSpotlightOuterAngle(), light->getSpotlightFalloff());
        lightCopy->setPowerScale(light->getPowerScale());
        lightCopy->setCastShadows(light->getCastShadows());

        // create a new container for the cloned light
        OgreContainer *lightCopyContainer = new OgreContainer(lightCopy);
        lightCopy->setUserAny(Ogre::Any(lightCopyContainer));
        if (!light->getUserAny().isEmpty()) {
            OgreContainer *lightContainer = Ogre::any_cast<OgreContainer *>(light->getUserAny());
            if (lightContainer)
                QObject::connect(lightContainer, SIGNAL(sceneNodeUpdated()), lightCopyContainer, SLOT(updateLight()));
        }
        result = dynamic_cast<Ogre::MovableObject *>(lightCopy);
    } else if (typeName == "Camera") {
        // clone camera
        Ogre::Camera *camera = dynamic_cast<Ogre::Camera *>(movableObject);
        Ogre::Camera *cameraCopy = sceneManager->createCamera(name.toStdString());
//.........这里部分代码省略.........
开发者ID:banduladh,项目名称:levelfour,代码行数:101,代码来源:OgreTools.cpp

示例15: frameStarted

	bool frameStarted(const Ogre::FrameEvent& evt){
		if(vidas==0)
			return false;
		_key->capture();
		_mouse->capture();
		
		float movSpeed = 500.0f;


		if (_key->isKeyDown(OIS::KC_ESCAPE))
			return false;

		Ogre::Vector3 t(0,0,0);

		if (_key->isKeyDown(OIS::KC_W))
			if (freemoving)
				t += Ogre::Vector3(0,0,-10);
			else
				nave->moverAdelante();
		if (_key->isKeyDown(OIS::KC_S))
			if (freemoving)
				t += Ogre::Vector3(0,0,10);
			else
				nave->moverAtras();

		if (_key->isKeyDown(OIS::KC_A))
			if (freemoving)
				t += Ogre::Vector3(-10,0,0);
			else
				nave->moverIzquierda();

		if (_key->isKeyDown(OIS::KC_D))
			if (freemoving)
				t += Ogre::Vector3(10,0,0);
			else
				nave->moverDerecha();
		if (_key->isKeyDown(OIS::KC_UP))
			nave->moverArriba();

		if (_key->isKeyDown(OIS::KC_DOWN))
			nave->moverAbajo();

		if (!_key->isKeyDown(OIS::KC_A) && !_key->isKeyDown(OIS::KC_D))
			nave->reset();

		if(_key->isKeyDown(OIS::KC_I))
			std::cout<<"CAMARA:"<<_cam->getPosition()<<std::endl
					 <<"NAVE:"<<nave->nodoNave->getPosition()<<std::endl;

		_cam->moveRelative(t*evt.timeSinceLastFrame*movSpeed);
		if (freemoving){
			float rotX = _mouse->getMouseState().X.rel * evt.timeSinceLastFrame* -1;
			float rotY = _mouse->getMouseState().Y.rel * evt.timeSinceLastFrame * -1;
		
			_cam->yaw(Ogre::Radian(rotX));
			_cam->pitch(Ogre::Radian(rotY));
		}
		for (int i = 0; i < num_monedas; i++)
		{
			moneda[i]->animState->addTime(evt.timeSinceLastFrame);
		}

		for (int i = 0; i < num_obstaculo; i++)
		{
			obstaculo[i]->animState->addTime(evt.timeSinceLastFrame);
		}

		for (int i = 0; i < num_monedas; i++)
		{
			if (moneda[i]->visible && nave->getBox().intersects(moneda[i]->getBox())){
				moneda[i]->visible = false;
				moneda[i]->nodoMoneda->setVisible(false);
				puntaje+=100;
				mostrarPuntaje();
			}
		}
		
		for (int i = 0; i < num_aros; i++)
		{
			Ogre::AxisAlignedBox boxNave = nave->getBox();
			Ogre::Vector3 centro = nave->getCenter();
			if (aro[i]->visible &&
				nave->getBox().intersects(aro[i]->getBox()) && 
				aro[i]->adentro(boxNave, centro))
			{
				aro[i]->visible = false;
				aro[i]->nodoAro->setVisible(false);
				puntaje+=200;
				mostrarPuntaje();
			}
		}
		
		for (int i = 0; i < num_obstaculo; i++)
		{
			if (obstaculo[i]->visible && nave->getBox().intersects(obstaculo[i]->getBox())){
				obstaculo[i]->visible = false;
				obstaculo[i]->nodoObstaculo->setVisible(false);
				vidas-=1;
				mostrarPuntaje();
			}
//.........这里部分代码省略.........
开发者ID:luiscarlo6,项目名称:Computacion-Grafica-USB,代码行数:101,代码来源:main.cpp


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