Archived

This topic is now archived and is closed to further replies.

Light Problem

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

Recommended Posts

I don''t get this, I can''t get lights working on my meshes (loaded from .x files), though they work on other objects (ie I copied the code from the sdk example that creates the rotating tube - that gets lit up). Anybody have any insight on my problem? (BTW I''m new to d3d, been about a week since I started learning).

Share on other sites
Hi

Does the x-file you are using contain normals? If not they must be created (use CloneMeshFVF to make room for normals in mesh and D3DXComputeNormals to create them).
Also, if you already have normals make sure they are normalized.

Share on other sites
Hi, thanks for the reply. I'm not sure if my .x files have normals, so I'll just assume that they don't. Can you give me some example code using those two functions (or at least the first one). I'm a little bit stuck on what parameters to use for the CloneMeshFVF function (yes I checked the docs, just not sure what to put in the DWORD Options, DWORD FVF parameters.)

Edit: Here is what I have so far:
DWORD dwFVF	= m_dwNumMaterials << D3DFVF_TEXCOUNT_SHIFT;m_pD3DMesh->CloneMeshFVF(D3DXMESH_VB_SYSTEMMEM, dwFVF | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_XYZ, m_pD3D->m_pD3DDevice, &m_pD3DMesh);D3DXComputeNormals(m_pD3DMesh, NULL);

Doesn't seem to change anything, still no lighting

Edit: Ok, I got it to work, just needed to change the parameters a bit to:

pD3DMesh->CloneMeshFVF(D3DXMESH_MANAGED, D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1, m_pD3D->m_pD3DDevice, &m_pD3DMesh);

Thanks again for the help

[edited by - Will O on May 5, 2003 9:23:46 PM]

[edited by - Will O on May 5, 2003 10:31:58 PM]

• Forum Statistics

• Total Topics
628697
• Total Posts
2984273

• 20
• 9
• 13
• 13
• 11