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