Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Hooden

Need Help with 3D rotations

This topic is 6913 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I think you are messed up with formulas.
I use the following:
- Around X axis
y1:=cbuffer[i].Y*Cos(xang)-cbuffer[i].z*sin(xang);
z1:=cbuffer[i].Y*Sin(xang)+cbuffer[i].z*cos(xang);
cBuffer[i].Y:=y1;
cBuffer[i].Z:=z1;

and soon...

FlyFire/CodeX
http://codexorg.webjump.com

Share this post


Link to post
Share on other sites
Advertisement
Thanks for the reply, but thats the same thing in a different form. I figured it out: its strange: all i did was change all my variables to doubles and it magically worked.

Share this post


Link to post
Share on other sites
Just goes to show you... unless memory is *really* tight, use doubles!

Btw, that code is basically a matrix multiplication, just unrolled.

Have fun,

White Fire

Share this post


Link to post
Share on other sites
Thanks for reading this. I am working on a 3D engine and i cant get my rotations working. When I press the key to start the z axis rotation, the square goes back into the z(the z value increases). And when i do a x or y axis rotation, the z value decreases(it comes towards the screen). Here are the formulas that i am using:

X:
-----
temp_y = (rect_3d.vert[i].y*cos(x_ang)) + (rect_3d.vert[i].z*sin(x_ang));
temp_z = (rect_3d.vert[i].y *-sin(x_ang)) + (rect_3d.vert[i].z*cos(x_ang));

rect_3d.vert[i].y = temp_y;
rect_3d.vert[i].z = temp_z;

Y:
-----
temp_x = (rect_3d.vert[i].x*cos(y_ang)) + (rect_3d.vert[i].z*-sin(y_ang));
temp_z = (rect_3d.vert[i].x *sin(y_ang)) + (rect_3d.vert[i].z*cos(z_ang));

rect_3d.vert[i].x = temp_x;
rect_3d.vert[i].z = temp_z;

Z:
-----
temp_x = (rect_3d.vert[i].x*cos(z_ang)) + (rect_3d.vert[i].y*sin(z_ang));
temp_y = (rect_3d.vert[i].x*-sin(z_ang)) + (rect_3d.vert[i].y*cos(z_ang));

rect_3d.vert[i].x = temp_x;
rect_3d.vert[i].y = temp_y;

--------
Any help would be appreciated, and yes i know i should use matrices.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!