Hi, I've recently made the move from 2D XNA to 3D. I've been playing around trying to create a basic 3D world as practice; I just plan to have a camera, some terrain and an avatar.
I took a look at the generated geometry sample found at
http://creators.xna.com/en-GB/sample/generatedgeometry and have been attempting to use it along with my own camera I made. I've been having two problems; the first is a strange kind of stretching of the texture (
http://www.jason-mitchell.com/images/textureStretch.JPG) and the second is that some of my terrain is appearing see through and terrain that should be blocked from site is visible (
http://www.jason-mitchell.com/images/renderError.JPG).
The TerrainProcessor has been copied exactly from the sample and I have also tried a solution from a book which has the exact same problems which leads me to think that the problem lies elsewhere.
Here is my drawing code:
| protected override void Draw(GameTime gameTime) |
| { |
| GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0); |
| |
| DrawTerrain(camera.ViewMatrix, camera.ProjectionMatrix); |
| |
| base.Draw(gameTime); |
| } |
| |
| private void DrawTerrain(Matrix view, Matrix projection) |
| { |
| foreach (ModelMesh mesh in terrain.Meshes) |
| { |
| foreach (BasicEffect effect in mesh.Effects) |
| { |
| effect.View = view; |
| effect.Projection = projection; |
| |
| effect.EnableDefaultLighting(); |
| } |
| |
| mesh.Draw(); |
| } |
| } |
As mentioned previously, the terrain processor code is exactly the same as in the Generated Geometry sample.
Does anyone know why this happens and how to solve it?
Thanks