Archived

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

GekkoCube

problem with D3DFVF_NORMAL

Recommended Posts

GekkoCube    116
when i use this flag for my vertices, everything is either one color like gray with no apparant shading, or flickering and one shade of color. here''s the render part, assuming everything else, like the material is set properly, which i think it is since i took it straight from d3d''s help.
  
#define D3DFVF_CUSTOMVERTEX_TEX ( D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX2 | D3DFVF_NORMAL )

struct CUSTOMVERTEX_TEX {
    FLOAT x, y, z;      // The transformed position for a vertex

    DWORD color;        // The vertex color 

    float tu, tv;       // texture coordinates

    float nx, ny, nz;
};
  

  
// Set render state(s)

	lpDevice->SetRenderState( D3DRS_ZENABLE, FALSE );

	// Set the material

	lpDevice->SetMaterial( &mtrl );

	// Set texture style(s)

	lpDevice->SetTexture( 0, m_pTexture );

	// Prepare vertex buffer and then draw

	lpDevice->SetStreamSource( 0, m_pVB, sizeof(CUSTOMVERTEX_TEX) );// )

	lpDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX_TEX );
	lpDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 10 );

	// Set render state(s) back to normal

	lpDevice->SetRenderState( D3DRS_ZENABLE, TRUE );

	// Set texture setting to NULL

	lpDevice->SetTexture( 0, NULL );
  

Share this post


Link to post
Share on other sites
GekkoCube    116
Really???

I didn''t think it mattered as long as I keep it consistent with my custom vertex.

If the normal comes right after the position, then my vertex set must be way out of whack!!

What is the standard anyway? I guess i should look it up on the d3d reference.

thanks for the help.

Share this post


Link to post
Share on other sites
d000hg    1199
Yeah the order of components in the vertex struct is essential. Otherwise how does D3D expect to know where to find stuff - you don''t declare it anywhere else!



Read about my game, project #1
NEW (18th December)2 new screenshots, one from the engine and one from the level editor



John 3:16

Share this post


Link to post
Share on other sites