游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1432|回复: 2

用DrawIndexedPrimitive绘制mesh模型的问题...

[复制链接]

23

主题

94

帖子

94

积分

注册会员

Rank: 2

积分
94
发表于 2007-4-10 15:46:00 | 显示全部楼层 |阅读模式
为什么我的这个绘制有问题?
请高手指点。谢谢了

VOID Render()
{
    g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
                         D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );   
    if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
    {
                SetupMatrices();
                LPDIRECT3DVERTEXBUFFER9 mesh_pVB                =        NULL;
                LPDIRECT3DINDEXBUFFER9        mesh_pIB                =        NULL;               
                HRESULT hr = g_pMesh->GetVertexBuffer( &mesh_pVB );
                hr = g_pMesh->GetIndexBuffer( &mesh_pIB );
               
                DWORD mesh_FVF = g_pMesh->GetFVF();

                DWORD mesh_NumVers = g_pMesh->GetNumVertices();

                g_pd3dDevice->SetFVF(mesh_FVF);
                g_pd3dDevice->SetStreamSource(0,mesh_pVB,0,sizeof(mesh_FVF));       
                g_pd3dDevice->SetIndices( mesh_pIB);
                g_pd3dDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );//默认填充模式

                DWORD numSubsets = 0;
                g_pMesh->GetAttributeTable(0, &numSubsets);
                D3DXATTRIBUTERANGE* table = new D3DXATTRIBUTERANGE[numSubsets];
                g_pMesh->GetAttributeTable(table, &numSubsets);
                for(DWORD i=0; i<numSubsets; i++)
                {
                        DWORD attribId = table.AttribId;
                        DWORD FaceStart = table.FaceStart;
                        DWORD FaceCount = table.FaceCount;
                        DWORD VertexStart = table.VertexStart;
                        DWORD VertexCount = table.VertexCount;
                       
            g_pd3dDevice->SetMaterial( &g_pMeshMaterials );
            g_pd3dDevice->SetTexture( 0, g_pMeshTextures );

            g_pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0,0,
                                           mesh_NumVers,FaceStart*3, FaceCount);
                }

                g_pd3dDevice->EndScene();
    }
    g_pd3dDevice-&gtresent( NULL, NULL, NULL, NULL );
}



       /* 这样绘制就是对的。
           for( DWORD i=0; i<g_dwNumMaterials; i++ )
        {
            g_pd3dDevice->SetMaterial( &g_pMeshMaterials );
            g_pd3dDevice->SetTexture( 0, g_pMeshTextures );
            g_pMesh->DrawSubset( i );
        }               
        */

23

主题

94

帖子

94

积分

注册会员

Rank: 2

积分
94
 楼主| 发表于 2007-4-10 15:49:00 | 显示全部楼层

Re: 用DrawIndexedPrimitive绘制mesh模型的问题...

我其实就是想用DrawIndexedPrimitive或者DrawPrimitive绘制mesh模型,不想用DrawSubset()

大家帮我找找问题吧。我上面的绘制,结果乱起八糟的

23

主题

94

帖子

94

积分

注册会员

Rank: 2

积分
94
 楼主| 发表于 2007-4-10 16:44:00 | 显示全部楼层

Re: 用DrawIndexedPrimitive绘制mesh模型的问题...

cactusnb: 用DrawIndexedPrimitive绘制mesh模型的问题...

为什么我的这个绘制有问题?
请高手指点。谢谢了

VOID Render()
{
    g_pd3dDevice->Clear( 0, N...

已经改好了,参数设置的问题... 谢谢各位。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-4-12 22:49

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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