my plugin problems



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

    On 08/09/2009 at 16:51, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   11 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    I am wondering why none of my functions do what they are supposed to. The DoCOmmand Function is supposed to subdivide the currently active object, when the command button is clocked, and the draw() is supposed to draw a square polygon if the check box named SHOW_PLANE is checked. Yet nothing is doing what I expect it to.

    Here is the code for my entire .cpp file. Does anyone see any reason why my code isn't doing anything?

    > `

      
    \>  #include "c4d.h"  
    \>  #include "c4d_symbols.h"  
    \>  #include "lib_modeling.h"  
    \>    
    \>  #include "c4d_descriptiondialog.h"  
    \>  #include "sculpttool.h"  
    \>    
    \>  #define ID_SCULPTTOOL               1024455  
    \>    
    \>  extern Bool AddUndo(BaseDocument* doc, AtomArray* arr, LONG type);  
    \>    
    \>  class SculptTool : public DescriptionToolData  
    \>  {       
    \>       DescriptionCommand* data;  
    \>       LONG buttonPress;  
    \>    
    \>    
    \>       public:  
    \>            SculptTool();  
    \>              
    \>            virtual LONG                    GetToolPluginId() { return ID_SCULPTTOOL; }  
    \>            virtual const String          GetResourceSymbol() { return String("SculptTool"); }  
    \>    
    \>            virtual Bool                    MouseInput(BaseDocument *doc, BaseContainer &data;, BaseDraw *bd, EditorWindow *win, const BaseContainer &msg;);  
    \>            virtual LONG                    GetState(BaseDocument *doc);  
    \>    
    \>            virtual void                    InitDefaultSettings(BaseDocument *doc, BaseContainer &data;);  
    \>            virtual Bool                    DoCommand(ModelingCommandData &mdat;);  
    \>            virtual Bool                    GetCursorInfo(BaseDocument *doc, BaseContainer &data;, BaseDraw *bd, Real x, Real y, BaseContainer &bc;);  
    \>    
    \>            virtual Bool                    GetDEnabling(BaseDocument *doc, BaseContainer &data;, const DescID &id;,GeData &t;_data,LONG flags,const BaseContainer *itemdesc);  
    \>            virtual LONG                    Draw(BaseDocument *doc, BaseContainer &data;, BaseDraw *bd, BaseDrawHelp *bh, BaseThread *bt,LONG flags);  
    \>                      Bool                    Message(BaseDocument* doc, BaseContainer& data, LONG type, void* t_data);  
    \>    
    \>       protected:  
    \>            Bool isdragging;  
    \>              
    \>  };  
    \>    
    \>  SculptTool::SculptTool()  
    \>  {       
    \>    
    \>       isdragging = FALSE;  
    \>  }  
    \>    
    \>  Bool SculptTool::GetCursorInfo(BaseDocument *doc, BaseContainer &data;, BaseDraw *bd, Real x, Real y, BaseContainer &bc;)  
    \>  {  
    \>       if (bc.GetId()==BFM_CURSORINFO_REMOVE) return TRUE;  
    \>       bc.SetString(RESULT_BUBBLEHELP, GeLoadString(IDS_HLP_SCULPTTOOL));  
    \>       return TRUE;  
    \>  }  
    \>    
    \>    
    \>  ///////////////////////////////////////////////////////////////////////////////////////////////////  
    \>  void SculptTool::InitDefaultSettings(BaseDocument *doc, BaseContainer &data;)  
    \>  {       
    \>       //This function sets the default perameters for the Sculpt Tool Options.  
    \>       BaseObject *op=doc->GetActiveObject();  
    \>       PolygonObject* objPoly;  
    \>       objPoly=(PolygonObject* )op;  
    \>    
    \>       Vector color;  
    \>       color = (1,0,0);  
    \>       GePrint("--------------------------------------------------------");  
    \>       GePrint(" Sculpt Tool Successfully Loaded!");  
    \>       GePrint("--------------------------------------------------------");  
    \>    
    \>       DescriptionToolData::InitDefaultSettings(doc,data);  
    \>       SetMousePointer (MOUSE_PAINTSELECTCIRCLE);  
    \>       data.SetReal(BRUSH_RADIUS,100);  
    \>       data.SetReal(SCULPT_STRENGTH,100);  
    \>       data.SetLong(SCULPT_TYPE, TYPE_SCULPT);  
    \>       data.SetLong(BRUSH_ORIENTATION, OR_NORMAL);  
    \>       data.SetLong(MIRROR_PLANE, X_PLANE);  
    \>       data.SetLong(NUM_SUBDIVISIONS, 1);  
    \>       data.SetLong(HYPERNURBS_SUBDIVISION, TRUE);  
    \>       data.SetReal(MAX_ANGLE,pi);  
    \>       if (objPoly)  
    \>       {  
    \>       data.SetLong(POLYGON_COUNT, objPoly->GetPolygonCount());  
    \>       }  
    \>       else  
    \>       {  
    \>            GePrint ("No Objects in the Scene");  
    \>       }  
    \>    
    \>  }  
    \>  ///////////////////////////////////////////////////////////////////////////////////////////////////  
    \>    
    \>  Bool SculptTool::GetDEnabling(BaseDocument *doc, BaseContainer &data;, const DescID &id;,GeData &t;_data,LONG flags,const BaseContainer *itemdesc)  
    \>  {  
    \>    
    \>       // Enable/disable our parameters  
    \>       Bool stampBox = data.GetBool(USE_STAMP);  
    \>       Bool enableMirror = data.GetBool(ENABLE_MIRROR);  
    \>       BaseObject* op = doc->GetActiveObject();  
    \>       if (!op)  
    \>            return false;  
    \>    
    \>       switch (id[0].id)  
    \>       {      case ENABLE_MIRROR:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case NUM_SUBDIVISIONS:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case HYPERNURBS_SUBDIVISION:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>         
    \>             case MAX_ANGLE:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case POLYGON_COUNT:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case SCULPT_TYPE:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case COMMAND_SUBDIVIDE:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case BRUSH_RADIUS:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case SCULPT_STRENGTH:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case TOOL_VARIATION:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case FALLOFF_CONTROL:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case USE_STAMP:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case STAMP_IMAGE:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon)&&stampBox;==TRUE)  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case BRUSH_ORIENTATION:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case MIRROR_PLANE:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon)&&enableMirror;==TRUE)  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case SHOW_PLANE:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon)&&enableMirror;==TRUE)  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case PLANE_COLOR:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon)&&enableMirror;==TRUE)  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>       }  
    \>       return TRUE;  
    \>    
    \>  }  
    \>    
    \>  LONG SculptTool::GetState(BaseDocument *doc)  
    \>  {       
    \>       return CMD_ENABLED;  
    \>  }  
    \>    
    \>    
    \>  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;  
    \>                 BaseContainer bc;  
    \>                 mdat.doc = doc;  
    \>                 mdat.bc = &bc;  
    \>                 mdat.mode = MODIFY_ALL;  
    \>              DoCommand(mdat);  
    \>                 }  
    \>            }  
    \>       }  
    \>       return TRUE;   
    \>  }  
    \>    
    \>  ///////////////////////////////////////////////////////////////////////////////////////////////////  
    \>  Bool SculptTool::DoCommand(ModelingCommandData &mdat;)  
    \>  {  
    \>  GePrint("In DoCommand");  
    \>  //CODE RELATED TO THE SUBDIVISION OPTIONS/////////////////////////////////  
    \>    
    \>       //Define Variables  
    \>    
    \>      PolygonObject *objPoly = ToPoly(mdat.doc->GetActiveObject());  
    \>       if (!objPoly) return FALSE;  
    \>       mdat.op = objPoly;  
    \>    
    \>       //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());//Shows the current polygon count  
    \>    
    \>         
    \>       return TRUE;  
    \>    
    \>  //END SUBDIVISION OPTIONS/////////////////////////////////////////////////  
    \>       GePrint("End Of DoCommand");  
    \>    
    \>  }  
    \>    
    \>  ///////////////////////////////////////////////////////////////////////////////////////////////////  
    \>    
    \>  LONG SculptTool::Draw(BaseDocument *doc, BaseContainer &data;, BaseDraw *bd, BaseDrawHelp *bh, BaseThread *bt,LONG flags)  
    \>  {  
    \>    
    \>    
    \>            PolygonObject *op = ToPoly(doc->GetActiveObject());  
    \>          LONG lngMySymPlane =doc->GetDataInstance()->GetLong (MIRROR_PLANE);  
    \>          LONG trans = 175;  
    \>          Vector color = data.GetVector(PLANE_COLOR);  
    \>    
    \>          //Matrix for determining scale, rotation, and position.   
    \>          Matrix m = op->GetMg();  
    \>          Vector rad = op->GetRad();  
    \>    
    \>          m.v1 *= rad.x+100;  
    \>          m.v2 *= rad.y+100;  
    \>          m.v3 *= rad.z+100;  
    \>    
    \>    
    \>          switch (lngMySymPlane)  
    \>          {  
    \>    
    \>                 case Z_PLANE:  
    \>                   
    \>                 if (doc->GetDataInstance()->GetBool(SHOW_PLANE)) // If SHOW_PLANE is checked, then draw the polygon.  
    \>                 {  
    \>                      GePrint("Z_PLANE");  
    \>                 Vector p[4];  
    \>    
    \>                 p[0] = Vector(-1,-1,0);  
    \>                 p[1] = Vector(-1,1,0);  
    \>                 p[2] = Vector(1,1,0);  
    \>                 p[3] = Vector(1,-1,0);  
    \>    
    \>                 p[0] = p[0] * m;  
    \>                 p[1] = p[1] * m;  
    \>                 p[2] = p[2] * m;  
    \>                 p[3] = p[3] * m;  
    \>    
    \>                 Vector f[3] = { Vector(color),Vector(color),Vector(color)};  
    \>    
    \>                 bd->SetLightList(BDRAW_SETLIGHTLIST_NOLIGHTS);  
    \>                 bd->SetTransparency(trans);  
    \>                 bd->Polygon3D(p,f,TRUE);  
    \>    
    \>                 return true;  
    \>                 }  
    \>                 else //If SHOW_PLANE is unchecked, stop drawing the polygon.  
    \>                 {  
    \>                 Vector p[4] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>                 Vector f[3] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>                 bd->Polygon3D(p,f,FALSE);  
    \>                 }  
    \>    
    \>              return DRAW_HANDLES|DRAW_AXIS;  
    \>                 break;  
    \>    
    \>                 case X_PLANE:  
    \>                 if (doc->GetDataInstance()->GetBool(SHOW_PLANE)) // If SHOW_PLANE is checked, then draw the polygon.  
    \>                 {  
    \>                 GePrint("X_PLANE");  
    \>                 Vector p[4];      
    \>                   
    \>                 p[0] = Vector(0,-1,-1);  
    \>                 p[1] = Vector(0,-1,1);  
    \>                 p[2] = Vector(0,1,1);  
    \>                 p[3] = Vector(0,1,-1);  
    \>    
    \>                 p[0] = p[0] * m;  
    \>                 p[1] = p[1] * m;  
    \>                 p[2] = p[2] * m;  
    \>                 p[3] = p[3] * m;  
    \>    
    \>                 Vector f[3] = { Vector(color),Vector(color),Vector(color)};  
    \>    
    \>                 bd->SetLightList(BDRAW_SETLIGHTLIST_NOLIGHTS);  
    \>                 bd->SetTransparency(trans);  
    \>                 bd->Polygon3D(p,f,TRUE);          
    \>                            
    \>                 return true;  
    \>                 }  
    \>                 else //If SHOW_PLANE is unchecked, stop drawing the polygon.  
    \>                 {  
    \>                 Vector p[4] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>                 Vector f[3] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>                 bd->Polygon3D(p,f,FALSE);  
    \>                 }  
    \>    
    \>              return DRAW_HANDLES|DRAW_AXIS;  
    \>                 break;  
    \>    
    \>                 case Y_PLANE:  
    \>                 if (doc->GetDataInstance()->GetBool(SHOW_PLANE)) // If SHOW_PLANE is checked, then draw the polygon.  
    \>                 {  
    \>                 GePrint("Y_PLANE");  
    \>                 Vector p[4];  
    \>                   
    \>                 p[0] = Vector(-1,0,-1);  
    \>                 p[1] = Vector(-1,0,1);  
    \>                 p[2] = Vector(1,0,1);  
    \>                 p[3] = Vector(1,0,-1);  
    \>    
    \>                 p[0] = p[0] * m;  
    \>                 p[1] = p[1] * m;  
    \>                 p[2] = p[2] * m;  
    \>                 p[3] = p[3] * m;  
    \>    
    \>                 Vector f[3] = { Vector(color),Vector(color),Vector(color)};  
    \>    
    \>                 bd->SetLightList(BDRAW_SETLIGHTLIST_NOLIGHTS);  
    \>                 bd->SetTransparency(trans);  
    \>                 bd->Polygon3D(p,f,TRUE);          
    \>                            
    \>                 return true;  
    \>                 }  
    \>                 else //If SHOW_PLANE is unchecked, stop drawing the polygon.  
    \>                 {  
    \>                 Vector p[4] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>                 Vector f[3] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>                 bd->Polygon3D(p,f,FALSE);  
    \>                 }  
    \>    
    \>              return DRAW_HANDLES|DRAW_AXIS;  
    \>                 break;  
    \>          }  
    \>       return TRUE;  
    \>  }  
    \>    
    \>  Bool SculptTool::MouseInput(BaseDocument *doc, BaseContainer &data;, BaseDraw *bd, EditorWindow *win, const BaseContainer &msg;)  
    \>  {  
    \>    
    \>    
    \>    
    \>       if (!doc) return FALSE;  
    \>         
    \>       Real mx = msg.GetReal(BFM_INPUT_X);  
    \>       Real my = msg.GetReal(BFM_INPUT_Y);  
    \>       Real mz = msg.GetReal(BFM_INPUT_Z);  
    \>       LONG button;  
    \>    
    \>       switch (msg.GetLong(BFM_INPUT_CHANNEL))  
    \>       {  
    \>            case BFM_INPUT_MOUSELEFT : button=KEY_MLEFT; break;  
    \>            case BFM_INPUT_MOUSERIGHT: button=KEY_MRIGHT; break;  
    \>            default: return TRUE;  
    \>       }  
    \>    
    \>    
    \>       Real dx, dy;  
    \>       BaseContainer bc;  
    \>       BaseContainer device;  
    \>       win->MouseDragStart(button,mx,my,MOUSEDRAG_DONTHIDEMOUSE|MOUSEDRAG_NOMOVE);  
    \>       while (win->MouseDrag(&dx;,&dy;,&device;)==MOUSEDRAG_CONTINUE)  
    \>       {  
    \>    
    \>       GePrint("Mouse's X Position is: " + RealToString(mx));  
    \>       GePrint("Mouse's Y Position is: " + RealToString(my));  
    \>       GePrint("Mouse's Z Position is: " + RealToString(mz));  
    \>         
    \>       return TRUE;  
    \>       }  
    \>  }  
    \>    
    \>  Bool RegisterSculptTool()  
    \>  {  
    \>       return RegisterToolPlugin(ID_SCULPTTOOL, GeLoadString(IDS_SCULPTTOOL), 0, GeLoadString(IDS_HLP_SCULPTTOOL), gNew SculptTool);  
    \>  }  
    \>  
    

    `



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

    On 08/09/2009 at 17:39, xxxxxxxx wrote:

    1. DoCommand() already exists as a virtual function. It is called explicitly by SendModelingCommand(). I would rename the function if you are calling it from Message() to avoid issues.

    2. The edgecuttool example calls the modeling function from MouseInput(). Of course, this will depend upon what you are doing. If your tool doesn't require mouse input, then it doesn't need to do that there.

    3. You are trying to store values in 'bc' attached to mdat but both of these are local variables and go away as soon as Message() exits. If you want to retain the values stored in 'bc', you will need to make it a member of your SculptTool class.

    4. Call this at the end of your InitDefaultSettings() :
    DescriptionToolData::InitDefaultSettings(doc,data);
       Call this at the end of your GetDEnabling() :
    return DescriptionToolData::GetDEnabling(doc,data,id,t_data,flags,itemdesc);

    5. Why are you getting your tool's description values from doc->GetDataInstance() in Draw()? The BaseContainer is sent as 'data'.



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

    On 08/09/2009 at 18:03, xxxxxxxx wrote:

    so for you third point.

    I should add :

    > `

      
    \>  ModelingCommandData mdat;  
    \>  BaseContainer bc;  
    \>  
    

    `

    to the SculptTool Class?

    ~Shawn



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

    On 08/09/2009 at 18:16, xxxxxxxx wrote:

    okay got the draw plane to work by changing everything to data.

    but it only refreshes if I make a change to the viewport, like zoom in or something. How can I make the viewport update after the draw() code is executed?

    Thanks,

    ~Shawn



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

    On 08/09/2009 at 18:53, xxxxxxxx wrote:

    Okay here's the code now..   The draw() function works great now..

    The Subdivide() function previously the DoCommand () still does nothing.

    Any thoughts?

    > `

      
    \>  #include "c4d.h"  
    \>  #include "c4d_symbols.h"  
    \>  #include "lib_modeling.h"  
    \>    
    \>  #include "c4d_descriptiondialog.h"  
    \>  #include "sculpttool.h"  
    \>    
    \>  #define ID_SCULPTTOOL               1024455  
    \>    
    \>  extern Bool AddUndo(BaseDocument* doc, AtomArray* arr, LONG type);  
    \>    
    \>  class SculptTool : public DescriptionToolData  
    \>  {       
    \>       DescriptionCommand* data;  
    \>       LONG buttonPress;  
    \>    
    \>    
    \>    
    \>       public:  
    \>       ModelingCommandData mdat;  
    \>       BaseContainer bc;  
    \>            SculptTool();  
    \>            Bool                              Subdivide(ModelingCommandData &mdat;);  
    \>              
    \>            virtual LONG                    GetToolPluginId() { return ID_SCULPTTOOL; }  
    \>            virtual const String          GetResourceSymbol() { return String("SculptTool"); }  
    \>    
    \>            virtual Bool                    MouseInput(BaseDocument *doc, BaseContainer &data;, BaseDraw *bd, EditorWindow *win, const BaseContainer &msg;);  
    \>            virtual LONG                    GetState(BaseDocument *doc);  
    \>    
    \>            virtual void                    InitDefaultSettings(BaseDocument *doc, BaseContainer &data;);  
    \>            virtual Bool                    DoCommand(ModelingCommandData &mdat;);  
    \>            virtual Bool                    GetCursorInfo(BaseDocument *doc, BaseContainer &data;, BaseDraw *bd, Real x, Real y, BaseContainer &bc;);  
    \>    
    \>            virtual Bool                    GetDEnabling(BaseDocument *doc, BaseContainer &data;, const DescID &id;,GeData &t;_data,LONG flags,const BaseContainer *itemdesc);  
    \>            virtual LONG                    Draw(BaseDocument *doc, BaseContainer &data;, BaseDraw *bd, BaseDrawHelp *bh, BaseThread *bt,LONG flags);  
    \>                      Bool                    Message(BaseDocument* doc, BaseContainer& data, LONG type, void* t_data);  
    \>    
    \>       protected:  
    \>            Bool isdragging;  
    \>              
    \>  };  
    \>    
    \>  SculptTool::SculptTool()  
    \>  {       
    \>    
    \>       isdragging = FALSE;  
    \>  }  
    \>    
    \>  Bool SculptTool::GetCursorInfo(BaseDocument *doc, BaseContainer &data;, BaseDraw *bd, Real x, Real y, BaseContainer &bc;)  
    \>  {  
    \>       if (bc.GetId()==BFM_CURSORINFO_REMOVE) return TRUE;  
    \>       bc.SetString(RESULT_BUBBLEHELP, GeLoadString(IDS_HLP_SCULPTTOOL));  
    \>       return TRUE;  
    \>  }  
    \>    
    \>    
    \>  ///////////////////////////////////////////////////////////////////////////////////////////////////  
    \>  void SculptTool::InitDefaultSettings(BaseDocument *doc, BaseContainer &data;)  
    \>  {       
    \>       //This function sets the default perameters for the Sculpt Tool Options.  
    \>       BaseObject *op=doc->GetActiveObject();  
    \>       PolygonObject* objPoly;  
    \>       objPoly=(PolygonObject* )op;  
    \>    
    \>       Vector color;  
    \>       color = Vector (0,1,0);  
    \>       GePrint("--------------------------------------------------------");  
    \>       GePrint(" Sculpt Tool Successfully Loaded!");  
    \>       GePrint("--------------------------------------------------------");  
    \>    
    \>    
    \>       SetMousePointer (MOUSE_PAINTSELECTCIRCLE);  
    \>       data.SetReal(BRUSH_RADIUS,100);  
    \>       data.SetReal(SCULPT_STRENGTH,100);  
    \>       data.SetLong(SCULPT_TYPE, TYPE_SCULPT);  
    \>       data.SetLong(BRUSH_ORIENTATION, OR_NORMAL);  
    \>       data.SetLong(MIRROR_PLANE, X_PLANE);  
    \>       data.SetLong(NUM_SUBDIVISIONS, 1);  
    \>       data.SetLong(HYPERNURBS_SUBDIVISION, TRUE);  
    \>       data.SetReal(MAX_ANGLE,pi);  
    \>       data.SetVector(PLANE_COLOR,color);  
    \>       if (objPoly)  
    \>       {  
    \>       data.SetLong(POLYGON_COUNT, objPoly->GetPolygonCount());  
    \>       }  
    \>       else  
    \>       {  
    \>            GePrint ("No Objects in the Scene");  
    \>       }  
    \>  DescriptionToolData::InitDefaultSettings(doc,data);  
    \>  }  
    \>  ///////////////////////////////////////////////////////////////////////////////////////////////////  
    \>    
    \>  Bool SculptTool::GetDEnabling(BaseDocument *doc, BaseContainer &data;, const DescID &id;,GeData &t;_data,LONG flags,const BaseContainer *itemdesc)  
    \>  {  
    \>    
    \>       // Enable/disable our parameters  
    \>       Bool stampBox = data.GetBool(USE_STAMP);  
    \>       Bool enableMirror = data.GetBool(ENABLE_MIRROR);  
    \>       BaseObject* op = doc->GetActiveObject();  
    \>       if (!op)  
    \>            return false;  
    \>    
    \>       switch (id[0].id)  
    \>       {      case ENABLE_MIRROR:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case NUM_SUBDIVISIONS:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case HYPERNURBS_SUBDIVISION:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>         
    \>             case MAX_ANGLE:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case POLYGON_COUNT:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case SCULPT_TYPE:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case COMMAND_SUBDIVIDE:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case BRUSH_RADIUS:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case SCULPT_STRENGTH:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case TOOL_VARIATION:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case FALLOFF_CONTROL:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case USE_STAMP:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case STAMP_IMAGE:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon)&&stampBox;==TRUE)  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case BRUSH_ORIENTATION:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon))  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case MIRROR_PLANE:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon)&&enableMirror;==TRUE)  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case SHOW_PLANE:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon)&&enableMirror;==TRUE)  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>    
    \>             case PLANE_COLOR:  
    \>                   
    \>                 if (op->IsInstanceOf(Opolygon)&&enableMirror;==TRUE)  
    \>                 {    return TRUE;  
    \>                 }  
    \>                 else  
    \>                 {    return FALSE;  
    \>                 }  
    \>       }  
    \>       return TRUE;  
    \>  return DescriptionToolData::GetDEnabling(doc,data,id,t_data,flags,itemdesc);  
    \>  }  
    \>    
    \>  LONG SculptTool::GetState(BaseDocument *doc)  
    \>  {       
    \>       return CMD_ENABLED;  
    \>  }  
    \>    
    \>    
    \>  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;  
    \>                 BaseContainer bc;  
    \>                 mdat.doc = doc;  
    \>                 mdat.bc = &bc;  
    \>                 mdat.mode = MODIFY_ALL;  
    \>              Subdivide(mdat);  
    \>                 }  
    \>            }  
    \>       }  
    \>       return TRUE;   
    \>  }  
    \>    
    \>  Bool SculptTool::DoCommand(ModelingCommandData &mdat;)  
    \>  {  
    \>       return TRUE;  
    \>  }  
    \>    
    \>    
    \>  ///////////////////////////////////////////////////////////////////////////////////////////////////  
    \>  Bool SculptTool::Subdivide(ModelingCommandData &mdat;)  
    \>  {  
    \>  GePrint("In Subdivide");  
    \>  //CODE RELATED TO THE SUBDIVISION OPTIONS/////////////////////////////////  
    \>    
    \>       //Define Variables  
    \>    
    \>      PolygonObject *objPoly = ToPoly(mdat.doc->GetActiveObject());  
    \>       if (!objPoly) return FALSE;  
    \>       mdat.op = objPoly;  
    \>    
    \>       //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());//Shows the current polygon count  
    \>    
    \>         
    \>       return TRUE;  
    \>    
    \>  //END SUBDIVISION OPTIONS/////////////////////////////////////////////////  
    \>       GePrint("End Of Subdivide");  
    \>    
    \>  }  
    \>    
    \>  ///////////////////////////////////////////////////////////////////////////////////////////////////  
    \>    
    \>  LONG SculptTool::Draw(BaseDocument *doc, BaseContainer &data;, BaseDraw *bd, BaseDrawHelp *bh, BaseThread *bt,LONG flags)  
    \>  {  
    \>    
    \>    
    \>            PolygonObject *op = ToPoly(doc->GetActiveObject());  
    \>          LONG lngMySymPlane =data.GetLong (MIRROR_PLANE);  
    \>          LONG trans = 175;  
    \>          Vector color = data.GetVector(PLANE_COLOR);  
    \>    
    \>          //Matrix for determining scale, rotation, and position.   
    \>          Matrix m = op->GetMg();  
    \>          Vector rad = op->GetRad();  
    \>    
    \>          m.v1 *= rad.x+100;  
    \>          m.v2 *= rad.y+100;  
    \>          m.v3 *= rad.z+100;  
    \>    
    \>    
    \>          switch (lngMySymPlane)  
    \>          {  
    \>    
    \>                 case Z_PLANE:  
    \>                   
    \>                 if (data.GetBool(SHOW_PLANE)) // If SHOW_PLANE is checked, then draw the polygon.  
    \>                 {  
    \>                      GePrint("Z_PLANE");  
    \>                 Vector p[4];  
    \>    
    \>                 p[0] = Vector(-1,-1,0);  
    \>                 p[1] = Vector(-1,1,0);  
    \>                 p[2] = Vector(1,1,0);  
    \>                 p[3] = Vector(1,-1,0);  
    \>    
    \>                 p[0] = p[0] * m;  
    \>                 p[1] = p[1] * m;  
    \>                 p[2] = p[2] * m;  
    \>                 p[3] = p[3] * m;  
    \>    
    \>                 Vector f[3] = { Vector(color),Vector(color),Vector(color)};  
    \>    
    \>                 bd->SetLightList(BDRAW_SETLIGHTLIST_NOLIGHTS);  
    \>                 bd->SetTransparency(trans);  
    \>                 bd->Polygon3D(p,f,TRUE);  
    \>                      EventAdd(EVENT_FORCEREDRAW);  
    \>    
    \>                 return true;  
    \>                 }  
    \>                 else //If SHOW_PLANE is unchecked, stop drawing the polygon.  
    \>                 {  
    \>                 Vector p[4] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>                 Vector f[3] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>                 bd->Polygon3D(p,f,FALSE);  
    \>                      EventAdd(EVENT_FORCEREDRAW);  
    \>                 }  
    \>    
    \>              return DRAW_HANDLES|DRAW_AXIS;  
    \>                 break;  
    \>    
    \>                 case X_PLANE:  
    \>                 if (data.GetBool(SHOW_PLANE)) // If SHOW_PLANE is checked, then draw the polygon.  
    \>                 {  
    \>                 GePrint("X_PLANE");  
    \>                 Vector p[4];      
    \>                   
    \>                 p[0] = Vector(0,-1,-1);  
    \>                 p[1] = Vector(0,-1,1);  
    \>                 p[2] = Vector(0,1,1);  
    \>                 p[3] = Vector(0,1,-1);  
    \>    
    \>                 p[0] = p[0] * m;  
    \>                 p[1] = p[1] * m;  
    \>                 p[2] = p[2] * m;  
    \>                 p[3] = p[3] * m;  
    \>    
    \>                 Vector f[3] = { Vector(color),Vector(color),Vector(color)};  
    \>    
    \>                 bd->SetLightList(BDRAW_SETLIGHTLIST_NOLIGHTS);  
    \>                 bd->SetTransparency(trans);  
    \>                 bd->Polygon3D(p,f,TRUE);   
    \>                      EventAdd(EVENT_FORCEREDRAW);  
    \>                            
    \>                 return true;  
    \>                 }  
    \>                 else //If SHOW_PLANE is unchecked, stop drawing the polygon.  
    \>                 {  
    \>                 Vector p[4] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>                 Vector f[3] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>                 bd->Polygon3D(p,f,FALSE);  
    \>                      EventAdd(EVENT_FORCEREDRAW);  
    \>                 }  
    \>    
    \>              return DRAW_HANDLES|DRAW_AXIS;  
    \>                 break;  
    \>    
    \>                 case Y_PLANE:  
    \>                 if (data.GetBool(SHOW_PLANE)) // If SHOW_PLANE is checked, then draw the polygon.  
    \>                 {  
    \>                 GePrint("Y_PLANE");  
    \>                 Vector p[4];  
    \>                   
    \>                 p[0] = Vector(-1,0,-1);  
    \>                 p[1] = Vector(-1,0,1);  
    \>                 p[2] = Vector(1,0,1);  
    \>                 p[3] = Vector(1,0,-1);  
    \>    
    \>                 p[0] = p[0] * m;  
    \>                 p[1] = p[1] * m;  
    \>                 p[2] = p[2] * m;  
    \>                 p[3] = p[3] * m;  
    \>    
    \>                 Vector f[3] = { Vector(color),Vector(color),Vector(color)};  
    \>    
    \>                 bd->SetLightList(BDRAW_SETLIGHTLIST_NOLIGHTS);  
    \>                 bd->SetTransparency(trans);  
    \>                 bd->Polygon3D(p,f,TRUE);   
    \>                      EventAdd(EVENT_FORCEREDRAW);  
    \>                            
    \>                 return true;  
    \>                 }  
    \>                 else //If SHOW_PLANE is unchecked, stop drawing the polygon.  
    \>                 {  
    \>                 Vector p[4] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>                 Vector f[3] = { Vector(0,0,0),Vector(0,0,0),Vector(0,0,0)};  
    \>                 bd->Polygon3D(p,f,FALSE);  
    \>                      EventAdd(EVENT_FORCEREDRAW);  
    \>                 }  
    \>    
    \>              return DRAW_HANDLES|DRAW_AXIS;  
    \>                 break;  
    \>          }  
    \>                   
    \>       return TRUE;  
    \>  }  
    \>    
    \>  Bool SculptTool::MouseInput(BaseDocument *doc, BaseContainer &data;, BaseDraw *bd, EditorWindow *win, const BaseContainer &msg;)  
    \>  {  
    \>    
    \>    
    \>    
    \>       if (!doc) return FALSE;  
    \>         
    \>       Real mx = msg.GetReal(BFM_INPUT_X);  
    \>       Real my = msg.GetReal(BFM_INPUT_Y);  
    \>       Real mz = msg.GetReal(BFM_INPUT_Z);  
    \>       LONG button;  
    \>    
    \>       switch (msg.GetLong(BFM_INPUT_CHANNEL))  
    \>       {  
    \>            case BFM_INPUT_MOUSELEFT : button=KEY_MLEFT; break;  
    \>            case BFM_INPUT_MOUSERIGHT: button=KEY_MRIGHT; break;  
    \>            default: return TRUE;  
    \>       }  
    \>    
    \>    
    \>       Real dx, dy;  
    \>       BaseContainer bc;  
    \>       BaseContainer device;  
    \>       win->MouseDragStart(button,mx,my,MOUSEDRAG_DONTHIDEMOUSE|MOUSEDRAG_NOMOVE);  
    \>       while (win->MouseDrag(&dx;,&dy;,&device;)==MOUSEDRAG_CONTINUE)  
    \>       {  
    \>    
    \>       GePrint("Mouse's X Position is: " + RealToString(mx));  
    \>       GePrint("Mouse's Y Position is: " + RealToString(my));  
    \>       GePrint("Mouse's Z Position is: " + RealToString(mz));  
    \>         
    \>       return TRUE;  
    \>       }  
    \>       return TRUE;  
    \>    
    \>    
    \>  }  
    \>    
    \>  Bool RegisterSculptTool()  
    \>  {  
    \>       return RegisterToolPlugin(ID_SCULPTTOOL, GeLoadString(IDS_SCULPTTOOL), 0, GeLoadString(IDS_HLP_SCULPTTOOL), gNew SculptTool);  
    \>  }  
    \>    
    \>  
    

    `



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

    On 08/09/2009 at 19:04, xxxxxxxx wrote:

    You'll have to remove the definition of ModelCommandData mdat and BaseContainer bc from Message(). Local variables always override more global variables.

    Do you actually get the GePrint() in Message() when the button is clicked?



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

    On 08/09/2009 at 19:12, xxxxxxxx wrote:

    yes I get the GePrint from Message() That says "Subdivide Button Clicked" I also get the first GePrint from Subdivide() that says "In Subdivide" I do not get the one at the end of Subdivide that says " End of Subdivide.



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

    On 08/09/2009 at 19:15, xxxxxxxx wrote:

    okay when I remove the definitions of ModelCommandData mdat and BaseContainer bc from Message(), c4d crashes when I click the button.

    ~Shawn



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

    On 08/09/2009 at 19:16, xxxxxxxx wrote:

    scratch that.. it doesn't crash anymore..   but still does nothing.. :(



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

    On 08/09/2009 at 19:19, xxxxxxxx wrote:

    GePrint("End Of Subdivide"); shows up now because I moved it above return TRUE;

    Seems like it's running the code in Subdivide() but it's not effecting the object.



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

    On 08/09/2009 at 20:29, xxxxxxxx wrote:

    Yeah, I was going to mention that the "End of Subdivide" would never print. :)

    The only thing that I can think of is that the object isn't really a Polygon object. For something like subdivision it must be. But if it is, then I'm at a loss. One thing to check is if SendModelingCommand() is succeeding or failing (if (!SendModelingCommand(...)). Another is to verify that the document is not a clone. Many times, Cinema 4D passes a clone of the document (like for rendering or generator plugins). I couldn't imagine this for a tool but best to verify, verify, verify!



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

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

    How can I make sure that the object is really a polygon object?



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

    On 08/09/2009 at 20:46, xxxxxxxx wrote:

    if (objPoly->IsInstanceOf(Opolygon)) // It's a polygon object ;)



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

    On 09/09/2009 at 02:52, xxxxxxxx wrote:

    Here's the Subdivide function with a few new checks in there...

    > `

      
    \>  Bool SculptTool::Subdivide(ModelingCommandData &mdat;)  
    \>  {  
    \>  GePrint("In Subdivide");  
    \>  //CODE RELATED TO THE SUBDIVISION OPTIONS/////////////////////////////////  
    \>    
    \>       //Define Variables  
    \>    
    \>      PolygonObject *objPoly = ToPoly(mdat.doc->GetActiveObject());  
    \>         
    \>         
    \>  if (objPoly->IsInstanceOf(Opolygon))  
    \>  {  
    \>       GePrint("It's a Polygon");  
    \>  }  
    \>  else  
    \>  {  
    \>       GePrint ("It's not a polygon");  
    \>       return FALSE;  
    \>  }  
    \>    
    \>    
    \>       mdat.op = objPoly;  
    \>    
    \>       //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());//Shows the current polygon count  
    \>       if (!SendModelingCommand(MCOMMAND_SUBDIVIDE, mdat))  
    \>       {  
    \>            GePrint("FAILURE");  
    \>       }  
    \>       else  
    \>       {  
    \>            GePrint("SUCCESS");  
    \>       }  
    \>    
    \>       GePrint("End Of Subdivide");  
    \>       return TRUE;  
    \>    
    \>  //END SUBDIVISION OPTIONS/////////////////////////////////////////////////  
    \>    
    \>    
    \>  }  
    \>  
    

    `

    In the console I get
    > `

      
    \>  Subdivide Button Clicked  
    \>  In Subdivide  
    \>  It's a Polygon  
    \>  SUCCESS  
    \>  End of Subdivide  
    \>  
    

    `

    But still it does not subdivide the current polygon object in the scene.

    Anyone know why this is? SEE above for other code in the plugin.



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

    On 09/09/2009 at 18:30, xxxxxxxx wrote:

    okay so I stripped it back down to just the message() and the DoCommand () code looks like this.

    > `

      
    \>  Bool SculptTool::Message(BaseDocument* doc, BaseContainer& data, LONG type, void* t_data)  
    \>  {  
    \>       PolygonObject *op = ToPoly(doc->GetActiveObject());  
    \>  switch (type)  
    \>       {  
    \>            case MSG_DESCRIPTION_COMMAND:  
    \>            {  
    \>            DescriptionCommand *dc = (DescriptionCommand* ) t_data;  
    \>            if (dc->id[0].id==COMMAND_SUBDIVIDE)  
    \>                 {  
    \>                 GePrint("Subdivide Button Clicked");  
    \>                 //Determine Attributes  
    \>                 mdat.doc = doc;  
    \>                 mdat.bc = &bc;  
    \>                 mdat.op = op;  
    \>    
    \>    
    \>                 mdat.mode = MODIFY_ALL;  
    \>              DoCommand(mdat);  
    \>                 }  
    \>    
    \>            }  
    \>       }  
    \>       return TRUE;   
    \>    
    \>  }  
    \>    
    \>  Bool SculptTool::DoCommand(ModelingCommandData &mdat;)  
    \>  {  
    \>       GePrint("In DoCommand");  
    \>    
    \>       SendModelingCommand(MCOMMAND_SUBDIVIDE, mdat);  
    \>    
    \>       return TRUE;  
    \>  }  
    \>  
    

    `

    Now when I click the button, the object subdivides.
    but I have no control over the attributes.

    When I try to add in the following.

    > `

      
    \>       //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, bc->GetLong(NUM_SUBDIVISIONS)); //Set Number of Subdivisions  
    \>       mdat.bc->SetReal(MDATA_SUBDIVIDE_ANGLE, mdat.bc->GetReal(MAX_ANGLE)); //Set Maxiumum Angle  
    \>  
    

    `

    It won't recognize the attributes and won't subdivide at all. Must be something in the way I am using the base container.   Any thoughts about this? Anyone know how I could edit the first code to be able to adjust subdivision attributes from the NUM_SUBDIVISIONS long and the MAX_ANGLE real?

    Thanks,

    ~Shawn



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

    On 10/09/2009 at 01:22, xxxxxxxx wrote:

    Don't pass the BaseContainder from Message() to mdat.

    Do something like this:

    BaseContainer bc;
    bc.SetLong(MDATA_SUBDIVIDE_SUB, data.GetLong(NUM_SUBDIVISIONS));
    bc.SetReal(MDATA_SUBDIVIDE_ANGLE,data.GetReal(MDATA_SUBDIVIDE_ANGLE));
    ModelingCommandData mdat;
    mdat.doc = doc;
    mdat.bc = &bc;
    mdat.op = op; //pass the pointer to the object
    SendModelingCommand(MCOMMAND_SUBDIVIDE, cd));

    cheers,
    Matthias



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

    On 10/09/2009 at 02:58, xxxxxxxx wrote:

    LOL...   it's always so simple.    Thanks, Matthias.. works like a charm now.

    ~Shawn


Log in to reply