Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SlopedThing : Candelabra
- {
- Default
- {
- +FLATSPRITE;
- //+ROLLCENTER;
- }
- private double Sign(double d)
- {
- if (d < 0) return -1.0;
- if (d > 0) return 1.0;
- return 0.0;
- }
- private void SetToSlope(double dang)
- {
- vector3 fnormal = CurSector.floorplane.normal;
- if (!CurSector.floorplane.isSlope())
- fnormal = (0, 0, 1);
- vector2 fnormalp1 = (fnormal.x != 0 || fnormal.y != 0) ? (fnormal.x, fnormal.y).Unit() : (0, 0);
- vector2 fnormalp2 = ((fnormal.x, fnormal.y).Length(), fnormal.z);
- vector2 angnormal1 = (cos(dang-90), sin(dang-90)).Unit();
- vector2 angnormal2 = (cos(dang), sin(dang)).Unit();
- double ddiff1 = (angnormal1.x*fnormalp1.x+angnormal1.y*fnormalp1.y); // dot product
- double ddiff2 = (angnormal2.x*fnormalp1.x+angnormal2.y*fnormalp1.y); // dot product
- self.pitch = atan2(fnormalp2.x, fnormalp2.y)*ddiff2-90;
- self.roll = -atan2(fnormalp2.x, fnormalp2.y);
- self.roll *= ddiff1;
- self.angle = dang;
- }
- override void PostBeginPlay()
- {
- Super.PostBeginPlay();
- }
- override void Tick()
- {
- double dang = (level.time*3)%360;
- //dang = 45;
- SetToSlope(dang);
- Super.Tick();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement