Legacy GM Rotation 3d blocks individually

D

DekuNut

Guest
So I want the blocks that I draw for each instance to rotate individually, but the seem to all rotate together on the same plane. The desired effect is that they all just spin in place.

Code:
d3d_transform_set_identity();
d3d_transform_add_rotation_y(x+rotate);
d3d_draw_block(x, y, 0, 
                x+sprite_width, y+sprite_height, 5,
                sprite_get_texture(spr_TileBlack, 0), 1, 1);
d3d_transform_set_identity();
draw_set_colour(c_white);
 
M

Misu

Guest
Well you are doing two things wrong.

For what you are trying to do requires to use d3d_transform_add_translation() which you not using. That function is used to place the actual relative position of the model, indicating where exactly it should rotate (orbit) around. So you should move your xyz position to that function. Now the other thing is drawing the block not centralized (assuming that is the opposite you are trying to perform as well). To draw a model centralized that depends also on the translation setting, youll need to use the half size. For example, if you are drawing like the following: 0,0,0, 5,5,5 then you are not centralizing it. You making the origin at 0,0,0 (just like sprite logic). You'll need to balance the value between negative and positive in a way you use the half of its actual size in order to make it centralize; something like this: -2.5,-2.5,-2.5, 2.5,2.5,2.5 That is considered a centralized block. However, to even its position out base on this centralize drawing, you'll need to sum up the xyz position in the translation with the half of its size.

Code:
d3d_transform_set_identity();
d3d_transform_add_rotation_y(x+rotate);
d3d_transform_add_translation(x+(sprite_width/2),y+(sprite_height/2),2.5)
d3d_draw_block(-(sprite_width/2),-(sprite_height/2), -2.5,
               (sprite_width/2),(sprite_height/2), 2.5,
               sprite_get_texture(spr_TileBlack, 0), 1, 1);
d3d_transform_set_identity();
draw_set_colour(c_white);
Also I dunno why you are applying the relative x position into the y rotation.
 
Top