Directx SOS(物资援助)
嗯。 我可以将网格加载到项目中,但无法更改网格的颜色。 在屏幕上,网格的颜色为白色。 我想把它换成红色,但我不能。 请帮忙 这是我的密码:Directx SOS(物资援助),directx,Directx,嗯。 我可以将网格加载到项目中,但无法更改网格的颜色。 在屏幕上,网格的颜色为白色。 我想把它换成红色,但我不能。 请帮忙 这是我的密码: g_pApp->m_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE); g_pApp->m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); g_pApp->m_pd3dDevice-&g
g_pApp->m_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
g_pApp->m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
g_pApp->m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
g_pApp->m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE);
g_pApp->m_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
g_pApp->m_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
g_pApp->m_pd3dDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
g_pApp->m_pd3dDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE);
D3DMATERIAL9 mtrl;
D3DUtil_InitMaterial(mtrl,1,1,1);
for(int j = 0 ; j < m_meshTarget[i].dwNumMaterial ; j++){
if( m_meshTarget[i].pnTextureIndex[j] != -1){
g_pApp->m_pd3dDevice->SetTexture(0, m_meshTarget[i].ppTexture[m_meshTarget[i].pnTextureIndex[j]]);}
else
g_pApp->m_pd3dDevice->SetTexture(0,0);
g_pApp->m_pd3dDevice->SetMaterial(&mtrl);
m_meshTarget[i].pMesh->DrawSubset(j);
}
g_pApp->m_pd3dDevice->SetRenderState(D3DRS_照明,错误);
g_pApp->m_pd3dDevice->SetTextureRestate(0,D3DTSS_颜色arg1,D3DTA_纹理);
g_pApp->m_pd3dDevice->settexturestate(0,D3DTSS_COLORARG2,D3DTA_DIFFUSE);
g_pApp->m_pd3dDevice->settexturestate(0,D3DTSS_COLOROP,D3DTOP_禁用);
g_pApp->m_pd3dDevice->SetRenderState(D3DRS_字母可转换,错误);
g_pApp->m_pd3dDevice->settexturestate(0,D3DTSS_ALPHAOP,D3DTOP_禁用);
g_pApp->m_pd3dDevice->settexturestrestate(1,D3DTSS_COLOROP,D3DTOP_DISABLE);
g_pApp->m_pd3dDevice->settexturestrestate(2,D3DTSS_COLOROP,D3DTOP_DISABLE);
D3D材料9 mtrl;
D3DUtil_初始材料(mtrl,1,1,1);
对于(intj=0;jm_pd3dDevice->SetTexture(0,m_meshTarget[i].ppTexture[m_meshTarget[i].pnTextureIndex[j]];}
其他的
g_pApp->m_pd3dDevice->SetTexture(0,0);
g_pApp->m_pd3dDevice->SetMaterial(&mtrl);
m_meshTarget[i].pMesh->DrawSubset(j);
}
不完全确定D3DUtil_InitMaterial()
的作用,但需要为mtrl
灯光属性设置适当的值
float red = 1.0f, green = 0.0f, blue = 0.0f;
mtrl.Diffuse.r = 1.0f;
mtrl.Diffuse.g = 1.0f;
mtrl.Diffuse.b = 1.0f;
mtrl.Ambient.r = red;
mtrl.Ambient.g = green;
mtrl.Ambient.b = blue;
mtrl.Specular.r = 0.5f;
mtrl.Specular.g = 0.5f;
mtrl.Specular.b = 0.5f;
mtrl.Power = 8.0f;
g_pApp->m_pd3dDevice->SetMaterial(&mtrl);
漫反射、镜面反射和功率值仅为示例。感谢您的帮助。但这对我一点帮助都没有。我不明白为什么网格的颜色是白色的。