Multiple projection matrices

Started by
2 comments, last by l99057j 21 years, 7 months ago
I have finally ported my GUI into 3D code, thanks to a lot of help from the people on this forum. I''m finally down to the last big task. Say I have 3 windows on my screen, from back to front we''ll call them #3, #2, and #1. 1 and 3 are typical boring windows with typical GUI controls. #2 however, is a 3D view of a globe. If I temporarily switch from an orthogonal projection (which I''m not sure is even legal within a BeginScene/EndScene) to a perspective projection and render the globe, how are the Z values treated? Say window 3 had a z value of 3, 2 had 2, and 1 had 1. When I switch to perspective my globe''s Z values range from negative 1000 to positive 1000. I don''t want my globe to occlude window #1, though. In DX7 I was rendering this to a DirectDraw Surface and then Blt''ing it to the screen so it wasn''t a problem. As always, thanks in advance for your help. Larry Johnson - Head flunky in charge of diddly-squat. www.sillisoft.com
Larry Johnson - Head flunky in charge of diddly-squat.www.sillisoft.com
Advertisement
Ummm... z values range from 0 to 1 in projected space (well there are other values, but these are beyond your clip-planes).
Remember that the important part in your projection matrix when it comes to visibility is the near and far clip-planes, then the prjected z value is a interpolation from these two points (note that I didn''t use the word linear anywhere).
If you''ve got a simple gui, then it''s better to draw in screen space already, if you can''t for some reason, then draw normally and apply a transparent draw on top (as cheap as you possibly can) on top of this gui just to set the z-value...
Maybe I worded that wrong. I know the projection ranges from 0 to 1, but in world space my windows would have values like 1,2,3,etc. Then in the middle of all of this madness one window is going to render an object that will have z values in the range of -1000 to 1000. Won''t D3D interpret that in a way that causes the contents of window #2 to be displayed on top of Window #1, even though #1 has focus? Or would temporarily changing the projection from orthogonal to perspective somehow handle this automatically?
Larry Johnson - Head flunky in charge of diddly-squat.www.sillisoft.com
I may be missing something here, but if you know the depth priority of your forms/windows why don't you clear the depth buffer before drawing each one? You'll mainly need to clear only if the form has a 3d viewport associated with it.

- Matt


Help me!

[edited by - 3dModelMan on October 4, 2002 5:44:32 PM]

This topic is closed to new replies.

Advertisement