Guest User

Step Event

a guest
Sep 26th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var temp,r,inc,azi,alpha,coun,m,n,obj;
  2. temp = 0;
  3. count = 0;
  4. coun = 0;
  5. m = 0;
  6. n = 0;
  7. obj = 0;
  8.  
  9. /*
  10. sin(x) Returns the sine of x (x in radians).
  11. cos(x) Returns the cosine of x (x in radians).
  12. tan(x) Returns the tangent of x (x in radians).
  13. arcsin(x) Returns the inverse sine of x.
  14. arccos(x) Returns the inverse cosine of x.
  15. arctan(x) Returns the inverse tangent of x.
  16. arctan2(y,x) Calculates arctan(Y/X), and returns an angle in the correct quadrant.
  17. degtorad(x) Converts degrees to radians.
  18. radtodeg(x) Converts radians to degrees.
  19. */
  20.  
  21.  
  22. if keyboard_check(ord('2'))
  23. {//3d transform x-down
  24.     repeat(object_vertices[obj])
  25.     {
  26.     r = sqrt(sqr(object_y[obj,coun]) + sqr(object_z[obj,coun]));
  27.     alpha = arctan2(object_y[obj,coun],object_z[obj,coun]) - pi/24;
  28.     object_z[obj,coun] = r*cos(alpha);
  29.     object_y[obj,coun] = r*sin(alpha);
  30.     coun += 1;
  31.     }
  32. coun = 0;
  33. }
  34. if keyboard_check(ord('8'))
  35. {//3d transform x-up
  36.     repeat(object_vertices[obj])
  37.     {
  38.     r = sqrt(sqr(object_y[obj,coun]) + sqr(object_z[obj,coun]));
  39.     alpha = arctan2(object_y[obj,coun],object_z[obj,coun]) + pi/24;
  40.     object_z[obj,coun] = r*cos(alpha);
  41.     object_y[obj,coun] = r*sin(alpha);
  42.     coun += 1;
  43.     }
  44. coun = 0;
  45. }
  46. if keyboard_check(ord('4'))
  47. {//3d transform y-left
  48.     repeat(object_vertices[obj])
  49.     {
  50.     r = sqrt(sqr(object_x[obj,coun]) + sqr(object_z[obj,coun]));
  51.     alpha = arctan2(object_z[obj,coun],object_x[obj,coun]) + pi/24;
  52.     object_x[obj,coun] = r*cos(alpha);
  53.     object_z[obj,coun] = r*sin(alpha);
  54.     coun += 1;
  55.     }
  56. coun = 0;
  57. }
  58. if keyboard_check(ord('6'))
  59. {//3d transform y-right
  60.     repeat(object_vertices[obj])
  61.     {
  62.     r = sqrt(sqr(object_x[obj,coun]) + sqr(object_z[obj,coun]));
  63.     alpha = arctan2(object_z[obj,coun],object_x[obj,coun]) - pi/24;
  64.     object_x[obj,coun] = r*cos(alpha);
  65.     object_z[obj,coun] = r*sin(alpha);
  66.     coun += 1;
  67.     }
  68. coun = 0;
  69. }
  70. if keyboard_check(ord('1'))
  71. {//3d transform z-counterclock
  72.     repeat(object_vertices[obj])
  73.     {
  74.     r = sqrt(sqr(object_x[obj,coun]) + sqr(object_y[obj,coun]));
  75.     alpha = arctan2(object_y[obj,coun],object_x[obj,coun]) - pi/24;
  76.     object_x[obj,coun] = r*cos(alpha);
  77.     object_y[obj,coun] = r*sin(alpha);
  78.     coun += 1;
  79.     }
  80. coun = 0;
  81. }
  82. if keyboard_check(ord('9'))
  83. {//3d transform z-clockwise
  84.     repeat(object_vertices[obj])
  85.     {
  86.     r = sqrt(sqr(object_x[obj,coun]) + sqr(object_y[obj,coun]));
  87.     alpha = arctan2(object_y[obj,coun],object_x[obj,coun]) + pi/24;
  88.     object_x[obj,coun] = r*cos(alpha);
  89.     object_y[obj,coun] = r*sin(alpha);
  90.     coun += 1;
  91.     }
  92. coun = 0;
  93. }
  94.  
  95. repeat(12) //12 triangles
  96. {
  97. vertex_x[coun] = object_x[m,ref_x1[0,count]]*6;
  98. vertex_y[coun] = object_y[m,ref_y1[0,count]]*6;
  99. vertex_z[coun] = (object_z[m,ref_z1[0,count]] - 1000)*6;
  100. vertex_x[coun+1] = object_x[m,ref_x2[0,count]]*6;
  101. vertex_y[coun+1] = object_y[m,ref_y2[0,count]]*6;
  102. vertex_z[coun+1] = (object_z[m,ref_z2[0,count]] - 1000)*6;
  103. vertex_x[coun+2] = object_x[m,ref_x3[0,count]]*6;
  104. vertex_y[coun+2] = object_y[m,ref_y3[0,count]]*6;
  105. vertex_z[coun+2] = (object_z[m,ref_z3[0,count]] - 1000)*6;
  106. coun += 3;
  107. count += 1;
  108. }
  109.  
  110. /*
  111. here comes the other object to triangle code
  112. */
  113.  
  114. //empty Zbuffer
  115. surface_set_target(global.surid);
  116. draw_set_color(c_white);
  117. draw_rectangle(0,0,view_wport,view_hport,false);
  118. draw_set_color(c_black);
  119. surface_reset_target();
  120. repeat(view_hport)
  121. {
  122.     repeat(view_wport)
  123.     {
  124.     global.Zbuffer[m,n] = -2147483647;
  125.     m+=1;
  126.     }
  127. n+=1;
  128. m = 0;
  129. }
Add Comment
Please, Sign In to add comment