I m working on a exporter, but the problem I m stuck at is the normal calculation.
I ve been reading many posts about this, and it seems like the "getnormal" function does not work like intended. (this is the one creating wrong results for my exporter).
So I need to recalculate it manually.
The question is - How do I do this? the part that calculates the normal now looks like this:
If you provide a function, then please keep in mind this code below, I d like to not rewrite everything.
thanks in advance.
for i = 1 to num_faces do
(
face = getFace Obj i
v1 = (MeshArrays[2].count + 1)
v2 = (MeshArrays[2].count + 2)
v3 = (MeshArrays[2].count + 3)
append MeshArrays[1] [v1,v2,v3]
v1 = coordsys world getvert Obj face.x
v2 = coordsys world getvert Obj face.y
v3 = coordsys world getvert Obj face.z
append MeshArrays[2] v1
append MeshArrays[2] v2
append MeshArrays[2] v3
v1 = (coordsys local getnormal Obj face.x) -- * theInvTM
v2 = (coordsys local getnormal Obj face.y) --* theInvTM
v3 = (coordsys local getnormal Obj face.z) --* theInvTM
append MeshArrays[4] v1
append MeshArrays[4] v2
append MeshArrays[4] v3
if Obj.numtverts != 0 then
(
tvface = getTVFace Obj i
v1 = getTVert Obj tvface.x
v2 = getTVert Obj tvface.y
v3 = getTVert Obj tvface.z
append MeshArrays[3] v1
append MeshArrays[3] v2
append MeshArrays[3] v3
)
)