UMSCamera
Class UMSCamera

source: e:\games\UnrealTournament\UMSCamera\Classes\UMSCamera.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--UMS1_6.UMS
         |
         +--UMS1_6.UMSModule
            |
            +--UMSCamera.UMSCamera
Direct Known Subclasses:None

class UMSCamera
extends UMS1_6.UMSModule


Variables
 MovieCamera activeCamera


Function Summary
 void ExecuteCutTo(Actor NewCamera)
 void ExecuteZoom(MovieCamera TargetCamera)
 MovieCamera FindCamera(string CameraName)



Source Code


00001	class UMSCamera expands UMSModule;
00002	
00003	var MovieCamera activeCamera;
00004	
00005	function bool runCommand(string Script[20])
00006	{
00007	    switch(Script[0])    
00008	    {
00009	        case "Camera":
00010	            return ExecuteCameraAction(Script);
00011	            break;
00012	        case "POV":						// Change Player view to a given object in the level.
00013	            ExecutePOV(Script);
00014				return true;
00015	            break;
00016	    }
00017	
00018		return false;
00019	}
00020	
00021	
00022	//*******************************************************************
00023	//Camera Stuff
00024	//*******************************************************************
00025	
00026	function bool ExecuteCameraAction(string Script[20])
00027	{
00028	    local MovieCamera TargetCamera;
00029	    
00030	    //find the camera
00031	    TargetCamera = FindCamera(Script[1]);
00032	    
00033	    switch(Script[2])
00034	    {
00035	        case "Pan":
00036	            ExecutePan(TargetCamera, Script);
00037	        	return true;
00038	            break;
00039	        case "Zoom":
00040	            ExecuteZoom(TargetCamera);
00041	        	return true;
00042	            break;
00043			case "Vertigo":
00044				ExecuteVertigo(TargetCamera, Script);
00045	        	return true;
00046				break;
00047	        case "Dolly":
00048	            ExecuteDolly(TargetCamera, Script);
00049	        	return true;
00050	            break;
00051	        case "Circle":
00052	            ExecuteCircle(TargetCamera, Script);
00053	        	return true;
00054	            break;
00055	        case "Track":
00056	            ExecuteTrack(TargetCamera, Script);
00057	        	return true;
00058	            break;
00059	        case "ChaseCam":
00060	            ExecuteChaseCam(TargetCamera, Script);
00061	        	return true;
00062	            break;
00063	        case "CutTo":
00064	            ExecuteCutTo(TargetCamera);
00065	        	return true;
00066	            break;
00067	        case "Interpolate":
00068	            ExecuteInterpolate(TargetCamera, Script); 
00069	        	return true;
00070	            break;
00071	    }
00072	    
00073	    return false;
00074	}
00075	
00076	function ExecuteCutTo(Actor NewCamera)
00077	{
00078	    local PlayerPawn P;
00079	    
00080	    if(activeCamera != NONE)
00081	    {
00082	    	activeCamera.setActive(false);
00083	    }
00084	    
00085	    if(NewCamera != NONE && NewCamera.IsA('MovieCamera'))
00086	    {
00087	    	MovieCamera(NewCamera).setActive(true);
00088	    	activeCamera = MovieCamera(NewCamera);
00089	    }
00090	    else
00091	    {
00092	    	activeCamera = NONE;
00093	    }
00094	    
00095	    foreach AllActors(class 'PlayerPawn', P)
00096	        P.ViewTarget = NewCamera;
00097	}
00098	
00099	function ExecutePan(MovieCamera TargetCamera, string Script[20])
00100	{
00101	    local actor PanTarget;
00102	    local vector TargetVector;
00103	    local rotator TargetRotation;
00104	    local float Time;
00105	    
00106	    //to something, or not to something, that is the question
00107	    if(Script[3] ~= "to")
00108	    {
00109	        //If no name after to, use the value in ScriptVectors
00110	        if(Script[4] == "")
00111	            PanTarget = NONE;
00112	        else
00113	            PanTarget = FindActor(Script[4]);
00114	        
00115	        if(PanTarget != NONE)
00116	            TargetVector = PanTarget.Location;
00117	        else
00118	            TargetVector = currentScriptVector;
00119	                    
00120	        TargetRotation = rotator(TargetVector - TargetCamera.Location);
00121	    }    
00122	    else
00123	        TargetRotation = TargetCamera.Rotation + currentScriptRotator;
00124	        
00125	    Time = currentScriptVal;
00126	    
00127	    TargetCamera.DoPan(TargetRotation, PanTarget, Time);
00128	}
00129	
00130	function ExecuteDolly(MovieCamera TargetCamera, string Script[20])
00131	{
00132	    local actor TargetActor;
00133	    local vector TargetLocation;
00134	    local float Time;
00135	    
00136	    if(Script[3] ~= "to")
00137	    {
00138		    if (Script[4] == "")
00139		        TargetActor = NONE;
00140		    else
00141		        TargetActor = FindActor(Script[4]);
00142		    
00143		    //Check for no target.
00144		    if(TargetActor == NONE)
00145		        TargetLocation = currentScriptVector;
00146		    else
00147		        TargetLocation = TargetActor.Location;
00148		}
00149		else
00150			TargetLocation = TargetCamera.Location + currentScriptVector;
00151	    
00152	    Time = currentScriptVal;
00153	    
00154	    log(Self$": Dollying to"@Script[3]@"in"@Time@"seconds.");
00155	    
00156	    TargetCamera.DoDolly(TargetLocation, TargetActor, Time);
00157	}
00158	
00159	function ExecuteZoom(MovieCamera TargetCamera)
00160	{
00161	    local float Zoom, Time; 
00162	
00163	    Time = currentScriptVal;
00164	    //  Okay, using a vector for the zoom dosen't make a whole lot of
00165	    //sense, but it keeps us from adding an entire nother array of 
00166	    //floats just for this one function.
00167	    //  So, just put a number in one of the three spaces for the 
00168	    //vector and that will where you zoom to.
00169	    Zoom = VSize(currentScriptVector);
00170	    
00171	    TargetCamera.DoZoom(Zoom, Time);
00172	}
00173	
00174	function ExecuteVertigo(MovieCamera TargetCamera, string Script[20])
00175	{
00176		local actor TargetActor;
00177		
00178		TargetActor = FindActor(Script[3]);
00179		
00180		TargetCamera.DoVertigo(TargetActor);
00181	}
00182	
00183	function ExecuteCircle(MovieCamera TargetCamera, string Script[20])
00184	{
00185	    local actor TargetActor;
00186	    local rotator Speed;
00187	    local vector Offset;
00188	    local float Distance;
00189	    
00190	    TargetActor = FindActor(Script[3]);
00191	    Speed = currentScriptRotator;
00192	    Offset = currentScriptVector;
00193	    Distance = currentScriptVal;
00194	    
00195	    TargetCamera.DoCircling(TargetActor, Speed, Offset, Distance);
00196	}
00197	
00198	function ExecuteTrack(MovieCamera TargetCamera, string Script[20])
00199	{
00200	    local actor TargetActor;
00201	    local vector Offset;
00202	    local rotator TrackDirections;
00203	    
00204	    TargetActor = FindActor(Script[3]);
00205	    Offset = currentScriptVector;
00206	    TrackDirections = currentScriptRotator;
00207	    
00208	    TargetCamera.DoTracking(TargetActor, Offset, TrackDirections);
00209	}
00210	
00211	function ExecuteChaseCam(MovieCamera TargetCamera, string Script[20])
00212	{
00213	    local actor TargetActor;
00214	    local vector Offset;
00215	    local rotator RotOffset;
00216	    local float Distance;
00217	
00218	    TargetActor = FindActor(Script[3]);
00219	    Offset = currentScriptVector;
00220	    RotOffset = currentScriptRotator;
00221	    
00222	    TargetCamera.DoChaseCam(TargetActor, Offset, RotOffset);
00223	}
00224	
00225	function ExecuteInterpolate(MovieCamera TargetCamera, string Script[20])
00226	{
00227	    local actor TargetActor;
00228	    local float NewRate, NewAlpha;
00229	
00230	    TargetActor = FindActor(Script[3]);
00231	    NewRate = currentScriptVal;
00232	    //As I've said before, we're just using the vector as a float.
00233	    //You'll want to set either X, Y, or Z to the value.
00234	    NewAlpha = VSize(currentScriptVector);
00235	    
00236	    TargetCamera.DoInterpolate(TargetActor, NewRate, NewAlpha);
00237	}
00238	
00239	
00240	//*******************************************************************
00241	//POV Stuff
00242	//*******************************************************************
00243	
00244	//Sets the player's view to being that of some object in
00245	//the level, which is presumably not a camera.
00246	function ExecutePOV(string Script[20])
00247	{
00248	    local Actor TargetActor;
00249	    
00250	    TargetActor = FindActor(Script[1]);
00251	    
00252	    ExecuteCutTo(TargetActor);
00253	}
00254	
00255	
00256	function MovieCamera FindCamera(string CameraName)
00257	{
00258	    local MovieCamera M;
00259	
00260	    foreach AllActors(class'MovieCamera', M)
00261	        if (CameraName ~= string(M.Tag) || CameraName ~= string(M.Name))
00262	               return M;
00263	    //If there is no matching pawn, return none.
00264	    return NONE;
00265	}
00266	
00267	defaultproperties
00268	{
00269	}

End Source Code