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 / pitch problems

Author
Message
JAW_THE_KILLER
8
Years of Service
User Offline
Joined: 23rd Feb 2011
Location:
Posted: 1st Mar 2011 20:59
Whenever I use the pitch object up command, it sets the objects Y angle to 0 while it's pitching, then sets its Y angle back to whatever it was before. Is this suppossed to happen, or am I missing something?

you are what you eat, and I eat noobs, so...
BN2 Productions
15
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 2nd Mar 2011 06:50
Sounds like you have some weird code, since there is no "while it's pitching", it just does it instantly. Post your code in the code tags and we can check it out.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
JAW_THE_KILLER
8
Years of Service
User Offline
Joined: 23rd Feb 2011
Location:
Posted: 3rd Mar 2011 20:13
here's the code im having trouble with


you are what you eat, and I eat noobs, so...
Latch
13
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 3rd Mar 2011 22:52
Pitch, Roll, and Turn, are not interchangeable with rotate object or xrotate,yrotate, and zrotate.

Pitch Roll and Turn adjust the angle of an object based on it's current orientation. You can consider these as relative rotations. Rotate Object, can be considered an absolute rotation because it affects specific axis rotations.

Pitch Roll and Turn may affect multiple axis rotations depending on the orientation of the object. Therefore, if you query an angle (say object angle y()) after performing Pitch, the orientation may not be what you expect because Pitch is changing the orientation of multiple axes at once.

If you look up Euler angles, it should help you understand what is going on.

Let's say I use Roll object left 180. That should be the same as zrotate object 180, right? Not necessarily in terms of calculating the orientation of the object. I could arrive at the same orientation by rotating the object's x and y angles 180 degrees:

rotate object <objnum>,180,180,0

Enjoy your day.
Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 4th Mar 2011 18:56 Edited at: 4th Mar 2011 21:28
[you didn't see me right?]


Everything worthwhile requires effort.
JAW_THE_KILLER
8
Years of Service
User Offline
Joined: 23rd Feb 2011
Location:
Posted: 4th Mar 2011 20:18
I think I understand what you are saying, but let me use an example to illustrate what I mean;
Mr. Boxy lives in a fixed camera world. He starts out facing away from the camera (Y angle = 0), but then turns to his right 30 degrees or so. When Mr. Boxy goes through my loop snippet thingy up there, he faces 0 degrees with respect to the worlds Y axis. When the loop is over, he returns to the 30 or so degree angle he was at before.

Does this help, or am I still missing your point(s)?

you are what you eat, and I eat noobs, so...
Latch
13
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Mar 2011 20:50 Edited at: 4th Mar 2011 20:51
Quote: "To simplify what Latch said:"

It's more than just relative vs absolute orientation. Pitch, roll, and turn may arrive at the final orientation of the object by combining multiple rotations around multiple axes. Back to the example I posted above, if your object starts at 0 degrees and you rotate it 180 degrees around the z axis, it will still be facing the same direction, but it's top will be pointing downward. Now, you can arrive at this same orientation starting at 0 degrees by rotating around the x axis 180 degrees and rotating around the y axis 180 degrees.

Pitch, roll, and turn may or may not use combinations of rotations around axes, therefore when you query the object's angle on a particular axis, it may not be what you expect.

For example, lets use pitch (relative x axis rotation) and turn (relative y axis rotation) to rotate a cube in the manner discussed above. We'll query the orientation of x y and z and notice that the only rotation that is significant is a z axis rotation of 180 degrees:



Enjoy your day.
Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 4th Mar 2011 21:27
Yes, that's what I was trying to get across, that no matter where your object is pointing the relative rotation will act in the same way but absolute rotation acts differently because it is working from the orientation that it started at. That is right isn't it? I'm getting confused now

Sorry I think I'm just complicating things because I have totally confused myself! I will go home and test it out.


Everything worthwhile requires effort.
Latch
13
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Mar 2011 22:55 Edited at: 4th Mar 2011 22:59
@Jaw
The timing of your posts appearing in the thread is behind the time we are posting responses so we may not see them until after we've already posted. So I'm not sure if you last question has been answered or not.

@Obese
Quote: "Yes, that's what I was trying to get across, that no matter where your object is pointing the relative rotation will act in the same way but absolute rotation acts differently because it is working from the orientation that it started at. That is right isn't it? I'm getting confused now"

I guess I meant that the object could be at zero degrees rotation where absolute and relative rotation starting angles are the same. If a turn object command is given (y rotation) and a pitch command is given (x rotation) the object may end up in the same orientation that a yrotate and an xrotate command may have given it, but upon looking at the angles using object angle x() object angle y() and object angle z() the final reported angles may be different depending on whether you used pitch roll turn, or rotate object - even though the starting orientation and the final orientation is the same and the same angles were used for the rotate and the pitch/roll/turn commands.

Yes, you are right that the relative rotation will act the same in controlling the object, but the question was why is the objects Y angle flipping to 0 when the object is pitching then it goes back to the direction it was facing. So you're answer and shortened version of my answer is correct, but I just wanted to be sure my answer was complete.

@Jaw
After all this is said and done, the reason the y angle behaves unexpectedly is because in the calculations for the relative pitch for the object, DBC has to recalculate the y angle to keep the object orientation the same as the object is pitching.

Enjoy your day.
JAW_THE_KILLER
8
Years of Service
User Offline
Joined: 23rd Feb 2011
Location:
Posted: 7th Mar 2011 20:15
Ok, thanks for the info. Can you suggest a way to make a box backflip without using the "pitch object up" command?

you are what you eat, and I eat noobs, so...
BN2 Productions
15
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 8th Mar 2011 00:48
You will want to use the XROTATE OBJECT, YROTATE OBJECT, and ZROTATE OBJECT. Keep in mind, these use absolute angle values, so you will want to use a setup similar to

XROTATE OBJECT 1,wrapvalue(OBJECT ANGLE X(1)+AngleToTurn)

Wrapvalue will take whatever the number is within the brackets and adjust it so that it is within 0 and 360 and is required for this command.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
JAW_THE_KILLER
8
Years of Service
User Offline
Joined: 23rd Feb 2011
Location:
Posted: 8th Mar 2011 21:12
@BN2 Productions
Ok, I tried this, and it did exactly what I thought it would. It rotated the object with respect to the world's x axis, and I want it to rotate about the object's x axis. I understand you can use combinations of those commands to create the desired effect, but I want to know how to do this using a changing absolute Y angle, so the box will backflip depending on its orientation.

you are what you eat, and I eat noobs, so...
Latch
13
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 9th Mar 2011 01:04
This is where using a pivot object or pivot limb comes in handy. A pivot object or limb is something that remains in a fixed orientation to which the main object is attached.

For example, let's say you build a human character that you want to back flip. The root limb might be a tiny plane or a tiny triangle. The main character is built attached to this limb. Whenever you position the character in 3d space, you position the root object. When you Y rotate the the character, you Y rotate the root. But whenever you X and Z rotate the character as a whole, you rotate the limb attached to the root (maybe the hips or the body depending on how the character was built.

This will allow you to change the y direction of the character and the world position without there being an influence by the X and Z angles (as long as you don't rotate the root.

A version of this without having the pivot limb built in is using glue object to limb. You would create a plane or a triangle, and Glue the character to limb 0 of the plane or triangle. For example:



Move the plain around and the human will move with it. Steer the plain (yrotate) and the human will steer. Back flip the human by x rotating object 1 (not the plain) as BN2 describes above.

This is a quick solution and will work well most of the time. Gluing though, will interfere with the glued object's collision testing because it's true position is not updated internally when glued. It's rendered (drawn) position is relative to the object it is glued to - but it's absolute position is not updated with the positioning of the pivot object. And if you hide the pivot object, move it, the glued object won't update until the pivot object is visible.

For these reasons, a pivot limb is a better choice, but if you are careful, you can use gluing the object to a pivot.

Enjoy your day.
JAW_THE_KILLER
8
Years of Service
User Offline
Joined: 23rd Feb 2011
Location:
Posted: 9th Mar 2011 20:24
@Latch
Thank you so much, it's working perfectly now! I never would have thought (and obviously I didn't) that making the box into a limb would have changed how the Pitch Object Up command affects it.

you are what you eat, and I eat noobs, so...
Latch
13
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 14th Mar 2011 22:45 Edited at: 14th Mar 2011 22:48
Great! I'm glad you got it working.

Enjoy your day.

Login to post a reply

Server time is: 2019-08-21 20:53:47
Your offset time is: 2019-08-21 20:53:47