Jump to content
  • Advertisement
Sign in to follow this  
BlenMiner

XNA Game (having issues! xD obviously)

This topic is 1238 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!