Advertisement
Guest User

Cube rotation axis coincide to cube wall script

a guest
Aug 15th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.12 KB | None | 0 0
  1. function void draw_cube_rot_axis (void)
  2. {
  3.  int x, y, z, d, t1, t2, t3, a, b, c;
  4.  int e = fixeddiv(2.0, sqrt_3);
  5.  int height = fixedmul(0.82, 56.0 + getVariable(radius));
  6.  thing_remove(getVariable(projectile_tag));
  7.     if(getVariable(rot_axis) && getVariable(radius)>34.65 && getVariable(pr_num))
  8.     {
  9.       //-----------------------------------------------------------------------------------------------
  10.         x = fixedmul(cos(getVariable(azimuth)), sin(getVariable(polar_angle)));
  11.         y = fixedmul(sin(getVariable(azimuth)), sin(getVariable(polar_angle)));
  12.         z = cos(getVariable(polar_angle));
  13.       //-----------------------------------------------------------------------------------------------
  14.         a = fixeddiv(X_rot[2][1073] - X_rot[0][1073], e);
  15.         b = fixeddiv(Y_rot[2][1073] - Y_rot[0][1073], e);
  16.         c = fixeddiv(Z_rot[2][1073] - Z_rot[0][1073], e);
  17.         d = -(fixedmul(a, X_rot[2][1073])+fixedmul(b, Y_rot[2][1073])+fixedmul(c, Z_rot[2][1073]));
  18.         t1 = fixeddiv(-d, fixedmul(a, x)+fixedmul(b, y)+fixedmul(c, z));
  19.         log(s:"t1 = ", f:t1);
  20.         if(t1<0) t1=-t1;
  21.       //-----------------------------------------------------------------------------------------------
  22.         a = fixeddiv(X_rot[2][1073] - X_rot[3][1073], e);
  23.         b = fixeddiv(Y_rot[2][1073] - Y_rot[3][1073], e);
  24.         c = fixeddiv(Z_rot[2][1073] - Z_rot[3][1073], e);
  25.         d = -(fixedmul(a, X_rot[2][1073])+fixedmul(b, Y_rot[2][1073])+fixedmul(c, Z_rot[2][1073]));
  26.         t2 = fixeddiv(-d, fixedmul(a, x)+fixedmul(b, y)+fixedmul(c, z));
  27.         log(s:"t2 = ", f:t2);
  28.         if(t2<0) t2=-t2;
  29.       //-----------------------------------------------------------------------------------------------
  30.         a = fixeddiv(X_rot[2][1073] - X_rot[6][1073], e);
  31.         b = fixeddiv(Y_rot[2][1073] - Y_rot[6][1073], e);
  32.         c = fixeddiv(Z_rot[2][1073] - Z_rot[6][1073], e);
  33.         d = -(fixedmul(a, X_rot[2][1073])+fixedmul(b, Y_rot[2][1073])+fixedmul(c, Z_rot[2][1073]));
  34.         t3 = fixeddiv(-d, fixedmul(a, x)+fixedmul(b, y)+fixedmul(c, z));
  35.         log(s:"t3 = ", f:t3);
  36.         if(t3<0) t3=-t3;
  37.       //-----------------------------------------------------------------------------------------------
  38.         if(t1<t2)d = t1; else d = t2;
  39.         if(d<t3)t1 = d; else t1 = t3;
  40.       //-----------------------------------------------------------------------------------------------
  41.         //if(1.0 - t1 > 0.001) good use t1; else draw to corner vertex;
  42.         if(1.0 - t1 > 0.001)
  43.         {
  44.             x = fixedmul(x, t1);
  45.             y = fixedmul(y, t1);
  46.             z = fixedmul(z, t1);
  47.             e = (getVariable(radius)/20)>>16;
  48.             if(e>0)
  49.             {
  50.                 for(t2 = 0; t2<e; t2++)
  51.                 {
  52.                     t3 = fixeddiv(t2 << 16, (e-t2-1) << 16);
  53.                     a=fixeddiv(0.0 + fixedmul(t3, x), 1.0+t3);
  54.                     b=fixeddiv(0.0 + fixedmul(t3, y), 1.0+t3);
  55.                     c=fixeddiv(0.0 + fixedmul(t3, z), 1.0+t3);
  56.                     Spawnprojectile(2, projectile_class[3], 0, 1, 0, 0, getVariable(projectile_tag));
  57.                     SetActorVelocity(getVariable(projectile_tag), 0.0, 0.0, 0.0, false, false);
  58.                     SetActorPosition(getVariable(projectile_tag), GetActorX(1)+fixedmul(getVariable(radius), a),
  59.                                                                   GetActorY(1)+fixedmul(getVariable(radius), b),
  60.                                                                   GetActorZ(1)+height+FixedMul(getVariable(radius), fixedmul(c, 0.82)), 0);                                            
  61.                 }
  62.                 SetActorPosition(getVariable(projectile_tag), GetActorX(1)+fixedmul(getVariable(radius), x),
  63.                                                               GetActorY(1)+fixedmul(getVariable(radius), y),
  64.                                                               GetActorZ(1)+height+FixedMul(getVariable(radius), fixedmul(z, 0.82)), 0);
  65.             }
  66.         }
  67.         else draw_sphere_rot_axis();
  68.     }
  69.     else if(getVariable(rot_axis) && getVariable(pr_num))log(s:"Radius is too little");
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement