Hi Scott. I’ll do my best to answer your questions.
With regards your first two questions it’s possible that you’re not aware that the CPolygon offers you array subscript operator access to it’s points for several Cinema versions in addition to the more traditional direct .a, .b, .c and .d access. So myPolygon is the same as myPolygon.b. Hopefully that should clear up your first two points.
Looking at your own code perhaps you need a refresher in the way selections are stored. For example this piece of code will not work or give you the result you are after :
while(esel->GetRange(seg++, MAXLONGl, &a, &b))
for(LONG i=a; i<=b; ++i)
edgePointIndex1 = i;
edgePointIndex2 = i+1;
//GePrint( LongToString(edgePointIndex1) + " " + LongToString(edgePointIndex2) );
Within Cinema edge indeces are stored as the polygon index * 4 + edge within polygon. See the SDK docs for this e.g. PolygonObject::GetEdgeS().
To retrieve actual point indeces from the edge selection you must retrieve the polygon
Int32 polygonIndex = edgePointIndex / 4;
Then the edge itself, the simplest way as it’s always from 0-3 is to use a bitmask i.e.
Int32 edgeIndex = edgePointIndex&3;
And finally you retrieve the two point indeces from this thus
const CPolygon* polys = object->GetPointR();
Int32 firstEdgeIndex = polys[polygonIndex][edgeIndex];
Int32 secondEdgeIndex = polys[polygonIndex][edgeIndex + 1];
Q: Why can you be so cavalier about the addition? A: Because the array subscript operator for the CPolygon has been designed to allow such abuse and uses the modulus of the passed index and the point point to return the correct corner point index.
Q: Why pass the edge index to the polygon? A: Because the edge index directly relates to the polygon index and is always made up of the two points poly[edge] and poly[edge + 1].
My psuedo code example wasn’t very pseudo, you really only need to swap out the for loop calls and feed it the correct initial inputs and it should give you a rough result.
Every application has a different set of internal data structures and accessors, so this is not going to be transportable code. However hopefully this answers your questions with regards the specifics of the Cinema plugin for you.