Setting obj position to bone
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 03/06/2003 at 02:25, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 7.3
Platform: Mac ;
Language(s) : C.O.F.F.E.E ;---------
Hi, I'm trying to 'boxify' a skeleton, by importing a BVH, then running my plugin to put cubes into bones, thus creating a 'box skeleton', moving as the bone skeleton moves....I've hit an early snag - can't get the position of an inserted cube to match the bone. I'm using my own code (that works in other plugins) and what I found by searching the archive here.
My version is:
makeObjectGlobalPointLocal(point,object)
{
var oM = object->GetMg();
oM->Invert();
point = oM->GetMulP(point);
return point;
}makeObjectLocalPointGlobal(point,object)
{
var oM = object->GetMg();
var oGV = oM->GetV0();
point = oM->GetMulP(point);
return point;
}... and what I found here:
// Matrix -> PSR
GetMatrixPosition(mat){
return mat->GetV0();
}GetMatrixRotation(mat)
{
return mat->GetHPB();
}GetMatrixScale(mat)
{
return vector(vlen(mat->GetV1()),
vlen(mat->GetV2()),
vlen(mat->GetV3()));
}// PSR -> Matrix
SetMatrixPosition(mat,pos)
{
mat->SetV0(pos);
}SetMatrixRotation(mat,rot)
{
var temp=mat->GetV0();
mat->SetRotHPB(rot);
mat->SetV0(temp);
}SetMatrixScale(mat,scale)
{
mat->SetV1(vnorm(mat->GetV1())*scale.x);
mat->SetV2(vnorm(mat->GetV2())*scale.y);
mat->SetV3(vnorm(mat->GetV3())*scale.z);
}... the odd thing is that when I do the calculations, the printout to the console reads both the bone and the inserted cube as same position point. But in the viewport the cube is offset from the bone. The further the bone is from 0,0,0 the greater the offset. The bone is disabled and there's no difference if I alter its settings. What's wrong?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 03/06/2003 at 16:06, xxxxxxxx wrote:
Mea culpa regarding the console printout, the values were actually different, there was an error in my code.
Have now solved the problem by ignoring the local-to-global point routines and instead setting the position of the cube like this, where 'box' is the cube and 'op' the target bone:
box->SetPosition((op->GetPosition()*-1)+op->GetPosition());
I arrived at this when I noticed that the cube offset was equal to the bone distance from 0,0,0. I thought that multiplying by -1 would bring the cube to the position of the bone, but it brought it to 0,0,0, so I then added the bone position and finally got the desired result.
Needless to say I'm thoroughly confused about it all, if anyone could shed some light on what's going on would be great, especially why my globalizing routines didn't work.