THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/08/2006 at 12:49, xxxxxxxx wrote:
Either using the cache (if you will only be reading the polygon points) or the converted polygon object, you need to do these:
// Cast the object to a polygon object. This just saves time recasting. Make sure that you have a polygon object.
if (!obj->IsInstanceOf(Opolygon)) // not a polygon object
PolygonObject* pobj = ToPoly(obj);
// Get the Polygon and Vector arrays and counts.
CPolygon* polys = pobj->GetPolygon();
Vector* verts = pobj->GetPoint();
LONG pcount = pobj->GetPolygonCount();
LONG vcount = pobj->GetPointCount();
if (!(polys && verts)) // raise an error
// Traverse the polygon list and get the polygon points
CPolygon* lp = polys+pcount;
Vector* v[4];
for (polys; polys != lp; polys++)
{
v[0] = verts[polys->a];
v[1] = verts[polys->b];
v[2] = verts[polys->c];
v[3] = verts[polys->d];
}
v[] contains the Vectors of the polygon. The Vector class contains the (X,Y,Z) coordinates of the point. For Polygons that are triangles, polys->c == polys->d.
These are the UNtransformed point coordinates. If you need the transformed coordinates, you'll need to get the object's global matrix and multiply to the points:
Matrix mg = pobj->GetMg();
v[0] = v[0] * mg;
v[1] = v[1] * mg;
...
If animation is involved, you'll need to AnimateDocument() or AnimateObject() and possibly GetCache() or GetDeformCache().