News:

As a consequence of the forum being updated and repaired, the chatbox has been lost.
However, you can still come say hi on our Discord server!

Main Menu

Help! How do you think of 3D space? I.e. which way is up?

Started by Thunder-squall, 27, April, 2014, 06:33:42 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Thunder-squall

I'm redoing some code that I use to do pseudo3D graphics, and I could really use some help defining the conventions.  There are different ways of doing it, but I'm trying to decide what's the best way for a Dark Dawn or Disgaea style world.

Describing 3D space

I'm using the basic x,y,z dimensions, but which is which?  Talking to mechanical engineering types, I know for them 'z' is up, but in early math classes, typically 'y' is up, and 'z' is 'depth.'  And of course if you're doing a 2d game, then there's just x and y.

Here's the default thing I'm going with for now.  Notice that now positive y is up, and negative y is down.  This is different than what I was doing before, where I was using the coordinate system that was inherent to love2d, where position 0,0 was in the upper left corner of the window.  It occurred to me that while I, as the programmer, might trying to be consistent with the love2d coordinate system, a user working on just maps or whatever might find that counter intuitive.  And so was I, once I was getting into coding 3D collision detection.

         +y  
           | -z
           |/  
   -x- - o - - +x
         / |
       +z |
          -y
(my current set up)

And it's not like no one else has taken this specific approach before
https://wiki.brown.edu/confluence/display/wdm/3D+Coordinate+System
http://resumbrae.com/ub/dms424_s03/03/p01.html
http://what-when-how.com/xna-game-studio-4-0-programmingdeveloping-for-windows-phone-7-and-xbox-360/3d-math-basics-xna-game-studio-4-0-programming-part-1/

Hey, do any of you remember the 'right hand rule' from math class?

(image from the XNA Game Studio link)

Rotation

I only need to include rotation about the y axis, and about the x axis.  And I've decided to have the units be pi-radians, since a rotation of 2pi radians is easier to consider than 360 degrees.  Though this did take some getting used to for me.

But I'm having a hard time considering which direction of rotation should be positive, and which should be negative.

1)  How do you envision the axis looking when rx = 0 and ry = 0?
2)  How do you envision the axis looking when rx = 0.5 pi, and ry = 0 pi?
3) How do you envision the axis looking when rx = 0, and ry = 0.5 pi?

What do you guys think about this version?


zoom
zoom = 0.5 means that the axis will appear half as big.
zoom = 1 means the axis will appear at it's standard size.

camera
The camera coordinates essentially change the point on the axis where it is drawn on screen, and about which it rotates.
By default this is set to x,y,z = 0,0,0.

Daddy Poi's Oily Gorillas

@x,y,z: Hmm... I generally like to look at z as your distance from sea level in 3D maps. From what I've seen with GS data, it appears to be ordered like x z y , so it might be possible that they do y and z backwards from the way I  like to look at it.

I guess you can see it either as a platformer, or a map...

x = run
y = rise
z = depth ?

I think those are the terms.

As for rotations... I would probably copy analog clocks and go clockwise, but it might not matter too much. (I haven't given it a lot of thought.)
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Thunder-squall

I guess the basic question is how you envision the map to look when there's no rotation applied to it at all.  Is it a top down view, or a view from the side, with the z axis coming straight out at the viewer?

Rolina

Something I find annoying?  That Y is for height.  The way I've always seen it, X is length, Y is width, and Z is depth.  What makes the most sense to me is for Z to be up and down, likely due to how graphs are done and the way my brain works.  I view graphs as being from a top down perspective, rather than being upright, so Y being vertical has always thrown me off.

Thunder-squall

^ Can I get more input like this from more people?  This is exactly the kind of thing I want to get a sense for.

Daddy Poi's Oily Gorillas

QuoteX is length, Y is width
Hmm... I think of X as width (left and right) ... and then get Y and Z mixed up as length and height? ; Although, to me, width/length/height sounds more like sizes than coordinates, but I guess whatever makes sense, works. (Since it's not like I'm familiar with coordinate terminology.)


One suggestion is to make X the left and right arrow keys and Y the up and down arrow keys. And since movement is on a flat map, then that's how we can decide what x, y, and z are?
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Thunder-squall

Quote from: Teawater on 29, April, 2014, 02:06:33 AM
QuoteX is length, Y is width
Hmm... I think of X as width (left and right) ... and then get Y and Z mixed up as length and height? ; Although, to me, width/length/height sounds more like sizes than coordinates, but I guess whatever makes sense, works. (Since it's not like I'm familiar with coordinate terminology.)

X: Horizontal
Y/Z: Vertical

Normally in 2d settings, people first think about horizontal first (X), then vertical (Y)
But in 3d settings, it seems that people first thing about position on the ground (X,Y), and then height or elevation (Z).

So often it seems that people think of two distinct coordinate systems when thinking about 2d or 3d space... And that's really messing with me, especially since I'm creating a 3D system in a 2D oriented framework, which has y as the distance from top to bottom.

A completely different alternative would be to drop the XYZ convention all together, and call them "horizontal, vertical, and depth."... gah, is that really worth trying?  I suppose I might as well give it a shot... okay, might as well.  Actually, that's probably going to end up being a better and less confusing implementation, since it'll no longer conflict with the terminology used to describe the in-window coordinates.

Quote from: Teawater on 29, April, 2014, 02:06:33 AM
One suggestion is to make X and Y be determined by arrow keys.

What do you mean?  You mean that when controlling an object with a dpad or keyboard, have pressing left/right change whatever the x coordinate is, and have pressing up/down change whatever the y coordinate is?

Otherwise I have no idea what you're saying.

Daddy Poi's Oily Gorillas

QuoteWhat do you mean?  You mean that when controlling an object with a dpad or keyboard, have pressing left/right change whatever the x coordinate is, and have pressing up/down change whatever the y coordinate is?

Otherwise I have no idea what you're saying.
Yes. And going up stairs affects the z coordinate. (Which can apply to all keys, usually not down arrow, though, since climbing stairs you can't see might look strange.) ; I gave this suggestion because Z is like the odd ball, and usually isn't used in 2D anyway.

And Z might not be used as much if you don't have ledges over ledges/ground. You could probably even try using x, y, depth? (If you're fine with only renaming one variable.)
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Thunder-squall

#8
well, Golden Sun puzzles, especially Dark Dawn, are all about elevation differences.  And so are tactics games, AND platformers, and they're also important to brawlers like Little Fighter 2 (great game, you should look it up).  These are fundamentally the reasons why I'm not using RPG Maker, which would otherwise be perfect.

Basically I'll be using height a lot.  Especially if I'm doing different game types.

Daddy Poi's Oily Gorillas

Okay... I feel a bit dumb now, but I suppose what I meant is that "it wouldn't be required as much as X and Y are." While yet, probably being more complex? (Well, the world map in GS1 and GS2 didn't seem to do much with elevation... which brings me to the question: Are you going to have a World Map in your game?)

Anyway, I remembered there are places where you travel under a bridge. (See Vale in GS1.)
In GS2, some of the Rock locations may also have a bit of elevation. Including climbing. (Like along the wall (gripping points?), on vines, and on ladders.) And there's even one psynergy you use on those rope things.
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Rolina

I always learned it in the order of Length/Width/Height, which is why I associate them as x/y/z respectively.  Plus, I find it very odd that when we go through games, the most common axises to traverse are X and Z, despite us learning to work with Y far before we fiddled with Z.  It just doesn't feel like the intuitive choice.

Thunder-squall

alright, I'm leaning towards the "z is up" way of doing things, which at least also seems to be the approach followed in Second Life, and I assume in other 3D systems like Blender, Maya, etc, though I haven't confirmed this.

Here are some links.  The later stuff even contains some equations and stuff which I might make use of, but in the short term I'll stick with adapting what I have. I mean, I ain't afraid of no gimbal locks... I think.

http://secondlife.wikia.com/wiki/Axis
http://wiki.secondlife.com/wiki/Rotation
http://en.wikipedia.org/wiki/Right_hand_rule  (but this time using z as up)
http://en.wikipedia.org/wiki/Tait-Bryan_angles#Tait.E2.80.93Bryan_angles