Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    AddJoint, SetWeight crash

    Scheduled Pinned Locked Moved SDK Help
    3 Posts 0 Posters 320 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

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

      On 12/10/2010 at 00:50, xxxxxxxx wrote:

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

      ---------
      Under what circumstances would AddJoint() from CAWeightTag return -1 for the joint index?
      I use the following code after I have allocated and added all joint objects to the document. 
      All joint object pointers are valid.

        
      CAWeightTag* tag = CAWeightTag::Alloc();  
      for(i=0; i < num_joints; i++) {  
         LONG joint_index = tag->AddJoint( joints[i].ob ); // returns -1 ???  
      }  
      pPoly->InsertTag( tag, NULL );  
      

      Then later, calling tag->SetWeight( joint_index, vindex, weight ); will crash the program from passing -1 as joint_index.

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

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

        On 12/10/2010 at 02:31, xxxxxxxx wrote:

        It seems that you have first to insert the tag before inserting the joints.

        little example:

          
        void StepThru(BaseObject *op, CAWeightTag *tag)  
        {  
          while (op && tag)  
          {  
              if (op->GetType() == Ojoint)  
              {  
                  tag->AddJoint(op);  
                  tag->Message(MSG_UPDATE);  
              }  
          
              StepThru(op->GetDown(), tag);  
              op = op->GetNext();  
          }  
        }  
          
        Bool MenuTest::Execute(BaseDocument *doc)  
        {  
          BaseObject *op = doc->GetActiveObject();  
          if (!op) return FALSE;  
          
          CAWeightTag *tag = CAWeightTag::Alloc();  
          if (!tag) return FALSE;  
                
          op->InsertTag(tag);  
          
          op->Message(MSG_UPDATE);  
          EventAdd();  
          
          StepThru(doc->GetFirstObject(), (CAWeightTag* )tag);  
          
          return TRUE;  
        }  
        

        cheers,
        Matthias

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

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

          On 12/10/2010 at 10:26, xxxxxxxx wrote:

          Great, got it working!  Thanks.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post