Horde3D

Next-Generation Graphics Engine
It is currently 28.03.2024, 11:11

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: 15.01.2013, 16:14 
Offline

Joined: 14.01.2013, 11:42
Posts: 3
Hi,
I was modifying the glfw example (for the Go bindings) and modifying some of the joints of the knight.
It happens that when a rotation get close to 90 deg rx and rz got swapped.
Here is the code I'm using to change the transformation:
Code:
if glfw.Key('O') == glfw.KeyPress {
        if num := horde3d.FindNodes(knight, "Bip01_Neck", horde3d.NodeTypes_Joint); num != 0 {
            head := horde3d.GetNodeFindResult(0)
            var tx, ty, tz, rx, ry, rz, sx, sy, sz float32
            horde3d.GetNodeTransform(head, &tx, &ty, &tz, &rx, &ry, &rz, &sx, &sy, &sz)
            horde3d.SetNodeTransform(head, tx, ty, tz, rx, ry, rz, sx, sy, sz)

        }
    }
    if glfw.Key('P') == glfw.KeyPress {
        if num := horde3d.FindNodes(knight, "Bip01_Neck", horde3d.NodeTypes_Joint); num != 0 {
            head := horde3d.GetNodeFindResult(0)
            var tx, ty, tz, rx, ry, rz, sx, sy, sz float32
            horde3d.GetNodeTransform(head, &tx, &ty, &tz, &rx, &ry, &rz, &sx, &sy, &sz)
            log.Printf("before: tx %f,ty %f,tz %f,rx %f,ry %f,rz %f,sx %f,sy %f,sz %f\n", tx, ty, tz, rx, ry, rz, sx, sy, sz)
            horde3d.SetNodeTransform(head, tx, ty, tz, rx, ry, rz, sx, sy, sz)
            log.Printf("after: tx %f,ty %f,tz %f,rx %f,ry %f,rz %f,sx %f,sy %f,sz %f\n", tx, ty, tz, rx, ry, rz, sx, sy, sz)

        }
   

and the logs:
Code:
2013/01/15 15:57:54 before: tx 9.184080,ty 0.000000,tz 0.003139,rx -86.450439,ry 22.060602,rz 0.000028,sx 1.000000,sy 0.999999,sz 0.999999
2013/01/15 15:57:54 after: tx 9.184080,ty 0.000000,tz 0.003139,rx -87.360443,ry 22.060602,rz 0.000028,sx 1.000000,sy 0.999999,sz 0.999999
2013/01/15 15:57:54 before: tx 9.184080,ty 0.000000,tz 0.003139,rx -87.360474,ry 22.060587,rz 0.000037,sx 1.000000,sy 0.999999,sz 0.999999
2013/01/15 15:57:54 after: tx 9.184080,ty 0.000000,tz 0.003139,rx -88.270477,ry 22.060587,rz 0.000037,sx 1.000000,sy 0.999999,sz 0.999999
2013/01/15 15:57:54 before: tx 9.184080,ty 0.000000,tz 0.003139,rx -88.270477,ry 0.000000,rz 22.051538,sx 1.000000,sy 0.999999,sz 0.999999
2013/01/15 15:57:54 after: tx 9.184080,ty 0.000000,tz 0.003139,rx -88.270477,ry 0.000000,rz 22.051538,sx 1.000000,sy 0.999999,sz 0.999999
2013/01/15 15:57:54 before: tx 9.184080,ty 0.000000,tz 0.003139,rx -88.270477,ry 0.000000,rz 22.051538,sx 1.000000,sy 0.999999,sz 0.999999
2013/01/15 15:57:54 after: tx 9.184080,ty 0.000000,tz 0.003139,rx -88.270477,ry 0.000000,rz 22.051538,sx 1.000000,sy 0.999999,sz 0.999999


The rotations swap does't happen again if the "rotation limit" is reached again.
Is this a bug or a known behavior?
As a workaround I'm keeping the rotation in (-87.0, 87.0).


Top
 Profile  
Reply with quote  
PostPosted: 15.01.2013, 22:54 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
I guess that's probably a problem called gimble lock, that occures when calling h3dGetNodeTransform. Horde3D stores transformations internally as a matrix and not as the single transformation parameters. If you request them using h3dGetNodeTransform it tries to decompose the internal matrix. That's something that should be avoided, as it suffers from mathematical issues and is not very fast. You could either store the single transformation parameters by yourself, change them and pass them again to h3dSetNodeTransform, or you use whole matrices instead and pass them via h3dSetNodeTransMat (use h3dGetNodeTransMats to query the node's internal matrices).


Top
 Profile  
Reply with quote  
PostPosted: 16.01.2013, 09:56 
Offline

Joined: 14.01.2013, 11:42
Posts: 3
I see.

Thanks for the help.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 30 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group