|

楼主 |
发表于 2010-8-27 16:49:00
|
显示全部楼层
Re:MultiAnimation 除了tiny模型,其他模型显示不出来
这种渲染方式很奇怪
//-----------------------------------------------------------------------------
// Name: CAnimInstance: rawMeshFrame()
// Desc: Renders a mesh container. Here we go through each attribute group
// and set up the matrix palette for each group by multiplying the
// bone offsets to its bone transformation. This gives us the completed
// bone matrices that can be used and blended by the pipeline. We then
// set up the effect and render the mesh.
//-----------------------------------------------------------------------------
void CAnimInstance::DrawMeshFrame( MultiAnimFrame* pFrame )
{
MultiAnimMC* pMC = ( MultiAnimMC* )pFrame->pMeshContainer;
D3DXMATRIX mx;
if( pMC->pSkinInfo == NULL )
return;
// get bone combinations
LPD3DXBONECOMBINATION pBC = ( LPD3DXBONECOMBINATION )( pMC->m_pBufBoneCombos->GetBufferPointer() );
DWORD dwAttrib, dwPalEntry;
// for each palette
for( dwAttrib = 0; dwAttrib < pMC->m_dwNumAttrGroups; ++ dwAttrib )
{
// set each transform into the palette
for( dwPalEntry = 0; dwPalEntry < pMC->m_dwNumPaletteEntries; ++ dwPalEntry )
{
DWORD dwMatrixIndex = pBC[ dwAttrib ].BoneId[ dwPalEntry ];
if( dwMatrixIndex != UINT_MAX )
D3DXMatrixMultiply( &m_pMultiAnim->m_amxWorkingPalette[ dwPalEntry ],
&( pMC->m_amxBoneOffsets[ dwMatrixIndex ] ),
pMC->m_apmxBonePointers[ dwMatrixIndex ] );
}
// set the matrix palette into the effect
m_pMultiAnim->m_pEffect->SetMatrixArray( "amPalette",
m_pMultiAnim->m_amxWorkingPalette,
pMC->m_dwNumPaletteEntries );
// we're pretty much ignoring the materials we got from the x-file; just set
// the texture here
m_pMultiAnim->m_pEffect->SetTexture( "g_txScene", pMC->m_apTextures[ pBC[ dwAttrib ].AttribId ] );
// set the current number of bones; this tells the effect which shader to use
m_pMultiAnim->m_pEffect->SetInt( "CurNumBones", pMC->m_dwMaxNumFaceInfls - 1 );
// set the technique we use to draw
if( FAILED( m_pMultiAnim->m_pEffect->SetTechnique( m_pMultiAnim->m_sTechnique ) ) )
return;
//pMC->m_pWorkingMesh->DrawSubset( dwAttrib );
UINT uiPasses, uiPass;
// run through each pass and draw
m_pMultiAnim->m_pEffect->Begin( &uiPasses, 0 );
for( uiPass = 0; uiPass < uiPasses; ++ uiPass )
{
m_pMultiAnim->m_pEffect->BeginPass( uiPass );
pMC->m_pWorkingMesh->DrawSubset( dwAttrib );
m_pMultiAnim->m_pEffect->EndPass();
}
m_pMultiAnim->m_pEffect->End();
}
}
|
|