anyone here know coffee


Does anyone here know coffeeI’m trying to add to the target node that comes with C4D. I want to add code that would
make a bone scale to reach its target as well as aim at the target. Here is the code I have so far but I’m stuck on how to make the bone scale to reach. I asked on the plugin cafe but that list does not seem very active and have not recived an answer so I thought I would ask here.

[left]How do I go about setting the bones length to the var (dist) I have?
[left]Here is the code with my line added in:
var mobj = Muscle->GetMg();
var tobj = Target->GetMg();

var p1 = mobj->GetV0();
var p2 = tobj->GetV0();
[left] var dist = p2 - p1; //gets distance from p1 to p2

var m = new(Matrix);
[left] m->SetV0(p1);
m->SetV3(vnorm(p2 - p1));
m->SetV2(vnorm(vcross(p2-p1, vector(0,1,0))));
m->SetV1(vnorm(vcross(p2-p1, vector(0,0,1))));

[left] var orot=mobj->GetHPB();



Hi dfaris,

First you have to compute the desired length by substracting the bone’s position from the target vector to get the vector connecting the two. Then you can get this vector’s length by using vlen(); Then you have to apply this value to the bone.

The bone length parameter is stored in the bones container as all attributes of C4D objects. A container is a custom data structure in some way similar to an array. The difference is, that it can store all types of data. The data (the object’s parameters) are accessed by a enumerated values. That means, in your case, that first you have to get the bone’s container with bone->GetConainer(); Then you can set the length value with container->SetData(); To do this you have to look for the correct identifier enum. It’s something like PRIM_BONELENGTH, but I do not remember it exactly. You may want to look for it in the COFFEE reference or in the C++ header files, as of R9 the COFFEE and C++ enums are identical.

Then you have to store the modified container back to the object with bone->SetContainer(); and you’re done.

hope that helps, cheers mnu


Hey thanks for that info. Is that for the 9.1 sdk or an older one? I did this

Muscle#BONEOBJECT_LENGTH = dist; and it seems to work ok. I’m not sure if I should do it a different way or not.


Hi again,

what you did works for the 9.1 SDK. My version is the old one. It should work in R9.1 anyway.

cheers mnu


This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.