2

我正在研究出口商,但我遇到的问题是正常计算。

我一直在阅读很多关于此的帖子,似乎“getnormal”功能不像预期的那样工作。(这是为我的出口商造成错误结果的原因)。

所以我需要手动重新计算。

问题是 - 我该怎么做?计算法线的部分现在看起来像这样:

如果你提供了一个函数,那么请记住下面的这段代码,我不想重写所有内容。

提前致谢。

   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 
     )


    )
4

1 回答 1

1

通过用以下代码替换相应的行来解决它:

--get the object's transformation
myTransform = Obj.transform

-- get the normal * transformation - translation
v1 = (coordsys local getnormal Obj face.x)* myTransform  - (myTransform.translationpart)
v2 = (coordsys local getnormal Obj face.y)* myTransform  - (myTransform.translationpart)
v3 = (coordsys local getnormal Obj face.z) * myTransform - (myTransform.translationpart)

--normalize them / and write normal to a new variable
v11 = normalize v1
v22 = normalize v2
v33 = normalize v3

--append to array
append MeshArrays[4] v11
append MeshArrays[4] v22
append MeshArrays[4] v33
于 2010-11-16T17:11:00.617 回答