Sign in to follow this  

[MDX] Mesh rendering only black

This topic is 3500 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

Hello, I am rendering a mesh in managed directx and for some reason it is always black. I have tried setting a texture on it and I have also tried turning the lighting off. Does anyone know why? Here is the code I use
        D3D.Mesh m_TestMesh;
        D3D.Texture m_Texture;

        public void InitObjectManager()
        {
            Microsoft.DirectX.Direct3D.Device ptrDevice = ManagedDirect3D.Instance.Device;
            m_TestMesh = Mesh.Box(ptrDevice, 1, 1, 1);
            string szFileName;
            szFileName = "Gold.bmp";

            m_Texture = null;
            m_Texture = TextureLoader.FromFile(ptrDevice, szFileName);

            ptrDevice.RenderState.Lighting = false;
        }

        public void RenderAllObjects()
        {
            Microsoft.DirectX.Direct3D.Device ptrDevice = ManagedDirect3D.Instance.Device;

            ptrDevice.SetTexture(0, m_Texture);
            m_TestMesh.DrawSubset(0);
        }

Share this post


Link to post
Share on other sites
Mesh.Box / D3DXCreateBox doesn't include texture coordinates, so texturing won't make any difference.

I'm not 100% sure but I think it only allocates space for normals and doesn't actually generate them. You may need to manually do this after creating the mesh if you also want to use lighting.

If, however, you don't want lighting you'll need to either set a constant multiplier in the texture cascade, disable texture*diffuse multiplication or add a per-vertex diffuse colour bright enough to show the texture. You'll also need to add texture coordinates, but as you'll quickly find out the 8 vertices D3DX generates make this quite tricky and you'll almost certainly end up writing your own Mesh.Box() method [smile]

hth
Jack

Share this post


Link to post
Share on other sites

This topic is 3500 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.

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