Page 1 of 1

Strange camera visualization [RESOLVED]

Posted: Sun Apr 26, 2009 5:17 pm
by AlmostNoob
Hi Bepu, here's my new problem.
I load my own object (static objects that don't needed to move) by my own GameComponent and the physic simulated objects by the Draw method from the DisplayModel class (I copied this class from your example). I have this strange issue:
cameraissue.jpg
cameraissue.jpg (10.76 KiB) Viewed 4484 times
As you can see, the cylinders are not correctly visualized. They are arranged in a pyramid.

Here's my Game Component to draw static objects:

Code: Select all

public class DisegnaScenografia : DrawableGameComponent
    {
        Gioco game;
        Model modello;
        string path;
        Vector3 posizione;

        public DisegnaScenografia(Gioco parGame, string parpath, Vector3 parPosizione)
        :base(parGame)
        {
            game = parGame;
            path = parpath;
            posizione = parPosizione;
        }

        protected override void LoadContent()
        {
            modello = game.Content.Load<Model>(path);
            base.LoadContent();
        }

        public override void Draw(GameTime gameTime)
        {
            
            foreach (ModelMesh mesh in modello.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.World = Matrix.CreateTranslation(posizione);
                    effect.View = variabili.view;
                    effect.Projection = variabili.projection;
                }
                mesh.Draw(SaveStateMode.SaveState);
            }

            base.Draw(gameTime);
        }
    }
Can you help me?

Re: Strange camera visualization

Posted: Sun Apr 26, 2009 7:34 pm
by Norbo
I'm not entirely sure, but it looks like your RenderState.CullMode is opposite what the objects were built for, allowing you to see through their front faces. There might be some perspective issues as well, but it's a bit hard to tell.

Re: Strange camera visualization

Posted: Mon Apr 27, 2009 11:50 am
by AlmostNoob
You've got the point, it's a RenderState issue!! I use a FrameRate class which draws the FPS on screen by SpriteBatch. 'Though it's not CullMode but it seems to be the DepthBufferEnable parameter: by setting "true", facing it's ok, but there are some glitches (flimmering), due to the z-buffer:
glitches.jpg
glitches.jpg (4.89 KiB) Viewed 4462 times
I'll write out how to resolve this error, hope it could be useful for someone...
It's a z-buffer issue, to resolve that raise up the NearPlaneDistance parameter of the "Matrix.CreatePerspectiveFieldOfView" method.