# When use D3DXMatrixOrthoLH, why mesh disappeared?

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

## Recommended Posts

I use D3DXMatrixOrthoLH to render some meshes to force them to keep their size. [As I mentioned in http://www.gamedev.net/community/forums/topic.asp?topic_id=370287] The function is as follows: D3DXMatrixOrthoLH(&matProject, width, height, 0.0f, 100000.0f); The problem is when I zoom the view, the mesh will disappear. If I change the zf to larger one, the mesh will be rendered weird. If I change the zf to smaller one, then the mesh will disappear. Why? I saw someone set the D3DXMatrixOrthoLH like this: D3DXMatrixOrthoLH(&matProject, width, height, 0.0f, 1.0f); It doesn’t work for me. Help!

##### Share on other sites
You need to understand what the near and far planes are actually doing. Values of 0.0f and 100000.0f are unlikely to be appropriate. The only case I can think of where they would be valid is for large scale terrain rendering.

Check out this classic. Plugging in your values generates some really odd results - in fact, it's really not too surprising you're getting unexpected results [smile]

The choice of a near/far distance is context sensitive - it depends on the size of your objects and the general scale of your world. You ideally want to choose them so that zNear is in front of the closest object to the camera and zFar is just behind the furthest object from the camera (that you actually render of course!).

Arbitrarily choosing 0.0f and 1.0f like your later example would only work if you had objects that were within 1.0 units of the camera.

Take a look at the actual matrix you're constructing:

2/w  0    0           00    2/h  0           00    0    1/(zf-zn)   00    0    zn/(zn-zf)  1

Your values will cause you to scale objects to 0.00001 of their Z dimension - which would pretty much flatten them [lol]

hth
Jack

##### Share on other sites
Thx, I know how to do, and that article is very good :)

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 48
• ### Forum Statistics

• Total Topics
632637
• Total Posts
3007577
• ### Who's Online (See full list)

There are no registered users currently online

×