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.

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 on other sites
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.

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

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

 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 on other sites
ok thanks a bunch.

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

• 9
• 9
• 9
• 14
• 12
• Forum Statistics

• Total Topics
633298
• Total Posts
3011260
• Who's Online (See full list)

There are no registered users currently online

×