Jump to content
  • Advertisement
Sign in to follow this  

how to guarantee the right vertex-buffer?

This topic is 3274 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 create a teapot through:D3DXCreateTeapot(Device, &Teapot, 0);. I want to change the vertex format through Flexible Vertex Format which is:
 struct sBlendVertex
{
	D3DXVECTOR3 pos;
	float	    blend;
	D3DXVECTOR3 normal;


};
#define BLEND_VERTEX_FVF (D3DFVF_XYZB1 | D3DFVF_NORMAL)
Then I use the BLEND_VERTEX_FVF to clone the teapot mesh to vertextBlendTeapot mesh and set according blend value for vertextBlendTeapot. Now my problem is: how to let the Device know that my current vertex buffer is vertextBlendTeapot's?

Share this post


Link to post
Share on other sites
Advertisement
When you call ID3DXMesh::DrawSubset, it'll set the vertex buffer as current. If you want to explicitly do that yourself (For if you're not calling DrawSubset()), you can call ID3DXMesh::GetVertexBuffer(), then IDirect3DDevice9::SetStreamSource() (Then Release() the vertex buffer).

Share this post


Link to post
Share on other sites
Thank you Evil Steve.
when call D3DXCreateCylinder() or D3DXCreateTeapot(), what 's the vertex format of the generated mesh?
BTW, is my vertex shader right when used to do vertex-blending(just one blending weight and two blend matrix).

matrix ViewProjMatrix;

matrix blend_matrix_1;
matrix blend_matrix_2;
vector Color;


//
// Input and Output structures.
//

struct VS_INPUT
{
vector position : POSITION;
float bendWeights : BLENDWEIGHT;
vector normal : NORMAL;
};

struct VS_OUTPUT
{
vector position : POSITION;
vector color : COLOR;
};

//
// Main
//

VS_OUTPUT Main(VS_INPUT input)
{
VS_OUTPUT output = (VS_OUTPUT)0;

vector tempPos;

tempPos=mul(input.position, blend_matrix_1)*input.bendWeights +
mul(input.position, blend_matrix_2)*(1-input.bendWeights);

tempPos.w=1;

output.position = mul(tempPos, ViewProjMatrix);
output.color = Color;

return output;
}



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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!