how to guarantee the right vertex-buffer?

Started by
1 comment, last by sunrisefe 14 years, 10 months ago
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?
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).
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;}


This topic is closed to new replies.

Advertisement