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 / I'm so confused! I thought X was up and down?! Now its left and right?

Author
Message
Blazed666
16
Years of Service
User Offline
Joined: 21st Sep 2007
Location:
Posted: 28th Jan 2010 05:27
Ok on the 3.6 "camera controls" dark basic tutorial it says this:

if upkey()=1 then yPos=yPos+1
if downkey()=1 then yPos=yPos-1
if rightkey()=1 then xPos=xPos+1
if leftkey()=1 then xPos=xPos-1

it has x as left and right but then the next tutorial it has x and up and down?! I'm so confused???

if upkey()=1 then xAng=wrapvalue(xAng+1)
if downkey()=1 then xAng=wrapvalue(xAng-1)
if rightkey()=1 then yang=wrapvalue(yang+1)
if leftkey()=1 then yang=wrapvalue(yang-1)
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 28th Jan 2010 05:48
Looks like you are getting rotation and position mixed up.

Hold a pen out in front of you horizontally. That is your x axis. You can be positioned along that (so anywhere right or left). Now spin the pen. Notice that spinning on the x axis will cause something to tilt up and down? Same ideas apply to the Y axis, except the pen is vertical.

Does this make sense?

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Blazed666
16
Years of Service
User Offline
Joined: 21st Sep 2007
Location:
Posted: 28th Jan 2010 06:08
Sorry im a little slow i still dont understtand

how can you tell which is x and which is y if they can both be left to right and up to down?!?! ahhh!
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th Jan 2010 08:45 Edited at: 28th Jan 2010 08:59
Quote: "how can you tell which is x and which is y if they can both be left to right and up to down?!?! ahhh!"

It seems that you are reading UPKEY() ,DOWNKEY(), LEFTKEY(), RIGHTKEY() as meaning up (towards the sky), down (towards the earth) left and right. UPKEY(), DOWNKEY() etc. are the control names of the arrow keys on your keyboard. The names don't really mean anything except to tell you (and the computer) which key you are pressing.

The directions in the 3D world are their own thing, so try and separate your mind from the direction in the world and the name of the control keys.

The other thing that you seem to be confusing, is rotation versus position as BN2 mentioned above.

if upkey()=1 then xAng=wrapvalue(xAng+1)

What I can assume from this code is that the x ANGLE not the x coordinate or the x position, but the ANGLE is being changed by pressing the up arrow key. That means the object is tilting forward or backward not moving forward or backward or up or down.

if upkey()=1 then yPos=yPos+1

From this code, I can assume that the y POSITION is changing by pressing the up arrow key. This is different from an angle changing which would cause rotation or tilt.

In general, if you are looking straight into your computer screen, the axes' directions are Y is up and down, X is left and right, and Z is straight into the monitor.

I knocked together a small bit of code that will allow you to move the camera around on the screen. The program will display your current X,Y and Z position as well as the current angles the camera is rotated at. In the center of the screen is a 3D axis that show what direction you are currently heading.

Steer with the mouse including some limited looking up and down, and move forward or backward with the up and down arrows keys. You'll notice that if you change direction, pressing the UP KEY won't always mean what you think it will. The code may be too difficult for you to understand just yet, but it's really the running of the code and seeing how the directions you face can change and the axis you are on can switch that's important.

Copy the code into your dark basic editor and press F5 to run it:



Positions in the 3d world are given based on an X,Y and Z coordinate system. Up, Down, Left, and Right don't really exist because they are always relative to the current orientation of either the camera, or another object. Orientation means "how something is rotated." The camera could be upside down in the 3D world but relative to that view, "up" could be -Y which seems to be the opposite of what one would expect.

However, the world axes are always oriented the same way. While the camera can rotate, or an object can rotate, the world axes stay the same. If the camera hasn't rotated at all and is at 0,0,0, then up, relative to the camera is +Y. To the world, up is also +Y. Now let's say I rotated the camera on it's Z axes 90 degrees so that it is basically on it's side. You can try this yourself by laying on your side on the floor. Up, in relation to the camera, would be on the -X axis or in relation to where the top of your head would be pointing if you were laying on the floor on your side; but to the 3D world (not the camera), up is still +Y or towards the ceiling of your house in the real world.

Does that make any sense?

Enjoy your day.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th Jan 2010 09:54
IN a nutshell, the first example is 2D where X is left/right and Y is up/down on a flat plane - like a piece of paper or your monitor screen.

The second example is 3D and is talking about rotating an object on it's 3 axis.

Completely different things.

With axis rotation, just remember X-Y-Z as Motorbike-Golf-Key.

The X axis rotation is like the twist grip of a motorcycle accelerator (toward you and away from you), Y axis rotation as a flagpole turning in a hole at a golf course and Z axis rotation being the turning of a key in a door lock.

Remember that and you won't go far wrong.

TDK

Blazed666
16
Years of Service
User Offline
Joined: 21st Sep 2007
Location:
Posted: 28th Jan 2010 22:28
Thank you guys!!!! Latch, that example there was veryy helpful. And the motorbike-golf-key thing will really help me remember what is what!
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 29th Jan 2010 06:19 Edited at: 29th Jan 2010 06:21
Remember when rotating you are moving AROUND the axis. I imagine each axis as a rod sticking out of the origin. Twisting the rods is like rotating the axis. The rods are joined so each rotation affects all axis.

"With games, we create these elaborate worlds in our minds, and the computer is there to do the bookkeeping." - Will Wright

Login to post a reply

Server time is: 2024-04-24 01:01:15
Your offset time is: 2024-04-24 01:01:15