游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2024|回复: 4

如何用DrawPrimitive或者DrawIndexedPrimitive渲染.x的mesh模型?

[复制链接]

23

主题

94

帖子

94

积分

注册会员

Rank: 2

积分
94
发表于 2007-4-10 13:25:00 | 显示全部楼层 |阅读模式
我只会这样...
        for( int i=0; i<m_dwNumMaterials; i++ )
        {
                m_pd3dDevice->SetMaterial( &m_pMeshMaterials );
                m_pd3dDevice->SetTexture( 0, m_pMeshTextures );               
                m_pMesh->DrawSubset( i );
        }


请问各位高手,我怎么才能改为用DrawPrimitive或者DrawIndexedPrimitive来画呢?
thx!

8

主题

284

帖子

296

积分

中级会员

Rank: 3Rank: 3

积分
296
QQ
发表于 2007-4-10 13:34:00 | 显示全部楼层

Re:如何用DrawPrimitive或者DrawIndexedPrimitive渲染.x的mesh模型?

ID3DXMesh::GetIndexBuffer
ID3DXMesh::GetVertexBuffer
ID3DXMesh::GetNumFaces
ID3DXMesh::GetNumVertices

23

主题

94

帖子

94

积分

注册会员

Rank: 2

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

Re: Re:如何用DrawPrimitive或者DrawIndexedPrimitive渲染.x的mesh模型

King_jinjing: Re:如何用DrawPrimitive或者DrawIndexedPrimitive渲染.x的mesh模型?

ID3DXMesh::GetIndexBuffer
ID3DXMesh::GetVertexBuffer
ID3DXMesh::GetNumFaces
ID3DXMesh::GetNumVert...


这样...怎么设置材质纹理呢?如下:

        LPDIRECT3DVERTEXBUFFER9 mesh_pVB                =        NULL;
        LPDIRECT3DINDEXBUFFER9        mesh_pIB                =        NULL;       
        m_pMesh->GetVertexBuffer( &mesh_pVB );
        m_pMesh->GetIndexBuffer( &mesh_pIB );       

        DWORD mesh_FVF = m_pMesh->GetFVF();
        DWORD mesh_NumVers = m_pMesh->GetNumVertices();
        DWORD mesh_BytesPerVertex = m_pMesh->GetNumBytesPerVertex();
        DWORD mesh_NumFaces = m_pMesh->GetNumFaces();
        m_pd3dDevice->SetFVF(mesh_FVF);
        m_pd3dDevice->SetStreamSource(0,mesh_pVB,0,sizeof(mesh_FVF));       
        m_pd3dDevice->SetIndices( mesh_pIB);
        m_pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0,0,              
                                            mesh_NumVers,0,mesh_NumFaces);


我就是按照上面这样做的,结果不对... 再说了,纹理、材质都没有设定啊。怎么知道哪个三角形面片应该用什么材质什么纹理?谢谢了



8

主题

284

帖子

296

积分

中级会员

Rank: 3Rank: 3

积分
296
QQ
发表于 2007-4-10 13:51:00 | 显示全部楼层

Re:如何用DrawPrimitive或者DrawIndexedPrimitive渲染.x的mesh模型?

ID3DXMesh::GetAttributeTable
ID3DXMesh::GetFVF

23

主题

94

帖子

94

积分

注册会员

Rank: 2

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

Re: Re:如何用DrawPrimitive或者DrawIndexedPrimitive渲染.x的mesh模型

King_jinjing: Re:如何用DrawPrimitive或者DrawIndexedPrimitive渲染.x的mesh模型?

ID3DXMesh::GetAttributeTable
ID3DXMesh::GetFVF


恩,我试试去,谢谢king_jinjing^_^
你用MSN吗?我想加你为好友^_^ 有空的时候聊聊天,向你请教问题等
我的MSN是:jiayuxu@yahoo.com.cn
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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