Sign in to follow this  
BlenMiner

XNA Game (having issues! xD obviously)

Recommended Posts

I am not doing any culling since I want to fixe this issue first!

This is my very FIRST time using xna (yeah I know its dead) actually my first day so yeah i am in a learning process.

 

Back on topic my issue is this:

 

 

From one side the chunk renders right http://oi62.tinypic.com/20fuqb.jpg

but from the other side the same chunk renders like this: http://oi57.tinypic.com/9qadlc.jpg

Share this post


Link to post
Share on other sites

It's really hard to tell anything from those screenshots since the lighting is so flat, but it looks like you have the winding order incorrect in some of your cubes vertices.

Share this post


Link to post
Share on other sites

I think they are right.. the faces underneath are overlayed with the faces on top for some reason..

const float tBlockSize = 1f / 16f;
        private void TopFace(int xOffset,int yOffset, int zOffset)
        {
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0, 0)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 1 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0 + tBlockSize, 0)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 1 + zOffset), Color.White, new Vector2(0, 0 + tBlockSize)));

            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 1 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0 + tBlockSize, 0)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 1 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 1 + zOffset), Color.White, new Vector2(0 + tBlockSize, 0 + tBlockSize)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 1 + zOffset), Color.White, new Vector2(0, 0 + tBlockSize)));
        }
        private void BottomFace(int xOffset, int yOffset, int zOffset)
        {
            yOffset--;

            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 1 + zOffset), Color.White, new Vector2(0, 0 + tBlockSize)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 1 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0 + tBlockSize, 0)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0, 0)));

            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 1 + zOffset), Color.White, new Vector2(0, 0 + tBlockSize)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 1 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 1 + zOffset), Color.White, new Vector2(0 + tBlockSize, 0 + tBlockSize)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 1 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0 + tBlockSize, 0)));
        }
        private void FrontFace(int xOffset, int yOffset, int zOffset)
        {
            yOffset--;

            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0, 0)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 1 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0 + tBlockSize, 0)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 1 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0, 0 + tBlockSize)));

            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 1 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0 + tBlockSize, 0)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 1 + xOffset, worldPos.Y + 1 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0 + tBlockSize, 0 + tBlockSize)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 1 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0, 0 + tBlockSize)));
        }
        private void BackFace(int xOffset, int yOffset, int zOffset)
        {
            yOffset--;
            zOffset++;

            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 1 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0, 0 + tBlockSize)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 1 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0 + tBlockSize, 0)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0, 0)));

            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 1 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0, 0 + tBlockSize)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 1 + xOffset, worldPos.Y + 1 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0 + tBlockSize, 0 + tBlockSize)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 1 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0 + tBlockSize, 0)));
        }
        private void RightFace(int xOffset, int yOffset, int zOffset)
        {
            yOffset--;

            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 1 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0, 0 + tBlockSize)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 1 + zOffset), Color.White, new Vector2(0 + tBlockSize, 0)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0, 0)));

            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 1 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0, 0 + tBlockSize)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 1 + yOffset, worldPos.Z + 1 + zOffset), Color.White, new Vector2(0 + tBlockSize, 0 + tBlockSize)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 1 + zOffset), Color.White, new Vector2(0 + tBlockSize, 0)));
        }
        private void LeftFace(int xOffset, int yOffset, int zOffset)
        {
            yOffset--;
            xOffset++;

            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0, 0)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 1 + zOffset), Color.White, new Vector2(0 + tBlockSize, 0)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 1 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0, 0 + tBlockSize)));

            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 0 + yOffset, worldPos.Z + 1 + zOffset), Color.White, new Vector2(0 + tBlockSize, 0)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 1 + yOffset, worldPos.Z + 1 + zOffset), Color.White, new Vector2(0 + tBlockSize, 0 + tBlockSize)));
            vertexList.Add(new VertexPositionColorTexture(new Vector3(worldPos.X + 0 + xOffset, worldPos.Y + 1 + yOffset, worldPos.Z + 0 + zOffset), Color.White, new Vector2(0, 0 + tBlockSize)));
        }
Edited by BlenMiner

Share this post


Link to post
Share on other sites

Yeah my issue was that i needed to reset these 2 variables to this:

 

GraphicsDevice.BlendState = BlendState.Opaque;
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
 
still learning! xd

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this