- //real smooth normals...
- vnormal.x:=0.0;
- vnormal.y:=0.0;
- vnormal.z:=0.0;
- for m := 0 to FNumMeshes - 1 do
- begin
- if FMesh[m].FNumIndices > 0 then
- begin
- f := 0;
- while f < FMesh[m].FNumIndices - 1 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) or (FMesh[m].FVertex[FMesh[m].FIndices[j]].y=Find.y) or (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;
- L:=sqrt(sqr (vertexn.x) + sqr(vertexn.y) + sqr(vertexn.z));
- if L>0 then
- begin
- vertexn.x:=vertexn.x/L;
- vertexn.y:=vertexn.y/L;
- vertexn.z:=vertexn.z/L;
- FMesh[m].FVnormal[FMesh[m].FIndices[f]] := vertexn;
- end;
- Shared:=0;
- vnormal.x:=0;
- vnormal.y:=0;
- vnormal.z:=0;
- f := f + 1;
- end;
- end;
- end;