THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/05/2008 at 10:14, xxxxxxxx wrote:
Hopefully, you've set up the vertices values (for a sphere) and set up the polygon indices (a,b,c,d) to point to the proper vertices by index in the Vector array. You should call obj->Message(MSG_UPDATE) after doing this setup.
The sphere primitive subdivision or lod only apply to the sphere primitive object. There can be no effect on the polygon object without direct intervention (you, that is).
BuildPolyHull() and BuildIsoHull() are what the Atom object in the examples is using to build the objects to represent the atom. These are probably a bit more complex than your needs since you are only interested in building a single object. I wouldn't worry about the BuildIsoHull() at all.
ToPoly() only changes the pointer type. To make an object polygonal (when possible) you need to use SendModelingCommand(MCOMMAND_CURENTSTATETOOBJECT). I don't think you should be doing this in a generator object's GetVirtualObject() method, though.
My thoughts here:
1. You could just use a tag plugin attached to a regular sphere primitive which sets the sphere primitive segments depending upon some calculation of the distance of the sphere from the current camera. Now you have a sphere with LOD. This is what makes tags so useful - we can't modify or augment existing object types in C4D, but we can do this (to some extent) with plugin tags. In some sense, the same is true of generator and modifier object plugins as well - but their purposes are more explicit.
2. If you are determined to go the generator object route, it may require that there is a child object (or not - not certain if GetVirtualObjects() is somehow not triggered without a child present). You should either just create a primitive sphere and do the LOD for its segments or just create a polygon object and set it up with the calculated vertices dependent upon the LOD. You can't convert the primitive into a polygon object while in GetVirtualObjects() as best I can tell (see this