Beispiel #1
0
/* Flips the status of tracking to the opposite of what it presently is */
void	camToggleStatus( void )
{
 	/* If it's off */
	if(trackingCamera.status == CAM_INACTIVE)
	{
		/* Switch it on */
		setWarCamActive(true);
	}
	else
	{
		/* Otherwise, switch it off */
		setWarCamActive(false);
		if(getDrivingStatus())
		{
			StopDriverMode();
		}
	}
}
Beispiel #2
0
/* Updates the viewpoint according to the object being tracked */
static bool camTrackCamera()
{
	PROPULSION_STATS *psPropStats;
	DROID *psDroid;
	bool bFlying = false;

	/* Most importantly - see if the target we're tracking is dead! */
	if(trackingCamera.target->died)
	{
		return(false);
	}

	/* Update the acceleration,velocity and position of the camera for movement */
	updateCameraAcceleration(CAM_ALL);
	updateCameraVelocity(CAM_ALL);
	updateCameraPosition(CAM_ALL);

	/* Update the acceleration,velocity and rotation of the camera for rotation */
	/*	You can track roll as well (z axis) but it makes you ill and looks
		like a flight sim, so for now just pitch and orientation */


	if(trackingCamera.target->type == OBJ_DROID)
	{
		psDroid = (DROID*)trackingCamera.target;
		psPropStats = asPropulsionStats + psDroid->asBits[COMP_PROPULSION].nStat;
		if (psPropStats->propulsionType == PROPULSION_TYPE_LIFT)
		{
				bFlying = true;
		}
	}

	if(bRadarAllign || trackingCamera.target->type == OBJ_DROID)
	{
		if(bFlying)
		{
			updateCameraRotationAcceleration(CAM_ALL);
		}
		else
		{
			updateCameraRotationAcceleration(CAM_X_AND_Y);
		}
	}
	if(bFlying)
	{
	 	updateCameraRotationVelocity(CAM_ALL);
		updateCameraRotationPosition(CAM_ALL);
	}
	else
	{
		updateCameraRotationVelocity(CAM_X_AND_Y);
		updateCameraRotationPosition(CAM_X_AND_Y);
	}

	/* Update the position that's now stored in trackingCamera.position */
	player.p.x = trackingCamera.position.x;
	player.p.y = trackingCamera.position.y;
	player.p.z = trackingCamera.position.z;

	/* Update the rotations that're now stored in trackingCamera.rotation */
	player.r.x = trackingCamera.rotation.x;
	player.r.y = trackingCamera.rotation.y;
	player.r.z = trackingCamera.rotation.z;

	/* There's a minimum for this - especially when John's VTOL code lets them land vertically on cliffs */
	if(player.r.x>DEG(360+MAX_PLAYER_X_ANGLE))
  	{
   		player.r.x = DEG(360+MAX_PLAYER_X_ANGLE);
   	}

	/* Clip the position to the edge of the map */
	CheckScrollLimits();

	/* Store away our last update as acceleration and velocity are all fn()/dt */
	trackingCamera.lastUpdate = realTime;
	if(bFullInfo)
	{
		flushConsoleMessages();
		if(trackingCamera.target->type == OBJ_DROID)
		{
			printDroidInfo((DROID*)trackingCamera.target);
		}
	}

	/* Switch off if we're jumping to a new location and we've got there */
	if(getRadarTrackingStatus())
	{
		/*	This will ensure we come to a rest and terminate the tracking
			routine once we're close enough
		*/
		if (trackingCamera.velocity*trackingCamera.velocity + trackingCamera.acceleration*trackingCamera.acceleration < 1.f &&
		    trackingCamera.rotVel*trackingCamera.rotVel     + trackingCamera.rotAccel*trackingCamera.rotAccel         < 1.f)
		{
			setWarCamActive(false);
		}
	}
	return(true);
}
Beispiel #3
0
/* Updates the viewpoint according to the object being tracked */
BOOL	camTrackCamera( void )
{
    PROPULSION_STATS	*psPropStats;
    DROID	*psDroid;
    BOOL	bFlying;

    bFlying = false;

    /* Most importantly - see if the target we're tracking is dead! */
    if(trackingCamera.target->died)
    {
        setFindNewTarget();
        return(false);
    }

    /*	Cancel tracking if it's no longer selected.
    	This may not be desirable? 	*/
    if(trackingCamera.target->type == OBJ_DROID)
    {

//		if(!trackingCamera.target->selected)
//		{
//			return(false);
//		}
    }

    /* Update the acceleration,velocity and position of the camera for movement */
    updateCameraAcceleration(CAM_ALL);
    updateCameraVelocity(CAM_ALL);
    updateCameraPosition(CAM_ALL);

    /* Update the acceleration,velocity and rotation of the camera for rotation */
    /*	You can track roll as well (z axis) but it makes you ill and looks
    	like a flight sim, so for now just pitch and orientation */


    if(trackingCamera.target->type == OBJ_DROID)
    {
        psDroid = (DROID*)trackingCamera.target;
        psPropStats = asPropulsionStats + psDroid->asBits[COMP_PROPULSION].nStat;
        if (psPropStats->propulsionType == PROPULSION_TYPE_LIFT)
        {
            bFlying = true;
        }
    }
    /*
    	bIsBuilding = false;
    	if(trackingCamera.target->type == OBJ_DROID)
    	{
    		psDroid= (DROID*)trackingCamera.target;
    		if(DroidIsBuilding(psDroid))
    		{
    			bIsBuilding = true;
    		}
    	}
    */


    if(bRadarAllign || trackingCamera.target->type == OBJ_DROID)
    {
        if(bFlying)
        {
            updateCameraRotationAcceleration(CAM_ALL);
        }
        else
        {
            updateCameraRotationAcceleration(CAM_X_AND_Y);
        }
    }
    if(bFlying)
    {
        updateCameraRotationVelocity(CAM_ALL);
        updateCameraRotationPosition(CAM_ALL);
    }
    /*
    else if(bIsBuilding)
    {
    	updateCameraRotationVelocity(CAM_X_ONLY);
    }
    */
    else
    {
        updateCameraRotationVelocity(CAM_X_AND_Y);
        updateCameraRotationPosition(CAM_X_AND_Y);
    }

    /* Record the old positions for comparison */
    oldPosition.x = player.p.x;
    oldPosition.y = player.p.y;
    oldPosition.z = player.p.z;

    /* Update the position that's now stored in trackingCamera.position */
    player.p.x = trackingCamera.position.x;
    player.p.y = trackingCamera.position.y;
    player.p.z = trackingCamera.position.z;

    /* Record the old positions for comparison */
    oldRotation.x = player.r.x;
    oldRotation.y = player.r.y;
    oldRotation.z = player.r.z;

    /* Update the rotations that're now stored in trackingCamera.rotation */
    player.r.x = trackingCamera.rotation.x;
    /*if(!bIsBuilding)*/
    player.r.y = trackingCamera.rotation.y;
    player.r.z = trackingCamera.rotation.z;

    /* There's a minimum for this - especially when John's VTOL code lets them land vertically on cliffs */
    if(player.r.x>DEG(360+MAX_PLAYER_X_ANGLE))
    {
        player.r.x = DEG(360+MAX_PLAYER_X_ANGLE);
    }

    /*
    if(bIsBuilding)
    {
    	player.r.y+=DEG(1);
    }
    */
    /* Clip the position to the edge of the map */
    CheckScrollLimits();

    /* Store away our last update as acceleration and velocity are all fn()/dt */
    trackingCamera.lastUpdate = gameTime2;
    if(bFullInfo)
    {
        flushConsoleMessages();
        if(trackingCamera.target->type == OBJ_DROID)
        {
            printDroidInfo((DROID*)trackingCamera.target);
        }
    }

    /* Switch off if we're jumping to a new location and we've got there */
    if(getRadarTrackingStatus())
    {
        /*	This will ensure we come to a rest and terminate the tracking
        	routine once we're close enough
        */
        if(getRotationMagnitude()<10000)
        {
            if(getPositionMagnitude() < 60)
            {
                setWarCamActive(false);
            }
        }
    }
    return(true);
}