Reputation: 1
I try to load an animation from a MD5ANIM and a MD5Mesh file (3d animation and model Format in Doom) into my DX 11 deferred renderer.
Everything works fine except to the point where I have to Update the Models vertex positions and normals for the animation with XNA Math.
The result of the following code to calculate the rotated normals is always -1.#QNAN00 and the Model appear completely black.
Apart from that the calculation of position works fine and you can see the animation normaly running without normals completly black.
// 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
The Values at the beginng of calculation are:
float tempWeight.bias = 1.0000000
XMFLOAT3 rotatedPoint x=-0.022973990 y=-0.053293169 z=-0.10924719
XMFLOAT3 tempVert.normal = x=0.00000000 y=0.00000000 z=0.00000000
I have to mention that I calculate the the Values in a for loop. After the loop I store the values like this:
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)));
Cheers Max
Upvotes: 0
Views: 338
Reputation: 41107
XMVector3Normalize
is going to return a floating-point special if you give it a normal of 0,0,0.
To compute a normal, you divide each element (a 0) by it's length (a 0). The result is a divide by zero failure.
Upvotes: 0