Advertisement
jewalky

Untitled

Jan 27th, 2017
231
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.19 KB | None
  1. class SlopedThing : Candelabra
  2. {
  3.     Default
  4.     {
  5.         +FLATSPRITE;
  6.         //+ROLLCENTER;
  7.     }
  8.    
  9.     private double AngDiffAs10(double a1, double a2)
  10.     {
  11.         double r = cos(Normalize180(a2-a1));
  12.         return r;
  13.     }
  14.    
  15.     private void SetToSlope(double dang)
  16.     {
  17.         vector3 fnormal = CurSector.floorplane.normal;
  18.         if (!CurSector.floorplane.isSlope())
  19.             fnormal = (0, 0, 1);
  20.         vector2 fnormalp1 = (fnormal.x != 0 || fnormal.y != 0) ? (fnormal.x, fnormal.y).Unit() : (0, 0);
  21.         vector2 fnormalp2 = ((fnormal.x, fnormal.y).Length(), fnormal.z);
  22.         double fang = atan2(fnormalp1.y, fnormalp1.x); // floor angle (not pitch!)
  23.         double ddiff1 = AngDiffAs10(fang, dang-90);
  24.         double ddiff2 = AngDiffAs10(fang, dang);
  25.         self.pitch = atan2(fnormalp2.x, fnormalp2.y)*ddiff2-90;
  26.         self.roll = -atan2(fnormalp2.x, fnormalp2.y)*ddiff1;
  27.         self.angle = dang;
  28.     }
  29.    
  30.     override void PostBeginPlay()
  31.     {
  32.         Super.PostBeginPlay();
  33.     }
  34.    
  35.     override void Tick()
  36.     {
  37.         double dang = (level.time*3)%360;
  38.         //dang = 45;
  39.         SetToSlope(dang);
  40.         Super.Tick();
  41.     }
  42. }
Advertisement
RAW Paste Data Copied
Advertisement