THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/08/2006 at 12:23, xxxxxxxx wrote:
Cinema 4D Version: 9.5
Platform: Windows ;
Language(s) : C++ ;
I'm trying to implement some objects constructed from a Sweep Object containing two splines (one for the path and one for the enveloppe).
I would like to know what are the positions of the points of the polygons of the Sweep Object when it is converted into a polygon object. Is it possible to find or to compute them?
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;
for (polys; polys != lp; polys++)
v = verts[polys->a];
v = verts[polys->b];
v = verts[polys->c];
v = 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 = v * mg;
v = v * mg;
If animation is involved, you'll need to AnimateDocument() or AnimateObject() and possibly GetCache() or GetDeformCache().
On 03/09/2006 at 06:16, xxxxxxxx wrote:
But this doesn't work when the object "obj" is a sweep nurbs object (type Osweep). I think that there is no solution because we can only access to the polygons of an object when this one was converted into a Polygon Object.
Am I wrong?
On 03/09/2006 at 13:19, xxxxxxxx wrote:
No, you are not wrong.
Yes, of course, the object must be a polygon object. You said "when it is converted into a polygon object" so I assumed that you were either calling "SendModelingCommand()" with MCOMMAND_MAKEEDITABLE or using a cache (which is alway turned into a polygon object). To access an object's polygon points, the object must be a polygon object (either directly or converted). That is a given. Procedural, deformer, and generator objects do not have polygons - even if the latter 'generates' them in the cache.
If you need to do this while retaining the original procedural object, just make a copy (clone) and convert that to get the points, removing it from the document and deleting it when done.
Just to add: if you only need to read the points of the converted polygon object and not change them, it would be best to use the cached object (let Cinema do the work for you). Check out BaseObject::GetCache() and GetDeformCache().