Units of Measurement in local space

Started by
2 comments, last by ext 17 years, 11 months ago
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?
Advertisement
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]

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

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.
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).

This topic is closed to new replies.

Advertisement