Subdivide

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/08/2009 at 08:23, xxxxxxxx wrote:

User Information:
Cinema 4D Version:    
Platform:      
Language(s) :

---------
Hi again,

I am looking to sudivide a polygon object. Can someone please point me to which function I should be using. This is for modeling tool plugin.

Thanks,

~Shawn

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/08/2009 at 08:39, xxxxxxxx wrote:

Use SendModelingCommand(MCOMMAND_SUBDIVIDE, mcd) where mcd is a ModelingCommandData structure filled with relevant information (there are settings for this command you set in a BaseContainer referenced by the mcd). Set the mode to MODIFY_ALL to consider all polygons in subdivision. This command works directly on the input object so you don't need to get the result from the mcd structure.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/08/2009 at 08:39, xxxxxxxx wrote:

Thanks Robert.
~Shawn

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/08/2009 at 09:05, xxxxxxxx wrote:

What does the code look like to set that subdivision to a hypernurbs subdivision?

I know that
MDATA_SUBDIVIDE_HYPER
is involved. Just not sure how to use it properly.

Thanks,

~Shawn

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/08/2009 at 09:33, xxxxxxxx wrote:

No idea. :) Haven't used it for anything but this should give you a start:

> // Initialize Subdivide ModelingCommandData and BaseContainer \> BaseContainer     sdbc; \> sdbc.SetBool(MDATA_SUBDIVIDE_HYPER,               TRUE); \> sdbc.SetReal(MDATA_SUBDIVIDE_ANGLE,               pi); \> sdbc.SetLong(MDATA_SUBDIVIDE_SPLINESUB,          0L); \> // This should represent the HyperNURBS subdivision amount \> sdbc.SetReal(MDATA_SUBDIVIDE_SUB,               1L); \> ModelingCommandData          sdmcd; \> // If the op is in a document, then set this to op->GetDocument() or the BaseDocument\* if you already have it \> sdmcd.doc =                    NULL; \> sdmcd.op =                    op; \> sdmcd.bc =                    &sdbc; \> sdmcd.mode =               MODIFY_ALL; \> sdmcd.flags =               0L; \> if (!SendModelingCommand(MCOMMAND_SUBDIVIDE, sdmcd))     return FALSE; \> // I'm not doing subdivision to a document object. \> // You may want to send op->Message(MSG_UPDATE); and EventAdd(); for the result to appear in the Editor

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/08/2009 at 09:37, xxxxxxxx wrote:

That helps a lot. What is that from?

~Shawn

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/08/2009 at 09:48, xxxxxxxx wrote:

I just modified my own code which is doing a simple polygon subdivision and not the HyperNURBS type. I don't need a document since this is being done to a Generator plugin result (not directly added to the document - C4D does that internally from GetVirtualObjects()).

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/08/2009 at 10:08, xxxxxxxx wrote:

okay so I want this to happen when the user clicks the button named SUBDIVIDE.

> `

  
\>  SendModelingCommand(MCOMMAND_SUBDIVIDE, mdat);  
\>  mdat.bc->SetBool(MDATA_SUBDIVIDE_HYPER,TRUE);  
\>  mdat.bc->SetReal(MDATA_SUBDIVIDE_ANGLE, pi);  
\>  

`

how do I determine if the button has been clicked?
Do I use...

mdat.bc->GetReal(SUBDIVIDE)
~Shawn

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/08/2009 at 10:24, xxxxxxxx wrote:

If this is a button in your tag (Attributes Manager), simply check for MSG_DESCRIPTION_COMMAND in its Message() function. I usually create functions to handle each message and send the casted data (DescriptionCommand* in this case) as an argument. The ID of the button is in that structure as DescID id. Get the actual ID value using id[0].id. Then you can do the operation. I might even make the code that I gave above a separate function called from this subfunction. So, something like this:

> // NodeData.Message \> //\*---------------------------------------------------------------------------\* \> Bool MyTag::Message(GeListNode\* node, LONG type, void\* data) \> //\*---------------------------------------------------------------------------\* \> { \>      if (!node) return FALSE; \>      if (type == MSG_DESCRIPTION_COMMAND) return MsgCommand(static_cast<DescriptionCommand\*>(data), static_cast<BaseTag\*>(node)); \>      return TRUE; \> } \> // MyTag.MsgCommand \> //\*---------------------------------------------------------------------------\* \> Bool MyTag::MsgCommand(DescriptionCommand\* dc, BaseTag\* tag) \> //\*---------------------------------------------------------------------------\* \> { \>      if (!dc) return TRUE; \>      LONG id = dc->id[0].id; \>      if (id == BUTTON_SUBDIVIDE) return Subdivide(tag->GetDocument(), tag->GetObject()); \>      return TRUE; \> } \> // MyTag.Subdivide \> //\*---------------------------------------------------------------------------\* \> Bool MyTag::Subdivide(BaseDocument\* doc, BaseObject\* op) \> //\*---------------------------------------------------------------------------\* \> { \>      if (!(doc && op)) return FALSE; \>      // Initialize Subdivide ModelingCommandData and BaseContainer \>      BaseContainer sdbc; \>      sdbc.SetBool(MDATA_SUBDIVIDE_HYPER, TRUE); \>      sdbc.SetReal(MDATA_SUBDIVIDE_ANGLE, pi); \>      sdbc.SetLong(MDATA_SUBDIVIDE_SPLINESUB, 0L); \>      // This should represent the HyperNURBS subdivision amount \>      // Note: Not sure where mdat is coming from. May need to pass to this function \>      sdbc.SetReal(MDATA_SUBDIVIDE_SUB, mdat); \>      ModelingCommandData sdmcd; \>      sdmcd.doc = doc; \>      sdmcd.op = op; \>      sdmcd.bc = &sdbc; \>      sdmcd.mode = MODIFY_ALL; \>      sdmcd.flags = 0L; \>      if (!SendModelingCommand(MCOMMAND_SUBDIVIDE, sdmcd)) return FALSE; \>      op->Message(MSG_UPDATE); \>      return TRUE; \> }

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/08/2009 at 17:51, xxxxxxxx wrote:

How do I do this is I am making a tool plugin not a tag plugin. This is for a different plugin than the symmetry one.

Thanks,

~Shawn

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/08/2009 at 18:04, xxxxxxxx wrote:

For tool plugins, you create a dialog which is 'stuffed' into the Attributes Manager (don't ask me why it is done this way here and not in other plugins). Put the button into the dialog and override the Command() function. Same idea after that - you get the dialog's button ID and call the function. Heed the Note there: Call StopAllThreads() before making scene modifications.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/08/2009 at 18:19, xxxxxxxx wrote:

great thanks. Now I have another question. Is it possible to create a true nurbs object within C4D? I suppose it would be done using splines. But its it possible to create geometry between splines?

Just curious.

~Shawn

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 03/09/2009 at 14:04, xxxxxxxx wrote:

So in my Message() for my tool plugin I have the following code.

> `

  
\>  Bool SculptTool::Message(BaseDocument* doc, BaseContainer& data, LONG type, void* t_data)  
\>  {  
\>    
\>  switch (type)  
\>       {  
\>            case MSG_DESCRIPTION_COMMAND:  
\>            {  
\>            DescriptionCommand *dc = (DescriptionCommand* ) t_data;  
\>            if (dc->id[0].id==COMMAND_SUBDIVIDE)  
\>                 {  
\>                 GePrint("Subdivide Button Clicked");  
\>                 }  
\>            }  
\>       }  
\>       return TRUE;  
\>  }  
\>  

`

Where if say's GePrint ("Subdivide Button Clicked"); I would instead like to execute the DoCommand() member. in that is the following code.

> `

  
\>  Bool SculptTool::DoCommand(ModelingCommandData &mdat;)  
\>  {  
\>    
\>  //CODE RELATED TO THE SUBDIVISION OPTIONS/////////////////////////////////  
\>    
\>       //Define Variables  
\>    
\>       BaseObject *op=mdat.doc->GetActiveObject();  
\>       PolygonObject* objPoly;  
\>       objPoly=(PolygonObject* )op;  
\>    
\>       //Determine Attributes  
\>    
\>       if (mdat.bc->GetBool(HYPERNURBS_SUBDIVISION, TRUE)) //If HyperNURBS is checked  
\>       {  
\>       mdat.bc->SetBool(MDATA_SUBDIVIDE_HYPER, TRUE); //Set HyperNURBS subdivision  
\>       }  
\>       else  
\>       {  
\>       mdat.bc->SetBool(MDATA_SUBDIVIDE_HYPER, FALSE); //Disable HyperNURBS subdivision  
\>       }  
\>       mdat.bc->SetLong(MDATA_SUBDIVIDE_SUB, mdat.bc->GetLong(NUM_SUBDIVISIONS)); //Set Number of Subdivisions  
\>       mdat.bc->SetReal(MDATA_SUBDIVIDE_ANGLE, mdat.bc->GetReal(MAX_ANGLE)); //Set Maxiumum Angle  
\>              
\>       //Subdivision Command  
\>       SendModelingCommand(MCOMMAND_SUBDIVIDE, mdat);  
\>       mdat.bc->SetLong(POLYGON_COUNT, objPoly->GetPolygonCount());  
\>         
\>       return true;  
\>    
\>  //END SUBDIVISION OPTIONS/////////////////////////////////////////////////  
\>    
\>    
\>  }  
\>  

`

Can anyone explain how ot do this?
Thanks
~Shawn

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 03/09/2009 at 19:11, xxxxxxxx wrote:

You should just call DoCommand() where you have that GePrint() in Message().

Save yourself unnecessary variables and wasted time and just do:

PolygonObject *objPoly = ToPoly(mdat.doc->GetActiveObject());

:)

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 03/09/2009 at 19:56, xxxxxxxx wrote:

Okay this is the code now.

> `

  
\>  Bool SculptTool::Message(BaseDocument* doc, BaseContainer& data, LONG type, void* t_data)  
\>  {  
\>    
\>  switch (type)  
\>       {  
\>            case MSG_DESCRIPTION_COMMAND:  
\>            {  
\>            DescriptionCommand *dc = (DescriptionCommand* ) t_data;  
\>            if (dc->id[0].id==COMMAND_SUBDIVIDE)  
\>                 {  
\>                 GePrint("Subdivide Button Clicked");  
\>                 DoCommand();  
\>                 }  
\>            }  
\>       }  
\>       return TRUE;  
\>  }  
\>  

`

This is the error I get now.

error C2660: 'SculptTool::DoCommand' : function does not take 0 arguments

any thoughts?

~Shawn

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 03/09/2009 at 20:02, xxxxxxxx wrote:

Well, I hate to be obvious but you need to fill and send the ModelingCommandData& mdat argument for your DoCommand() function. :)

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 03/09/2009 at 20:14, xxxxxxxx wrote:

LOL..   obviously the obvious eludes me some times. HAHA..

Do I fill it the way it is declared?

like this.

DoCommand(ModelingCommandData &mdat;);

or do I need something else in the parenthesis?

LOL. thank you for you patience with this noob.

~Shawn

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 03/09/2009 at 20:27, xxxxxxxx wrote:

Like this unless you have another mdat you have already alotted for this:

> Bool SculptTool::Message(BaseDocument\* doc, BaseContainer& data, LONG type, void\* t_data) \> { \> switch (type) \>      { \>           case MSG_DESCRIPTION_COMMAND: \>           { \>           DescriptionCommand \*dc = (DescriptionCommand\* ) t_data; \>           if (dc->id[0].id==COMMAND_SUBDIVIDE) \>                { \>                GePrint("Subdivide Button Clicked"); \>                ModelingCommandData     mdat; \>                DoCommand(mdat); \>                } \>           } \>      } \>      return TRUE; \> } \>

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 03/09/2009 at 20:31, xxxxxxxx wrote:

HAHA.. WOW.. that couldn't be more obvious..   LOL

thanks Robert. Not sure what time it is where you are but it's 11:30 PM here in NY.    I'm obviously tired..

Thanks again.

~Shawn

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 03/09/2009 at 20:36, xxxxxxxx wrote:

Okay. so now it calls the DoCommand function but as soon as it does, C4D crashes out...

Do you see anything in this code that would cause C4D to crash?

> `

  
\>  Bool SculptTool::DoCommand(ModelingCommandData &mdat;)  
\>  {  
\>    
\>  //CODE RELATED TO THE SUBDIVISION OPTIONS/////////////////////////////////  
\>    
\>       //Define Variables  
\>    
\>      PolygonObject *objPoly = ToPoly(mdat.doc->GetActiveObject());  
\>    
\>       //Determine Attributes  
\>    
\>       if (mdat.bc->GetBool(HYPERNURBS_SUBDIVISION, TRUE)) //If HyperNURBS is checked  
\>       {  
\>       mdat.bc->SetBool(MDATA_SUBDIVIDE_HYPER, TRUE); //Set HyperNURBS subdivision  
\>       }  
\>       else  
\>       {  
\>       mdat.bc->SetBool(MDATA_SUBDIVIDE_HYPER, FALSE); //Disable HyperNURBS subdivision  
\>       }  
\>       mdat.bc->SetLong(MDATA_SUBDIVIDE_SUB, mdat.bc->GetLong(NUM_SUBDIVISIONS)); //Set Number of Subdivisions  
\>       mdat.bc->SetReal(MDATA_SUBDIVIDE_ANGLE, mdat.bc->GetReal(MAX_ANGLE)); //Set Maxiumum Angle  
\>              
\>       //Subdivision Command  
\>       SendModelingCommand(MCOMMAND_SUBDIVIDE, mdat);  
\>       mdat.bc->SetLong(POLYGON_COUNT, objPoly->GetPolygonCount());  
\>         
\>       return TRUE;  
\>    
\>  //END SUBDIVISION OPTIONS/////////////////////////////////////////////////  
\>    
\>    
\>  }  
\>    
\>  

`

Thanks,

~Shawn