0

我尝试将 MD5ANIM 和 MD5Mesh 文件(Doom 中的 3d 动画和模型格式)中的动画加载到我的 DX 11 延迟渲染器中。
一切正常,除了我必须使用 XNA Math 更新动画的模型顶点位置和法线。以下代码计算旋转法线的结果始终为 -1。#QNAN00 并且模型显示为完全黑色。除此之外,位置的计算工作正常,您可以看到动画正常运行,没有法线完全黑色。

 // Add to vertices normal and ake weight bias into account
    tempVert.normal.x -= rotatedPoint.x * tempWeight.bias;
    tempVert.normal.y -= rotatedPoint.y * tempWeight.bias;
    tempVert.normal.z -= rotatedPoint.z * tempWeight.bias;
    //End

计算开始时的值是:

浮动 tempWeight.bias = 1.0000000

XMFLOAT3 旋转点 x=-0.022973990 y=-0.053293169 z=-0.10924719

XMFLOAT3 tempVert.normal = x=0.00000000 y=0.00000000 z=0.00000000

我不得不提到我在 for 循环中计算了值。在循环之后,我存储这样的值:

MD5Model.subsets[k].positions[i] = tempVert.pos;        // Store the vertices position in the position vector instead of straight into the vertex vector
MD5Model.subsets[k].vertices[i].normal = tempVert.normal;       // Store the vertices normal
XMStoreFloat3(&MD5Model.subsets[k].vertices[i].normal,XMVector3Normalize(XMLoadFloat3(&MD5Model.subsets[k].vertices[i].normal)));

干杯马克斯

4

1 回答 1

0

XMVector3Normalize如果你给它一个正常的 0,0,0,它将返回一个浮点数。

要计算法线,您需要将每个元素 (a 0) 除以它的长度 (a 0)。结果是除以零失败。

于 2015-06-13T16:09:53.147 回答