Jump to content
  • Advertisement
Sign in to follow this  

Units of Measurement in local space

This topic is 4580 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I wanted to draw a simple cube with a length of 5units in all three directions (x,y,z). But Direct3D wouldn't draw it, so after a long experimenting time I set the values to 0.5 instead of 5 and direct3d draws the cube. So now I'm wondering why direct3d draws only objects with coordinates in the range from -1 to 1. I thought I could choose my units of measurement in a free manner. What do I have to do, if I want my cube 5unit wide, hight and deep? I've set my near clipping plane to 1.0 and the far one to 10,000.0 (1unit shall be 1cm). Is there a difference between units in local space and in world space?

Share this post

Link to post
Share on other sites
The units used by Direct3D are just numbers - they have no particular relation to meters/feet etc..

What view matrix (aka camera) configuration were you using? If your camera were located around (5,5,5) looking at(0,0,0) you wouldn't see a 5x5x5 cube as it would be clipped/culled due to its proximity to the camera and the projection clipping planes.

The D3D application I'm working on right now has objects ~20x20 units, and they're not defined in the -1..+1 space you suggest - so it is definitely possible [grin]


Share this post

Link to post
Share on other sites
I thought that they're just numbers, but then why does the following NOT work:

In my left handed coordinate system:
I have my cam at (0|0|-6) looking at (0|0|0)
And my projection is
D3DXMatrixPerspectiveFovLH( &proj, D3DX_PI / 4, 1.333f, 1.0f, 10000.0f );

I have a rectangle with the following coordinates (it's a textured one)

static const DWORD FVF = D3DFVF_XYZ | D3DFVF_TEX1;
Vertex vt[ 6 ] =
{ -0.5f, -0.5f, 1.0f, 0, 1 },
{ 0.5f, -0.5f, 1.0f, 1, 1 },
{ -0.5f, 0.5f, 1.0f, 0, 0 },
{ 0.5f, -0.5f, 1.0f, 1, 1 },
{ 0.5f, 0.5f, 1.0f, 1, 0 },
{ -0.5f, 0.5f, 1.0f, 0, 0 }

If I draw it, it's centered inside my windows (as it should be), but changing the z values from 1.0 to 2.0 all I get is a black screen.
Am I missing something, or why is it no longer visible?

And my cube with values 0 or 5 (a vertex from my cube is either on one of the axis or 5units away) shows only at the top right of the window, no matter what values i choose for my cam.

The stranges thing is that the rectangle from above is actually drawn behind that "thing" in the top right of my window.

D3DRS_ZENABLE is set to TRUE and I'm trying now for hours and still I don't know why it doesn't draw it right.

No matter where I set my look at point to, the rectangle is always in the center, too. For example I have my cam with the following values:

D3DXVECTOR3 pos( 15, 15, 16 );
D3DXVECTOR3 la( 150, 15, 5 );
D3DXVECTOR3 up( 0, 1, 0 );

The rectangle should not be visible because it's behind me.

Share this post

Link to post
Share on other sites
I just found my mistake I was resetting the device in the WM_SIZE message, the only problem was that I forgot to care for my other dx resources (they were added today, the rest of the code is older).

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!