English 中文(简体)
Recalculate normal on editable poly object
原标题:

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 
     )


    )
最佳回答

resolved it by replacing the appropriate lines with the following code:

--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
问题回答

暂无回答




相关问题
Creating a walk-through using Virtools

I m creating a virtual walk-through in a museum environment. I have constructed the 3D virtual environment in 3Ds Max and I need to create the walking part in Virtools. I have found some tutorials ...

Extract vertex data from an FBX file?

I m trying to extract vertex and UV map information from a FBX file created with 3ds max 2010. All i could get from the file are good vertex and polygon index data but wrong UV maps. Can someone ...

How RPG characters are made

If RPG with the ability to change armors and clothes are made, how is it done? I mean the 3d side mostly If i make normal character, that has flat clothes, it would be easy, just change textures, but ...

How to check if MAX has finished loading

I am trying to instantiate a program via a python script as follows os.startfile( "C:/Program Files/Autodesk/3ds Max 2010/3dsmax.exe" ) since 3dsMax takes a bit of time to load, I wanna ...

Should I parse git status or use gitsharp?

I d like to integrate git into production pipeline to stage 3dsmax files. While it is alright to work with git through TortoiseGit, I d like to communicate with it from the Maxscript to add custom ...

Using 3D Studio Max DirectX shader in XNA problem

UPDATE 2: It now appears this is more of a modelling issue than a programming one. Whoops. I m new to XNA development, and despite my C# experience, I ve been stuck at one spot for going on two days ...

热门标签