# 3DHow do I find the next coordinates after transformations

R

#### RedGhost

##### Guest
I use 3D transformations (the directions to be specific) to rotate a model along all 3D axis's.(Axi?)

However, I want to draw the same model directly above the centerpoint of the top surface of the previous model.

Both models are 32 width, 16 depth and 32 high. The lower model rotates around on the lowert surface's middle point. I want the higher model rotating on the middle point of the top surface of the lower model..
It's for a basic 3D animator using body segments. The two models both compose the body.

How could I achieve such task?

Thanks in advance!

#### flyingsaucerinvasion

##### Member
You have to add transformations in the right order. Here, thing 2 to should be attached to thing 1, thing 2 should follow all of thing 1's transformations, while having its own translation relative to thing 1 (along thing 1's y axis), and while also rotating around its own z axis.
Code:
``````thing_1_rot_x++;
thing_2_rot_z++;

//draw thing 1
d3d_transform_set_rotation_x(thing_1_rot_x);
d3d_transform_add_translation(x,y,0);
draw_sprite(sprite1,0,0,0);

//draw thing 2
//apply thansformations for thing 2 relative to thing 1
d3d_transform_set_rotation_z(thing_2_rot_z);
d3d_transform_add_translation(0,thing_2_y,0);
//then apply thing 1 transformations
d3d_transform_add_rotation_x(thing_1_rot_x);
d3d_transform_add_translation(x,y,0);
draw_sprite(spr_circle,0,0,0);

//reset identity
d3d_transform_set_identity();``````

here's the same thing using matrices. The matrices would only need to be rebuilt and multiplied in the event that any of the transformations have changed.
Code:
``````thing_1_rot_x++;
thing_2_rot_z++;

thing_1_mat = matrix_build(x,y,0,thing_1_rot_x,0,0,1,1,1);
thing_2_mat = matrix_build(0,thing_2_y,0,0,0,thing_2_rot_z,1,1,1);

matrix_set(matrix_world,thing_1_mat);
draw_sprite(sprite1,0,0,0);
matrix_set(matrix_world,matrix_multiply(thing_2_mat,thing_1_mat));
draw_sprite(spr_circle,0,0,0);
d3d_transform_set_identity();``````

Last edited: