dongju.jeong Posted January 10, 2019 Share Posted January 10, 2019 (edited) In the process of setting up the transformation, rotate using a quaternion. but Why does the Gimbal lock occur? ex) node->SetWorldTransform(node->getWorldTransform()*rotate(quat(20,90,0))); ex)handsample->setWorldBoneTransform(13, handsample->getWorldBoneTransform(13)*(Mat4)rotate(quat(40, 90, 0))); handsample->setWorldBoneTransform(13, (Mat4)rotate(quat(40, 90, 0))); The SetBoneRotation () function in the Utils file in the VRtemplete project has the same problem. I tested using this hand model(upload file). How do I apply a Rotation with a quaternion without a gimbal Lock? (To node or bone transform) Hand_rigged.3DS Hand_rigged.FBX Hand_rigged.FBX.meta material #16.mat material #16.mat.meta Edited January 10, 2019 by dongju.jeong Link to comment
cash-metall Posted January 10, 2019 Share Posted January 10, 2019 Please, tell us in more detail how you get Gimbal lock. Maybe a video or a simple example? In the VRTemplate, I see such code void setBoneRotation(ObjectMeshSkinnedPtr &skin, int boneNum, const quat &rot) { mat4 transform = skin->getBoneTransform(boneNum); mat3 rotMat = rot.getMat3(); transform.setColumn3(0, rotMat.getColumn(0)); transform.setColumn3(1, rotMat.getColumn(1)); transform.setColumn3(2, rotMat.getColumn(2)); skin->setBoneChildrenTransform(boneNum, transform); } without WorldBoneTransform, maybe this is a mistake? Link to comment
dongju.jeong Posted January 10, 2019 Author Share Posted January 10, 2019 (edited) void setBoneRotation(ObjectMeshSkinnedPtr &skin, int boneNum, const quat &rot, const vec3 &scale) { mat4 transform = skin->getBoneTransform(boneNum); mat3 rotMat = rot.getMat3(); transform.setColumn3(0, vec3(rotMat.getColumn(0))); transform.setColumn3(1, vec3(rotMat.getColumn(1))); transform.setColumn3(2, vec3(rotMat.getColumn(2))); transform *= (mat4)Math::scale(scale); skin->setBoneTransform(boneNum, transform); } I use this on test. OnUpdate() { static float i = 0; i += 0.5f; setBoneRotation(handsample, 13, quat(i,90,0),vec3(0.001)); or setBoneRotation(handsample, 13, quat(0,90,i),vec3(0.001)); } Both rotate relative to the local Z axis. when use "setBoneRotation(handsample, 13, quat(i,90,0),vec3(0.001));" , How can I programing rotate relative to the changed local x axis? and when using SetWorldBoneTransform() too. Edited January 10, 2019 by dongju.jeong Link to comment
cash-metall Posted January 10, 2019 Share Posted January 10, 2019 you can try split rotation quat(i, 90, 0) as two rotation quat(0, 90, 0) * quat(i, 0, 0) to avoid Gimbal lock. Also, we recomended use another constructor quat(vec3 axis, float angle) for rotation arround any axis, without use Euler Rotation. 1 Link to comment
dongju.jeong Posted January 10, 2019 Author Share Posted January 10, 2019 thank you. When I only know the some destination matrix( such as leapmotion's hand.basis), how do you rotate it using the quat (axis, angle) function? using destination matrix, I can calculate how many need degree values each in the world standard X axis, Y axis, and Z axis. But I do not know how to rotate with quat (axis, angle) at once. Link to comment
cash-metall Posted January 10, 2019 Share Posted January 10, 2019 first turn, then transform rotate(quat_rotation) * tranform_matrix; Link to comment
dongju.jeong Posted January 15, 2019 Author Share Posted January 15, 2019 (edited) I got ploblem about rotate this hand model bone using leapmotion bone basis matrix. I try to test base on left hand. But I do not understand this sentence . "You can change from right-hand to left-hand rule by multiplying the z basis vector by -1." How I use leapmotion bone basis value for hand model bones.? first, I do this. Mat4 basis = Mat4(offsetHead)*Mat4(bones[a].basis); //bones[a] is some finger's bone. quat Rotate = quat(basis.getRotate().getAngle(vec3(-1, 0, 0)), basis.getRotate().getAngle(vec3(0, 1, 0)), basis.getRotate().getAngle(vec3(0, 0, -1))); Edited January 15, 2019 by dongju.jeong Link to comment
cash-metall Posted January 15, 2019 Share Posted January 15, 2019 Quote "You can change from right-hand to left-hand rule by multiplying the z basis vector by -1." it's about how to translate from leapmotion coordinate system(left) to world(right) and backward. basis.setColumn3(2, basis.getColumn3(2) * -1); you can also look at an example Samples/3rd party/other/LeapMotionVisualizer 1 Link to comment
dongju.jeong Posted January 15, 2019 Author Share Posted January 15, 2019 thank you. It was a great help to me. Link to comment
dongju.jeong Posted January 16, 2019 Author Share Posted January 16, 2019 I have one more question. Do you have a hand model sample that you can experiment with at Unigine ?? My model is not suitable for test in Unigine. Link to comment
silent Posted January 16, 2019 Share Posted January 16, 2019 I'm afraid there is no such model available in SDK, sorry. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Recommended Posts