I am using the XNA built into WinForms, which is downloaded from the Microsoft website. And they noticed that when the models are drawn, everything looks fine, but as soon as I rotate my camera, the edges on the model begin to look jagged. Here are two pictures of what I'm talking about:


This is more noticeable the closer the camera is to the target. I use this to draw each grid:
foreach (ModelMesh mesh in model.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.View = cam.view; effect.Projection = cam.projection; effect.World = mesh.ParentBone.Transform; effect.EnableDefaultLighting(); } mesh.Draw(); }
Also sometimes, when I rotate the model, some strange shading appears. Shadows do not even change their "location", but remain elongated the same.
EDIT: So, I searched a little Google and saw that turning on MultiSampling should get rid of the jagged edges. Now, does anyone know how to do this in WinForms?
EDIT 2: About the backbuffer, I don't install it anywhere, so I assume this is the way it should be. This is the constructor of GraphicsDeviceService.cpp:
GraphicsDeviceService(IntPtr windowHandle, int width, int height) { parameters = new PresentationParameters(); parameters.BackBufferWidth = Math.Max(width, 1); parameters.BackBufferHeight = Math.Max(height, 1); parameters.BackBufferFormat = SurfaceFormat.Color; parameters.DepthStencilFormat = DepthFormat.Depth24; parameters.DeviceWindowHandle = windowHandle; parameters.PresentationInterval = PresentInterval.Immediate; parameters.IsFullScreen = false; graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.Reach, parameters); }
Also, the reset method sets the backBuffer accordingly.
EDIT 3: I tried to set MultiSampleCount to a larger number, but nothing helped, now here are two pictures of what is happening. First I create an object in some place, and then I move the camera only to the right. And the whole object is stretched and gets these jagged edges, as shown in this image below. This is the camera movement code:
http://img152.imageshack.us/img152/5204/normalu.png
http://img28.imageshack.us/img28/4434/movedright.png
KeyboardState state = Keyboard.GetState(); Vector3 v; if (state.IsKeyDown(Keys.Up) || state.IsKeyDown(Keys.W)) v = new Vector3(0, 0, 1) * moveSpeed; else if (state.IsKeyDown(Keys.Down) || state.IsKeyDown(Keys.S)) v = new Vector3(0, 0, -1) * moveSpeed; else if (state.IsKeyDown(Keys.Left) || state.IsKeyDown(Keys.A)) v = new Vector3(1, 0, 0) * moveSpeed; else if (state.IsKeyDown(Keys.Right) || state.IsKeyDown(Keys.D)) v = new Vector3(-1, 0, 0) * moveSpeed; else if (state.IsKeyDown(Keys.PageUp)) v = new Vector3(0, -1, 0) * moveSpeed; else if (state.IsKeyDown(Keys.PageDown)) v = new Vector3(0, 1, 0) * moveSpeed; else v = new Vector3(0, 0, 0); view *= Matrix.CreateTranslation(v);
And the view and projection of the camera:
view = Matrix.CreateLookAt(cameraPos, Vector3.Zero, Vector3.Up); projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45f), ratio, 0.5f, 50f);
cameraPos in this case 0,0,10 .
EDIT: Shading I finnally got a picture of the shading problem. As you can see, each grid has its own shadow, and not just one shadow passing through all the grids.
http://img843.imageshack.us/img843/8263/weirdshadowing.png
This is the top view of the model.