Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Rotating a cube?

Author
Message
PrimaryDimension
22
Years of Service
User Offline
Joined: 1st Nov 2002
Location:
Posted: 10th Feb 2003 00:20
I'm trying to rotate a cube using the arrow keys, one face at a time keeping the camera set in one constant direction. I can yrotate fine. Xrotate works fine until the Y angle of the cube is 90 or 270 degrees, then the cube spins sideways. I realize that the perspective of the cube has changed, so I tried zrotate when the Y angle = 90 or 270 degrees. It did the same thing as xrotate. How can I make the cube rotate up and down from the cameras perspective when the Y angle is 90 or 270 degrees. If someone could write some example code of how to rotate a cube correctly I would greatly appreciate it.
Gilfalas
21
Years of Service
User Offline
Joined: 26th Jan 2003
Location: Luxembourg
Posted: 10th Feb 2003 00:50
I know what you mean, and I can try to give you an explanation. Please excuse my bad english. Imagine your 3 dimensional vectors X,Y,Z as lines in space. Y facing up, X pointing to your right and Z to the front of you. Now if you rotate your object by 90 degrees clockwise along the Y axis, all the sudden, X is pointing behind you and Z to your right. This is why your object will seem to rotate arround the Z axis instead of X axis and vice versa.

The way to handle this would be to create your cube, and another invisible object (we will call it tilt object). Glue those two objects together using the glue object to limb command. Only use the tilt object (invisible one) to do the Y axis rotation and your cube to handle X and Z rotation.

I'll try to fix a piece of code quickly and post it.

Gilfalas
21
Years of Service
User Offline
Joined: 26th Jan 2003
Location: Luxembourg
Posted: 10th Feb 2003 01:03


Gilfalas
21
Years of Service
User Offline
Joined: 26th Jan 2003
Location: Luxembourg
Posted: 10th Feb 2003 01:04
Hope this solves your problem. Best I could come up with in 10 minutes.

Login to post a reply

Server time is: 2024-11-24 01:54:47
Your offset time is: 2024-11-24 01:54:47