How do I generate normals in DX8? 
Author Message
 How do I generate normals in DX8?

Hi,

I've got a lot of X files which don't have normals. I used to load them in
DX7 using something like

    mesh.LoadFromFile App.Path & "\armchair.x", 1, D3DRMLOAD_FROMFILE,
Nothing, Nothing

and all the normals would be created automatically. Now I do the following
in DX8 ...

    Set Mesh = D3DX.LoadMeshFromX(App.Path & "\armchair.x",
D3DXMESH_MANAGED, _
        D3DDevice, Nothing, materialBuffer, noMaterials)

and now the mesh renders with no shading.

How do I generate normals for a mesh in DX8?

Thanks

Tim Skillman.



Mon, 08 Nov 2004 18:44:16 GMT  
 How do I generate normals in DX8?
Upon loading your .x files, check to see if the FVF contains normals
(D3DXBaseMesh.GetFVF).  If not, use the D3DXBaseMesh.CloneMeshFVF method to
change the vertex format of the mesh.  Then you could use the
D3DX8.ComputeNormals function to generate your normals.

hth

--
Eric DeBrosse
http://www.mvps.org/vbdx/
Microsoft Visual Basic DirectX MVP

The opinions expressed in this message are my own personal views and
do not reflect the official views of Microsoft Corporation. The MVP program
does not constitute employment or contractual obligation with Microsoft.


Quote:
> Hi,

> I've got a lot of X files which don't have normals. I used to load them in
> DX7 using something like

>     mesh.LoadFromFile App.Path & "\armchair.x", 1, D3DRMLOAD_FROMFILE,
> Nothing, Nothing

> and all the normals would be created automatically. Now I do the following
> in DX8 ...

>     Set Mesh = D3DX.LoadMeshFromX(App.Path & "\armchair.x",
> D3DXMESH_MANAGED, _
>         D3DDevice, Nothing, materialBuffer, noMaterials)

> and now the mesh renders with no shading.

> How do I generate normals for a mesh in DX8?

> Thanks

> Tim Skillman.



Tue, 09 Nov 2004 00:35:57 GMT  
 How do I generate normals in DX8?
That's fixed the problem! ... the FVF was set to D3DFVF_XYZ (ie. no normal
or texture info)
I resolved this with the following code;

If (Mesh.GetFVF And D3DFVF_NORMAL) = 0 then
    '--Force FVF to D3DFVF_VERTEX
    Dim TempMesh as D3DXMesh
    Set TempMesh = Mesh.CloneMeshFVF(D3DXMESH_MANAGED, D3DFVF_VERTEX,
D3DDevice)
    Set Mesh = TempMesh
    '--Generate normals
    Dim bmesh as DXDXBaseMesh
    Set bmesh = Mesh
    D3DX.ComputeNormals bmesh
    Set Mesh = bmesh
Endif

Voila! ... works a real treat

Thanks

Tim Skillman.



Quote:
> Upon loading your .x files, check to see if the FVF contains normals
> (D3DXBaseMesh.GetFVF).  If not, use the D3DXBaseMesh.CloneMeshFVF method
to
> change the vertex format of the mesh.  Then you could use the
> D3DX8.ComputeNormals function to generate your normals.

> hth

> --
> Eric DeBrosse
> http://www.mvps.org/vbdx/
> Microsoft Visual Basic DirectX MVP

> The opinions expressed in this message are my own personal views and
> do not reflect the official views of Microsoft Corporation. The MVP
program
> does not constitute employment or contractual obligation with Microsoft.



> > Hi,

> > I've got a lot of X files which don't have normals. I used to load them
in
> > DX7 using something like

> >     mesh.LoadFromFile App.Path & "\armchair.x", 1, D3DRMLOAD_FROMFILE,
> > Nothing, Nothing

> > and all the normals would be created automatically. Now I do the
following
> > in DX8 ...

> >     Set Mesh = D3DX.LoadMeshFromX(App.Path & "\armchair.x",
> > D3DXMESH_MANAGED, _
> >         D3DDevice, Nothing, materialBuffer, noMaterials)

> > and now the mesh renders with no shading.

> > How do I generate normals for a mesh in DX8?

> > Thanks

> > Tim Skillman.



Tue, 09 Nov 2004 22:26:33 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Some problems DX8.0-DX8.1

2. MCI control doesn't generate DONE Event

3. MCI Control Gets Into a Tizzy - Done Events Not Being Generated

4. Cylinder - Calculating Normals of a TriStrip

5. ADO thinks DBMS is done, but DBMS ain't done

6. Dynamic generated DownDown, Buttons, Names generates errors

7. Dynamic generated DownDown, Buttons, Names generates errors

8. Generate random number (how to generate seed)

9. DX8.DrawPrimitiveUP / Pointers to Structures ???

10. DX8 DirectXFileData issues

11. DX8 Glass

12. Render AVI to DX8.1 surface

 

 
Powered by phpBB® Forum Software