DirectGui coordinates

I’m trying to map a DirectGui object’s coordinates to window/form coordinates ([0,0] upper left, [width, height] lower right). I assume that calling the object’s getPos method gives me its coordinates with respect to aspect2d?

Would the following be correct mappings?

aspect2d -> form

[0,0] -> [width/2, height/2] (center)

[-1,1] -> [0, 0] (upper left)

[1,1] -> [width, 0] (upper right)

[-1,-1] -> [0, height] (lower left)

[1,-1] -> [width, height] (lower right)

aspect2d contains coordinates scaled by the aspect ratio, so you wont get [-1, 1] ranges except for square windows.

getPos returns the position relative to the parent, whether aspect2d, render2d or something else, so the scale of the parent is taken in regard as well.
Use getPos(aspect2d) to get them relative to aspect2d, or getPos(render2d) to get them in -1, 1 range.

Also consider getBounds and getRelativePoint to map the corners of the things to render2d’s coordinate system.

And don’t forget base.a2dTopLeft etc. if all you want is to position things relative to the corners and edges of the screen.


render2d.getRelativePoint seems to be what I’m looking for. Thanks a bunch.