SOLVED Get normals of an arbitrary Cinema 4d object

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.

HemisphereIntersection.PNG

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.

AFAIK, a normal tag is usually only used for special cases, like imports from CAD programs. If it's not being explicitly generated by whatever process created the object, then you will not have one. Which means, you almost never have one.

Calculate your normals from the polygons by the cross product.

As for your other question, which primitives cannot be converted to a polygon object? For cameras, lights etc. this should be obvious?

Aha I see, this makes sense for the NormalTag data. And yeah of course cross product is what I need...

Regarding the primitives not turning into polygon object, I thought that was happening with a cube, but now after testing it again it definitely is. So I must have been mistaken before.

Thanks for the help, going to mark this as solved.