Advertisement
jewalky

Untitled

Jan 27th, 2017
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 KB | None | 0 0
  1. class SlopedThing : Candelabra
  2. {
  3.     Default
  4.     {
  5.         +FLATSPRITE;
  6.         //+ROLLCENTER;
  7.     }
  8.    
  9.     private void SetToSlope(double dang)
  10.     {
  11.         vector3 fnormal = CurSector.floorplane.normal;
  12.         vector2 fnormalp1 = (fnormal.x != 0 || fnormal.y != 0) ? (fnormal.x, fnormal.y).Unit() : (0, 0);
  13.         vector2 fnormalp2 = ((fnormal.x, fnormal.y).Length(), fnormal.z);
  14.         double fang = atan2(fnormalp1.y, fnormalp1.x); // floor angle (not pitch!)
  15.         double fpitch = atan2(fnormalp2.x, fnormalp2.y); // floor pitch
  16.         double ddiff1 = cos(fang-(dang-90));
  17.         double ddiff2 = cos(fang-dang);
  18.         self.pitch = fpitch*ddiff2-90;
  19.         self.roll = -fpitch*ddiff1;
  20.         self.angle = dang;
  21.     }
  22.    
  23.     override void PostBeginPlay()
  24.     {
  25.         Super.PostBeginPlay();
  26.     }
  27.    
  28.     override void Tick()
  29.     {
  30.         double dang = (level.time*3)%360;
  31.         //dang = 45;
  32.         SetToSlope(dang);
  33.         Super.Tick();
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement