Jump to content
  • Advertisement
Sign in to follow this  
davidx9

Understanding D3DVERTEXELEMENT9

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

I am building a rendering engine, and need to take advantage of multiple vertex streams. I have two vertex buffers, one with x and z coords, and one with y(height) and normal data. My two vertex formts are struct xGridVertex { D3DXVECTOR2 pos; //XZ coords FLOAT tu, tv; }; #define D3DFVF_GRIDVERTEX (D3DDECLTYPE_FLOAT2|D3DFVF_TEX1) struct xSectionVertex { FLOAT height; // Y coord D3DXVECTOR3 normal; }; #define D3DFVF_SECTIONVERTEX (D3DDECLTYPE_FLOAT1|D3DFVF_NORMAL) and my D3DVERTEXDECLARATION9 is static D3DVERTEXELEMENT9 vertex_description[] = { {0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, {0, 8, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0}, {1, 0, D3DDECLTYPE_FLOAT1, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 1}, {1, 4, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0}, D3DDECL_END() }; Now my main question is... How do I instruct the pipeline to convert the xy data in stream 0 into xz data, and then combine the solitary height value in stream 1 as the y component? Secondly, is this the correct way to render such a situation? hr = pDevice->SetVertexDeclaration(vertex_dec); hr = pDevice->SetStreamSource(0, vb_grid, 0, sizeof(xGridVertex)); hr = pDevice->SetStreamSource(1, vb_heights, 0, sizeof(xSectionVertex)); hr = pDevice->SetIndices(ib_section_grid); D3DXMATRIXA16 matWorld; D3DXMatrixIdentity(&matWorld); pDevice->SetTransform(D3DTS_WORLD, &matWorld); hr = pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLESTRIP, 0, 0, 32*32, 0, 32*32*2);

Share this post


Link to post
Share on other sites
Advertisement
I believe you'll need to write a simple vertex shader in order to accomplish what you want. At least, if you have any special usages (as you do with a second position element).

Share this post


Link to post
Share on other sites
Quote:
Original post by Zipster
I believe you'll need to write a simple vertex shader in order to accomplish what you want. At least, if you have any special usages (as you do with a second position element).


Thank you very much, I had a feeling that might be the solution, but I was trying the old fixed function method.

Vertex shader will give me more flexibility anyway. Thanx.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!