Esempio n. 1
0
	//--------------------------------------------------------------------------------------------------------------------------------------
	void FPSCamera::OnActionInput( ActionManager& am )
	{

		if( am.isTouch() && am.isMove() )
		{

			if ( am.isTowPoint() )
			{//视射线方向的移动
				float d = am.DistanceTowPoint() - am.LastDistanceTowPoint();
				float movedis = m_MoveSpeed * d;
				this->Move( vector3f( 0, 0, -movedis ) );
			}
			else
			{//旋转
				float xd = -( am.TouchPoint().m_x - am.LastTouchPoint().m_x ) / 2.0;//TouchPoint是(-1,1)区间的
				float yd = -( am.TouchPoint().m_y - am.LastTouchPoint().m_y ) / 2.0;
				this->Rotate(xd,yd);
				//DEBUGLOG("Camera Rotate\n",1);
			}

		}
		{//平移
			vector3f move;
			bool isMove = false;
			float movedis = m_MoveSpeed * Engine::Instance().GetTimeSpan() / 1000.0f;
			if( am.isAction( ActionManager::ACTION_MOVEFORWARD ) )
			{
				isMove = true;
				move += vector3f( 0, 0, -movedis );
			}
			if( am.isAction( ActionManager::ACTION_MOVEBACK ) )
			{
				isMove = true;
				move += vector3f( 0, 0, movedis );
			}
			if( am.isAction( ActionManager::ACTION_MOVELRIGHT ) )
			{
				isMove = true;
				move += vector3f( movedis, 0, 0 );
			}
			if( am.isAction( ActionManager::ACTION_MOVELEFT ) )
			{
				isMove = true;
				move += vector3f( -movedis, 0, 0 );
			}
			if( isMove )
			{
				this->Move( move );
			}
		}
	}
Esempio n. 2
0
	//--------------------------------------------------------------------------------------------------------------------------------------
	void TrackballCamera::OnActionInput( ActionManager& am )
	{
		if( am.isTouch() && am.isMove() )
		{
			if( am.isTowPoint() )
			{
				float d = am.DistanceTowPoint() - am.LastDistanceTowPoint();
				this->ZoomInOut( d );
				//DEBUGLOG("Camera zoom\n",1);
			}
			else
			{
				float xd = -( am.TouchPoint().m_x - am.LastTouchPoint().m_x ) / 2.0;//TouchPoint是(-1,1)区间的
				float yd = -( am.TouchPoint().m_y - am.LastTouchPoint().m_y ) / 2.0;
				this->Rotate(xd,yd);
				//DEBUGLOG("Camera Rotate\n",1);
			}
		}
	}