I know there are a couple of threads here discussing this issue, but unfortunately I wasnt able to find a solution to the problem Im having.
Using the fbx sdk I can parse vertex coordinates and indices. I can draw meshes correctly but now am trying to implement very rudimentary lighting. For this I obviously need to read normals and doing so for a simple cube which has a side length of 1, 8 vertices and 36 indices. When using the fbx sdk my normals for the cube are parsed like this:
else if (fbxNormal->GetMappingMode() == FbxGeometryElement::eByPolygonVertex){
if (fbxNormal->GetReferenceMode() == FbxGeometryElement::eDirect){ // this is where the if is true, nowhere else
vertices[i].nor = XMFLOAT3(static_cast<float>(fbxNormal->GetDirectArray().GetAt(i).mData[0]),static_cast<float>(fbxNormal->GetDirectArray().GetAt(i).mData[1]),static_cast<float>(fbxNormal->GetDirectArray().GetAt(i).mData[2]));
}
I understand that to have lighting for a cube I should have 3 normals per vertex but right now when doing some checks the code runs in the code block specified above (the if statements). When I check the vertices I see this:
The normals seem very weird, am I exporting it wrong from 3ds?
My very simple lighting shader looks like this:
float4 diffuse = light.diffuse;
float3 finalColor = diffuse*light.ambient;
finalColor += saturate(dot(-light.dir,input.nor)*light.diffuse*diffuse);
return float4(finalColor,diffuse.a);
This is what the result looks like:
http://postimg.org/image/nh8vjyfep/full/
http://postimg.org/image/rj2s4fbm3/full/
Very odd :(