How to change from polyop to meshop & Is the angle between two faces inside or outside of an object?

StackOverflow https://stackoverflow.com/questions/10050792

  •  29-05-2021
  •  | 
  •  

سؤال

Part 1:

How does

for i = 1 To polyop.getNumEdges $ do
(
  append faces ((polyop.getfacesusingedge $ #{i}) as array)
  if faces[i][2] != undefined then
  (
    f1 = polyop.getfacenormal $ faces[i][1];
    f2 = polyop.getfacenormal $ faces[i][2];  
  )
)

look using meshop?

This code reads all edges from an editable poly, appends the faces connecting at the edges to faces for easier access and gets the normals.

Problem is that previously the object was an editable mesh. After conversion to e.p. for some reason the number of faces is lessened. I need the whole object to consist of triangles only, so I cannot use this approach, as the conversion seems to combine some triangles to polygons.

Part 2:

I have a function

fn getAnglebetweentwoFaces face1 face2 =
(
    --theAngle = acos(dot face1 face2)
    theAngle = acos(dot (normalize face1) (normalize face2))
    return theAngle
) 

which works "well". It does tell me the angle between two faces but I need to know whether it is the angle inside of an object those two faces are a part of or outside. How do I do that?

Thanks in advance.

EDIT: I added

if face2Coord < 0 then
(
  normAngle = 360 - normAngle
)
normAngle = 180 - normAngle
return normAngle

to your function, now I get minus values for inner angles and plus values for outer angles

هل كانت مفيدة؟

المحلول

Part 1:

Not a direct answer but if the only issue is the number of faces seemingly getting lower after the conversion and you want to keep it simple, just make all mesh edges visible before converting. The structure of editable mesh is quite different from that of editable poly, in eMesh you'd iterate over the faces, each having three vertices - and three edges, none of which is shared with another face, which makes thing like these needlessly complicated. In ePoly the structure is defined by edges, making things like loop and ring selection and finding edges shared between faces (well, polygons actually) much easier.

Part 2:

You need some additional data to achieve that, for example centres of the faces (depending on how twisted your geometry is, pick either getFaceCenter or getSafeFaceCenter method). When you have these points, the rest is easy, if the center of one face lies above the plane of the other face, it's the smaller angle and you don't change it, if it's the opposite, it's the explement (360 - angle).

fn getAngleBetweenFaces normal1 normal2 center1 center2 =
(
    local face1Matrix = translate (matrixFromNormal normal1) center1
    local face2Coord = (center2 * (inverse face1Matrix)).z
    local normAngle = acos(dot (normalize normal1) (normalize normal2))
    if face2Coord < 0 do normAngle = 360 - normAngle
    normAngle 
)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top