1
\$\begingroup\$

I'm trying to draw a 'axis' model named 'XYZ'. The problem is that it is rendered wrong (screenshot below). enter image description here

You can see that the blue face can be seen through the red face. The black, green and red faces have no problem. Here is my code for drawing the axis.

protected override void Initialize()
    {
        this.IsMouseVisible = true;
        this.Window.Title = "3DRadSpace -Editor- 3dradspace.org";
        Tools Toolz = new Tools();
        Toolz.Show();
        // TODO: Add your initialization logic here
        base.Initialize();
        RasterizerState stat = new RasterizerState();
        stat.CullMode = CullMode.None; //Does nothing, the default does the same thing
    }
protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();
            MS = Mouse.GetState();
            if (MS.X < 120 && MS.Y < 120 && MS.X > 0 && MS.Y > 0 && MS.LeftButton == ButtonState.Pressed)
            {
            }
            KB = Keyboard.GetState();
            if (KB.IsKeyDown(Keys.Left))
            {
                Cam = new Vector3(Cam.X -= 1, Cam.Y, Cam.Z);
                view = Matrix.CreateLookAt(Cam, new Vector3(0, 0, 0), Vector3.UnitY);
            }
            if (KB.IsKeyDown(Keys.Right))
            {
                Cam = new Vector3(Cam.X += 1, Cam.Y, Cam.Z);
                view = Matrix.CreateLookAt(Cam, new Vector3(0, 0, 0), Vector3.UnitY);
            }
            if (KB.IsKeyDown(Keys.Up))
            {
                Cam = new Vector3(Cam.X, Cam.Y, Cam.Z+=1);
                view = Matrix.CreateLookAt(Cam, new Vector3(0, 0, 0), Vector3.UnitY);
            }
            if (KB.IsKeyDown(Keys.Down))
            {
                Cam = new Vector3(Cam.X, Cam.Y, Cam.Z-=1);
                view = Matrix.CreateLookAt(Cam, new Vector3(0, 0, 0), Vector3.UnitY);
            }
            if (KB.IsKeyDown(Keys.Q))
            {
                Cam = new Vector3(Cam.X, Cam.Y+-1, Cam.Z);
                view = Matrix.CreateLookAt(Cam, new Vector3(0, 0, 0), Vector3.UnitY);
            }
            if (KB.IsKeyDown(Keys.E))
            {
                Cam = new Vector3(Cam.X, Cam.Y+= 1, Cam.Z);
                view = Matrix.CreateLookAt(Cam, new Vector3(0, 0, 0), Vector3.UnitY);
            }
            base.Update(gameTime);
        }
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(new Color(75,75,255));
            DrawModel(axis, world, view, projection);
            spriteBatch.Begin();
            spriteBatch.Draw(MovX,new Vector2(0,0), Color.White);
            spriteBatch.End();
            // TODO: Add your drawing code here
            base.Draw(gameTime);
        }
        private void DrawModel(Model model, Matrix world, Matrix view, Matrix projection)
        {
            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.World = world;
                    effect.View = view;
                    effect.Projection = projection;
                }
                mesh.Draw();
            }
        }
\$\endgroup\$
  • \$\begingroup\$ Solved it myself. The solution : stackoverflow.com/questions/14938832/… . Can a moderator mark this as solved? \$\endgroup\$ – NicusorN5 Aug 7 '17 at 19:44
  • \$\begingroup\$ You can only mark it as solved if you've posted it as an answer. \$\endgroup\$ – Steven Mar 14 '18 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.