Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm new to XNA and 3D game development in general.

I'm creating a puzzle game kind of similar to tetris, built with blocks. I decided to build the game in 3D since I can do some cool animations and transitions when using 3D blocks with physics etc.

However, I really do want the game to look "2D". My blocks are made up of 3D models, but I don't want that to be visible when they're not animating.

I have followed some XNA tutorials and set up my scene like this:

this.view = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up);
            this.aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;
            this.projection = Matrix.CreatePerspectiveFieldOfView(
                        MathHelper.ToRadians(45.0f), aspectRatio,
                        1.0f, 10000.0f);

... and it gives me a very 3D-ish look. For example, the blocks in the center of the screen looks exactly how I want them, but closer to the edges of the screen I can see the rotation and sides of them.

My guess is that I'm not after a perspective field of view, but any help on which field of view/settings to use to get a "flat" look when the blocks aren't rotated would be great!

share|improve this question
1  
Erm, if you don't want ortographic... Can you make a sketch what you have and what do you want? –  sm4 Jun 30 '13 at 12:32
    
Yes, that would help. Sorry! Not a sketch, but compare these images from a similar game: i.imgur.com/jSmoGpk.jpg and i.imgur.com/dYsZSwR.jpg. The first one is "2D" and the second one has obvious depth. What I'm after is to make a view which makes it appear like the whole thing is 2D, like the first image. –  Accatyyc Jul 1 '13 at 8:20
add comment

2 Answers

up vote 1 down vote accepted

In your supplied code, notice that you use the following to create your projection:

this.projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 10000.0f);

The first value is your field of view, in this case, 45 degrees. You can modify this value to be something that gives you what you're looking for. The documentation is here.

http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.matrix.createperspectivefieldofview.aspx

If you want a truly 2D effect, you'll will need to set your projection to orthographic using CreateOrthographic. You mention that you want something that still shows "some depth", in which case you might have more luck with CreateOrthographicOffCenter in which your camera is off to one side (perhaps try altering your left and right values by a 0.2 offset.)

http://msdn.microsoft.com/en-us/library/bb195659.aspx

share|improve this answer
    
Thanks! Yes, I will play around with the FOV when I get home. I think this is the way to go. –  Accatyyc Jul 1 '13 at 8:23
add comment

I guess you are looking for Orthographic projections. I don't know about XNA in detail, but this link could be a starting point.

share|improve this answer
    
Thanks, that works kind of. Though it would be nice to have the perspective when blocks go further back in the screen, for example in falling animations. Maybe I just need perspective but a smaller field of view or something, so the frontmost blocks all appear at the same place –  Accatyyc Jun 30 '13 at 11:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.