Sign in to follow this  
Gus1960

3D Coordinate Confuse

Recommended Posts

Hey guys, I'm new to 3D and i'm a little bit confuse on how 3D coordinate work.
I have wrote a little test app that simply init the main window, and D3D, then created a vertexbuffer to draw a square.
Setting the square like: -1,-1,0 -1,1,0 1,-1,0 1,1,0
with no camera and world transform, this fill the entire screen or window. Am I ok to assume that the origin in 3D is the center
of the window or screen? and if so how do you position an object at a precise location?

I meen let say for exemple, that I wanted to draw my square at 100 pixel in the left top corner, that is 100 x, 100 y
since -1 if way left and 1 is way right, I could translate the square maybe like -0.700 but that would be a guest not precision.
I'm kinda confuse a bit. Another ex: would be, let say I have a texture 64x64 pixel image. I want to apply it to my square, Logicaly
if I don't want to tile the texture, the square have to be 64x64, I could scale the scare but how do I make it the perfect size?

Anyone can shade some light???
Thank's

Share this post


Link to post
Share on other sites
[quote name='AlainSab' timestamp='1298097922' post='4776226']
Hey guys, I'm new to 3D and i'm a little bit confuse on how 3D coordinate work.
I have wrote a little test app that simply init the main window, and D3D, then created a vertexbuffer to draw a square.
Setting the square like: -1,-1,0 -1,1,0 1,-1,0 1,1,0
with no camera and world transform, this fill the entire screen or window. Am I ok to assume that the origin in 3D is the center
of the window or screen? and if so how do you position an object at a precise location?[/quote]
This will be easier to understand once you know more about how the graphics pipeline works, but when all transforms are identity, the origin is in the center of the screen, more or less. (More specifically, the projection is orthographic and the point (0, 0, 0) will map to the center of the screen.)

To position or orient an object or the (virtual) camera, you use an appropriate transform or series of transforms.

[quote]I meen let say for exemple, that I wanted to draw my square at 100 pixel in the left top corner, that is 100 x, 100 y
since -1 if way left and 1 is way right, I could translate the square maybe like -0.700 but that would be a guest not precision.
I'm kinda confuse a bit. Another ex: would be, let say I have a texture 64x64 pixel image. I want to apply it to my square, Logicaly
if I don't want to tile the texture, the square have to be 64x64, I could scale the scare but how do I make it the perfect size?[/quote]
By setting the projection transform (most likely orthographic in this case) appropriately, you can 'map' the viewport coordinates in different ways. For example, you could set up an orthographic projection such that the viewport coordinates mapped to the actual window coordinates. Then, for example, if the window dimensions were 800x600, a rectangle with dimensions 400x300 (and appropriately positioned) would occupy half the screen.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this