I'm developing a plugin on Windows 10 with C++, R23, which represents a fluid volume.
So I've got a functionality which needs to preview the intersection of my object with a Cinema 4D object. You can imagine the below screenshot to have the magenta mesh only in the hollow hemisphere.
Anyway for that I need the vertices, triangle faces and normals data from the hemisphere. For that I do the following:
BaseObject *intersectionGeometry = ...; // ACQUIRED FROM LINK
if (intersectionObject != nullptr) {
ModelingCommandData mcd;
mcd.doc = document;
mcd.op = intersectionObject;
if (!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, mcd)) return;
C4DAtom* atom = mcd.result->GetIndex(0);
BaseObject* const res = static_cast<BaseObject*>(atom); // WITH SOME STANDARD PRIMITIVES THIS IS NULLPTR
if (res != nullptr && res->GetType() == Opolygon) {
PolygonObject* polyObjectRes= static_cast<PolygonObject*>(res);
Vector* points = polyObjectRes->GetPointW();
CPolygon* polygons = polyObjectRes->GetPolygonW();
unsigned polygonsCount = polyObjectRes->GetPolygonCount();
unsigned pointsCount = polyObjectRes->GetPointCount();
NormalTag* normalTag = static_cast<NormalTag*>(polyObjectRes>GetTag(Tnormal)); // THIS IS ALWAYS NULLPTR!
}
}
So as you can see I'm taking a BaseObject*
and convert to a PolygonObject*
with ModelingCommandData*
. Not sure if this is the best way but it works for most standard primitives (like a sphere or torus).
After I have the PolygonObject*
I take its vertices and polygons arrays which is fine.
But then I'm having difficulty with the NormalTag*
which is never anything else but nullptr.
My main question is about the NormalTag
and how can I access that data? And my secondary question is how come not all primitives can be converted to a PolygonObject*
? Any help would be appreciated.
Regards,
Georgi.