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

Jailbreak.JBCamController


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
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
// ============================================================================
// JBCamController
// Copyright 2004 by Mychaeel <mychaeel@planetjailbreak.com>
// $Id: JBCamController.uc,v 1.2 2004/03/28 22:45:37 mychaeel Exp $
//
// Controls movement of a camera actor.
// ============================================================================


class JBCamController extends Object
  hidecategories (Object)
  editinlinenew;


// ============================================================================
// Properties
// ============================================================================

var() bool bIgnoreOutsideCollision;  // ignore players outside collision

var() bool bIgnorePlayersFree;       // ignore free players
var() bool bIgnorePlayersInArena;    // ignore players in arena
var() bool bIgnorePlayersInJail;     // ignore players in jail

var() bool bIgnoreTeamRed;           // ignore players on red team
var() bool bIgnoreTeamBlue;          // ignore players on blue team

var() float RatingFactor;            // factor to bias camera rating


// ============================================================================
// Variables
// ============================================================================

var JBCamera Camera;                 // camera controlled by this object


// ============================================================================
// Init
//
// Called both server-side and client-side at game start for initialization.
// ============================================================================

function Init();


// ============================================================================
// UpdateMovement
//
// Called both server-side and client-side once a tick as long as the camera
// is being used by at least one player. The given delta time reflects the
// time since the last movement update; the very first update is passed zero.
// ============================================================================

function UpdateMovement(float TimeDelta);


// ============================================================================
// IsPlayerIgnored
//
// Checks and returns whether the given player should be ignored by this
// camera. This does not affect which players are actually displayed, just
// which ones are rated and possibly tracked by it.
// ============================================================================

function bool IsPlayerIgnored(JBTagPlayer TagPlayer)
{
  local int iTeam;
  local Pawn PawnPlayer;

  if (TagPlayer == None)
    return True;

  PawnPlayer = TagPlayer.GetPawn();
  if (PawnPlayer == None)
    return True;
  
  if (bIgnoreOutsideCollision && !Camera.TouchingActor(PawnPlayer))
    return True;

  if (bIgnorePlayersFree    && TagPlayer.IsFree())    return True;
  if (bIgnorePlayersInArena && TagPlayer.IsInArena()) return True;
  if (bIgnorePlayersInJail  && TagPlayer.IsInJail())  return True;

  iTeam = TagPlayer.GetTeam().TeamIndex;
  if (bIgnoreTeamRed  && iTeam == 0) return True;
  if (bIgnoreTeamBlue && iTeam == 1) return True;
  
  return False;
}


// ============================================================================
// RateCurrentView
//
// Returns a cumulated rating of the view this camera has on players at its
// current location and rotation. Assumes a 4:3 screen aspect ratio.
// ============================================================================

function float RateCurrentView()
{
  local float Rating;
  local float Limit;
  local vector LocationPlayer;
  local vector LocationTransformed;
  local Coords CoordsCamera;
  local Pawn PawnPlayer;
  local JBTagPlayer firstTagPlayer;
  local JBTagPlayer thisTagPlayer;
  
  GetAxes(Camera.Rotation,
    CoordsCamera.XAxis,
    CoordsCamera.YAxis,
    CoordsCamera.ZAxis);
  
  Limit = Sin(Camera.FieldOfView * Pi / 360.0);
  
  firstTagPlayer = JBGameReplicationInfo(Camera.Level.Game.GameReplicationInfo).firstTagPlayer;
  for (thisTagPlayer = firstTagPlayer; thisTagPlayer != None; thisTagPlayer = thisTagPlayer.nextTag) {
    if (IsPlayerIgnored(thisTagPlayer))
      continue;
  
    PawnPlayer = thisTagPlayer.GetPawn();
    if (PawnPlayer == None)
      continue;
    
    LocationPlayer = Normal(PawnPlayer.Location - Camera.Location);
    
    LocationTransformed.X = LocationPlayer dot CoordsCamera.YAxis;
    LocationTransformed.Y = LocationPlayer dot CoordsCamera.ZAxis;
    LocationTransformed.Z = LocationPlayer dot CoordsCamera.XAxis;
    
    if (LocationTransformed.Z <= 0.0)
      continue;  // directly on or behind camera
    
    LocationTransformed /= Limit;
    
    if (Abs(LocationTransformed.X) <= 1.00 &&
        Abs(LocationTransformed.Y) <= 0.75)
      Rating += thisTagPlayer.RateViewOnPlayer(Camera.Location);
  }
  
  // correct rating for camera zoom
  Rating /= Square(Limit);

  return Rating * RatingFactor;
}


// ============================================================================
// InterpolateRotation
//
// Smoothly rotates the camera to the given desired rotation.
// ============================================================================

function InterpolateRotation(rotator Rotation, float TimeDelta)
{
  if (TimeDelta == 0.0)
         Camera.SetRotation(Rotation);
    else Camera.SetRotation(Camera.Rotation + Normalize(Rotation - Camera.Rotation) * FMin(1.0, TimeDelta * 2.0));
}


// ============================================================================
// InterpolateLocation
//
// Smoothly moves the camera to the given desired location.
// ============================================================================

function InterpolateLocation(vector Location, float TimeDelta)
{
  if (TimeDelta == 0.0)
         Camera.SetLocation(Location);
    else Camera.SetLocation(Camera.Location + (Location - Camera.Location) * FMin(1.0, TimeDelta * 3.0));
}


// ============================================================================
// Defaults
// ============================================================================

defaultproperties
{
  RatingFactor = 1.0;
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Mo 29.3.2004 00:45:38.000 - Creation time: Do 14.8.2014 09:58:41.853 - Created with UnCodeX