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.

DarkBASIC Discussion / Free flight rotation

Author
Message
BN2 Productions
16
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 20th Sep 2010 07:42
After running into some angle value issues due to the TURN PITCH and ROLL OBJECT commands, I have decided to try to switch my program over to using XROTATE, YROTATE, and ZROTATE to control pitch, yaw, and roll.

Here is the problem that has developed:
There seems to be no order to do these things that will make it work.
When object rotation is set to XYZ, the Y and Z axes that are used for rotation are the object's local axes. That is, the Y axis is always coming out the top (even if the top is pointing downward) and Z is always coming out the front. X however, remains along the world X axis. So if the object is turned 90 degrees and you try to adjust the X angle, it rolls instead of pitching up/down.

When the rotation is set to ZYX, the X angle seems local and Y and Z angles are global. Essentially it is the opposite of the other method.

I tried using some trig to figure out the correct rotation values for the Y and Z axes in the ZYX rotation system, but I couldn't get appropriate results.

Has anyone done this or have an idea on something else to try?

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Latch
14
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 20th Sep 2010 20:12 Edited at: 20th Sep 2010 20:17
This is where the beauty of using pivot objects or limbs as pivot points comes into play.

You could use glue object, and glue an object to another object that is fixed to the camera. You can then rotate the glued object independently. Or, you could use limbs to the same effect. I prefer to us limbs because the glue object command can be quirky in many situations.

Here's some code quickly knocked together to show the process. The controls are a little lacking, but you could make those whatever you want; the concept is still sound. The main object is positioned and oriented to the camera. A limb (the ship) is offset ahead of the main object. The main object is rotated with the camera's x and y angles. The ship is then allowed to roll and bank by rotating the limb's z axis.

Use < > to decrease or increase speed
UP Down arrows to pitch up or down
left right arrows to bank and turn
move mouse left or right to roll (though I didn't account for the influence of banking here)



Enjoy your day.
29 games
14
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 20th Sep 2010 23:05 Edited at: 20th Sep 2010 23:06
That's a pretty good idea, Latch. I've had simillar problems with the rotation and angle commands and have never sorted it out to my satisfaction.

This might be off topic but what I did for a rolling ball demo is to use the "fix object pivot" command. This gives the problem of essentially losing the object's direction but this may not matter, depending on what you're trying to do.




I also tried something with memblocks but it didn't work out mainly because I also had to recalculate the directions of the normals which was causing a problem (I think it was due to float errors).
Latch
14
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 21st Sep 2010 02:16 Edited at: 21st Sep 2010 02:19
Quote: "I also tried something with memblocks but it didn't work out mainly because I also had to recalculate the directions of the normals which was causing a problem (I think it was due to float errors)."


I was using memblocks for my rubiks cube demo that is in one of the last few DBC challenges. Once the normals are set, you can rotate them just like you would rotate the vertices. Since the normals are relative to the vertices, they will be aligned correctly if the same rotation is applied. The things you wouldn't change are the faces or the UVs. But in my demo, to save time, I only rotated the verts. It actually gives a better effect with the lighting in my opinion

Enjoy your day.

Login to post a reply

Server time is: 2020-08-12 02:57:06
Your offset time is: 2020-08-12 02:57:06