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

Jailbreak.JBCamControllerSweeping


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
// ============================================================================
// JBCamControllerSweeping
// Copyright 2004 by Mychaeel <mychaeel@planetjailbreak.com>
// $Id: JBCamControllerSweeping.uc,v 1.3 2006-07-13 20:55:02 jrubzjeknf Exp $
//
// Sweeps a camera between two LookTarget actors.
// ============================================================================


class JBCamControllerSweeping extends JBCamController
  editinlinenew;


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

var() name TagLookTargetLeft;          // tag of LookTarget on left  range end
var() name TagLookTargetRight;         // tag of LookTarget on right range end

var() float TimeSweep;                 // time to sweep between LookTargets
var() float TimeWait;                  // time to wait before sweeping back


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

var private int YawSweepLeft;          // yaw on left  end of sweep
var private int YawSweepRight;         // yaw on right end of sweep
var private int YawSweepDelta;         // yaw difference and current direction

var private float TimeCountdownSweep;  // countdown for sweep
var private float TimeCountdownWait;   // countdown for wait


// ============================================================================
// Init
//
// Finds the two LookTarget actors which define the sweeping range. Outputs a
// log error message and sets the camera's caption to an error message if one
// or both can not be found.
// ============================================================================

function Init()
{
  local rotator Rotation;
  local string Error;
  local LookTarget LookTargetLeft;
  local LookTarget LookTargetRight;

  if (TagLookTargetLeft  == '' || TagLookTargetLeft  == 'None' ||
      TagLookTargetRight == '' || TagLookTargetRight == 'None') {
    Error = "TagLookTargetLeft and/or TagLookTargetRight have not been set";
  }
  else {
    foreach Camera.DynamicActors(Class'LookTarget', LookTargetLeft,  TagLookTargetLeft)  break;
    foreach Camera.DynamicActors(Class'LookTarget', LookTargetRight, TagLookTargetRight) break;

    if (LookTargetLeft  == None ||
        LookTargetRight == None) {
      Error = "No matching LookTarget actor found for TagLookTargetLeft and/or TagLookTargetRight";
    }
    else {
      YawSweepLeft  = rotator(LookTargetLeft .Location - Camera.Location).Yaw;
      YawSweepRight = rotator(LookTargetRight.Location - Camera.Location).Yaw;

      if (YawSweepRight < YawSweepLeft)
        YawSweepRight += 65536;

      YawSweepDelta = YawSweepRight - YawSweepLeft;

      Rotation = Camera.Rotation;
      Rotation.Yaw = (YawSweepLeft + YawSweepRight) / 2;
      Camera.SetRotation(Rotation);

      TimeCountdownSweep = TimeSweep / 2.0;
    }
  }

  if (Error != "") {
    Log("Unable to initialize" @ Self @ "of" @ Camera $ ":" @ Error);

    Camera.Caption.Text = "Error:" @ Error;
    Camera.Caption.Position = 0.5;
    Camera.Caption.Color.R  = 255;
    Camera.Caption.Color.G  =   0;
    Camera.Caption.Color.B  =   0;
    Camera.Caption.Color.A  = 255;
  }
}


// ============================================================================
// UpdateMovement
//
// Sweeps the camera back and forth about the yaw axis.
// ============================================================================

function UpdateMovement(float TimeDelta)
{
  local rotator Rotation;

  if (TimeCountdownSweep > 0.0) {
    TimeCountdownSweep -= TimeDelta;

    if (TimeCountdownSweep <= 0.0) {
      TimeCountdownSweep = 0.0;
      TimeCountdownWait  = TimeWait;
    }

    Rotation = Camera.Rotation;

    if (YawSweepDelta > 0)
           Rotation.Yaw = YawSweepRight - YawSweepDelta * TimeCountdownSweep / TimeSweep;
      else Rotation.Yaw = YawSweepLeft  - YawSweepDelta * TimeCountdownSweep / TimeSweep;

    Camera.SetRotation(Rotation);
  }

  else {
    TimeCountdownWait -= TimeDelta;

    if (TimeCountdownWait <= 0.0) {
      TimeCountdownWait  = 0.0;
      TimeCountdownSweep = TimeSweep;
      YawSweepDelta = -YawSweepDelta;
    }
  }
}


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

defaultproperties
{
  TimeSweep = 4.0;
  TimeWait  = 2.0;
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Mo 17.7.2006 13:53:24.000 - Creation time: Do 14.8.2014 09:58:41.871 - Created with UnCodeX