Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

AdvKit.AdvKitCamera


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
/**
 * Camera that provides third person functionality for the "classic" third person view
 * 
 * Thanks a bunch to Psilocybe for this tutorial:
 * http://forums.epicgames.com/threads/726985-Tutorial-Third-Person-Game-with-GOW-camera
 * Note that I only use the basic functionality explained in the tutorial, 
 * take a look to find out more!
 * 
 * 2013 by FreetimeCoder
 * www.freetimestudio.net
 */
class AdvKitCamera extends Camera;


/**
 * to provide smooth zoom FreeCamDistance is used as the target value
 * in Lerp, while fActualFreeCAmDistance holds the current distance
 */
var float fActualFreeCamDistance;

/**
 * how fast to lerp the camera distance
 */
var float fZoomSpeed;

/**
 * an offset value from the water surface in global Z Axis. Setting the 
 * camera directly onto the surface Z would cause clipping errors
 */
var float fWaterSurfaceOffset;

/**
 * whether or not to let the camera collide with the water surface
 */
var bool bCollideWithWaterSurface;

/**Camera.uc:
 * Query ViewTarget and outputs Point Of View.
 *
 * @param	_OutVT		ViewTarget to use.
 * @param	_fDeltaTime Delta Time since last camera update (in seconds).
 */
 function UpdateViewTarget(out TViewTarget _OutVT, float _fDeltaTime)
{
	local AdvKitPawn advPawn;
	local vector vViewTargetLocation;
	local Vector vNewLocation;
	local Rotator rNewRotation;
	local CameraActor CamActor;
	
	/** NOTE Copycat code that makes Matinee work -- I have no idea what I am doing, just copied this over from the Camera.uc **/
	// Don't update outgoing viewtarget during an interpolation 
	if( PendingViewTarget.Target != None && _OutVT == ViewTarget && BlendParams.bLockOutgoing )
	{
		return;
	}
	// Viewing through a camera actor.
	CamActor = CameraActor(_OutVT.Target);
	if( CamActor != None )
	{
		CamActor.GetCameraView(_fDeltaTime, _OutVT.POV);

		// Grab aspect ratio from the CameraActor.
		bConstrainAspectRatio	= bConstrainAspectRatio || CamActor.bConstrainAspectRatio;
		_OutVT.AspectRatio		= CamActor.AspectRatio;

		// See if the CameraActor wants to override the PostProcess settings used.
		CamOverridePostProcessAlpha = CamActor.CamOverridePostProcessAlpha;
		CamPostProcessSettings = CamActor.CamOverridePostProcess;
		return;
	}
	/** End of copycat code **/

	//Just take a look at the tutorial code
	vViewTargetLocation = _OutVT.Target.Location;
	vNewLocation = vViewTargetLocation;
	rNewRotation = _OutVT.Target.Rotation;

	if (CameraStyle == 'ThirdPerson' || CameraStyle == 'Swimming' || CameraStyle == 'Diving')
	{
		rNewRotation = PCOwner.Rotation; //setting the rotation of the camera to the rotation of the controller
		
		vViewTargetLocation += FreeCamOffset >> rNewRotation;
		if(fActualFreeCamDistance != FreeCamDistance)
		{
			fActualFreeCamDistance = Lerp(fActualFreeCamDistance,FreeCamDistance,FMin(1,fZoomSpeed*_fDeltaTime));
		}

		vNewLocation = vViewTargetLocation - Vector(rNewRotation)*fActualFreeCamDistance;
		vNewLocation.X += sin(-rNewRotation.Yaw * UnrRotToRad);
		vNewLocation.Y += cos(rNewRotation.Yaw * UnrRotToRad);

		//if the player is swimming
		advPawn = AdvKitPawn(PCOwner.Pawn);
		if(advPawn!=none && bCollideWithWaterSurface)
		{
			//do not let the camera go under the surface
			if(CameraStyle == 'Swimming' && vNewLocation.Z < advPawn.fWaterSurfaceZ+fWaterSurfaceOffset)
			{
				vNewLocation.Z = advPawn.fWaterSurfaceZ+fWaterSurfaceOffset;
			}

			//do not let the camera go over the surface
			if(CameraStyle == 'Diving' && vNewLocation.Z > advPawn.fWaterSurfaceZ-fWaterSurfaceOffset)
			{
				vNewLocation.Z = advPawn.fWaterSurfaceZ-fWaterSurfaceOffset;
			}
		}
	}

	_OutVT.POV.Location = vNewLocation;
	_OutVT.POV.Rotation = rNewRotation;
	SetRotation(rNewRotation);
}

defaultproperties
{
	bCollideWithWaterSurface=true
	FreeCamDistance = 256.f
	fZoomSpeed = 10
	FreeCamOffset=(Z=32)
	fWaterSurfaceOffset=8
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Sa 10.8.2013 21:35:02.000 - Creation time: Di 17.9.2013 17:47:16.816 - Created with UnCodeX