Skip to main content
GameDev.net gamedev.net
🔒 Locked

Light Problem

Started by Will O May 5, 2003 at 4:35 PM 1 replies 500+ views
Original Post
Will O
Will O
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).
aronj
aronj
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.
Will O
Will O
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]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.