游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2027|回复: 3

MultiAnimation 除了tiny模型,其他模型显示不出来

[复制链接]

52

主题

155

帖子

160

积分

注册会员

Rank: 2

积分
160
发表于 2010-8-27 15:43:00 | 显示全部楼层 |阅读模式
微软那个骨骼动画的例子,
我用3d max 导出三个动作集的.x
然后加载显示,调试没任何错误,模型也加载上去了。 就是显示不出来。

而我用skinmesh例子来看,导出的模型是正确的。问题出在MultiAnimation的代码上,
我试了更换投影举证,更改视点,初始位置矫正,都不行。 试了两天了,无结果。
哪位大侠能帮忙看看。


http://rapidshare.com/files/415378291/MultiAnimation.rar.html
代码和模型都放在这里啦

52

主题

155

帖子

160

积分

注册会员

Rank: 2

积分
160
 楼主| 发表于 2010-8-27 15:45:00 | 显示全部楼层

Re:MultiAnimation 除了tiny模型,其他模型显示不出来

http://www.toymaker.info/Games/html/invisible_geometry.html
按照这里面说的,都试了,还是不行

52

主题

155

帖子

160

积分

注册会员

Rank: 2

积分
160
 楼主| 发表于 2010-8-27 16:36:00 | 显示全部楼层

Re:MultiAnimation 除了tiny模型,其他模型显示不出来

仔细看了下,发现这个例子在渲染的时候,根本不传入D3DTS_WORLD,而是在shader里通过vsArray20这个鸟东西计算顶点位置。好奇怪,第一次看见这种写法。

int CurNumBones = 2;

VertexShader vsArray20[ 4 ] = { compile vs_2_0 VertSkinning( 1 ),
                                compile vs_2_0 VertSkinning( 2 ),
                                compile vs_2_0 VertSkinning( 3 ),
                                compile vs_2_0 VertSkinning( 4 ) };


//--------------------------------------------------------------------------------------
// Techniques
//--------------------------------------------------------------------------------------




technique Skinning20
{
    pass p0
    {
        VertexShader = ( vsArray20[ CurNumBones ] );
        PixelShader = compile ps_2_0 PixScene();
    }
}

52

主题

155

帖子

160

积分

注册会员

Rank: 2

积分
160
 楼主| 发表于 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();
               
    }
}

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-8-18 20:28

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表