|
|
今天小弟偶然看到一个顶点混合的小例子,但是有很多东西不很明白
struct CUSTOMVERTEX
{
D3DXVECTOR3 position;
FLOAT b[3]; //????
DWORD index; //????
DWORD color;
FLOAT tu,tv; };
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZB4|D3DFVF_LASTBETA_UBYTE4|D3DFVF_DIFFUSE|D3DFVF_TEX1)
以上打问号的不清楚
还有
D3DFVF_XYZB4|D3DFVF_LASTBETA_UBYTE4 也不明白
InitVB中的代码:
/// 创建顶点缓冲
if( FAILED( g_pd3dDevice->CreateVertexBuffer( 50*2*sizeof(CUSTOMVERTEX),
0, D3DFVF_CUSTOMVERTEX,
D3DPOOL_DEFAULT, &g_pVB, NULL ) ) )
{
return E_FAIL;
}
CUSTOMVERTEX* pVertices;
if( FAILED( g_pVB->Lock( 0, 0, (void**)&pVertices, 0 ) ) )
return E_FAIL;
for( DWORD i=0; i<50; i++ )
{
FLOAT theta = (2*D3DX_PI*i)/(50-1);
pVertices[2*i+0].position = D3DXVECTOR3( sinf(theta),-1.0f, cosf(theta) );
pVertices[2*i+0].b[0] = 1.0f;???
pVertices[2*i+0].b[1] = 0.0f;???
pVertices[2*i+0].b[2] = 0.0f;???
pVertices[2*i+0].index = 0x0000; /// 0号权重受到1.0的0号矩阵影响
pVertices[2*i+0].color = 0xffffffff;
pVertices[2*i+0].tu = ((FLOAT)i)/(50-1);
pVertices[2*i+0].tv = 1.0f;
pVertices[2*i+1].position = D3DXVECTOR3( sinf(theta), 1.0f, cosf(theta) );
pVertices[2*i+1].b[0] = 0.5f;???
pVertices[2*i+1].b[1] = 0.5f;???
pVertices[2*i+1].b[2] = 0.0f;???
pVertices[2*i+1].index = 0x0001; /// 0号权重受到0.5的1号矩阵影响
pVertices[2*i+1].color = 0xff808080;
pVertices[2*i+1].tu = ((FLOAT)i)/(50-1);
pVertices[2*i+1].tv = 0.0f;
}
g_pVB->Unlock();
以上打问号的实在搞不懂是什么意思,还望各位大哥哥大姐姐不吝赐教 [em19]
|
|