如何在DirectX 9中转换XMVECTOR到d3vector和D3DCOLORVALUE

how to convert XMVECTOR to D3DVECTOR and to D3DCOLORVALUE in DirectX 9?

本文关键字:XMVECTOR d3vector D3DCOLORVALUE 转换 DirectX      更新时间:2023-10-16

我从www.directxtutorial.com学习DirectX (DirectX 9),并在windows 8中使用visual studio 2012。d3dx9 (d3dx)替换为其他头如DirectXMath,因此我替换了所有需要的,但有一个问题-将XMVECTOR转换为D3DVECTOR和D3DCOLORVALUE。

问题代码(The problem written -/problem!/):

void init_light(void) {
D3DLIGHT9 light;    // create the light struct
D3DMATERIAL9 material;    // create the material struct
ZeroMemory(&light, sizeof(light));    // clear out the light struct for use
light.Type = D3DLIGHT_DIRECTIONAL;    // make the light type 'directional light'
light.Diffuse = D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f); /*problem!*/   // set the light's color
light.Direction = D3DXVECTOR3(-1.0f, -0.3f, -1.0f); /*problem!*/
d3ddev->SetLight(0, &light);    // send the light struct properties to light #0
d3ddev->LightEnable(0, TRUE);    // turn on light #0
ZeroMemory(&material, sizeof(D3DMATERIAL9));    // clear out the struct for use
material.Diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); /*problem!*/   // set diffuse color to white
material.Ambient = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); /*problem!*/   // set ambient color to white
d3ddev->SetMaterial(&material);    /*set the globably-used material to &material*/ }

你应该用XMVECTOR替换所有的d3vector,用XMCOLOR替换所有的d3dxcolor。