PDA

View Full Version : getVertsUsingFace / wrong sequence?


losbellos
03-29-2009, 01:21 PM
Hello,
when I use the polyop.getVertsUsingFace and using the array what I get to build an other polygon then it creates an enveloped shaped polygon instead of rectangle.
Obviously because the index sequence is wrong. (I checked it manually)
I wonder how to get it right withouth manually switching the last two elements.
The code basically is a poly copy.

Could somebody please help me out in this one?
THanks a lot




theFace = polyop.getfaceselection p
theVerts = polyop.getVertsUsingFace p theFace

theVerts = theVerts as array -- CONVERT BITARR TO ARRAY

for v=1 to theVerts.count do (
theVertsPos[v] = polyop.getVert p theVerts[v]
tempIdx = polyop.createvert p theVertsPos[v]
append theVerts2 tempIdx
)

polyop.createPolygon p theVerts2

SyncViewS
03-29-2009, 02:50 PM
Hi losbellos,
polyop.getVertsUsingFace returns a BitArray, that you cast to an Array, that implies elements (vertices in this case) are ordered by ascending index, which is quite never true when applied to actual topology.

You can use the Editable Poly GetFaceVertex method:

<index><EditablePoly>.GetFaceVertex <index>faceID <index>corner

Returns the vertex index of the Nth vertex used by the specified face. (where N is between 1 and the number of face corners). If the corner argument is higher than the number of face corners, the function will return 0.
(
local oPoly = convertToPoly(Plane())
local iFace = 1 -- as example
local aiVerts = #()

aiVerts = for i = 1 to (oPoly.getFaceDegree iFace) collect (oPoly.GetFaceVertex iFace i)

format "Vertices: % in Face: %\n" aiVerts iFace
)
-- output: Vertices: #(6, 1, 2, 7) in Face: 1
- Enrico

losbellos
03-29-2009, 03:52 PM
thanks a lot.

CGTalk Moderation
03-29-2009, 03:52 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.