SendModelingCommand() document
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/12/2008 at 21:31, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R9-R11
Platform: Windows ; Mac ; Mac OSX ;
Language(s) : C++ ;---------
My code needs to do three SendModelingCommand() (one optional). First, MCOMMAND_CURRENTSTATETOOBJECT on the source object. Then a MCOMMAND_TRIANGULATE and MCOMMAND_REVERSENORMALS (optional) is done on the result inserted into a fake document.For the latter two, do I need to insert back into the fake document after each command? Do I need a document at all? Where is the result of MCOMMAND_REVERSENORMALS? Is it the same as MCOMMAND_TRIANGULATE?
[Ivory Soap Box]
As I stated some time ago, you guys *really* need an example for EACH and EVERY command (or at least one for every variation). I'm frigging guessing out my ass because there isn't a single set of examples here, in the docs, in the cinema4dsdk code. How long has Cinema 4D been around? I don't have nine lives and time to speculate on how every function (of the thousands) works in the SDK. My god, every function is different and unknown territory requiring an R&D; department. Now you know why there are sooooo few C4D plugin devs out there. The simplest things require an expeditionary force. You want more devs - fill us in. Please...
[/Ivory Soap Box] -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/12/2008 at 03:54, xxxxxxxx wrote:
You need a document for Currentstatetoobject for sure. The other two I am not sure but it wouldn´t hurt passing a document. Reversenormals and triangulate should directly change the passed object I´d assume. currentstatetoobject results in the atomarray, so a new object. All results should be equal to how it works in c4d (currentstate creates a new object in OM, triangulate and reverse normal do not...)
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/12/2008 at 07:45, xxxxxxxx wrote:
I already know how to use MCOMMAND_CURRENTSTATETOOBJECT. MCOMMAND_TRIANGULATE has one message here which mentions that the result is returned in mcd.op (and, no, it doesn't need a document thankfully). That seems to work. MCOMMAND_REVERSENORMALS crashes C4D every time I try it. I implemented my own routine to reverse the polygon index order - fast and, look, no crashes.
There are 50 modeling commands, not including the modeling library tool commands and modeling library menu commands. Yet there are about three or four of all of these covered anywhere. I've used some others successfully (selection commands and whatnot) but there has to be (actually there is) a better, more reliable, standard way to do these. Why not simply provide functions instead of this terse and unreliable system!?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/12/2008 at 07:58, xxxxxxxx wrote:
Howdy,
> Quote: Originally posted by kuroyume0161 on 10 December 2008
>
> * * *
>
> ...I implemented my own routine to reverse the polygon index order - fast
> and, look, no crashes.
>
> * * *Yeah, I did the same thing and it works plenty fast enough. ;o)
I have to agree with you on the fact that there aren't enough examples on the more obscure functions of the SDK. It seems that I end up experimenting with them until I come up with the right solution, which is really time consuming. :o(
Adios,
Cactus Dan -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/12/2008 at 11:05, xxxxxxxx wrote:
It's bad when your own routines are preferred over the SDK's!
Continuing onward, this entire scenario stems from the plugin tool being created. In order to use the tool, the user selects an object in the document, selects the tool, and then double-clicks a point (seed point) on the object before starting the process. Since the source object may be deformed or generated or primitive, I need a polygonal representation (if there is one).
What I'm finding is that if the MCOMMAND_CURRENTSTATETOOBJECT result isn't inserted into a document, I can't apply the global matrix (if the object is translated/rotated/scaled). The result is only needed to get the seed point using GeRayCollider in the tool's MouseInput to see if the point is on the object and, most importantly, where on the object.
Problem is that in no way do I want to insert the result into the actual document - the result is strictly for seeding and then passed on for processing. So I create a fake document in which the result is inserted and its global matrix set to that of the object. But this isn't working as expected. It may be that the camera/screen isn't correct - but the process works (even without a fake document) if the object has no tranformations! What the...
Maybe I should reuse Polygonize() again but there are some issues with it searching the forum here and it led to crashes after some use of the tool (which creates polygon objects btw). Again, the easy solution is always the least stable - why? Nowhere is it mentioned that Polygonize() shouldn't be used in relation to a tool (Draw() I could see, but in MouseInput()?). Can it not handle polygonizing scenes with lots of polygons already?
This plugin is so simple. The non-C4D code is simple and works beautifully. The C4D code on the other hand is driving me insane. Hint: GeRayCollider should do ALL of this for you - send it any object, it polygonizes it, does its thing, and returns the point. If there aren't any polygons, as it works now. How novel...
Any suggestions on getting proper results here? I've been using this SDK for years and its complexity and quirkiness never fails to cause grief.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/12/2008 at 17:39, xxxxxxxx wrote:
After venting all of my frustrations, I have finally stumbled (apt word here) upon a methodology that works. One thing that was leading to crashes but didn't seem to become evident previous was filling in the current document in the routine (CSTO seemed to ignore it but attempting to insert the result thereafter was the crash culprit). So, here's the routine which gets me a polygonized-triangulated-transformed object just so I can test if the cursor was clicked over it (and where). Eeks. Note that I'm taking care elsewhere to delete the previous incarnation after removing it from the document (right after the ray collision test).
>
// - IvyTool.PolygonizeObject : Account for deformers and such on Source \> //\*---------------------------------------------------------------------------\* \> PolygonObject\* IvyTool::PolygonizeObject(BaseDocument\* doc) \> //\*---------------------------------------------------------------------------\* \> { \> // CurrentStateToObject obj \> BaseContainer mbc; \> mbc.SetBool(MDATA_CURRENTSTATETOOBJECT_INHERITANCE, TRUE); \> mbc.SetBool(MDATA_CURRENTSTATETOOBJECT_KEEPANIMATION, FALSE); \> #ifdef C4D_R95 \> mbc.SetBool(MDATA_CURRENTSTATETOOBJECT_NOGENERATE, FALSE); \> #endif // C4D_R95 \> ModelingCommandData mcd; \> mcd.doc = doc; \> mcd.flags = 0L; \> mcd.bc = &mbc; \> mcd.mode = MODIFY_ALL; \> mcd.op = obj; \> if (!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, mcd)) \> { \> return (PolygonObject\* )ErrorException::NullThrow(GeLoadString(SIVY_ERR_GENERAL), "IvyTool.PolygonizeObject.SendModelingCommand(CURRENTSTATETOOBJECT)"); \> } \> BaseObject\* cstoObj = static_cast<BaseObject\*>(mcd.result->GetIndex(0L)); \> if (!cstoObj) return (PolygonObject\* )ErrorException::NullThrow(GeLoadString(SIVY_ERR_GENERAL), "IvyTool.PolygonizeObject.cstoObj"); \> // - If the converted object is under Null objects, get PolygonObject underneath \> BaseObject\* dop; \> for (dop = cstoObj; dop && !dop->IsInstanceOf(Opolygon); dop = dop->GetDown()); \> if (!dop) \> { \> BaseObject::Free(cstoObj); \> return NULL; \> } \> if (dop != cstoObj) \> { \> dop->Remove(); \> BaseObject::Free(cstoObj); \> } \> PolygonObject\* pop = ToPoly(dop); \> \> // Apply matrix to vertices \> Vector\* pts = pop->GetPointW(); \> if (!pts) \> { \> PolygonObject::Free(pop); \> return (PolygonObject\* )ErrorException::NullThrow(GeLoadString(SIVY_ERR_GENERAL), "IvyTool.PolygonizeObject.No Vertices"); \> } \> LONG cnt = pop->GetPointCount(); \> Matrix mg = obj->GetMg(); \> for (LONG i = 0L; i != cnt; ++i) \> { \> pts[i] \*= mg; \> } \> \> // Triangulate pobj \> mcd.op = pop; \> mcd.doc = NULL; \> mcd.bc = NULL; \> if (!SendModelingCommand(MCOMMAND_TRIANGULATE, mcd)) \> { \> PolygonObject::Free(pop); \> return (PolygonObject\* )ErrorException::NullThrow(GeLoadString(SIVY_ERR_GENERAL), "IvyTool.PolygonizeObject.SendModelingCommand(TRIANGULATE)"); \> } \> pop = static_cast<PolygonObject\*>(mcd.op); \> doc->InsertObject(pop, NULL, NULL, FALSE); \> EventAdd(); \> return pop; \> } \>