Joints how to get them?

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

On 19/12/2011 at 11:27, xxxxxxxx wrote:

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

---------
Hi,
I'm wondering if it is possible to use/insert joints with while using a ObjectDataPlugin.
The SDK isn't giving that much of a example how to use the functions.
I'm trying to build such a structure

I think i've to use the AddJoint function but i kind a need a example, to see how exactly i've to use all the functions.
stuff like DescItems are used often in the example plugins which are in the SDK but nothing with joints.

So the question is anybody got experience with joints ?

thanks

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

On 19/12/2011 at 16:05, xxxxxxxx wrote:

There's information about joints scattered throughout the archives.
I've built this little example to use as a reference guide:

//This code creates a mesh object and adds a weight tag to it  
//Then it creates a joint and inserts it into the weight tag  
//Then the SetPose button is executed  
  
#include "lib_ca.h" //Use this header for access to needed CA resources  
  
  
  
  BaseDocument *doc = GetActiveDocument();             //Get the active document  
  BaseObject *myMesh = BaseObject::Alloc(Ocylinder);  //Creates an instance of the BaseObject class to create a cylinder primitive object   
  if (!myMesh) return FALSE;  
    
  myMesh->SetParameter(DescID(PRIM_CYLINDER_HSUB), GeData(4.0), DESCFLAGS_SET_0); //Sets number of segments to four      
  doc->InsertObject( myMesh, NULL, NULL );     //Inserts the cylinder object into the OM  
  
  ModelingCommandData mcd;  
  mcd.bc = myMesh->GetDataInstance();  
  mcd.doc = doc;  
  mcd.op = myMesh;      
  mcd.mode = MODELINGCOMMANDMODE_ALL;  
  mcd.flags = MODELINGCOMMANDFLAGS_CREATEUNDO;      
  if (!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, mcd)) return FALSE;  
  EventAdd();//Update all the changes  
  
  BaseObject *first = doc->GetFirstObject();  
  first->Remove();  
  myMesh = doc->GetFirstObject();                   //Grabs the new polygon based cylinder and assigns it back to same variable "myMesh"  
  
  CAWeightTag *wtag = CAWeightTag::Alloc();         //Creates an instance of the CAWeightTag class to create a weight tag  
  if (!wtag) return FALSE;  
  myMesh->InsertTag(wtag);                          //Adds the weight tag to the mesh object  
  
  BaseObject *myJoint1 = BaseObject::Alloc(Ojoint);  //Creates an instance of the BaseObject class to create a joint object  
  if (!myJoint1) return FALSE;   
  BaseObject *myJoint2 = BaseObject::Alloc(Ojoint);  //Creates an instance of the BaseObject class to create a joint object   
  if (!myJoint2) return FALSE;   
  doc->InsertObject( myJoint1, myMesh, NULL );       //Inserts the joint object as a child of the mesh  
  myJoint1->SetAbsPos(Vector(0,-100,0));  
  doc->InsertObject( myJoint2, myJoint1, NULL );     //Inserts the joint object as a child of the first joint  
  myJoint2->SetAbsPos(Vector(0,100,0));  
  
  wtag->AddJoint(myJoint1);                          //Adds the joint to the weight tag  
  wtag->AddJoint(myJoint2);                          //Adds the joint to the weight tag  
  myJoint1->GetTag(Tweights);  
  
  
  DescriptionCommand dc;                          //Create a variable to hold the id number we will get next   
  dc.id = DescID(DescLevel(2005));                //Assign the SetPose button ID to the variable  
  wtag->Message(MSG_DESCRIPTION_COMMAND, &dc);    //Execute the "SetPose" Button on the weight tag  
  
  EventAdd();

Important Note :The weight tag must exist in the OM before you try to add joints to it.
AFAIK. We aren't allowed to add joints to the tag in memory.

Also be aware of this when dealing with the buttons on the weight tag:

//The string names for the weight tag are no longer valid..so You must use their numerical ID's  
  
ID_CA_WEIGHT_TAG_JOINTS_GROUP = 5000,          
ID_CA_WEIGHT_TAG_RESET = 2001,  
ID_CA_WEIGHT_TAG_SET = 2005,  
ID_CA_WEIGHT_TAG_TOTALWEIGHT = 2007,  
ID_CA_WEIGHT_TAG_JOINT_MAP = 2008,  
ID_CA_WEIGHT_TAG_JOINTS_LIST = 2009,

-ScottA

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

On 06/01/2012 at 21:57, xxxxxxxx wrote:

Thanks it helps a lot.
I made a selection field for other Objects(Meshs). I get all the Data like name etc while using BaseList2D
But as much as i can tell from you example I need BaseObjects. So the question is how to convert a baselist2d to a baseobject.

 BaseList2D objSe = b.GetLink(OBJ_AUSWAHL, doc); 
BaseObject Mesh = objSe;

the GetLink is not available for BaseObjects. So the question is how to convert Baselist2D into a Baseobject.

Or am I missing an alternative to get the Info/Mesh from a "DTYPE_BASELISTLINK" "SetLink" DESC Field type

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

On 07/01/2012 at 03:18, xxxxxxxx wrote:

Assuming that in your code snippet 'b' is a BaseContainer, just cast the returned object:

  
BaseObject* Mesh = (BaseObject* )b.GetLink(OBJ_AUSWAHL, doc);   

Note also that GetLink() returns a pointer, not an object instance.

Steve

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

On 07/01/2012 at 11:26, xxxxxxxx wrote:

oh shame on me 😕
hm is there a way to save into the Baseobject Mesh the object Instance?
I'am thinking about something like this

BaseObject *myMesh = BaseObject::Alloc(Ocylinder)

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

On 07/01/2012 at 14:41, xxxxxxxx wrote:

That's correct, that's how you would allocate a new object instance. Alloc() returns a pointer to the new object. Although just to note, IMO it's better to use GeneratePrimitive() for the inbuilt primitives like cylinders.

Steve