Jump to content

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Need Help with 3D rotations

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 Hooden   Members   

122
Like
Likes
Like

Posted 19 August 1999 - 05:01 PM

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.


#2 FlyFire   Members   

122
Like
Likes
Like

Posted 13 August 1999 - 08:37 PM

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


#3 Hooden   Members   

122
Like
Likes
Like

Posted 18 August 1999 - 02:06 AM

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.

#4 White Fire   Members   

122
Like
Likes
Like

Posted 19 August 1999 - 05:01 PM

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





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.