RuneI
Class Movie

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

class Movie
extends RuneI.Cinematography

//============================================================================= // Movie. //=============================================================================
Variables
 Performer CameraDummy
           The head of the list is the camera performer
 SkelModel CameraMesh
 PlayerPawn MovieInstigator
           The head of the list is the camera performer
 float MovieTime
           The head of the list is the camera performer
 Performer PerfHead
           The head of the list is the camera performer
 SkelModel PerformerMeshes[10]
 name SceneName
 int SceneNumber
 bool bInteractiveMovie
           The head of the list is the camera performer
 bool bLoopMovie
           The head of the list is the camera performer
 bool bMovieActive


Function Summary
 void BeginPlay()
 
simulated
Debug(Canvas Canvas, int mode)
 void TerminateMovie()
 void Tick(float DeltaTime)
 void trigger(Actor other, Pawn EventInstigator)



Source Code


00001	//=============================================================================
00002	// Movie.
00003	//=============================================================================
00004	class Movie extends Cinematography;
00005	
00006	var() SkelModel CameraMesh;
00007	var() SkelModel PerformerMeshes[10];
00008	var() int SceneNumber;
00009	var() name SceneName;
00010	var bool bMovieActive;
00011	var Performer PerfHead; // The head of the list is the camera performer
00012	var Performer CameraDummy;
00013	var float MovieTime;
00014	var PlayerPawn MovieInstigator;
00015	
00016	// Make loop-able or not
00017	// Make interactive or not
00018	// Make fade in / fade out mode for camera transition (from Ragnar)
00019	// Make smooth camera move from Ragnar to camera position
00020	
00021	var bool bLoopMovie;
00022	var bool bInteractiveMovie;
00023	
00024	
00025	function BeginPlay()
00026	{
00027		bMovieActive = FALSE;
00028		Disable( 'Tick' );
00029	}
00030	
00031	function trigger( Actor other, Pawn EventInstigator )
00032	{
00033		local int i;
00034		local Performer perf;
00035		local Performer lastPerf;
00036		local int perfCount;
00037	
00038		if( bMovieActive )
00039		{
00040			return;
00041		}
00042	
00043		if( EventInstigator.bIsPlayer == False )
00044		{
00045			return;
00046		}
00047		MovieInstigator = PlayerPawn( EventInstigator );
00048	
00049		// Spawn the camera performer
00050		if( CameraMesh == None )
00051		{
00052			return;
00053		}
00054		perf = Spawn( class 'Performer' );
00055		if( perf == None )
00056		{
00057			return;
00058		}
00059		PerfHead = perf;
00060		PerfHead.Skeletal = CameraMesh;
00061		PerfHead.SkelGroupFlags[0] = 1;
00062		PerfHead.LoopAnim( SceneName, 2.0 );
00063		lastPerf = PerfHead;
00064	
00065		perfCount = 0;
00066		for( i = 0; i < 10; i++ )
00067		{
00068			if( PerformerMeshes[i] == None )
00069			{ // Empty slot
00070				continue;
00071			}
00072			// Spawn a performer
00073			perf = Spawn( class 'Performer' );
00074			if( perf != None )
00075			{
00076				// Initialize performer mesh and animation
00077				perf.Skeletal = PerformerMeshes[i];
00078				perf.LoopAnim( SceneName, 2.0 );
00079	
00080				// Add to linked list
00081				lastPerf.Next = perf;
00082				lastPerf = perf;
00083				perfCount++;
00084			}
00085		}
00086		if( lastPerf == PerfHead )
00087		{ // Nothing to watch
00088			PerfHead.Destroy();
00089			return;
00090		}
00091	
00092		// Terminate linked list
00093		lastPerf.Next = None;
00094	
00095		// Create the dummy camera actor
00096		CameraDummy = Spawn( class 'Performer' );
00097		if( CameraDummy == None )
00098		{
00099			TerminateMovie();
00100			return;
00101		}
00102		CameraDummy.bHidden = True;
00103		CameraDummy.SetPhysics( PHYS_None );
00104		MovieInstigator.ViewTarget = CameraDummy;
00105	
00106		// Disable the player
00107		//MovieInstigator.SetPhysics( PHYS_None );
00108	
00109		bMovieActive = true;
00110		MovieTime = 0.0;
00111		Enable( 'Tick' );
00112	}
00113	
00114	function Tick( float DeltaTime )
00115	{
00116		local vector camPos;
00117		local rotator camRot;
00118		local vector offset;
00119		local vector X,Y,Z,X2,Y2,Z2;
00120		local vector jointpos;
00121		local rotator jointrot;
00122		local int i;
00123		local rotator pitchandyaw, wholedeal;
00124		local vector lookat;
00125		local float cosroll;
00126	
00127		local vector camFocus;
00128		local vector camDir;
00129	
00130		if( !bMovieActive )
00131		{
00132			return;
00133		}
00134		MovieTime += DeltaTime;
00135	
00136		offset = Location - PerfHead.Location;
00137		camPos = PerfHead.GetJointPos( 1 );
00138		camPos += offset;
00139		CameraDummy.SetLocation( camPos );
00140		PerfHead.SetLocation( camPos );
00141	
00142		camRot = PerfHead.GetJointRot( 1 );
00143	
00144		// Hack for X oriented camera
00145		GetAxes(camRot,X,Y,Z);
00146		lookat = -Y;
00147		pitchandyaw = rotator(lookat);
00148		GetAxes(pitchandyaw, X2,Y2,Z2);
00149		cosroll = X dot Y2;
00150		wholedeal = pitchandyaw;
00151		wholedeal.Roll = cosroll;	//TODO: Make Acos() intrinsic to deal with this
00152	
00153		CameraDummy.SetRotation( wholedeal );
00154	
00155		//camFocus = Location;
00156		//camDir = camFocus - camPos;
00157		//camRot = Rotator( camDir );
00158		//slog( "rot=" $ camRot );
00159		//CameraDummy.SetRotation( camRot );
00160	
00161		//CameraDummy.SetRotation( MovieInstigator.Rotation );
00162	
00163		if( MovieTime > 20 )
00164		{
00165			TerminateMovie();
00166		}
00167	}
00168	
00169	simulated function Debug(canvas Canvas, int mode)
00170	{
00171		local rotator camrot;
00172		local vector campos,X,Y,Z;
00173		
00174		camPos = PerfHead.GetJointPos( 1 );
00175		camRot = PerfHead.GetJointRot( 1 );
00176		GetAxes(camrot,X,Y,Z);
00177		Y *= -1000;
00178		
00179		Canvas.DrawLine3D(campos, campos+Y, 10, 0, 0);
00180	}
00181	
00182	
00183	function TerminateMovie()
00184	{
00185		local Performer perf;
00186		local Performer perfNext;
00187	
00188		// Return camera to player
00189		MovieInstigator.ViewTarget = None;
00190	
00191		// Destroy performers and dummy camera actor
00192		perf = PerfHead;
00193		while( perf != None )
00194		{
00195			perfNext = perf.Next;
00196			perf.Destroy();
00197			perf = perfNext;
00198		}	
00199		if( CameraDummy != None )
00200		{
00201			CameraDummy.Destroy();
00202		}
00203	
00204		// Stop Movie activity
00205		Disable( 'Tick' );
00206		bMovieActive = False;
00207	
00208		// Enable the player
00209	}
00210	
00211	defaultproperties
00212	{
00213	     bHidden=True
00214	}

End Source Code