3D d3d_transform_add_rotation

M

maelstrom

Guest
Is it ok to add several d3d_transform_add_rotation(s) together? ie. is this valid?

d3d_transform_set_identity();
d3d_transform_add_rotation_z(45);
d3d_transform_add_rotation_x(45);
d3d_transform_add_translation(x,y,0);
d3d_model_draw(model,0,0,0,tex);
d3d_transform_set_identity();

my problem is, I'm getting the z rotation but not the x? Is there info I'm missing?
 

kamiyasi

Member
The order of the events also matters.

d3d_transform_set_identity();
d3d_transform_add_rotation_x(0);
d3d_transform_add_rotation_y(0);
d3d_transform_add_rotation_z(0);
d3d_transform_add_scaling(1,1,1);
d3d_transform_add_translation(x,y,0);
d3d_transform_set_identity();

If you put translation before rotation you will have problems as well, so best to keep that in mind.
 
M

maelstrom

Guest
still not working? is it ok to follow rotations one line after another like this?

d3d_transform_add_rotation_x(45);
d3d_transform_add_rotation_z(45);

I'm definitely doing rotation before translation and I have rotation x before rotation z
 

Yal

šŸ§ *penguin noises*
GMC Elder
Keep in mind that rotation_x rotates around the x axis, so it affects the Y and Z coordinates of the thing you're drawing... not the X ones.
 
M

maelstrom

Guest
I'm trying to spin a tennis ball

In the draw event...

I want to apply rotation on the z axis (z axis being the one the viewer looks down into the screen)
I want to apply rotation on the x axis (x axis running left to right across screen)

then draw the result
 
M

maelstrom

Guest
fixed - in addition to what I learned above from your comments, I mistakenly assumed...

d3d_transform_add_rotation_x(45);

...would add this amount each draw event, causing a constant rotation. Having just tested this on a simple example, I know it not to be the case.
 

Juju

Member
Seems like you've answered your own question there. The model transformation matrix will get reset at the end of the Draw cycle.
 
Top