Maxsdk: FlipNormal is not updating faces

Maxsdk: FlipNormal is not updating faces

Anonymous
Not applicable
722 Views
3 Replies
Message 1 of 4

Maxsdk: FlipNormal is not updating faces

Anonymous
Not applicable

Hi, I am flipping the face of a mesh in SDK using the following pseudo/code. 

 

The problem is even the indices in the face array are restructured by FlipNormals, I am still not able to see the corrected face in the viewport or when exported. Perhaps some work needs to be done to update the normals array?

 

Mesh mesh = triOb->GetMesh();
mesh.FlipNormal(faceIndex)

triOb->mesh = mesh;
triOb->mesh.InvalidateTopologyCache();
triOb->mesh.buildRenderNormals();
triOb->NotifyDependents(FOREVER, PART_ALL, REFMSG_CHANGE);
triOb->Update(t);

Interface* ip = GetCOREInterface();
ip->RedrawViews(ip->GetTime());

 

0 Likes
723 Views
3 Replies
Replies (3)
Message 2 of 4

klvnk
Collaborator
Collaborator

try....

Mesh& mesh = triObj->GetMesh();
mesh.FlipNormal(f);
mesh.InvalidateTopologyCache();
Message 3 of 4

Anonymous
Not applicable

Thanks for the reply, I see that you are saving the reference of mesh and I was copying it back.

 

I can see that some models get updated on the viewport, but when testing on more meshes the faces on the viewport still don't change even vertex winding has been flipped (I confirm this by comparing vertex array).

What do you think could be the reason?

0 Likes
Message 4 of 4

klvnk
Collaborator
Collaborator

have you tried just....

 

 

 

 

Face& face = mesh.faces[f];
std::swap(face.v[0], face.v[2]);
// or
DWORD* fverts = mesh.faces[f].v;
std::swap(fverts[0], fverts[2]);

 

 

 

 

0 Likes