Advertisement
jewalky

Untitled

Jan 27th, 2017
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.34 KB | None | 0 0
  1.  
  2. class SlopedThing : Candelabra
  3. {
  4.     Default
  5.     {
  6.         +FLATSPRITE;
  7.         //+ROLLCENTER;
  8.     }
  9.    
  10.     private double Sign(double d)
  11.     {
  12.         if (d < 0) return -1.0;
  13.         if (d > 0) return 1.0;
  14.         return 0.0;
  15.     }
  16.    
  17.     private void SetToSlope(double dang)
  18.     {
  19.         vector3 fnormal = CurSector.floorplane.normal;
  20.         if (!CurSector.floorplane.isSlope())
  21.             fnormal = (0, 0, 1);
  22.         vector2 fnormalp1 = (fnormal.x != 0 || fnormal.y != 0) ? (fnormal.x, fnormal.y).Unit() : (0, 0);
  23.         vector2 fnormalp2 = ((fnormal.x, fnormal.y).Length(), fnormal.z);
  24.         vector2 angnormal1 = (cos(dang-90), sin(dang-90)).Unit();
  25.         vector2 angnormal2 = (cos(dang), sin(dang)).Unit();
  26.         double ddiff1 = (angnormal1.x*fnormalp1.x+angnormal1.y*fnormalp1.y); // dot product
  27.         double ddiff2 = (angnormal2.x*fnormalp1.x+angnormal2.y*fnormalp1.y); // dot product
  28.         self.pitch = atan2(fnormalp2.x, fnormalp2.y)*ddiff2-90;
  29.         self.roll = -atan2(fnormalp2.x, fnormalp2.y);
  30.         self.roll *= ddiff1;
  31.         self.angle = dang;
  32.     }
  33.    
  34.     override void PostBeginPlay()
  35.     {
  36.         Super.PostBeginPlay();
  37.     }
  38.    
  39.     override void Tick()
  40.     {
  41.         double dang = (level.time*3)%360;
  42.         //dang = 45;
  43.         SetToSlope(dang);
  44.         Super.Tick();
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement