⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chvrmltransition.cpp

📁 Windows上的MUD客户端程序
💻 CPP
📖 第 1 页 / 共 4 页
字号:

	if (boolFound)
	{

		m_flags = flMods;
		return true;
	}

	return false;
};

// Handlers
bool ChVrmlFlySTM::MoveForwardStart()
{
	RecordTime();
	MoveForward( );
	return true;
};	   

bool ChVrmlFlySTM::MoveReverseStart()
{
	RecordTime();
	MoveReverse( );
	return true;
};	   

bool ChVrmlFlySTM::MoveUpStart()
{
	RecordTime();
	MoveUp( );
	return true;
};	   

bool ChVrmlFlySTM::MoveDownStart()
{
	RecordTime();
	MoveDown( );
	return true;
};	   

bool ChVrmlFlySTM::TurnLeftStart()
{
	RecordTime();
	TurnLeft( );
	return true;
};	   

bool ChVrmlFlySTM::RollLeftStart()
{
	RecordTime();
	RollLeft( );
	return true;
};	   

bool ChVrmlFlySTM::MoveLeftStart()
{
	RecordTime();
	MoveLeft( );
	return true;
};	   

bool ChVrmlFlySTM::TurnRightStart()
{
	RecordTime();
	TurnRight( );
	return true;
};	   

bool ChVrmlFlySTM::RollRightStart()
{
	RecordTime();
	RollRight( );
	return true;
};	   

bool ChVrmlFlySTM::MoveRightStart()
{
	RecordTime();
	MoveRight( );
	return true;
};	   

bool ChVrmlFlySTM::TurnUpStart()
{
	RecordTime();
	TurnUp( );
	return true;
};	   

bool ChVrmlFlySTM::TurnDownStart()
{
	RecordTime();
	TurnDown( );
	return true;
};	   

bool ChVrmlFlySTM::MoveForward()
{
	m_pWnd->GetCameraControl()->MoveForward( GetMoveAmountDistance() );
	RecordTime();
	return true;
};	   

bool ChVrmlFlySTM::MoveReverse()
{
	m_pWnd->GetCameraControl()->MoveBackward( GetMoveAmountDistance() );
	RecordTime();
	return true;
};	   

bool ChVrmlFlySTM::MoveUp()
{
	m_pWnd->GetCameraControl()->MoveUp( GetMoveAmountDistance() );
	RecordTime();
	return true;
};	   

bool ChVrmlFlySTM::MoveDown()
{
	m_pWnd->GetCameraControl()->MoveDown(  GetMoveAmountDistance() );
	RecordTime();
	return true;
};	   

bool ChVrmlFlySTM::TurnLeft()
{
	m_pWnd->GetCameraControl()->Yaw( GetMoveAmountAngle() );
	RecordTime();
	return true;
};	   

bool ChVrmlFlySTM::RollLeft()	// CCW camera roll
{
	m_pWnd->GetCameraControl()->Roll( - 2 * GetMoveAmountAngle() );
	RecordTime();
	return true;
};	   

bool ChVrmlFlySTM::MoveLeft()
{
	m_pWnd->GetCameraControl()->MoveLeft( GetMoveAmountDistance() );
	return true;
};	   

bool ChVrmlFlySTM::TurnRight()
{
	m_pWnd->GetCameraControl()->Yaw( -(GetMoveAmountAngle()) );
	RecordTime();
	return true;
};	   

bool ChVrmlFlySTM::RollRight()	 // CW for the camera - image goes ccw
{
	m_pWnd->GetCameraControl()->Roll( 2 * (GetMoveAmountAngle()) );
	RecordTime();
	return true;
};	   

bool ChVrmlFlySTM::MoveRight()
{
	m_pWnd->GetCameraControl()->MoveRight( GetMoveAmountDistance() );
	return true;
};	   

bool ChVrmlFlySTM::TurnUp()
{
	m_pWnd->GetCameraControl()->Pitch( (GetMoveAmountAngle()) );
	RecordTime();
	return true;
};	   

bool ChVrmlFlySTM::TurnDown()
{
	m_pWnd->GetCameraControl()->Pitch( -(GetMoveAmountAngle()) );
	RecordTime();
	return true;
};	   


bool ChVrmlFlySTM::FlyStart()
{
	RecordTime();
	RecordPressTime();
	m_iAnchorX = m_ix;
	m_iAnchorY = m_iy;

	return true;
};	   

bool ChVrmlFlySTM::CrabbishStart()
{
	RecordTime();
	RecordPressTime();
	m_iAnchorX = m_ix;
	m_iAnchorY = m_iy;

	return true;
};	   


bool ChVrmlFlySTM::DragFly()
{
		
	return true;
};	   

bool ChVrmlFlySTM::DragCrabbishly()
{
	return true;
};	   


bool ChVrmlFlySTM::TickFly()
{
	float		fMoveX, fMoveY;

	if(!(GetKeyState( VK_CONTROL ) & 0x8000))
	{
		fMoveX = GetMoveAmountAngle(m_iAnchorX - m_ix);
		//fMoveX /= HACK_HACK_ANGLE;

		fMoveY = GetMoveAmountAngle(m_iAnchorY - m_iy);
		//fMoveY /= HACK_HACK_ANGLE;

		float fDistance = GetMoveAmountDistance();
		if(GetKeyState( 'Z' ) & 0x8000)
		{
			fDistance = -fDistance;
		}

		if(fMoveX != 0.0)
		{
			m_pWnd->GetCameraControl()->Yaw( fMoveX, true );   // set dirty for no
															   // to cause use of smarter collision tester
		}
		if(fMoveX != 0.0)
		{
			m_pWnd->GetCameraControl()->Pitch( fMoveY, true );
		}
		m_pWnd->GetCameraControl()->MoveForward( fDistance );
		RecordTime();
	}
	return true;
};	   

bool ChVrmlFlySTM::TickCrabbishly()
{
	float		fMoveX, fMoveY;

	fMoveX = m_iAnchorX - m_ix;
	fMoveX /= HACK_HACK;

	fMoveY = m_iAnchorY - m_iy;
	fMoveY /= HACK_HACK;

	m_pWnd->GetCameraControl()->MoveUp(  m_pWnd->CalcAccel( fMoveY ), false );  // relatively up
	m_pWnd->GetCameraControl()->MoveLeft(  m_pWnd->CalcAccel( fMoveX ) );
	RecordTime();

	return true;
};	   


bool ChVrmlFlySTM::LeftClick()
{
	if(GetKeyState( VK_CONTROL ) & 0x8000)
	{
#if !defined(CH_USE_3DR)

		SetState(s_goTowardsBegin);
		return false;
#endif
	}
	else 
	{
		OnLeftClick(m_ix, m_iy, m_mouseFlags);
	}

	return true;
};	   

bool ChVrmlFlySTM::LeftClickSlow()
{
	if(IsWithinFastClickTime())
	{
		return LeftClick();
	}
	else if(GetKeyState( 'Z' ) & 0x8000)
	{
		SetState(s_thrustBack);
		return false;
	}
	return true;
};	   


bool ChVrmlFlySTM::RightClick()
{
	OnRightClick(m_ix, m_iy, m_mouseFlags);
	return true;
};	   

bool ChVrmlFlySTM::RightClickSlow()
{   
	if(m_mouseAvgVelocity.magnitude() > spinThresholdSpeed)
	{
		SetState(s_spinningBegin);
		return false;
	}                               
	else if(IsWithinFastClickTime())
	{
		return RightClick();
	}
	
	return true;
};	   

bool ChVrmlFlySTM::GoTowardsStart()
{
#if !defined(CH_USE_3DR)
	GxVec3f	target;
	bool boolHit = m_pWnd->GetRenderContext()->GetHitPoint(m_ix, m_iy, target);

	if(boolHit)
	{
		RecordTime();
		//m_pWnd->GetCameraControl()->LookAt( target, false );	  // Turn towards it
		m_target = target;

		GxVec3f	camLoc = m_pWnd->GetRenderContext()->GetCameraLoc();
		target += camLoc;
		target *= .5;					// Go halfway there, not keeping y constant
		//target.y() = camLoc.y();		   

		m_startLook = ((ChQvPCameraRenderData *)(m_pWnd->GetRenderContext()->GetCurrentCamera()->GetRenderData()))->GetDir();
		m_destination = target;
		m_start = camLoc;
	}
	else
	{
		if(GetKeyState( VK_MENU ) & 0x8000) SetState(s_alt);
		else SetState(s_start);
		return false;
	}
#endif
	return true;
}

bool ChVrmlFlySTM::GoTowards()
{
#if !defined(CH_USE_3DR)
	GxVec3f	camLoc = m_pWnd->GetRenderContext()->GetCameraLoc();
	GxVec3f	target = m_target;
	GxVec3f	start = m_start;
	GxVec3f	destination = m_destination;

	float perCent = GetElapsedTicks() / float(animMoveTowardsTicks);	// how far we 'oughta' be
	if(GetKeyState( VK_SHIFT ) & 0x8000) perCent *= 2;

	perCent = min(perCent, 1.0);
	perCent = Smooth(perCent);

	//camLoc.y() = destination.y() = start.y() = 0;	// ignore y

	GxVec3f v = destination;
	v -= start;			// vector to move total
	v *= perCent;		// vector we should have moved
	v += start;			// where we oughta be
	v -= camLoc;		// how far we have to go, vectorish

	// Now compute the new lookDirection; linearly interpolate from original
	// look direction to final, which is staring right at target
	GxVec3f startLook = m_startLook;

	GxVec3f endLook = m_target;
	endLook -= m_destination;
	endLook.normalize();

	startLook *= (1.0 - perCent);
	endLook *= perCent;

	GxVec3f lookDir = endLook;
	lookDir += startLook;

	lookDir.normalize;

	m_pWnd->GetCameraControl()->SetLookDir( lookDir, false );	  // Turn towards it
	m_pWnd->GetCameraControl()->Shift( v.x(), v.y(), v.z(), true );

	if(perCent >= 1.0)
	{
		if(GetKeyState( VK_MENU ) & 0x8000) SetState(s_alt);
		else SetState(s_start);
		return false;
	}
#endif
	return true;

}

// --------------------------------------------------------------------------
// Examiner
// --------------------------------------------------------------------------

ChVrmlExaminerSTM::ChVrmlExaminerSTM(ChMazeWnd *pWnd) : ChVrmlFlySTM(pWnd) 
{
	Init();
}

void ChVrmlExaminerSTM::Init()
{

	// Now populate the STM
	// SetCell( int iState, int iEvent, int iNewState, ChTransitionActionHandler action)
	ChVrmlFlySTM::Init();

				
	// --			
	AddCell(s_start,	ep_up,		s_up, 		ChVrmlExaminerSTM,	TurnUpStart);
	AddCell(s_up, 		e_tick,		s_up,		ChVrmlExaminerSTM,	TurnUp);

	// --			
	AddCell(s_start,	ep_down,	s_down, 	ChVrmlExaminerSTM,	TurnDownStart);
	AddCell(s_down, 	e_tick,		s_down,		ChVrmlExaminerSTM,	TurnDown);

	// --			
	AddCell(s_start,		ep_left,	s_left,		ChVrmlExaminerSTM,	TurnLeftStart);
	AddCell(s_left, 		e_tick,		s_left,		ChVrmlExaminerSTM,	TurnLeft);

	AddCell(s_start,		ep_right,	s_right, 		ChVrmlExaminerSTM,	TurnRightStart);
	AddCell(s_right, 		e_tick,		s_right,		ChVrmlExaminerSTM,	TurnRight);

	//
	AddCell(s_spinningBegin,	ep_up,		s_up, 		ChVrmlExaminerSTM,	TurnUpStart);
	AddCell(s_spinningBegin,	ep_down,	s_down, 	ChVrmlExaminerSTM,	TurnDownStart);
	AddCell(s_spinningBegin,	ep_left,	s_left,		ChVrmlExaminerSTM,	TurnLeftStart);
	AddCell(s_spinningBegin,	ep_right,	s_right, 		ChVrmlExaminerSTM,	TurnRightStart);
	AddCell(s_spinning,	ep_up,		s_up, 		ChVrmlExaminerSTM,	TurnUpStart);
	AddCell(s_spinning,	ep_down,	s_down, 	ChVrmlExaminerSTM,	TurnDownStart);
	AddCell(s_spinning,	ep_left,	s_left,		ChVrmlExaminerSTM,	TurnLeftStart);
	AddCell(s_spinning,	ep_right,	s_right, 		ChVrmlExaminerSTM,	TurnRightStart);
}

// Handlers
bool ChVrmlExaminerSTM::TurnLeftStart()
{
	RecordTime();
	TurnLeft( );
	return true;
};	   

bool ChVrmlExaminerSTM::TurnRightStart()
{
	RecordTime();
	TurnRight( );
	return true;
};	   
bool ChVrmlExaminerSTM::TurnDownStart()
{
	RecordTime();
	TurnDown( );
	return true;
};	   

bool ChVrmlExaminerSTM::TurnUpStart()
{
	RecordTime();
	TurnUp( );
	return true;
};	   
bool ChVrmlExaminerSTM::TurnLeft()
{
	m_pWnd->GetCameraControl()->RotateBallHorz( GetMoveAmountAngle() );
	RecordTime();
	return true;
};	   
bool ChVrmlExaminerSTM::TurnRight()
{
	m_pWnd->GetCameraControl()->RotateBallHorz( -(GetMoveAmountAngle()) );
	RecordTime();
	return true;
};	   

bool ChVrmlExaminerSTM::TurnUp()
{
	m_pWnd->GetCameraControl()->RotateBallVert( (GetMoveAmountAngle()) );
	RecordTime();
	return true;
};	   

bool ChVrmlExaminerSTM::TurnDown()
{
	m_pWnd->GetCameraControl()->RotateBallVert( -(GetMoveAmountAngle()) );
	RecordTime();
	return true;
};	   




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -