MackeyK24 Posted April 29, 2018 Share Posted April 29, 2018 Hi Guys... Yo @Deltakosh or anybody else Gotta a quick question. Is there a way to "MIRROR" an skeletal animation pose (bone._martix)... If is was playing animation of walk left... and I have access to and want to FLIP/MIRROR that matrix pose to make it walk right... is the some kind of BABYLON.Matrix.Mirror type function ??? Quote Link to comment Share on other sites More sharing options...
Gijs Posted April 29, 2018 Share Posted April 29, 2018 How about bone._martix.invert()? Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted April 29, 2018 Author Share Posted April 29, 2018 Does that flip left to right ? Quote Link to comment Share on other sites More sharing options...
Guest Posted April 29, 2018 Share Posted April 29, 2018 Multiply it by Matrix.Scaling(1, -1, 1) ? Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted April 30, 2018 Author Share Posted April 30, 2018 Nope, neither matrix.invert or matrix.scaling (1,-1,1) actually flips or mirrors the pose left to right. I am trying to save space in encoding animation keys, if i have a walk left, i would like to NOT have to encode a walk right animation. So i was think i could MIRROR or FLIP the pose at actual runtime animation when i interpolate the animation frame to get the POSE for that frame update. But i am afraid i DONT know the math involded in FLIPPING or MIRRORING the animation pose matrix... Does anyone know how or if maybe i have decompose the matrix and then flip or mirror the individual TRS (Translation, Rotation and Scale) then put back together...Kinda like a DecomposedLerp maybe ???? Anyone got any thoughts :) Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted April 30, 2018 Share Posted April 30, 2018 Well, Blender has a copy / paste to the other side functionality. I just posed a bone many different ways, copied to clipboard, & "cross-pasted" it. The UI show that the signs on the Y & Z of the quaternion part are flipped. In BJS coordinate is switched where Z is up, but it is still Y & Z. Maybe Matrix.Scaling(1, -1, -1) or just update the quarternion Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted April 30, 2018 Author Share Posted April 30, 2018 Myabe im using Matrix.Scaling() wrong... How would i use Matrix.Scaling to SCALE another matrix ?? testMatrix = testMatrix * BABYLON.Scaling(1,-1,-1); or something like that ??? Quote Link to comment Share on other sites More sharing options...
Guest Posted April 30, 2018 Share Posted April 30, 2018 I think so Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted May 1, 2018 Author Share Posted May 1, 2018 Well I tried to multiply by scaling(1,-1,-1)... Does not work... makes my model SQIUSH down to little blob or disappears complete from view. Take a look at my HOW i am trying to MIRROR a pose if the blender.mirror flag is set...But the sampleMatrix multiply by scaling does not work: if (blender.track != null) { this._sampleMatrix.reset(); BABYLON.Utilities.SampleAnimationMatrix(this._boneAnim, blender.frame, BABYLON.Scalar.Clamp(blender.track.behavior, 0, 1), this._sampleMatrix); if (blender.mirror === true) { this._sampleMatrix.multiplyToRef(BABYLON.Matrix.Scaling(1,-1,-1), this._sampleMatrix); } this.blendAnimationMatrix(layer, this._sampleMatrix, blender.weight); } Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted May 1, 2018 Share Posted May 1, 2018 I would suggest a test apart from your code, where say leftFoot bone is rotated. Grab matrix & do stuff to it, then assign it to rightFoot bone & mark bone dirty. If this is not working, try decomposing, changing rotation recombine. You are doing too much. Part of this code not great production quality yet, but should work. if (blender.track !== null) & if (blender.mirror === true) probably better. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted May 2, 2018 Author Share Posted May 2, 2018 9 hours ago, JCPalmer said: I would suggest a test apart from your code, where say leftFoot bone is rotated. Grab matrix & do stuff to it, then assign it to rightFoot bone & mark bone dirty. If this is not working, try decomposing, changing rotation recombine. You are doing too much. Part of this code not great production quality yet, but should work. if (blender.track !== null) & if (blender.mirror === true) probably better. I dont know about toooo much... Each line is doing something specific in the animation process... What make you say DOING too much ??? the first line blender.track != null .... Need that ! the second line reset a matrix buffer so i dont instantiate new matrix each frame... Need that ! the third line actually SAMPLES the animation matrix pose... Need that ! the forth and fifth lines TRY to mirror if the blender.mirror flag is set... Need that ! the six and final line ADDS the animation matrix to the current BLEND BUFFER that later gets assigned bone and the matrix is updated. I have all the animation frame code as OPTIMIZED i can get it... I can blend multiple animation from multiple layers with a MINIMUM amount of overhead Note: I always get issues when test for null using !== as apposed to != (for null only).... And i am just OLD school i know blender.mirror and blender.mirror === true are the same thing... I just like SEEING blender.mirror === true or blender.value === false.... More easy to tell when i am glancing thru code the blender.mirror or !blender.mirror So again i dont know what mean... Doing too much... How could i be doing ANY less ??? For a larger picture of the actual Animation State Machine: babylon.scenestates.ts Note: Still a work in progress... But so far i am doing all this with like 1 to 1.5 millisecs overhead (THUS FAR) Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted May 2, 2018 Share Posted May 2, 2018 I mean get the pose cross copy working, before trying to put everything through that Blender thing. I made a PG, which shows switching the sign on the Y & Z of the quaternion does the trick. Playing with the scale DOES NOT WORK. Without simplifying your test, running it through an interpolater is just going to make matters much harder to figure out. You do not need anything, if the pose is not right. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.