Jump to content
  • Advertisement
Sign in to follow this  
TheNobleOne

Orthographic Clipping panes.

This topic is 4828 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

Ok here is what I am doing. I am creating a 2D engine where the resolution can vary depending on the user of the engine wish. The tiles are 32x32 pixles in size. I am using a z buffer for my layer system. Now first off I want my (0,0) position to be at the top left corner of the screen where pos y is down and pos x is right and pos z is facing the user. This is not the hard part. I just rotate the world matrix on the x axis by 180 degrees. My problem arises when setting up the projection matrix it takes all floats and I don't know what to put in it. obviously I want all the negative values 0.0f as I don't need them. Which should automatically put the world axis up in the top left corner of the screen. But how do I create the pos clipping panes? What values do I use? Also should I rotate the world before I set up the projection or after? BTW I am using MDX :P

Share this post


Link to post
Share on other sites
Advertisement
Think of the screen like this:
0;0                 10;0
+------------------+
| |
| |
| |
| |
| |
+------------------+
0;8 10;8


Now, if you want to setup your projection so that it looks like the thing I tried to draw you'd do this:


D3DXMATRIX projMatrix;
D3DXMatrixOrthoLH( &projMatrix, 10.0f, 8.0f, nearClipPlane, farClipPlane );


I think this example is pretty self-explainatory.

[edit]I never used MDX, but I believe you can find out how to do the equivalent.

Share this post


Link to post
Share on other sites
ok I got the idea but screen coords go by pixels so how would I convert a float position to a pixel valued position so that I know how many tiles I can get on the screen? is there some formula like 0.1 f = 1 pixel type thing?

Share this post


Link to post
Share on other sites
It's pretty simple, instead of using 10.0f and 8.0f use the same values you used to create your backbuffer, then make sure your backbuffer is not being streched (sp?) or something, like having it display in a window bigger then the backbuffer or vice-versa.

But in my personal opinion you shouldn't make your game be "pixel aligned", that way you can zoom in/out and stuff. The only thing I'd "tolerate" (don't know a better word) that uses this in a modern 2D game is the HUD. But this is just my opinion.

[edit] btw, screen coordinates in Direct3D range from 0.0 to 1.0
[edit2] screen coordinates range from -1.0 to 1.0.. sorry, I need to sleep...

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!