- //real smooth normals...
- vnormal.x:=0.0;
- vnormal.y:=0.0;
- vnormal.z:=0.0;
- shared:=0;
- for m := 0 to FNumMeshes -1 do
- begin
- if FMesh[m].FNumIndices > 0 then
- begin
- f := 0;
- while f < (FMesh[m].FNumIndices - 3) do // go through all vertexes and
- begin
- Find:=FMesh[m].FVertex[FMesh[m].FIndices[f]];
- for J:=0 to FMesh[m].FNumIndices-1 do
- if ((FMesh[m].FVertex[FMesh[m].FIndices[j]].x=Find.x) and (FMesh[m].FVertex[FMesh[m].FIndices[j]].y=Find.y) and (FMesh[m].FVertex[FMesh[m].FIndices[j]].z=Find.z)) then
- begin
- vnormal.x:=vnormal.x+FMesh[m].FVNormal[FMesh[m].FIndices[j]].x;
- vnormal.y:=vnormal.y+FMesh[m].FVNormal[FMesh[m].FIndices[j]].y;
- vnormal.z:=vnormal.z+FMesh[m].FVNormal[FMesh[m].FIndices[j]].z;
- Inc(Shared);
- end;
- vertexn.x:=vnormal.x / shared;
- vertexn.y:=vnormal.y / shared;
- vertexn.z:=vnormal.z / shared;
- FMesh[m].FVnormal[FMesh[m].FIndices[f]] := normalize(vertexn);
- Shared:=0;
- vnormal.x:=0;
- vnormal.y:=0;
- vnormal.z:=0;
- f := f + 3;
- end;
- end;
- end;