RuneI
Class CineCamera

source: c:\runehov\RuneI\Classes\CineCamera.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Keypoint
         |
         +--RuneI.CineCamera
Direct Known Subclasses:None

class CineCamera
extends Engine.Keypoint

//============================================================================= // CineCamera. // // RUNE: Cinematic Camera. Controls the camera on players during in-game cutscenes //=============================================================================
Variables
 StartPt, EndPt
 StartPt2, EndPt2
 float EndSpeed
           Speed to interpolate the camera back to behind the player
 CineInterpolationPoint FirstNode
 float StartSpeed
           Speed to initially interpolate the camera to the CinePoint
 bool bInteruptable
           Speed to interpolate the camera back to behind the player

States
Interpolating

Function Summary
 void BeginPlay()
 void FireLastPointEvent()
     
//============================================================================
//
// FireLastPointEvent
//
//============================================================================
 void ResetPath()
     
//============================================================================
//
// ResetPath
//
// Reset the path to it's original state
//============================================================================
 void StartCam(bool Smooth, bool Interuptable)
     
//============================================================================
//
// StartCam
//
// Starts the camera on a given interpolation path
//============================================================================


State Interpolating Function Summary
 void InterpolateEnd(Actor Other)
     
//========================================================================
 void Timer()
     
//========================================================================



Source Code


00001	//=============================================================================
00002	// CineCamera.
00003	//
00004	// RUNE:  Cinematic Camera.  Controls the camera on players during in-game cutscenes
00005	//=============================================================================
00006	class CineCamera expands Keypoint;
00007	
00008	const DIST_THRESH = 5;
00009	
00010	var CineInterpolationPoint FirstNode;
00011	var CineInterpolationPointTemp StartPt, EndPt;
00012	var CineInterpolationPointTemp StartPt2, EndPt2;
00013	var float StartSpeed;	// Speed to initially interpolate the camera to the CinePoint
00014	var float EndSpeed; // Speed to interpolate the camera back to behind the player
00015	var bool bInteruptable;
00016	
00017	
00018	function BeginPlay()
00019	{
00020		local RunePlayer P;
00021	//	local name StateName;
00022		
00023		// When spawned, take control of the camera on all players in the game
00024		// TODO:  This takes the location/rotation from the last player in the game
00025		// Need a different scheme so that this doesn't pop the camera in netgames?
00026		foreach AllActors(class'RunePlayer', P)
00027		{
00028			if (P.Health > 0)
00029			{
00030				P.ViewTarget = self;
00031				SetLocation(P.SavedCameraLoc);
00032				SetRotation(P.SavedCameraRot);
00033				
00034				P.OrderObject = None;
00035				P.GotoState('Scripting');
00036	
00037				if(P.myHud != None)
00038				{
00039					P.myHud.GotoState('Cinematic', 'begin');
00040				}
00041			}
00042			else
00043			{
00044				Destroy();
00045				break;
00046			}
00047		}
00048	}
00049	
00050	//============================================================================
00051	//
00052	// ResetPath
00053	//
00054	// Reset the path to it's original state
00055	//============================================================================
00056	function ResetPath()
00057	{
00058		// Reset the path to its original state
00059		if (FirstNode != None && EndPt != None)
00060		{
00061			FirstNode.Prev = EndPt.Prev;
00062			if(FirstNode.Prev != None)
00063			{
00064				FirstNode.Prev.Next = FirstNode;
00065			}
00066		}
00067		
00068		// Destroy the StartPoints
00069		if(StartPt != None)
00070		{
00071			StartPt.Destroy();
00072		}
00073		if(StartPt2 != None)
00074		{
00075			StartPt2.Destroy();
00076		}
00077	
00078		// Destroy the EndPoint
00079		if(EndPt != None)
00080		{
00081			EndPt.Destroy();
00082		}
00083					
00084		Destroy(); // Remove the CineCamera
00085	}
00086	
00087	
00088	//============================================================================
00089	//
00090	// FireLastPointEvent
00091	//
00092	//============================================================================
00093	function FireLastPointEvent()
00094	{
00095		local CineInterpolationPoint i;
00096		
00097		// Call the event of the last editor-placed point to cleanup
00098		foreach AllActors(class 'CineInterpolationPoint', i, Event)
00099		{
00100			if(i.Next != None && (i.Next.IsA('CineInterpolationPointTemp') || i.Next.Position == 0))
00101			{ // Found the last point that was editor-placed
00102				i.FireEvent(i.Event);
00103				return;
00104			}
00105		}
00106	}
00107	
00108	
00109	//============================================================================
00110	//
00111	// StartCam
00112	//
00113	// Starts the camera on a given interpolation path
00114	//============================================================================
00115	
00116	function StartCam(bool Smooth, bool Interuptable)
00117	{
00118		local CineInterpolationPoint i;
00119		local InterpolationPoint oldPrev;
00120	
00121		bInteruptable = Interuptable;
00122	
00123		foreach AllActors(class 'CineInterpolationPoint', i, Event)
00124		{
00125			if(i.Position == 0)
00126			{ // Found a matching path
00127	
00128				if(Smooth)
00129				{ // Smoothly interpolate from the current position to the start of the path			
00130					// Create three "dummy" points to smooth out the start and end of the
00131					// path from the camera point						
00132					FirstNode = i;
00133					oldPrev = i.Prev;
00134	
00135					StartPt = Spawn(class'CineInterpolationPointTemp',,, Location, Rotation);
00136					StartPt2 = Spawn(class'CineInterpolationPointTemp',,, Location, Rotation);
00137					EndPt = Spawn(class'CineInterpolationPointTemp',,, Location, Rotation);
00138	
00139					// Copy bool bSplineThruPoints to the dummy points
00140					StartPt.bSplineThruPoints = i.bSplineThruPoints;
00141					StartPt2.bSplineThruPoints = i.bSplineThruPoints;
00142					EndPt.bSplineThruPoints = i.bSplineThruPoints;
00143	
00144					StartPt.Prev = EndPt;
00145					StartPt2.Prev = StartPt;
00146					StartPt.Next = StartPt2;
00147					StartPt2.Next = i;
00148	
00149					EndPt.Prev = oldPrev;
00150					EndPt.Next = StartPt;
00151					if(EndPt.Prev != None)
00152					{
00153						EndPt.Prev.Next = EndPt;
00154					}
00155	
00156					i.Prev = StartPt;			
00157	
00158					EndPt.bEndOfPath = true; // Guarantee that the pathing will finish
00159	
00160					Target = StartPt;
00161				}
00162				else
00163				{ // Instantly start at the path
00164					Target = i;
00165				}
00166				
00167				SetPhysics(PHYS_Interpolating);
00168				PhysRate = 1.0;
00169				PhysAlpha = 0.0;
00170				bInterpolating = true;
00171				
00172				GotoState('Interpolating');						
00173				return;
00174			}
00175		}
00176	}
00177	
00178	//============================================================================
00179	//
00180	// STATE Interpolating
00181	//
00182	//============================================================================
00183	
00184	state Interpolating
00185	{
00186		//========================================================================
00187		//
00188		// Timer
00189		//
00190		// Tripped when the CineCamera Pauses at an interpolation point
00191		//========================================================================
00192	
00193		function Timer()
00194		{
00195			bInterpolating = true; // Resume interpolation
00196		}
00197	
00198		//========================================================================
00199		//
00200		// InterpolateEnd
00201		//
00202		// Called when the CineCamera hits an interpolation point
00203		//========================================================================
00204	
00205		function InterpolateEnd(Actor Other)
00206		{	
00207			local RunePlayer P;
00208			local CineInterpolationPoint I;
00209			
00210			I = CineInterpolationPoint(Other);
00211	
00212			// This is a bit of a hack.
00213			// What this does is updates the dummy points to reflect the
00214			// new location of the SavedCamera position.  This must be done
00215			// because the camera position will have moved slightly due to the
00216			// Camera smoothing.  Without this adjustment the CineCamera will "pop"
00217			// a bit at the end.  Enough to be jarring.
00218			if(I.Next.Next.Next != None && I.Next.Next.Next == EndPt)
00219			{
00220				foreach AllActors(class'RunePlayer', P)
00221				{
00222					StartPt.SetLocation(P.SavedCameraLoc);
00223					StartPt.SetRotation(P.SavedCameraRot);
00224					StartPt2.SetLocation(P.SavedCameraLoc);
00225					StartPt2.SetRotation(P.SavedCameraRot);
00226					EndPt.SetLocation(P.SavedCameraLoc);
00227					EndPt.SetRotation(P.SavedCameraRot);
00228					break;
00229				}
00230			}
00231			
00232			// Pause if the interpolation point has a PauseTime
00233			if(I.PauseTime > 0)
00234			{
00235				bInterpolating = false; // Stop interpolating for now
00236				SetTimer(I.PauseTime, false);
00237			}
00238			
00239			if(I.bEndOfPath)
00240			{ // One past the end of path, so remove the cinecamera!		
00241				foreach AllActors(class'RunePlayer', P)
00242				{
00243					if(P.ViewTarget == self)
00244					{
00245						P.ReleaseFromCinematic();
00246					}
00247				}
00248				
00249				ResetPath();
00250			}
00251		}
00252		
00253	begin:
00254	}
00255	
00256	defaultproperties
00257	{
00258	     bStatic=False
00259	     Physics=PHYS_Flying
00260	}

End Source Code