# [Bullet physics] Combining two rotations

This topic is 3113 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Guys,
there is a small issue i am facing now and cannot find a clue how to overcome the problem.

What i have and what i need?

1. Have

I have an animated box having 100 frames of a rotation within Y, so within 100 frames my box rotates 360^. The rotation is being made on a bone - and i can obtain the current rotation of the bone at any time.

I have a Bullet physics engine implemented and when i drop my box out in the space, the bullet calculates all required things like transformation and rotation by himself. Of course i can also obtain current physic_rotation values at any time.

So for now i have:

Vector3 animation_rotation <x,y,z>
Vector3 physic_rotation <x,y,z>

(both can be retrieved as quaternions)

2. Need

What i need to do is :

- drop the box on the scene with its animation
- let the physic_rotation and animation_rotation vectors work together.

Actually i can choose between rotations (physic or animation) to be applied on to the model,

when i apply :

animation_rotation ( the one obtained from the model ) - everytime when animation starts from the beggining ( frame 1 ) my model 'resets' its rotation to the one defined in animation cycle - which looks ugly, as when the physics are applied it behaves unnaturaly due to the fact it gets a rotation reset to frame 1 rotation vector. in other words, when animation is played it overwrites the actual physical_rotation

physic_rotation ( the one from bullet ) - my model won't animate - and this is correct as i am not applying any bone rotation on it.just a plain physic.

Now, i am standing at the end of the code, what i have to do is to 'combine' somehow those two vectors of rotation so they 'cooperate' all the time.

						 CVector3 animation_rotation;						 btQuaternion physic_rotation = trans.getRotation();						 						 animation_rotation=DYNAMICITEM[a].XYN.GetBoneRotation(0);						 animation_rotation.x+=physic_rotation.getX();						 animation_rotation.y+=physic_rotation.getY();						 animation_rotation.z+=physic_rotation.getZ();						 physic_rotation.setX(animation_rotation.x);						 physic_rotation.setY(animation_rotation.y);						 physic_rotation.setZ(animation_rotation.z);						 trans.setRotation(physic_rotation);						 DYNAMICITEM[a].PHYSICS_body->setWorldTransform(trans);

I tried adding them, but the final effect is just a trash,
how to have them combined, is it possible?

Am i clear enough ?:)

[Edited by - razor1911 on July 16, 2010 4:13:27 PM]

##### Share on other sites
It sounds like you just need to multiply the two quaternions together. (The order should probably be physics*animation, but depending on the conventions used by the math library, it could be animation*physics.)

##### Share on other sites
Thanks mate,
i'll have a look and give u a shout if that worked - but i suppose that's exactly what i should do.

##### Share on other sites
Perfect,
the rotations are now combined but the model rotates 100 times faster than the animation when multiplied with physic rotation:

physic_rotation= physic_rotation*anim;

What might be the cause of such action?

[Edited by - razor1911 on July 16, 2010 4:51:34 AM]

##### Share on other sites
I'll upload a vid to show you the effect of multiplying two quaternions :

Physic*animation;

The behaviour of the model is now correct, the only thing that is strange is the speed of the animation it is runnig due to that multiplication.

The goal is achieved but one small issue appeared.

>Video

And debug view of the calculation...

[source lang=cpp]PHYSICQ:0.000038 -0.534325 0.001246 * ANIMQ-0.000387 -0.030850 0.000000 = -0.000251 -0.560148 0.001037PHYSICQ:-0.000251 -0.560148 0.001037 * ANIMQ-0.000387 -0.030850 0.000000 = -0.000539 -0.585438 0.000827PHYSICQ:-0.000539 -0.585438 0.000827 * ANIMQ-0.000387 -0.030850 0.000000 = -0.000827 -0.610170 0.000617

[Edited by - razor1911 on July 16, 2010 5:38:32 AM]

##### Share on other sites
If done correctly, combining the physics and animation orientations should not make the animation appear to run faster.

I can't say what the problem is based on what you've posted, but a good test (which you may already be doing) would be to set up the physics object so that it's stationary (i.e. no rotation or linear motion), turn off the animation to confirm that the object is stationary, and then turn on the animation. If the animation runs faster than expected, and if that behavior appears to be related to combining the physics and animation transforms, then it's likely you're doing something wrong in your code somewhere.

One thing I'll mention is to make sure you're not overwriting the physics transform with the newly computed 'combined' orientation. (I don't know if this is possible with Bullet, but I thought I'd at least mention it.) In pseudocode, it should look something like this:
quaternion physics_rotation = object.get_orientation();quaternion anim_rotation = anim.get_orientation();quaternion orientation = physics_rotation * anim_rotation;// Then render using 'orientation'.

##### Share on other sites
jyk,

i am guessing the 'speed' problem can be caused by two things running out of sync in my application now:

the animation framerate
engine stepping

Animation framerate is not synchronized with bullet stepping.

Animation frames are calculated 60 times per second, while the physic
is updated continously without interval - this desynch might cause the trouble ..

So finally, physics are 10times faster than the bone animation, and this sounds a bit logical.

Gotta have a look and try to synch both of them,
any logical ideas / tips or tricks how to add next animation frame with a full synchro to physic engine update?

##### Share on other sites
Still the same,
i update the animation frame every 10ms
the same goes with physics engine and the results are pretty weird.

Animation applied onto the object - runs fine, as per my settings in 3DS MAX.
When two quaternions are multiplied :

final_rotation=actual_physic_rotation*actual_animation_frame_rotation;

Animation does not reset the actual physic rotation, and starts from actual physic position, but the animation itself is acting strange.

I can't find a clue, what is causing this strange effect,
both rotations are stored as quaternions, below - a list of animation frames and rotation quaternion dumped X,Y,Z,W

ANIMFRAME: 0  < -0.000000 -0.000000 -0.000000 1.000000 >ANIMFRAME: 1  < 0.000007 0.000000 -0.000936 1.000000 >ANIMFRAME: 2  < 0.000029 -0.000000 -0.003720 0.999993 >ANIMFRAME: 3  < 0.000065 0.000000 -0.008312 0.999965 >ANIMFRAME: 4  < 0.000115 -0.000000 -0.014677 0.999892 >ANIMFRAME: 5  < 0.000179 -0.000000 -0.022774 0.999741 >ANIMFRAME: 6  < 0.000256 -0.000000 -0.032565 0.999470 >ANIMFRAME: 7  < 0.000346 -0.000000 -0.044011 0.999031 >ANIMFRAME: 8  < 0.000448 -0.000000 -0.057069 0.998370 >ANIMFRAME: 9  < 0.000563 -0.000000 -0.071696 0.997426 >ANIMFRAME: 10  < 0.000690 -0.000000 -0.087848 0.996134 >ANIMFRAME: 11  < 0.000828 0.000000 -0.105477 0.994421 >ANIMFRAME: 12  < 0.000978 -0.000000 -0.124531 0.992215 >ANIMFRAME: 13  < 0.001138 0.000000 -0.144958 0.989437 >ANIMFRAME: 14  < 0.001309 -0.000000 -0.166698 0.986007 >ANIMFRAME: 15  < 0.001490 -0.000000 -0.189689 0.981843 >ANIMFRAME: 16  < 0.001680 -0.000000 -0.213867 0.976861 >ANIMFRAME: 17  < 0.001878 -0.000000 -0.239159 0.970979 >ANIMFRAME: 18  < 0.002085 -0.000000 -0.265489 0.964112 >ANIMFRAME: 19  < 0.002299 0.000000 -0.292776 0.956178 >ANIMFRAME: 20  < 0.002520 0.000000 -0.320934 0.947098 >ANIMFRAME: 21  < 0.002748 -0.000000 -0.349870 0.936794 >ANIMFRAME: 22  < 0.002980 -0.000000 -0.379488 0.925192 >ANIMFRAME: 23  < 0.003217 -0.000000 -0.409686 0.912221 >ANIMFRAME: 24  < 0.003458 0.000000 -0.440354 0.897817 >ANIMFRAME: 25  < 0.003702 -0.000000 -0.471382 0.881921 >ANIMFRAME: 26  < 0.003948 -0.000000 -0.502652 0.864480 >ANIMFRAME: 27  < 0.004194 -0.000000 -0.534042 0.845447 >ANIMFRAME: 28  < 0.004441 -0.000000 -0.565429 0.824785 >ANIMFRAME: 29  < 0.004686 -0.000000 -0.596682 0.802464 >ANIMFRAME: 30  < 0.004929 -0.000000 -0.627672 0.778462 >ANIMFRAME: 31  < 0.005170 -0.000000 -0.658265 0.752769 >ANIMFRAME: 32  < 0.005406 -0.000000 -0.688327 0.725380 >ANIMFRAME: 33  < 0.005637 -0.000000 -0.717724 0.696305 >ANIMFRAME: 34  < 0.005861 -0.000000 -0.746320 0.665562 >ANIMFRAME: 35  < 0.006078 -0.000000 -0.773982 0.633178 >ANIMFRAME: 36  < 0.006287 -0.000000 -0.800579 0.599194 >ANIMFRAME: 37  < 0.006487 -0.000000 -0.825984 0.563657 >ANIMFRAME: 38  < 0.006676 -0.000000 -0.850069 0.526628 >ANIMFRAME: 39  < 0.006854 -0.000000 -0.872718 0.488177 >ANIMFRAME: 40  < 0.007019 -0.000000 -0.893814 0.448383 >ANIMFRAME: 41  < 0.007172 -0.000000 -0.913250 0.407335 >ANIMFRAME: 42  < 0.007311 -0.000000 -0.930927 0.365132 >ANIMFRAME: 43  < 0.007435 -0.000000 -0.946752 0.321878 >ANIMFRAME: 44  < 0.007544 -0.000000 -0.960642 0.277688 >ANIMFRAME: 45  < 0.007638 -0.000000 -0.972523 0.232682 >ANIMFRAME: 46  < 0.007715 -0.000000 -0.982332 0.186986 >ANIMFRAME: 47  < 0.007775 -0.000000 -0.990017 0.140733 >ANIMFRAME: 48  < 0.007818 -0.000000 -0.995536 0.094058 >ANIMFRAME: 49  < 0.007844 -0.000000 -0.998859 0.047100 >ANIMFRAME: 50  < 0.007853 -0.000000 -0.999969 0.000000 >ANIMFRAME: 51  < 0.007844 -0.000000 -0.998859 -0.047100 >ANIMFRAME: 52  < 0.007818 -0.000000 -0.995536 -0.094058 >ANIMFRAME: 53  < 0.007775 -0.000000 -0.990017 -0.140733 >ANIMFRAME: 54  < 0.007715 -0.000000 -0.982332 -0.186986 >ANIMFRAME: 55  < 0.007638 -0.000000 -0.972523 -0.232682 >ANIMFRAME: 56  < 0.007544 -0.000000 -0.960642 -0.277687 >ANIMFRAME: 57  < 0.007435 -0.000000 -0.946752 -0.321878 >ANIMFRAME: 58  < 0.007311 -0.000000 -0.930927 -0.365131 >ANIMFRAME: 59  < 0.007172 -0.000000 -0.913251 -0.407335 >ANIMFRAME: 60  < 0.007019 -0.000000 -0.893814 -0.448383 >ANIMFRAME: 61  < 0.006854 -0.000000 -0.872718 -0.488177 >ANIMFRAME: 62  < -0.006676 -0.000000 0.850070 0.526628 >ANIMFRAME: 63  < -0.006487 -0.000000 0.825984 0.563657 >ANIMFRAME: 64  < -0.006287 -0.000000 0.800579 0.599194 >ANIMFRAME: 65  < -0.006078 -0.000000 0.773982 0.633178 >ANIMFRAME: 66  < -0.005861 -0.000000 0.746320 0.665562 >ANIMFRAME: 67  < -0.005637 -0.000000 0.717724 0.696305 >ANIMFRAME: 68  < -0.005406 -0.000000 0.688327 0.725380 >ANIMFRAME: 69  < -0.005170 -0.000000 0.658265 0.752768 >ANIMFRAME: 70  < -0.004929 -0.000000 0.627672 0.778462 >ANIMFRAME: 71  < -0.004686 -0.000000 0.596682 0.802464 >ANIMFRAME: 72  < -0.004441 -0.000000 0.565429 0.824785 >ANIMFRAME: 73  < -0.004194 -0.000000 0.534043 0.845447 >ANIMFRAME: 74  < -0.003948 -0.000000 0.502652 0.864480 >ANIMFRAME: 75  < -0.003702 -0.000000 0.471382 0.881921 >ANIMFRAME: 76  < -0.003458 0.000000 0.440354 0.897817 >ANIMFRAME: 77  < -0.003217 -0.000000 0.409686 0.912221 >ANIMFRAME: 78  < -0.002980 -0.000000 0.379488 0.925192 >ANIMFRAME: 79  < -0.002748 -0.000000 0.349870 0.936794 >ANIMFRAME: 80  < -0.002520 0.000000 0.320934 0.947098 >ANIMFRAME: 81  < -0.002299 0.000000 0.292776 0.956178 >ANIMFRAME: 82  < -0.002085 -0.000000 0.265489 0.964112 >ANIMFRAME: 83  < -0.001878 -0.000000 0.239159 0.970979 >ANIMFRAME: 84  < -0.001680 -0.000000 0.213867 0.976861 >ANIMFRAME: 85  < -0.001490 -0.000000 0.189690 0.981843 >ANIMFRAME: 86  < -0.001309 -0.000000 0.166698 0.986007 >ANIMFRAME: 87  < -0.001138 0.000000 0.144958 0.989437 >ANIMFRAME: 88  < -0.000978 -0.000000 0.124531 0.992215 >ANIMFRAME: 89  < -0.000828 0.000000 0.105477 0.994421 >ANIMFRAME: 90  < -0.000690 -0.000000 0.087849 0.996134 >ANIMFRAME: 91  < -0.000563 -0.000000 0.071697 0.997426 >ANIMFRAME: 92  < -0.000448 -0.000000 0.057069 0.998370 >ANIMFRAME: 93  < -0.000346 -0.000000 0.044011 0.999031 >ANIMFRAME: 94  < -0.000256 -0.000000 0.032565 0.999470 >ANIMFRAME: 95  < -0.000179 -0.000000 0.022774 0.999741 >ANIMFRAME: 96  < -0.000115 -0.000000 0.014677 0.999892 >ANIMFRAME: 97  < -0.000065 0.000000 0.008313 0.999965 >ANIMFRAME: 98  < -0.000029 -0.000000 0.003720 0.999993 >ANIMFRAME: 99  < -0.000007 0.000000 0.000936 1.000000 >

ANIMATION CHANGED TO RUNNINGFRAME: 1 PHYSICQ <0.000000,0.000000,0.000000,1.000000> ANIMQ<0.000007,0.000000,-0.000936,1.000000>  MULTIPLIEDQ<0.000007,0.000000,-0.000936,1.000000>FRAME: 2 PHYSICQ <0.000007,0.000000,-0.000936,1.000000> ANIMQ<0.000029,-0.000000,-0.003720,0.999993>  MULTIPLIEDQ<0.000037,0.000000,-0.004656,0.999989>FRAME: 3 PHYSICQ <0.000037,0.000000,-0.004656,0.999989> ANIMQ<0.000065,0.000000,-0.008312,0.999965>  MULTIPLIEDQ<0.000102,0.000000,-0.012968,0.999916>FRAME: 4 PHYSICQ <0.000102,0.000000,-0.012968,0.999916> ANIMQ<0.000115,-0.000000,-0.014677,0.999892>  MULTIPLIEDQ<0.000217,0.000000,-0.027642,0.999618>FRAME: 5 PHYSICQ <0.000217,0.000000,-0.027642,0.999618> ANIMQ<0.000179,-0.000000,-0.022774,0.999741>  MULTIPLIEDQ<0.000396,0.000000,-0.050400,0.998729>FRAME: 6 PHYSICQ <0.000396,0.000000,-0.050400,0.998729> ANIMQ<0.000256,-0.000000,-0.032565,0.999470>  MULTIPLIEDQ<0.000651,0.000000,-0.082897,0.996558>FRAME: 7 PHYSICQ <0.000651,0.000000,-0.082897,0.996558> ANIMQ<0.000346,-0.000000,-0.044011,0.999031>  MULTIPLIEDQ<0.000995,0.000000,-0.126676,0.991944>FRAME: 8 PHYSICQ <0.000995,0.000000,-0.126676,0.991944> ANIMQ<0.000448,-0.000000,-0.057069,0.998370>  MULTIPLIEDQ<0.001438,0.000000,-0.183078,0.983097>FRAME: 9 PHYSICQ <0.001438,0.000000,-0.183078,0.983097> ANIMQ<0.000563,-0.000000,-0.071696,0.997426>  MULTIPLIEDQ<0.001988,0.000000,-0.253092,0.967440>FRAME: 10 PHYSICQ <0.001988,0.000000,-0.253092,0.967440> ANIMQ<0.000690,-0.000000,-0.087848,0.996134>  MULTIPLIEDQ<0.002647,0.000000,-0.337101,0.941465>FRAME: 11 PHYSICQ <0.002647,0.000000,-0.337101,0.941465> ANIMQ<0.000828,0.000000,-0.105477,0.994421>  MULTIPLIEDQ<0.003412,0.000000,-0.434524,0.900654>FRAME: 12 PHYSICQ <0.003412,0.000000,-0.434524,0.900654> ANIMQ<0.000978,-0.000000,-0.124531,0.992215>  MULTIPLIEDQ<0.004267,0.000000,-0.543301,0.839527>FRAME: 13 PHYSICQ <0.004267,0.000000,-0.543301,0.839527> ANIMQ<0.001138,0.000000,-0.144958,0.989437>  MULTIPLIEDQ<0.005177,0.000000,-0.659258,0.751899>FRAME: 14 PHYSICQ <0.005177,0.000000,-0.659258,0.751899> ANIMQ<0.001309,-0.000000,-0.166698,0.986007>  MULTIPLIEDQ<0.006089,0.000000,-0.775373,0.631475>FRAME: 15 PHYSICQ <0.006089,0.000000,-0.775373,0.631475> ANIMQ<0.001490,-0.000000,-0.189689,0.981843>  MULTIPLIEDQ<0.006919,-0.000000,-0.881078,0.472920>FRAME: 16 PHYSICQ <-0.006919,0.000000,0.881078,-0.472920> ANIMQ<0.001680,-0.000000,-0.213867,0.976861>  MULTIPLIEDQ<-0.007554,0.000000,0.961833,-0.273532>FRAME: 17 PHYSICQ <-0.007554,0.000000,0.961833,-0.273532> ANIMQ<0.001878,-0.000000,-0.239159,0.970979>  MULTIPLIEDQ<-0.007848,0.000000,0.999337,-0.035549>FRAME: 18 PHYSICQ <-0.007848,0.000000,0.999337,-0.035549> ANIMQ<0.002085,-0.000000,-0.265489,0.964112>  MULTIPLIEDQ<-0.007641,0.000000,0.972911,0.231056>FRAME: 19 PHYSICQ <-0.007641,0.000000,0.972911,0.231056> ANIMQ<0.002299,0.000000,-0.292776,0.956178>  MULTIPLIEDQ<-0.006775,0.000000,0.862628,0.505793>FRAME: 20 PHYSICQ <-0.006775,0.000000,0.862628,0.505793> ANIMQ<0.002520,0.000000,-0.320934,0.947098>  MULTIPLIEDQ<-0.005141,0.000000,0.654668,0.755899>FRAME: 21 PHYSICQ <-0.005141,0.000000,0.654668,0.755899> ANIMQ<0.002748,-0.000000,-0.349870,0.936794>  MULTIPLIEDQ<-0.002739,0.000000,0.348823,0.937185>FRAME: 22 PHYSICQ <-0.002739,0.000000,0.348823,0.937185> ANIMQ<0.002980,-0.000000,-0.379488,0.925192>  MULTIPLIEDQ<0.000259,0.000000,-0.032923,0.999458>FRAME: 23 PHYSICQ <0.000259,0.000000,-0.032923,0.999458> ANIMQ<0.003217,-0.000000,-0.409686,0.912221>  MULTIPLIEDQ<0.003452,0.000000,-0.439496,0.898238>FRAME: 24 PHYSICQ <0.003452,0.000000,-0.439496,0.898238> ANIMQ<0.003458,0.000000,-0.440354,0.897817>  MULTIPLIEDQ<0.006205,0.000000,-0.790130,0.612908>FRAME: 25 PHYSICQ <0.006205,0.000000,-0.790130,0.612908> ANIMQ<0.003702,-0.000000,-0.471382,0.881921>  MULTIPLIEDQ<0.007741,0.000000,-0.985746,0.168060>FRAME: 26 PHYSICQ <-0.007741,-0.000000,0.985746,-0.168060> ANIMQ<0.003948,-0.000000,-0.502652,0.864480>  MULTIPLIEDQ<-0.007356,-0.000000,0.936634,0.350234>FRAME: 27 PHYSICQ <-0.007356,-0.000000,0.936634,0.350233> ANIMQ<0.004194,-0.000000,-0.534042,0.845447>  MULTIPLIEDQ<-0.004750,0.000000,0.604835,0.796337>FRAME: 28 PHYSICQ <-0.004750,0.000000,0.604835,0.796337> ANIMQ<0.004441,-0.000000,-0.565429,0.824785>  MULTIPLIEDQ<-0.000382,0.000000,0.048587,0.998819>FRAME: 29 PHYSICQ <-0.000382,0.000000,0.048587,0.998819> ANIMQ<0.004686,-0.000000,-0.596682,0.802464>  MULTIPLIEDQ<0.004374,0.000000,-0.556988,0.830509>FRAME: 30 PHYSICQ <0.004374,0.000000,-0.556988,0.830509> ANIMQ<0.004929,-0.000000,-0.627672,0.778462>  MULTIPLIEDQ<0.007499,0.000000,-0.954881,0.296893>FRAME: 31 PHYSICQ <-0.007499,-0.000000,0.954881,-0.296892> ANIMQ<0.005170,-0.000000,-0.658265,0.752769>  MULTIPLIEDQ<-0.007180,0.000000,0.914239,0.405112>FRAME: 32 PHYSICQ <-0.007180,0.000000,0.914239,0.405112> ANIMQ<0.005406,-0.000000,-0.688327,0.725380>  MULTIPLIEDQ<-0.003018,0.000000,0.384321,0.923195>FRAME: 33 PHYSICQ <-0.003018,0.000000,0.384321,0.923195> ANIMQ<0.005637,-0.000000,-0.717724,0.696305>  MULTIPLIEDQ<0.003102,0.000000,-0.394994,0.918678>FRAME: 34 PHYSICQ <0.003102,0.000000,-0.394994,0.918678> ANIMQ<0.005861,-0.000000,-0.746320,0.665562>  MULTIPLIEDQ<0.007449,0.000000,-0.948521,0.316627>FRAME: 35 PHYSICQ <-0.007449,-0.000000,0.948521,-0.316627> ANIMQ<0.006078,-0.000000,-0.773982,0.633178>  MULTIPLIEDQ<-0.006641,-0.000000,0.845647,0.533702>FRAME: 36 PHYSICQ <-0.006641,0.000000,0.845647,0.533702> ANIMQ<0.006287,-0.000000,-0.800579,0.599194>  MULTIPLIEDQ<-0.000624,0.000000,0.079436,0.996840>FRAME: 37 PHYSICQ <-0.000624,0.000000,0.079436,0.996840> ANIMQ<0.006487,-0.000000,-0.825984,0.563657>  MULTIPLIEDQ<0.006115,0.000000,-0.778599,0.627492>FRAME: 38 PHYSICQ <0.006115,0.000000,-0.778599,0.627492> ANIMQ<0.006676,-0.000000,-0.850069,0.526628>  MULTIPLIEDQ<0.007409,0.000000,-0.943444,-0.331449>FRAME: 39 PHYSICQ <-0.007409,-0.000000,0.943444,0.331449> ANIMQ<0.006854,-0.000000,-0.872718,0.488177>  MULTIPLIEDQ<-0.001345,0.000000,0.171307,0.985217>FRAME: 40 PHYSICQ <-0.001345,0.000000,0.171307,0.985217> ANIMQ<0.007019,-0.000000,-0.893814,0.448383>  MULTIPLIEDQ<0.006312,0.000000,-0.803789,0.594881>FRAME: 41 PHYSICQ <0.006312,0.000000,-0.803789,0.594881> ANIMQ<0.007172,-0.000000,-0.913250,0.407335>  MULTIPLIEDQ<0.006838,-0.000000,-0.870687,-0.491790>FRAME: 42 PHYSICQ <-0.006838,0.000000,0.870687,0.491790> ANIMQ<0.007311,-0.000000,-0.930927,0.365132>  MULTIPLIEDQ<0.001099,0.000000,-0.139906,0.990164>FRAME: 43 PHYSICQ <0.001099,0.000000,-0.139906,0.990164> ANIMQ<0.007435,-0.000000,-0.946752,0.321878>  MULTIPLIEDQ<0.007716,0.000000,-0.982472,0.186248>FRAME: 44 PHYSICQ <-0.007716,-0.000000,0.982473,-0.186248> ANIMQ<0.007544,-0.000000,-0.960642,0.277688>  MULTIPLIEDQ<-0.003548,0.000000,0.451738,0.892144>FRAME: 45 PHYSICQ <-0.003548,0.000000,0.451738,0.892144> ANIMQ<0.007638,-0.000000,-0.972523,0.232682>  MULTIPLIEDQ<0.005988,0.000000,-0.762519,0.646938>FRAME: 46 PHYSICQ <0.005988,0.000000,-0.762519,0.646938> ANIMQ<0.007715,-0.000000,-0.982332,0.186986>  MULTIPLIEDQ<0.006111,-0.000000,-0.778089,-0.628125>FRAME: 47 PHYSICQ <-0.006111,0.000000,0.778089,0.628125> ANIMQ<0.007775,-0.000000,-0.990017,0.140733>  MULTIPLIEDQ<0.004024,0.000000,-0.512351,0.858767>FRAME: 48 PHYSICQ <0.004024,0.000000,-0.512351,0.858767> ANIMQ<0.007818,-0.000000,-0.995536,0.094058>  MULTIPLIEDQ<0.007093,-0.000000,-0.903124,-0.429321>FRAME: 49 PHYSICQ <-0.007093,0.000000,0.903124,0.429321> ANIMQ<0.007844,-0.000000,-0.998859,0.047100>  MULTIPLIEDQ<0.003034,0.000000,-0.386294,0.922371>FRAME: 50 PHYSICQ <0.003034,0.000000,-0.386294,0.922371> ANIMQ<0.007853,-0.000000,-0.999969,0.000000>  MULTIPLIEDQ<0.007243,-0.000000,-0.922342,-0.386306>FRAME: 51 PHYSICQ <-0.007243,0.000000,0.922342,0.386306> ANIMQ<0.007844,-0.000000,-0.998859,-0.047100>  MULTIPLIEDQ<0.003372,0.000000,-0.429307,0.903152>FRAME: 52 PHYSICQ <0.003372,0.000000,-0.429308,0.903152> ANIMQ<0.007818,-0.000000,-0.995536,-0.094058>  MULTIPLIEDQ<0.006744,-0.000000,-0.858741,-0.512366>FRAME: 53 PHYSICQ <-0.006744,0.000000,0.858741,0.512366> ANIMQ<0.007775,-0.000000,-0.990017,-0.140733>  MULTIPLIEDQ<0.004933,0.000000,-0.628105,0.778113>FRAME: 54 PHYSICQ <0.004933,0.000000,-0.628105,0.778113> ANIMQ<0.007715,-0.000000,-0.982332,-0.186986>  MULTIPLIEDQ<0.005080,-0.000000,-0.646919,-0.762542>FRAME: 55 PHYSICQ <-0.005080,0.000000,0.646919,0.762542> ANIMQ<0.007638,-0.000000,-0.972523,-0.232682>  MULTIPLIEDQ<0.007006,0.000000,-0.892116,0.451753>FRAME: 56 PHYSICQ <-0.007006,-0.000000,0.892116,-0.451753> ANIMQ<0.007544,-0.000000,-0.960642,-0.277687>  MULTIPLIEDQ<-0.001463,0.000000,0.186244,0.982503>FRAME: 57 PHYSICQ <-0.001463,0.000000,0.186244,0.982503> ANIMQ<0.007435,-0.000000,-0.946752,-0.321878>  MULTIPLIEDQ<0.007776,0.000000,-0.990134,-0.139908>FRAME: 58 PHYSICQ <-0.007776,-0.000000,0.990134,0.139908> ANIMQ<0.007311,-0.000000,-0.930927,-0.365131>  MULTIPLIEDQ<0.003862,0.000000,-0.491773,0.870715>FRAME: 59 PHYSICQ <0.003862,0.000000,-0.491773,0.870715> ANIMQ<0.007172,-0.000000,-0.913251,-0.407335>  MULTIPLIEDQ<0.004672,-0.000000,-0.594864,-0.803813>FRAME: 60 PHYSICQ <-0.004672,0.000000,0.594864,0.803813> ANIMQ<0.007019,-0.000000,-0.893814,-0.448383>  MULTIPLIEDQ<0.007737,0.000000,-0.985186,0.171315>FRAME: 61 PHYSICQ <-0.007737,-0.000000,0.985186,-0.171315> ANIMQ<0.006854,-0.000000,-0.872718,-0.488177>  MULTIPLIEDQ<0.002603,0.000000,-0.331436,0.943474>FRAME: 62 PHYSICQ <0.002603,0.000000,-0.331436,0.943474> ANIMQ<-0.006676,-0.000000,0.850070,0.526628>  MULTIPLIEDQ<-0.004928,0.000000,0.627475,0.778621>FRAME: 63 PHYSICQ <-0.004928,0.000000,0.627475,0.778621> ANIMQ<-0.006487,-0.000000,0.825984,0.563657>  MULTIPLIEDQ<-0.007828,-0.000000,0.996809,-0.079441>FRAME: 64 PHYSICQ <-0.007828,-0.000000,0.996809,-0.079441> ANIMQ<-0.006287,-0.000000,0.800579,0.599194>  MULTIPLIEDQ<-0.004191,-0.000000,0.533682,-0.845675>FRAME: 65 PHYSICQ <0.004191,0.000000,-0.533682,0.845675> ANIMQ<-0.006078,-0.000000,0.773982,0.633178>  MULTIPLIEDQ<-0.002487,0.000000,0.316621,0.948549>FRAME: 66 PHYSICQ <-0.002487,0.000000,0.316621,0.948549> ANIMQ<-0.005861,-0.000000,0.746320,0.665562>  MULTIPLIEDQ<-0.007214,0.000000,0.918652,0.395003>FRAME: 67 PHYSICQ <-0.007214,0.000000,0.918652,0.395003> ANIMQ<-0.005637,-0.000000,0.717724,0.696305>  MULTIPLIEDQ<-0.007250,-0.000000,0.923165,-0.384337>FRAME: 68 PHYSICQ <-0.007250,-0.000000,0.923165,-0.384337> ANIMQ<-0.005406,-0.000000,0.688327,0.725380>  MULTIPLIEDQ<-0.003181,-0.000000,0.405096,-0.914269>FRAME: 69 PHYSICQ <0.003181,0.000000,-0.405096,0.914269> ANIMQ<-0.005170,-0.000000,0.658265,0.752768>  MULTIPLIEDQ<-0.002332,0.000000,0.296888,0.954909>FRAME: 70 PHYSICQ <-0.002332,0.000000,0.296888,0.954909> ANIMQ<-0.004929,-0.000000,0.627672,0.778462>  MULTIPLIEDQ<-0.006522,0.000000,0.830486,0.557001>FRAME: 71 PHYSICQ <-0.006522,0.000000,0.830486,0.557001> ANIMQ<-0.004686,-0.000000,0.596682,0.802464>  MULTIPLIEDQ<-0.007844,-0.000000,0.998788,-0.048594>FRAME: 72 PHYSICQ <-0.007844,-0.000000,0.998788,-0.048594> ANIMQ<-0.004441,-0.000000,0.565429,0.824785>  MULTIPLIEDQ<-0.006254,-0.000000,0.796309,-0.604858>FRAME: 73 PHYSICQ <0.006254,0.000000,-0.796309,0.604858> ANIMQ<-0.004194,-0.000000,0.534043,0.845447>  MULTIPLIEDQ<0.002750,0.000000,-0.350217,0.936664>FRAME: 74 PHYSICQ <0.002750,0.000000,-0.350217,0.936664> ANIMQ<-0.003948,-0.000000,0.502652,0.864480>  MULTIPLIEDQ<-0.001320,0.000000,0.168060,0.985776>FRAME: 75 PHYSICQ <-0.001320,0.000000,0.168060,0.985776> ANIMQ<-0.003702,-0.000000,0.471382,0.881921>  MULTIPLIEDQ<-0.004813,0.000000,0.612893,0.790151>FRAME: 76 PHYSICQ <-0.004813,0.000000,0.612893,0.790151> ANIMQ<-0.003458,0.000000,0.440354,0.897817>  MULTIPLIEDQ<-0.007054,0.000000,0.898213,0.439504>FRAME: 77 PHYSICQ <-0.007054,0.000000,0.898213,0.439504> ANIMQ<-0.003217,-0.000000,0.409686,0.912221>  MULTIPLIEDQ<-0.007849,0.000000,0.999427,0.032917>FRAME: 78 PHYSICQ <-0.007849,0.000000,0.999427,0.032917> ANIMQ<-0.002980,-0.000000,0.379488,0.925192>  MULTIPLIEDQ<-0.007360,-0.000000,0.937154,-0.348839>FRAME: 79 PHYSICQ <-0.007360,-0.000000,0.937154,-0.348839> ANIMQ<-0.002748,-0.000000,0.349870,0.936794>  MULTIPLIEDQ<-0.005936,-0.000000,0.755871,-0.654693>FRAME: 80 PHYSICQ <0.005936,0.000000,-0.755871,0.654693> ANIMQ<-0.002520,0.000000,0.320934,0.947098>  MULTIPLIEDQ<0.003972,0.000000,-0.505771,0.862659>FRAME: 81 PHYSICQ <0.003972,0.000000,-0.505771,0.862659> ANIMQ<-0.002299,0.000000,0.292776,0.956178>  MULTIPLIEDQ<0.001814,0.000000,-0.231042,0.972942>FRAME: 82 PHYSICQ <0.001814,0.000000,-0.231042,0.972942> ANIMQ<-0.002085,-0.000000,0.265489,0.964112>  MULTIPLIEDQ<-0.000279,0.000000,0.035555,0.999368>FRAME: 83 PHYSICQ <-0.000279,0.000000,0.035555,0.999368> ANIMQ<-0.001878,-0.000000,0.239159,0.970979>  MULTIPLIEDQ<-0.002148,0.000000,0.273531,0.961861>FRAME: 84 PHYSICQ <-0.002148,0.000000,0.273531,0.961861> ANIMQ<-0.001680,-0.000000,0.213867,0.976861>  MULTIPLIEDQ<-0.003714,0.000000,0.472912,0.881102>FRAME: 85 PHYSICQ <-0.003714,0.000000,0.472912,0.881102> ANIMQ<-0.001490,-0.000000,0.189690,0.981843>  MULTIPLIEDQ<-0.004959,0.000000,0.631461,0.775392>FRAME: 86 PHYSICQ <-0.004959,0.000000,0.631461,0.775392> ANIMQ<-0.001309,-0.000000,0.166698,0.986007>  MULTIPLIEDQ<-0.005905,0.000000,0.751881,0.659272>FRAME: 87 PHYSICQ <-0.005905,0.000000,0.751881,0.659272> ANIMQ<-0.001138,0.000000,0.144958,0.989437>  MULTIPLIEDQ<-0.006593,0.000000,0.839506,0.543311>FRAME: 88 PHYSICQ <-0.006593,0.000000,0.839506,0.543311> ANIMQ<-0.000978,-0.000000,0.124531,0.992215>  MULTIPLIEDQ<-0.007073,0.000000,0.900630,0.434530>FRAME: 89 PHYSICQ <-0.007073,0.000000,0.900630,0.434530> ANIMQ<-0.000828,0.000000,0.105477,0.994421>  MULTIPLIEDQ<-0.007393,0.000000,0.941438,0.337104>FRAME: 90 PHYSICQ <-0.007393,0.000000,0.941438,0.337104> ANIMQ<-0.000690,-0.000000,0.087849,0.996134>  MULTIPLIEDQ<-0.007597,-0.000000,0.967413,0.253092>FRAME: 91 PHYSICQ <-0.007597,-0.000000,0.967413,0.253092> ANIMQ<-0.000563,-0.000000,0.071697,0.997426>  MULTIPLIEDQ<-0.007720,-0.000000,0.983069,0.183076>FRAME: 92 PHYSICQ <-0.007720,-0.000000,0.983069,0.183076> ANIMQ<-0.000448,-0.000000,0.057069,0.998370>  MULTIPLIEDQ<-0.007790,-0.000000,0.991914,0.126671>FRAME: 93 PHYSICQ <-0.007790,-0.000000,0.991914,0.126671> ANIMQ<-0.000346,-0.000000,0.044011,0.999031>  MULTIPLIEDQ<-0.007826,-0.000000,0.996528,0.082891>FRAME: 94 PHYSICQ <-0.007826,-0.000000,0.996528,0.082891> ANIMQ<-0.000256,-0.000000,0.032565,0.999470>  MULTIPLIEDQ<-0.007843,-0.000000,0.998699,0.050393>FRAME: 95 PHYSICQ <-0.007843,-0.000000,0.998699,0.050393> ANIMQ<-0.000179,-0.000000,0.022774,0.999741>  MULTIPLIEDQ<-0.007850,-0.000000,0.999587,0.027634>FRAME: 96 PHYSICQ <-0.007850,-0.000000,0.999587,0.027634> ANIMQ<-0.000115,-0.000000,0.014677,0.999892>  MULTIPLIEDQ<-0.007852,-0.000000,0.999885,0.012959>FRAME: 97 PHYSICQ <-0.007852,-0.000000,0.999885,0.012959> ANIMQ<-0.000065,0.000000,0.008313,0.999965>  MULTIPLIEDQ<-0.007853,-0.000000,0.999958,0.004647>FRAME: 98 PHYSICQ <-0.007853,-0.000000,0.999958,0.004647> ANIMQ<-0.000029,-0.000000,0.003720,0.999993>  MULTIPLIEDQ<-0.007853,-0.000000,0.999969,0.000927>FRAME: 99 PHYSICQ <-0.007853,-0.000000,0.999969,0.000927> ANIMQ<-0.000007,0.000000,0.000936,1.000000>  MULTIPLIEDQ<-0.007853,-0.000000,0.999969,-0.000010>

Sorry for a long dump, but maybe the multiplication can be the issue here?

##### Share on other sites
this is a step by step guide how do i calculate the stuff:

//pseudocode//Quaternion current_animation_frame=Object.Bone.GetRotation();Quaternion current_physical=Object.GetPhysicRotation();Quaternion final_rotation=current_physical*current_animation_frame;Object.physics.applyrotation(final_rotation);//....//Object.Draw()

So i read the bone rotation quaternion at actual frame,
i read the actual physical rotation,
i multiply physic*bone_rotation
i apply new quaternion to the physic.

And then i render my object..

Can't find any solution.. :(

##### Share on other sites
I really couldn't say what the problem is. I did notice this code:
Object.physics.applyrotation(final_rotation);
Again, make sure you're not actually applying the newly computed rotation to the physics object itself. (I think you said you weren't doing this, but I thought I'd mention it again just in case.)

If it's just a sync issue (and isn't related to combining the rotations per se), then I couldn't say what the problem is (in that case, it's probably just a logic problem with your code or a problem with the animation data rather than a mathematical problem).

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• 11
• 15
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
634151
• Total Posts
3015825
×