Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2016
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.82 KB | None | 0 0
  1. #include "zcommon.acs"
  2.  
  3. function void DrawText3D(str text, int id, int color, int alpha, int x, int y, int z)
  4. {
  5.     int wd = 640;
  6.     int ht = 480;
  7.    
  8.     if (GetCVar("screenblocks") < 11) ht -= 64;
  9.     if (z > 0) return;
  10.    
  11.     // modify scale based on z.
  12.     int scale = -z / ht;
  13.     wd = FixedMul(wd<<16, scale)>>16;
  14.     ht = FixedMul(ht<<16, scale)>>16;
  15.    
  16.     int hwd = wd/2;
  17.     int hht = ht/2;
  18.     int KP = hwd;
  19.    
  20.     SetHudSize(wd, ht, 0);
  21.     int tX = ((FixedDiv(x, z)*KP)>>16)+hwd;
  22.     int tY = ((FixedDiv(y, z)*KP)>>16)+hht;
  23.     HudMessage(s:text; HUDMSG_PLAIN|HUDMSG_NOWRAP|HUDMSG_ALPHA, id, color, tX<<16, tY<<16, 0.1, alpha);
  24. }
  25.  
  26. function int Scale12(int i) { return FixedMul(i, 1.2); }
  27. function int Abs(int i) { if (i < 0) return -i; return i; }
  28.  
  29. function void DrawText3DTrans(str text, int id, int color, int alpha, int x, int y, int z, int px, int py, int pz, int fang, int YAng)
  30. {
  31.     fang += 0.25;
  32.     fang = (fang+1.0) % 1.0;
  33.    
  34.     //z = Scale12(z);
  35.     //pz = Scale12(pz);
  36.     //YAng += 0.25;
  37.     //printbold(f:YAng);
  38.    
  39.     x -= px;
  40.     y -= py;
  41.     z -= pz;
  42.  
  43.     int dst = VectorLength(z, VectorLength(x, y)) / 512;
  44.     int fix = 1.13826;
  45.     //printbold(f:fix);
  46.     //int fix = 1.2;
  47.     //
  48.    
  49.     // one-sided adjustment.
  50.     // disclaimer: I DON'T FUCKING KNOW HOW THIS WORKS O_O
  51.     int yangmul = 1.0-(Abs(YAng)*4);
  52.     YAng = FixedMul(YAng, 1.0+FixedMul(0.235, yangmul));
  53.     z = Scale12(z);
  54.    
  55.     YAng = (YAng+2.0) % 1.0;
  56.    
  57.     int x1s, z1s;
  58.     x1s = FixedMul(y, sin(fang)) + FixedMul(x, cos(fang));
  59.     z1s = FixedMul(y, cos(fang)) - FixedMul(x, sin(fang));
  60.    
  61.     x = x1s;
  62.     y = FixedMul(z, cos(YAng)) - FixedMul(z1s, sin(YAng));
  63.     z = FixedMul(z, sin(YAng)) + FixedMul(z1s, cos(YAng));
  64.    
  65.     DrawText3D(text, id, color, alpha, x, y, z);
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement