Strange camera visualization [RESOLVED]

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
AlmostNoob
Posts: 13
Joined: Sun Jan 11, 2009 6:34 pm

Strange camera visualization [RESOLVED]

Post 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 4474 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?
Last edited by AlmostNoob on Mon Apr 27, 2009 12:07 pm, edited 1 time in total.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Strange camera visualization

Post 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.
AlmostNoob
Posts: 13
Joined: Sun Jan 11, 2009 6:34 pm

Re: Strange camera visualization

Post 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 4452 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.
Post Reply