benoit-1842 Posted February 6, 2015 Share Posted February 6, 2015 So I will explain my situation. I am now good with creating a scene in Blender and porting it to babylon.js in two viewports (thanx Gryff and Iceman). So right now I have a model that plays an animation created in Blender. But now I want to create an animation directly through code (i.e moving one of my bones through code not passing by Blender).... So how works the animation of a model bone through code ? I have seen the dude tutorial and I still need some enlightement and my ultimate challenge it's to put kinect 2 data x,y,z qx,qy,qz and qw in my bone information so it can move accordingly to the position I get from my motion capture.... So for example this is my data for my left knee : "x": 0.223173529, "y": -0.388017774, "z": 0.582939148, "qx": 0.425287217, "qy": 0.6508006, "qz": -0.478602648, "qw": -0.408079475 How can I implement that "inside my bone " data in babylon.js........it will be fantastic !!!! This is my model :https://drive.google.com/file/d/0B_ZBy6q5jS8xOE1xNndzcWZ2d0k/view?usp=sharing Quote Link to comment Share on other sites More sharing options...
Samuel Girardin Posted February 7, 2015 Share Posted February 7, 2015 Hi, I did something with babylon that maybe could help you : http://www.html5gamedevs.com/topic/11918-ts-sources-character-study-demo-keyframe-animation-ragdoll/ It s about switching keyframes animation character to a ragdoll physic mode. So I had to reflect ragdoll part to bones. You can have a look to my source, perhaps it will help you. My dev is very specific to the model I use, but you can give it a try. Sam Quote Link to comment Share on other sites More sharing options...
benoit-1842 Posted February 7, 2015 Author Share Posted February 7, 2015 Bonjour Samuel..... Yesterday I have downloaded your code of your chef d'oeuvre !!!! I couldn't find the file(s) that was coding the *switch* of animation.... If you can point me in witch file it is, it will be very cool.... Merci, Benoit Quote Link to comment Share on other sites More sharing options...
Samuel Girardin Posted February 7, 2015 Share Posted February 7, 2015 Salut, It's in Bundle.ts public compute(v:BABYLON.Vector3 , o:BABYLON.Quaternion): void { //waarning call order here are very important // translation offset var t: BABYLON.Vector3 = this.offset; this.helper.locallyTranslate(new BABYLON.Vector3(-t.x, -t.y, -t.z)); //compute matrix and update skeleton var world: BABYLON.Matrix = this.helper.getWorldMatrix(); world.invert(); var m = this.bone.getWorldMatrix().multiply(world); // waitt 1 one frame before update if (!this.wait) { this.bone.update(m); } // this f..... rotation quaternion offset fix var qinvert = BABYLON.Quaternion.Inverse(this.qset); var r = this.mesh.rotationQuaternion; this.helper.rotationQuaternion = r.multiply(qinvert); var t = new BABYLON.Vector3(this.mesh.position.x-v.x, this.mesh.position.y-v.y, this.mesh.position.z-v.z) this.helper.position = t; this.wait = false; }As I said you it's very specific to my model, and I need to deal with some strange 3dsmax exporter behavior (the new one maybe fix that). It's very important to do not have hierarchy between your bones when you export you model. Hope this help. Quote Link to comment Share on other sites More sharing options...
benoit-1842 Posted February 7, 2015 Author Share Posted February 7, 2015 thank you.... what do you mean by no hierarchy between bones, that there's no parenting at all, each bone are like independant ? Merci, Benoit Quote Link to comment Share on other sites More sharing options...
Samuel Girardin Posted February 7, 2015 Share Posted February 7, 2015 Exactly, I use this trick because, with hierarchy each bone is relative to his parent. I was no very comfortable with heavy matrix computing. With independant bones, position and rotation are stored in world unit. So it was not a problem for keyframe mode and for the ragdoll mode, the hierarchy is giving by the ragdoll boxes. Quote Link to comment Share on other sites More sharing options...
benoit-1842 Posted February 12, 2015 Author Share Posted February 12, 2015 So is it possible if I use data from a kinect has a json file to update my model everytime.... Because that's the goal, I have a model and I want to be able to change the animation of my model with the info of a json file.... Merci, Benoit Quote Link to comment Share on other sites More sharing options...
Samuel Girardin Posted February 12, 2015 Share Posted February 12, 2015 Sure ! If you can update you data in real time and pass them to the bones. That's what I m doing reflecting oimo mesh pos & rot to my bones model (here oimo mesh are you kinect data). Quote Link to comment Share on other sites More sharing options...
benoit-1842 Posted February 12, 2015 Author Share Posted February 12, 2015 Cool..... Can you give me or point me a little step by step to how I do that...... For example which function i must use etc..... I am newbie with all that !!! Merci beaucoup, Benoit 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.