Jump to content
  • Advertisement
Sign in to follow this  
kgstation

[Winstore D3D]HELP!My mesh only show its backface!

This topic is 2118 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 followed Direct3DTutorial sample to create a box.

The sample is from here:https://login.live.com/login.srf?wa=wsignin1.0&wtrealm=code.msdn.microsoft.com&wreply=https%3a%2f%2fcode.msdn.microsoft.com%2fwindowsapps%2fDirect3D-Tutorial-Sample-08667fb0%3fstoAI%3d10&wp=MBI_FED_SSL&wlcxt=microsoft%24microsoft%24microsoft

And I changed the cubeVertices and cubeIndices to this

   VertexPNT cubeVertices[] =
    {
		{ float3(-1.0f, -1.0f, -1.0f), float3(0.0f, 0.0f, -1.0f), float2(0.0f, 1.0f) }, // +Y (top face)
		{ float3(-1.0f, 1.0f, -1.0f), float3(0.0f, 0.0f, -1.0f), float2(0.0f, 0.0f) },
		{ float3(1.0f, 1.0f, -1.0f), float3(0.0f, 0.0f, -1.0f), float2(1.0f, 0.0f) },
		{ float3(1.0f, -1.0f, -1.0f), float3(0.0f, 0.0f, -1.0f), float2(1.0f, 1.0f) },

		{ float3(-1.0f, -1.0f, 1.0f), float3(0.0f, 0.0f, 1.0f), float2(1.0f, 1.0f) }, // -Y (bottom face)
		{ float3(1.0f, -1.0f, 1.0f), float3(0.0f, 0.0f, 1.0f), float2(0.0f, 1.0f) },
		{ float3(1.0f, 1.0f, 1.0f), float3(0.0f, 0.0f, 1.0f), float2(0.0f, 0.0f) },
		{ float3(-1.0f, 1.0f, 1.0f), float3(0.0f, 0.0f, 1.0f), float2(1.0f, 0.0f) },

		{ float3(-1.0f, 1.0f, -1.0f), float3(0.0f, 1.0f, 0.0f), float2(0.0f, 1.0f) }, // +X (right face)
		{ float3(-1.0f, 1.0f, 1.0f), float3(0.0f, 1.0f, 0.0f), float2(1.0f, 0.0f) },
		{ float3(1.0f, 1.0f, 1.0f), float3(0.0f, 1.0f, 0.0f), float2(1.0f, 1.0f) },
		{ float3(1.0f, 1.0f, -1.0f), float3(0.0f, 1.0f, 0.0f), float2(0.0f, 1.0f) },

		{ float3(-1.0f, -1.0f, -1.0f), float3(0.0f, -1.0f, 0.0f), float2(0.0f, 0.0f) }, // -X (left face)
		{ float3(1.0f, -1.0f, -1.0f), float3(0.0f, -1.0f, 0.0f), float2(1.0f, 0.0f) },
		{ float3(1.0f, -1.0f, 1.0f), float3(0.0f, -1.0f, 0.0f), float2(1.0f, 1.0f) },
		{ float3(-1.0f, -1.0f, 1.0f), float3(0.0f, -1.0f, 0.0f), float2(0.0f, 1.0f) },

		{ float3(-1.0f, -1.0f, 1.0f), float3(-1.0f, 0.0f, 0.0f), float2(0.0f, 0.0f) }, // +Z (front face)
		{ float3(-1.0f, 1.0f, 1.0f), float3(-1.0f, 0.0f, 0.0f), float2(1.0f, 0.0f) },
		{ float3(-1.0f, 1.0f, -1.0f), float3(-1.0f, 0.0f, 0.0f), float2(1.0f, 1.0f) },
		{ float3(-1.0f, -1.0f, -1.0f), float3(-1.0f, 0.0f, 0.0f), float2(0.0f, 1.0f) },

		{ float3(1.0f, -1.0f, -1.0f), float3(1.0f, 0.0f, 0.0f), float2(0.0f, 0.0f) }, // -Z (back face)
		{ float3(1.0f, 1.0f, -1.0f), float3(1.0f, 0.0f, 0.0f), float2(1.0f, 0.0f) },
		{ float3(1.0f, 1.0f, 1.0f), float3(1.0f, 0.0f, 0.0f), float2(1.0f, 1.0f) },
		{ float3(1.0f, -1.0f, 1.0f), float3(1.0f, 0.0f, 0.0f), float2(0.0f, 1.0f) },
    };

    unsigned int cubeIndices[] =
    {
        0, 1, 2,
        0, 2, 3,

        4, 5, 6,
        4, 6, 7,

        8, 9, 10,
        8, 10, 11,

        12, 13, 14,
        12, 14, 15,

        16, 17, 18,
        16, 18, 19,

        20, 21, 22,
        20, 22, 23
    };

BUT I don't know why this shows only cube back face like this

1.png

I think my cube vertices and indices are correct!

I wonder how this happened!

Any help would be appreciated;

Share this post


Link to post
Share on other sites
Advertisement

The winding order of your mesh is backwards. You need to flip the order of your vertex data.

 

 

Styves is correct. The order you send the vertices determine the front/back face of a mesh. Here's a bit of a tutorial on how winding order works.

 

Thank you very much!

My problem solved now!

Edited by kgs

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!