Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var temp,r,inc,azi,alpha,coun,m,n,obj;
- temp = 0;
- count = 0;
- coun = 0;
- m = 0;
- n = 0;
- obj = 0;
- /*
- sin(x) Returns the sine of x (x in radians).
- cos(x) Returns the cosine of x (x in radians).
- tan(x) Returns the tangent of x (x in radians).
- arcsin(x) Returns the inverse sine of x.
- arccos(x) Returns the inverse cosine of x.
- arctan(x) Returns the inverse tangent of x.
- arctan2(y,x) Calculates arctan(Y/X), and returns an angle in the correct quadrant.
- degtorad(x) Converts degrees to radians.
- radtodeg(x) Converts radians to degrees.
- */
- if keyboard_check(ord('2'))
- {//3d transform x-down
- repeat(object_vertices[obj])
- {
- r = sqrt(sqr(object_y[obj,coun]) + sqr(object_z[obj,coun]));
- alpha = arctan2(object_y[obj,coun],object_z[obj,coun]) - pi/24;
- object_z[obj,coun] = r*cos(alpha);
- object_y[obj,coun] = r*sin(alpha);
- coun += 1;
- }
- coun = 0;
- }
- if keyboard_check(ord('8'))
- {//3d transform x-up
- repeat(object_vertices[obj])
- {
- r = sqrt(sqr(object_y[obj,coun]) + sqr(object_z[obj,coun]));
- alpha = arctan2(object_y[obj,coun],object_z[obj,coun]) + pi/24;
- object_z[obj,coun] = r*cos(alpha);
- object_y[obj,coun] = r*sin(alpha);
- coun += 1;
- }
- coun = 0;
- }
- if keyboard_check(ord('4'))
- {//3d transform y-left
- repeat(object_vertices[obj])
- {
- r = sqrt(sqr(object_x[obj,coun]) + sqr(object_z[obj,coun]));
- alpha = arctan2(object_z[obj,coun],object_x[obj,coun]) + pi/24;
- object_x[obj,coun] = r*cos(alpha);
- object_z[obj,coun] = r*sin(alpha);
- coun += 1;
- }
- coun = 0;
- }
- if keyboard_check(ord('6'))
- {//3d transform y-right
- repeat(object_vertices[obj])
- {
- r = sqrt(sqr(object_x[obj,coun]) + sqr(object_z[obj,coun]));
- alpha = arctan2(object_z[obj,coun],object_x[obj,coun]) - pi/24;
- object_x[obj,coun] = r*cos(alpha);
- object_z[obj,coun] = r*sin(alpha);
- coun += 1;
- }
- coun = 0;
- }
- if keyboard_check(ord('1'))
- {//3d transform z-counterclock
- repeat(object_vertices[obj])
- {
- r = sqrt(sqr(object_x[obj,coun]) + sqr(object_y[obj,coun]));
- alpha = arctan2(object_y[obj,coun],object_x[obj,coun]) - pi/24;
- object_x[obj,coun] = r*cos(alpha);
- object_y[obj,coun] = r*sin(alpha);
- coun += 1;
- }
- coun = 0;
- }
- if keyboard_check(ord('9'))
- {//3d transform z-clockwise
- repeat(object_vertices[obj])
- {
- r = sqrt(sqr(object_x[obj,coun]) + sqr(object_y[obj,coun]));
- alpha = arctan2(object_y[obj,coun],object_x[obj,coun]) + pi/24;
- object_x[obj,coun] = r*cos(alpha);
- object_y[obj,coun] = r*sin(alpha);
- coun += 1;
- }
- coun = 0;
- }
- repeat(12) //12 triangles
- {
- vertex_x[coun] = object_x[m,ref_x1[0,count]]*6;
- vertex_y[coun] = object_y[m,ref_y1[0,count]]*6;
- vertex_z[coun] = (object_z[m,ref_z1[0,count]] - 1000)*6;
- vertex_x[coun+1] = object_x[m,ref_x2[0,count]]*6;
- vertex_y[coun+1] = object_y[m,ref_y2[0,count]]*6;
- vertex_z[coun+1] = (object_z[m,ref_z2[0,count]] - 1000)*6;
- vertex_x[coun+2] = object_x[m,ref_x3[0,count]]*6;
- vertex_y[coun+2] = object_y[m,ref_y3[0,count]]*6;
- vertex_z[coun+2] = (object_z[m,ref_z3[0,count]] - 1000)*6;
- coun += 3;
- count += 1;
- }
- /*
- here comes the other object to triangle code
- */
- //empty Zbuffer
- surface_set_target(global.surid);
- draw_set_color(c_white);
- draw_rectangle(0,0,view_wport,view_hport,false);
- draw_set_color(c_black);
- surface_reset_target();
- repeat(view_hport)
- {
- repeat(view_wport)
- {
- global.Zbuffer[m,n] = -2147483647;
- m+=1;
- }
- n+=1;
- m = 0;
- }
Add Comment
Please, Sign In to add comment