Jump to content


Photo

DataRun - CameraVolume


  • Please log in to reply
14 replies to this topic

#1 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 01 May 2008 - 07:53 PM

Hi all,
after speaking with Luke, I implemented the prototype of CameraVolume.

What is CameraVolume?
When a playerController enters the volume, his Point Of View switches to CameraVolume Point Of View. The cameravolume is linked to a cameraActor which become CameraVolume's Point of View.

2 ways to set the CameraActor:
- add a CameraActor in the Map set cameratag field and set the same tagname in CameraVolume properties
- set relative position and rotation to a camera which will spawned when game start

2 CameraActors are currently available
- fixedCameraActor: fixed location and rotation
- rotateCameraActor: fixed location rotation (face the PlayerOwner)

Here is a video of the rotate camera: Rotate Camera

CameraVolume
class DataRun_CameraVolume extends PhysicsVolume
	placeable;

var DataRun_FixedCameraActor cameraActor;


enum CameraActorType
{
 TYPE_FIXED, TYPE_ROTATE
};
enum CameraType
{
 TYPE_EXTERNAL_CAMERA, TYPE_MANUAL_CAMERA
};

var() CameraType camType;

var(ExistingCamera) string cameraTag;

var(OwnCamera) CameraActorType camActorType;
var(OwnCamera) vector cameraRelativePosition;
var(OwnCamera) rotator cameraRelativeRotation;


simulated function PostBeginPlay()
{
   local box ActorBox;
   local DataRun_FixedCameraActor a;

   switch(camType)
   {
	 case CameraType.TYPE_MANUAL_CAMERA:

		cameraRelativePosition += location;
		cameraRelativeRotation += rotation;
		//GetComponentsBoundingBox(ActorBox);
		switch(camActorType)
		{
		   case  CameraActorType.TYPE_FIXED:
				cameraActor = Spawn(class'DataRun_FixedCameraActor', self,,,,, TRUE);
				break;

		   case  CameraActorType.TYPE_ROTATE:
				cameraActor = Spawn(class'DataRun_RotateCameraActor', self,,,,, TRUE);
				break;
		}

		cameraActor.SetLocation(cameraRelativePosition);
		cameraActor.SetRotation(cameraRelativeRotation);

	 break;
	 case  CameraType.TYPE_EXTERNAL_CAMERA:

	   foreach WorldInfo.AllActors(class'DataRun_FixedCameraActor', a)
		{
		   if(a.cameraTag == cameraTag)
		   {
			  cameraActor = a;
			  break;
		   }
		}
   }

   LogInternal("CameraActor: "$cameraActor);
}

event PawnEnteredVolume(Pawn Other)
{
   if(PlayerController(Other.Controller) != None)
   {
	  cameraActor.PC = UTPlayerController(Other.Controller);
	  UTPlayerController(Other.Controller).MatineeCameraClass = class'DataRun_FixedCamera';
	  UTPlayerController(Other.Controller).SpawnCamera();
	  UTPlayerController(Other.Controller).PlayerCamera.SetViewTarget(cameraActor);

   }
}


event PawnLeavingVolume(Pawn Other)
{
   if(PlayerController(Other.Controller) != None)
   {
	  UTPlayerController(Other.Controller).MatineeCameraClass = none;
	  if(UTPlayerController(Other.Controller).PlayerCamera != None)
	  {

		UTPlayerController(Other.Controller).PlayerCamera.SetViewTarget(Other);
		UTPlayerController(Other.Controller).PlayerCamera.Destroy();
		UTPlayerController(Other.Controller).PlayerCamera = none;
	  }
   }
}



function Vector getVolumeCenter()
{
  local box ActorBox;
  local Vector diagonal;
  GetComponentsBoundingBox(ActorBox);
  diagonal = ActorBox.Max - ActorBox.Min;
  return diagonal / 2;
}

defaultproperties
{
  camType =TYPE_MANUAL_CAMERA
  camActorType = TYPE_ROTATE
}

FixedCameraActor
class DataRun_FixedCameraActor extends DynamicCameraActor
	placeable;

var() string cameraTag;
var PlayerController PC;

simulated function GetCameraView(float DeltaTime, out TPOV OutPOV)
{
	GetActorEyesViewPoint(OutPOV.Location, OutPOV.Rotation);
	OutPOV.FOV = FOVAngle;
}

defaultproperties
{
 cameraTag="DataRun_FixedCameraActor";
}

RotateCameraActor
class DataRun_RotateCameraActor extends DataRun_FixedCameraActor
	  placeable;

simulated function GetCameraView(float DeltaTime, out TPOV OutPOV)
{
	super.GetCameraView(DeltaTime, OutPOV);
	if(PC == None)
	  return;
	OutPOV.Rotation = rotator(PC.Pawn.Location-Location);
}
defaultproperties
{
  cameraTag="DataRun_RotateCameraActor";
}

Camera
class DataRun_FixedCamera extends Camera;

Comment ?

#2 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 01 May 2008 - 09:24 PM

Looking good. All you need is a smooth transition from when the player enters and leaves the volume, and you're sorted.

#3 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 01 May 2008 - 10:27 PM

I'll give it a try as soon as my girlfriend stops monopolizing the computer :p
I already have an idea. Moving OutPOV.location along the vector between Pawn.location and Camera.location. Don't know if it will be smooth, we'll see. If anyone has a better idea? let me know
I'll try tomorrow.

#4 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 03 May 2008 - 12:48 AM

Hi all, double post.

I've implemented a kind of smooth transition, you can see the video => Here

Basically, it decreased at each tick the distance between the pawn and the camera location when entering the volume (the POV follows the oriented vector (Pawn's location to Camera's Location) and the contrary when leaving the volume.
Leaving pawn is a little tricky but it looks good

2 classes have been modified to handle this:

CameraVolume
class DataRun_CameraVolume extends PhysicsVolume
	placeable;

var DataRun_FixedCameraActor cameraActor;


enum CameraActorType
{
 TYPE_FIXED, TYPE_ROTATE
};
enum CameraType
{
 TYPE_EXTERNAL_CAMERA, TYPE_MANUAL_CAMERA
};

var() CameraType camType;

var(ExistingCamera) string cameraTag;

var(OwnCamera) CameraActorType camActorType;
var(OwnCamera) vector cameraRelativePosition;
var(OwnCamera) rotator cameraRelativeRotation;


simulated function PostBeginPlay()
{
   local box ActorBox;
   local DataRun_FixedCameraActor a;

   switch(camType)
   {
	 case CameraType.TYPE_MANUAL_CAMERA:

		cameraRelativePosition += location;
		cameraRelativeRotation += rotation;
		GetComponentsBoundingBox(ActorBox);
		LogInternal("ActorBox: Max "$ActorBox.Max);
		LogInternal("ActorBox: Min "$ActorBox.Min);
		LogInternal("location "$location);
		switch(camActorType)
		{
		   case  CameraActorType.TYPE_FIXED:
				cameraActor = Spawn(class'DataRun_FixedCameraActor', self,,,,, TRUE);
				break;

		   case  CameraActorType.TYPE_ROTATE:
				cameraActor = Spawn(class'DataRun_RotateCameraActor', self,,,,, TRUE);
				break;
		}

		cameraActor.SetLocation(cameraRelativePosition);
		cameraActor.SetRotation(cameraRelativeRotation);

	 break;
	 case  CameraType.TYPE_EXTERNAL_CAMERA:

	   foreach WorldInfo.AllActors(class'DataRun_FixedCameraActor', a)
		{
		   if(a.cameraTag == cameraTag)
		   {
			  cameraActor = a;
			  break;
		   }
		}
   }
}

event PawnEnteredVolume(Pawn Other)
{
   if(PlayerController(Other.Controller) != None)
   {
	  cameraActor.startTransition(UTPlayerController(Other.Controller));
   }
}

event PawnLeavingVolume(Pawn Other)
{
   if(PlayerController(Other.Controller) != None)
   {
	  UTPlayerController(Other.Controller).MatineeCameraClass = none;
	  if(UTPlayerController(Other.Controller).PlayerCamera != None)
	  {
		 cameraActor.stopTransition(UTPlayerController(Other.Controller));
	  }
   }
}

function Vector getVolumeCenter()
{
  local box ActorBox;
  local Vector diagonal;
  GetComponentsBoundingBox(ActorBox);
  diagonal = ActorBox.Max - ActorBox.Min;
  return diagonal / 2;
}

defaultproperties
{
  camType =TYPE_MANUAL_CAMERA
  camActorType = TYPE_ROTATE
}

CameraActor
class DataRun_FixedCameraActor extends DynamicCameraActor
	placeable;

enum transitionState
{
 START_TRANSITION, STOP_TRANSITION, INTER_TRANSITION
};

var() string cameraTag;
var PlayerController pController;
var transitionState trState;


var vector previousLocation;
var float distanceMin;


var int distanceStartTransitionFinish;
var int distanceStopTransitionFinish;
var float rate;


function startTransition(PlayerController PC)
{
	  pController = PC;
	  UTPlayerController(PC).MatineeCameraClass = class'DataRun_FixedCamera';
	  UTPlayerController(PC).SpawnCamera();
	  UTPlayerController(PC).PlayerCamera.SetViewTarget(self);

	  trState =  transitionState.START_TRANSITION;
}

function stopTransition(PlayerController PC)
{
	pController = PC;
	trState =  transitionState.STOP_TRANSITION;
}

function stopCamera()
{
	if( pController.Pawn != None)
	{
	  UTPlayerController(pController).PlayerCamera.SetViewTarget(pController.Pawn);
	}
	UTPlayerController(pController).PlayerCamera.Destroy();
	UTPlayerController(pController).PlayerCamera = none;
	previousLocation = vect(0,0,0);
	distanceMin = 0;
}

simulated function GetCameraView(float DeltaTime, out TPOV OutPOV)
{
	GetActorEyesViewPoint(OutPOV.Location, OutPOV.Rotation);

	//handle transition
	if(pController != None && pController.Pawn != None)
	{
	   switch (trState)
	   {
		  case transitionState.START_TRANSITION:
				   if(previousLocation == vect(0,0,0))
				   {
					  previousLocation = pController.Pawn.Location;
				   }
				   previousLocation -= (previousLocation-Location)*DeltaTime*rate/10;
				   OutPOV.location = previousLocation;
				   if(VSize(PreviousLocation - Location) < distanceStartTransitionFinish)
				   {
					  trState = transitionState.INTER_TRANSITION;
				   }
				   break;

		  /*
		   At Each tick, the camera view point is moved to the player's pawn location
		   until it reaches a distance considered as distanceFinish. If the player goes fast,
		   this distance is sometimes never reached. To handle this problem, during camera
		   point of view move, the min distance between Camera POV and pawn is updated
		   at each tick. If one time, the distance increased and the current distance
		   is greater than the distanceFinish, the camera switches off
		  */
		  case transitionState.STOP_TRANSITION:

				   previousLocation += Normal(pController.Pawn.Location-Location)*rate;
				   OutPOV.location = previousLocation;
				   if((distanceMin == 0 || VSize(pController.Pawn.Location - PreviousLocation) < distanceMin) &&
					   VSize(pController.Pawn.Location - PreviousLocation) > distanceStopTransitionFinish)
				   {
					 distanceMin = VSize(pController.Pawn.Location - PreviousLocation);
				   }
				   else
				   {
					  trState = transitionState.INTER_TRANSITION;
					  stopCamera();
				   }
				   break;

	   }
	}

	OutPOV.FOV = FOVAngle;
}

defaultproperties
{
 cameraTag="DataRun_FixedCameraActor"
 trState=INTER_TRANSITION
 distanceStartTransitionFinish = 20
 distanceStopTransitionFinish = 150
 rate = 20
 distanceMin = 0
}

comment ?

#5 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 03 May 2008 - 11:53 AM

Looking pretty sharp :p

I'll have to give it a play with at some point.

#6 Guest_Guest_*

Guest_Guest_*
  • Guests

Posted 15 May 2008 - 05:37 PM

Hi Im on the ps3 and am in desperate need of a decent camera volume, one that would allow full rotation around the character but is a little closer than action cam i guess...if this is any better than action cam could you please release it?

#7 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 16 May 2008 - 09:13 AM

This camera volume is specific to the game mode - it can only be used with the game mode, and cannot be used with official maps either; the maps need to be built to support it.

There is a camera mod called RypelCam, but I'm unsure if it's Ps3 compatible, since it's primary use is free camera in demo playback.

#8 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 19 May 2008 - 11:02 PM

I've updated the CameraActors classes, it works like a charm now
There were some problems with update rotation and location, it's fixed now :p

FixedCameraClass
class DataRun_FixedCameraActor extends DynamicCameraActor
	placeable;

enum transitionState
{
 START_TRANSITION, STOP_TRANSITION, INTER_TRANSITION
};

var() string cameraTag;
var PlayerController pController;
var transitionState trState;


var vector previousLocation;

var int distanceStartTransitionFinish;
var int distanceStopTransitionFinish;

var() float rampUpRate;
var() float rampDownRate;


function startTransition(PlayerController PC)
{
	  pController = PC;
	  UTPlayerController(PC).MatineeCameraClass = class'DataRun_FixedCamera';
	  UTPlayerController(PC).SpawnCamera();
	  UTPlayerController(PC).PlayerCamera.SetViewTarget(self);

	  trState =  transitionState.START_TRANSITION;
}

function stopTransition(PlayerController PC)
{
	pController = PC;
	trState =  transitionState.STOP_TRANSITION;
}

function stopCamera()
{
	if( pController.Pawn != None)
	{
	  UTPlayerController(pController).PlayerCamera.SetViewTarget(pController.Pawn);
	}
	UTPlayerController(pController).PlayerCamera.Destroy();
	UTPlayerController(pController).PlayerCamera = none;
	previousLocation = vect(0,0,0);
}

simulated function GetCameraView(float DeltaTime, out TPOV OutPOV)
{
	GetActorEyesViewPoint(OutPOV.Location, OutPOV.Rotation);
	performTransition(DeltaTime, OutPOV);
	OutPOV.FOV = FOVAngle;
}

function performTransition(float DeltaTime, out TPOV OutPOV)
{
	   	//handle transition
	if(pController != None && pController.Pawn != None)
	{
	   switch (trState)
	   {
		  case transitionState.START_TRANSITION:
				   if(previousLocation == vect(0,0,0))
				   {
					  previousLocation = pController.Pawn.Location;
				   }
				   previousLocation -= Normal(previousLocation-Location)*rampDownRate;
				   OutPOV.location = previousLocation;
				   OutPOV.Rotation = rotator(pController.Pawn.Location-previousLocation);
				   if(VSize(PreviousLocation - Location) < distanceStartTransitionFinish)
				   {
					  trState = transitionState.INTER_TRANSITION;
				   }
				   break;

		  case transitionState.STOP_TRANSITION:

				   OutPOV.Rotation = rotator(pController.Pawn.Location-previousLocation);
				   previousLocation += vector(OutPOV.Rotation)*rampUpRate;
				   OutPOV.location = previousLocation;

				   if(VSize(pController.Pawn.Location - PreviousLocation) < distanceStopTransitionFinish)
				   {
					  trState = transitionState.INTER_TRANSITION;
					  stopCamera();
				   }
				   break;

	   }
	}
}

defaultproperties
{
 cameraTag="DataRun_FixedCameraActor"
 trState=INTER_TRANSITION
 distanceStartTransitionFinish = 20
 distanceStopTransitionFinish = 20
 rampUpRate = 60
 rampDownRate = 60
}

RotateCameraClass
class DataRun_RotateCameraActor extends DataRun_FixedCameraActor
	  placeable;

simulated function GetCameraView(float DeltaTime, out TPOV OutPOV)
{
	GetActorEyesViewPoint(OutPOV.Location, OutPOV.Rotation);

	if(pController == None || pController.Pawn == None)
	  return;
	OutPOV.Rotation = rotator(pController.Pawn.Location-Location);

	performTransition(DeltaTime, OutPOV);
	OutPOV.FOV = FOVAngle;
}
defaultproperties
{
  cameraTag="DataRun_RotateCameraActor";
}


#9 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 24 May 2008 - 02:33 PM

Hi all,
I've uploaded Interpolating Camera System sources and documentation (Appendix) on svn. I've also updated Appendix Section on wiki :D
I guess this task is finished, I have a new idea of Camera but it could be implemented in a second time (CameraNodeActor) ( An Example ^^)

#10 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 25 May 2008 - 02:52 PM

Camera system is looking sharp. We could upgrade it to a node-based system - but then we'd probably be better tying it into matinee - which would probablt prove rather complicated.

#11 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 25 May 2008 - 05:00 PM

Not sure to understand what sharp means. Is it the fact that the transition in the video I uploaded is fast? I didn't make video of the last modification but now you can modify speed as you wish :p
Matinee ? I only know the word :thumbsupsmiley: , that sounds powerful and also complicated.
It was just an idea ok ^^

#12 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 26 May 2008 - 02:02 AM

Sharp means, strong, fine, acute, whatever :thumbsupsmiley:

Matinee is one of UnrealEd's most powerful tools. The moment you want to deal with complex moving objects (such as cameras with specific paths). then Matinee is what you want. Matinee is what drives things like the robots on the assembly lines and the moving platforms on Carbon Fire.

#13 Sleepy

Sleepy
  • New Members
  • 2 posts

Posted 09 December 2009 - 10:04 AM

hello. i'm currently in the process of doing some camera work myself, and i stumbled across this thread. if you're looking to do a node system via matinee; since you already seem to have a good feel for volumes; you could set up your nodes and pathing for them, then be able to toggle which node the player is viewing their character from based on whatever camera volume the player happens to be standing in. the cameras themselves probably wouldn't be that much work to set up. you'd just have to code in a way to keep those cameras locked in on the player's origin (or more likely a bit off center favoring the front) and move along their path. the player enters and you blend the camera from one node to another. from this point you could easily script in various camera effects (shake, rebound, perhaps sync bob with run cycle frame if you're feeling ambitious) to directly affect the already referenced camera node.

i've actually been trying to set something like this up for a while now, and am kinda smacking myself in the head right now for not thinking of using volumes for it. i'll probably check back in on this thread from time to time. if you hit any road blocks i might be able to help you out.
X_X

#14 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 31 December 2009 - 03:26 AM

Haha, thanks Sleepy. I believe you'll find that this thread is however from May, and that the project is no longer in development. you are describing the exact sort of approach we were intending on using, however. I believe it should work well.

#15 Sleepy

Sleepy
  • New Members
  • 2 posts

Posted 31 March 2010 - 10:21 AM

haha. thats good to hear. and after many months i finally check the thread again.

i've been stuck in asset making for a while so i haven't been back to working on the camera since a few days after i posted. should you read this: how's it coming along?
X_X




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users