PolygonObject, Clone, Scope, Free
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/06/2005 at 13:31, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 7.3/8.5
Platform: Windows ;
Language(s) : C++ ;---------
I just got out of bed so maybe this will clear itself up as I wake up some, but here's what I want to do...
1. get pointer to active (polygon) object
2. make a clone of that object
3. walk the list of tags on the clone, while...
4. potentially adding additional tags to the original
5. free the clone when done.
...I don't want to be adding tags to the original, while I'm in a loop walking down the list of tags - which is the (only) reason for the clone. I have no problems with the code involved in steps 1,3 or 4... my question revolves around making and freeing the clone. The clone will need to have copies of all the tags off the original, as well as access to the vertices of the original polygon object.
So... it looks like the base class of the PolygonObject class (C4DAtom) has a 'GetClone()' routine, but it's unclear to me at this point how I'd go about freeing the cloned object if I use that (?).
Alternatively, the PolygonObject itself has a Alloc() and Free() functions which would create/free a new one and presumably there's a CopyTo() somewhere (?) n the class tree that I could use to clone the original... but in this case, it's unclear to me if/whether all the tags would get copied as well.
Could anyone clarify this for me?
Thanks,
- Keith -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/06/2005 at 15:05, xxxxxxxx wrote:
If you go down the class inheritance list, PolygonObject eventually gets to the Atom class. This has GetClone() and CopyTo(). When you clone an object, unless you use the COPY_NO_BRANCHES flag, the branches (tags) are cloned as well. So you shouldn't need CopyTo().
When you create a cloned object, unless you insert it into a document, you are the owner and are responsible for Free()ing its resources (i.e.: "The caller owns the pointed object"). A simple PolygonObject::Free(op) should free the object and any tags attached (I think!). You can always GetTag() loop and free them as well (then call PolygonObject::Free(op). If this causes a crash, definitely let the object Free(op) do the work. In other words, I'm not certain who 'owns' the tags attached to the object, but most likely, the object does and will free them itself.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/06/2005 at 16:30, xxxxxxxx wrote:
Thanks Robert... some coffee (the kind you drink) cleared some of that up for me... in the end, I decided to just alter and add the cloned object to the document, so I don't alter the original and I don't have to worry about freeing it ;).
I also just ended up allocating the clone PolyObject, then doing a pOrigPolyObj->CopyTagsTo() to the clone, then cloned the faces and vertices by hand. The normals, UVs, phong, etc tags all got taken care of with the CopyTagsTo() call.
- Keith -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/06/2005 at 16:43, xxxxxxxx wrote:
BTW, this plugin is the 4th of a suite that I mentioned in my recent thread in the C4D forums on R'osity (I'm Spanki). This one fixes up all the 'group selections' that got mirrored from collapsing a Symmetry object.
It takes all the polygons that belong in a 'rHand' (for example) group/selection out of the (mirrored) 'lHand' group and creates the new 'rHand' group and puts those polys in there.
For my particular case at least (there are 16 groups, that make up one hand alone, plus the forearm, shoulder, collar, buttock, thigh, shin, foot, toe and eyes), it works like a champ and will save me hours of teduis work.
For the time-being, I hard-coded the names of all the mirrored groups ("leftEye", "rightEye"), so I still need to add the code to load that info from some user-supplied file, but so far, so good.
- Keith