geraint

UDNPawn old

Oct 11th, 2011
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class UDNPawn extends UTPawn;
  2.  
  3. Enum CameraPerspective
  4. {
  5.    CAM_FirstPerson,
  6.    CAM_ThirdPerson,
  7.    CAM_TopDown,
  8.    CAM_SideScroller,
  9.    CAM_Isometric
  10. };
  11.  
  12. var bool bFollowPlayerRotation;
  13. var CameraPerspective CameraType;
  14. var float CamOffsetDistance;
  15. var int IsoCamAngle;
  16.  
  17. exec function CameraMode(CameraPerspective mode)
  18. {
  19.    local UTPlayerController UTPC;
  20.  
  21.    CameraType = mode;
  22.  
  23.    UTPC = UTPlayerController(Controller);
  24.    if (UTPC != None)
  25.    {
  26.       if(CameraType != CAM_FirstPerson)
  27.       {
  28.          UTPC.SetBehindView(true);
  29.          if(CameraType != CAM_ThirdPerson)
  30.          {
  31.             UTPC.bNoCrosshair = true;
  32.          }
  33.          else
  34.          {
  35.             UTPC.bNoCrosshair = false;
  36.          }
  37.       }
  38.       else
  39.       {
  40.          UTPC.bNoCrosshair = false;
  41.  
  42.          UTPC.SetBehindView(false);
  43.       }
  44.       SetMeshVisibility(UTPC.bBehindView);
  45.    }
  46. }
  47.  
  48. exec function IsoAngle(int angle)
  49. {
  50.    IsoCamAngle = angle;
  51. }
  52.  
  53. /* BecomeViewTarget
  54.    Called by Camera when this actor becomes its ViewTarget */
  55. simulated event BecomeViewTarget( PlayerController PC )
  56. {
  57.    local UTPlayerController UTPC;
  58.  
  59.    Super.BecomeViewTarget(PC);
  60.  
  61.    if (LocalPlayer(PC.Player) != None)
  62.    {
  63.       UTPC = UTPlayerController(PC);
  64.       if (UTPC != None)
  65.       {
  66.          if(CameraType != CAM_FirstPerson)
  67.          {
  68.             UTPC.SetBehindView(true);
  69.             if(CameraType != CAM_ThirdPerson)
  70.             {
  71.                UTPC.bNoCrosshair = true;
  72.             }
  73.             else
  74.             {
  75.                UTPC.bNoCrosshair = false;
  76.             }
  77.          }
  78.          else
  79.          {
  80.             UTPC.bNoCrosshair = false;
  81.  
  82.             UTPC.SetBehindView(false);
  83.          }
  84.          SetMeshVisibility(UTPC.bBehindView);
  85.       }
  86.    }
  87. }
  88.  
  89. /**
  90.  *   Calculate camera view point, when viewing this pawn.
  91.  *
  92.  * @param   fDeltaTime   delta time seconds since last update
  93.  * @param   out_CamLoc   Camera Location
  94.  * @param   out_CamRot   Camera Rotation
  95.  * @param   out_FOV      Field of View
  96.  *
  97.  * @return   true if Pawn should provide the camera point of view.
  98.  */
  99. simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
  100. {
  101.    // Handle the fixed camera
  102.  
  103.    if (bFixedView)
  104.    {
  105.       out_CamLoc = FixedViewLoc;
  106.       out_CamRot = FixedViewRot;
  107.    }
  108.    else
  109.    {
  110.       if ( CameraType == CAM_ThirdPerson )   // Handle BehindView
  111.       {
  112.          CalcThirdPersonCam(fDeltaTime, out_CamLoc, out_CamRot, out_FOV);
  113.       }
  114.       else if ( CameraType == CAM_TopDown )   // Handle BehindView
  115.       {
  116.          CalcTopDownCam(fDeltaTime, out_CamLoc, out_CamRot, out_FOV);
  117.       }
  118.       else if ( CameraType == CAM_SideScroller )   // Handle BehindView
  119.       {
  120.          CalcSideScrollerCam(fDeltaTime, out_CamLoc, out_CamRot, out_FOV);
  121.       }
  122.       else if ( CameraType == CAM_Isometric )   // Handle BehindView
  123.       {
  124.          CalcIsometricCam(fDeltaTime, out_CamLoc, out_CamRot, out_FOV);
  125.       }
  126.       else
  127.       {
  128.          // By default, we view through the Pawn's eyes..
  129.          GetActorEyesViewPoint( out_CamLoc, out_CamRot );
  130.       }
  131.  
  132.       if ( UTWeapon(Weapon) != none)
  133.       {
  134.          UTWeapon(Weapon).WeaponCalcCamera(fDeltaTime, out_CamLoc, out_CamRot);
  135.       }
  136.    }
  137.  
  138.    return true;
  139. }
  140.  
  141. simulated function bool CalcTopDownCam( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
  142. {
  143.      out_CamLoc = Location;
  144.    out_CamLoc.X -= Cos(IsoCamAngle * UnrRotToRad) * CamOffsetDistance;
  145.    out_CamLoc.Z += Sin(IsoCamAngle * UnrRotToRad) * CamOffsetDistance;
  146.  
  147.    out_CamRot.Pitch = -1 * IsoCamAngle;  
  148.    out_CamRot.Yaw = 0;
  149.    out_CamRot.Roll = 0;
  150.  
  151.     return true;
  152. }
  153.  
  154. simulated function bool CalcSideScrollerCam( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
  155. {
  156.    out_CamLoc = Location;
  157.    out_CamLoc.X -= Cos(IsoCamAngle * UnrRotToRad) * CamOffsetDistance;
  158.    out_CamLoc.Z += Sin(IsoCamAngle * UnrRotToRad) * CamOffsetDistance;
  159.  
  160.    out_CamRot.Pitch = -1 * IsoCamAngle;  
  161.    out_CamRot.Yaw = 0;
  162.    out_CamRot.Roll = 0;
  163.  
  164.     return true;
  165. }
  166.  
  167. simulated function bool CalcIsometricCam( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
  168. {
  169.    out_CamLoc = Location;
  170.    out_CamLoc.X -= Cos(IsoCamAngle * UnrRotToRad) * CamOffsetDistance;
  171.    out_CamLoc.Z += Sin(IsoCamAngle * UnrRotToRad) * CamOffsetDistance;
  172.  
  173.    out_CamRot.Pitch = -1 * IsoCamAngle;  
  174.    out_CamRot.Yaw = 0;
  175.    out_CamRot.Roll = 0;
  176.  
  177.    return true;
  178. }
  179.  
  180. /**
  181.  * returns base Aim Rotation without any adjustment (no aim error, no autolock, no adhesion.. just clean initial aim rotation!)
  182.  *
  183.  * @return   base Aim rotation.
  184.  */
  185. simulated singular event Rotator GetBaseAimRotation()
  186. {
  187.    local vector   POVLoc;
  188.    local rotator   POVRot, tempRot;
  189.  
  190.    if(CameraType == CAM_TopDown || CameraType == CAM_Isometric || CameraType == CAM_SideScroller)
  191.    {
  192.       tempRot = Rotation;
  193.       tempRot.Pitch = 0;
  194.       SetRotation(tempRot);
  195.       POVRot = Rotation;
  196.       POVRot.Pitch = 0;
  197.    }
  198.    else if(CameraType == CAM_FirstPerson)
  199.    {
  200.       POVRot = Rotation;
  201.       if( (Rotation.Yaw % 65535 > 16384 && Rotation.Yaw % 65535 < 49560) ||
  202.           (Rotation.Yaw % 65535 < -16384 && Rotation.Yaw % 65535 > -49560) )
  203.       {
  204.          POVRot.Yaw = 32768;
  205.       }
  206.       else
  207.       {
  208.          POVRot.Yaw = 0;
  209.       }
  210.          
  211.       if( POVRot.Pitch == 0 )
  212.       {
  213.          POVRot.Pitch = RemoteViewPitch << 8;
  214.       }
  215.    }
  216.    else
  217.    {
  218.       if( Controller != None && !InFreeCam() )
  219.       {
  220.          Controller.GetPlayerViewPoint(POVLoc, POVRot);
  221.          return POVRot;
  222.       }
  223.       else
  224.       {
  225.          POVRot = Rotation;
  226.          
  227.          if( POVRot.Pitch == 0 )
  228.          {
  229.             POVRot.Pitch = RemoteViewPitch << 8;
  230.          }
  231.       }
  232.    }
  233.  
  234.    return POVRot;
  235. }
  236.  
  237.  
  238. defaultproperties
  239. {
  240.    CameraType=CAM_Isometric;
  241.    bFollowPlayerRotation = false;
  242.    CamOffsetDistance=300
  243.    IsoCamAngle=4500 //35.264 degrees
  244. }
  245.  
Advertisement
Add Comment
Please, Sign In to add comment