opensg-users

 [Opensg-users] Rotation From: Robin Steinke - 2006-09-27 10:47:52 ```Hi again, i step into another problem. i have setup the leg, but when i apply a rotation to any link, it seems to be, the leg is rotated around the origin point of the scene (0,0,0). one thing, that gets me confused is, that in my understanding it should rotated around the local coordinate system, not the global. if not, ok, one solution would be, to translate the object to the origin and after the rotation is applied, translate it back. to do such an operation, i require the global translation matrix of the given link. but when i call: Matrix tempTrans = linkTransformNodes[1]->getToWorld(); it returns the identity matrix. any ideas how i can get the global translation matrix? on the other hand, i wonder if there is a way to move the pivot point of an object to the local origin point? another point is, that the rotation works just fine that way, when i setup the leg with openSG primitives. Code: void Leg::setRotation(int n) { TransformPtr resultTrans = linkTransform[n]; Matrix tempJ, tempR, t, r; tempJ.setIdentity(); tempR.setIdentity(); tempTrans.setIdentity(); r.setIdentity(); if(resultTrans!=NullFC) { tempR = resultTrans->getMatrix(); tempJ.setRotate(Quaternion(Vec3f(1,0,0),deg2rad(-45))); tempJ.mult(tempR); tempTrans = linkTransformNodes[n]->getToWorld(); r.inverse(tempTrans); cout << "tx:" << t[0] << " rx:" << r[0] << endl; cout << "tx:" << t[1] << " rx:" << r[1] << endl; cout << "tx:" << t[2] << " rx:" << r[2] << endl; beginEditCP(resultTrans, Transform::MatrixFieldMask); //resultTrans->setMatrix(r); resultTrans->setMatrix(tempJ); endEditCP(resultTrans, Transform::MatrixFieldMask); } else cout << "No rotation was set!" << endl; } best regards, robin p.s. thanks a lot, for the help with the actions, works fine now ```
 Re: [Opensg-users] Rotation From: Antonio Bleile - 2006-09-27 11:04:57 ```> Hi again, > > i step into another problem. i have setup the leg, but when i apply a > rotation to any link, it seems to be, the leg is rotated around the > origin point of the scene (0,0,0). one thing, that gets me confused is, > that in my understanding it should rotated around the local coordinate > system, not the global. if not, ok, one solution would be, to translate > the object to the origin and after the rotation is applied, translate it > back. to do such an operation, i require the global translation matrix > of the given link. but when i call: > Matrix tempTrans = linkTransformNodes[1]->getToWorld(); > it returns the identity matrix. any ideas how i can get the global > translation matrix? That looks like your leg has been modelled (or has been saved?) in world coordinates... There are apparently no translations/rotations whatsoever between your leg node and the root scene node (that's what getToWorld does, it walks up the graph accumulating all transformation it encounters on its way up to the root). Cheers, Toni ```