Jump to content
Developer Wiki and Function Reference Links ×

Need a challenge?


Recommended Posts

I could use some insight on this one.

I have a 3D polygon with 4 verticies. In a nutshell, I need to reverse the order of the verticies...whereby when you scroll through the verticies in the object info palette (OIP), they've reversed direction, i.e. instead of being clockwise, they'll now be counter clockwise.

Now a simple way to handle this is to use the mirror tool on the 3D polygon, but of course I have some non-symmetry situations where that doesn't work.

The problem I've run into is I haven't found a function for getting the vertex ID number. There are many functions where you have to specify the vertex number, but I'm missing one that gets the number and allows me to re-order the verticies....and more importantly, a function that allows me to set or renumber the verticies. Any suggestions?

Link to comment

This is for reversing vertices of a path PIO, but you should be able to modify it to work on 3D polys - just remember that the first vertex is 0, not 1.

Synopsis:

- read vertex coordinates into an array

- use the array to reposition vertices in the reverse order

------------

PROCEDURE ReversePath; { ? Petri Sakkinen 2002 }

VAR

i, j, n : INTEGER;

x, y, t, r : REAL;

obHd, pHd : HANDLE;

vx, vy : ARRAY[1..100] OF REAL;

ok : BOOLEAN;

BEGIN

obHd:=FSACTLAYER;

pHd:=GETCUSTOMOBJECTPATH(obHd);

n:=GETVERTNUM(pHd);

FOR i:=1 TO n DO

GETPOLYLINEVERTEX(pHd, i, vx, vy, t, r);

FOR i:=0 TO n-2 DO

SETPOLYLINEVERTEX(pHd, n-i, vx[i+2], vy[i+2], t, r, TRUE);

END;

RUN(ReversePath);

---------------------

Link to comment

Well Petri, that didn't work for 3D stuff, but it did make me realize that I need to relocate the points in reverse order, not RENUMBER the verticies in reverse order. Since 99% of the polygons I reverse are quads, I was able to just swap verticies 1 and 3 effectively mirroring the piece. It's a quick fix for now, but the concept would apply to an array for reversing points too. I'll develop that in the near future. Thank you for getting me past my brain freeze.

PROCEDURE ReverseVerticies;

VAR

VertX,

VertY,

VertZ :ARRAY[1..50] OF REAL;

hobject :HANDLE;

BEGIN

hobject:=FSActlayer;

WHILE hobject<>NIL DO BEGIN

GetPolyPt3D(hobject,1,VertX[1],VertY[1],VertZ[1]);GetPolyPt3D(hobject,3,VertX[2],VertY[2],VertZ[2]);

SetPolyPt3D(hobject,1,VertX[2],VertY[2],VertZ[2]);

SetPolyPt3D(hobject,3,VertX[1],VertY[1],VertZ[1]);

hobject:=NextSObj(hobject);

END;

END;

Run(ReverseVerticies);

[ 10-06-2004, 03:02 PM: Message edited by: tom kyler ]

Link to comment

OK, finally got it, here's the final setup:

PROCEDURE ReverseVerticies;

VAR

VertNum,

i :INTEGER;

VertX,

VertY,

VertZ :ARRAY[1..50] OF REAL;

hobject :HANDLE;

BEGIN

hobject:=FSActlayer;

WHILE hobject<>NIL DO BEGIN

Vertnum:=GetVertNum(hobject);

For i:=1 to (Vertnum-1) DO BEGIN

GetPolyPt3D(hobject,i,VertX,VertY,VertZ);

END;

For i:=(Vertnum-1) DownTo 1 DO BEGIN

SetPolyPt3D(hobject,VertNum-i,VertX,VertY,VertZ);

END;

hobject:=NextSObj(hobject);

END;

END;

Run(ReverseVerticies);

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...