Raggar Posted February 7, 2017 Share Posted February 7, 2017 Here's the deal, I'm importing a model with skeleton, bones, animations etc. I assign the model (Index 0) and the skeleton (index 0) global variables. Then, outside of Babylon's native import function, I clone the model and the skeleton, and run animation (from frames) just fine. The problem is, when I try to manually manipulate bones using their getters and setters, somehow, rotating 1 bone from 1 clone of the original, also rotates the bones of all other clones, as well as the original. Changing the names and ID's of bones doesn't seem to help, either. Soo. Is there any way of cloning bones? no clone function exists, and I'm unsure of how to approach this. I'll see if I can create a simple PG, as the project is pretty complex by now. As I mentioned, I can run different animations on the different skeletons without any issues. But as soon as I manually rotate bones, all clones + original are all affected. Quote Link to comment Share on other sites More sharing options...
dbawel Posted February 7, 2017 Share Posted February 7, 2017 http://www.babylonjs-playground.com/#1EL5BE#21 I didn't write this, but it helped me to clone bones. DB Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 7, 2017 Share Posted February 7, 2017 Ping our bones expert @adam Quote Link to comment Share on other sites More sharing options...
adam Posted February 7, 2017 Share Posted February 7, 2017 I'm working on a fix for this. Quote Link to comment Share on other sites More sharing options...
adam Posted February 7, 2017 Share Posted February 7, 2017 This is a tough one. You might already now this, but it will work if you import the mesh instead of cloning. http://www.babylonjs-playground.com/#1ZBQR3#0 Raggar, gryff and JCPalmer 3 Quote Link to comment Share on other sites More sharing options...
Raggar Posted February 8, 2017 Author Share Posted February 8, 2017 18 hours ago, adam said: I'm working on a fix for this. 16 hours ago, adam said: This is a tough one. You might already now this, but it will work if you import the mesh instead of cloning. http://www.babylonjs-playground.com/#1ZBQR3#0 Yeah. I thought of 2 solutions. 1) Split the mesh into multiple meshes, and rotate the specific parts instead of their corresponding bones. 2) Loading the model everytime it is required. But then, what if I need 20 player objects? That's 20 x importing of meshes and skeletons/bones, and might give some drops in performance every time a new object is required. Maybe IndexedDB could help, by at least cutting the bandwidth? I tried #1. Didn't quite like it. I'll give #2 a go, and see whether or not it is practical. Can you verify that this is indeed a bug? I've been through my code many times, doing various optimizations and bug hunts, and I'm certain that I've done it right. Quote Link to comment Share on other sites More sharing options...
Raggar Posted February 8, 2017 Author Share Posted February 8, 2017 I just tested the multi-load solution, and can confirm that it is working, although your PG already did just that. I'll let this be a temporary fix. Quote Link to comment Share on other sites More sharing options...
gryff Posted February 8, 2017 Share Posted February 8, 2017 @adam: Loved the PG. I changed the bone index number to 4 and 5 - almost choked on my coffee cheers, gryff Quote Link to comment Share on other sites More sharing options...
adam Posted February 9, 2017 Share Posted February 9, 2017 On 2/8/2017 at 10:22 AM, gryff said: I changed the bone index number to 4 and 5 - almost choked on my coffee http://www.babylonjs-playground.com/#1ZBQR3#2 Quote Link to comment Share on other sites More sharing options...
adam Posted February 9, 2017 Share Posted February 9, 2017 On 2/8/2017 at 8:59 AM, Raggar said: Can you verify that this is indeed a bug? It is was bug. Here is the fix I came up with: https://github.com/BabylonJS/Babylon.js/pull/1759 When the playground is updated with this code, the dude on the right won't copy the other dude's head rotation: http://www.babylonjs-playground.com/#1ZBQR3#5 60 cloned dudes: http://www.babylonjs-playground.com/#1ZBQR3#7 It loads much faster than using import mesh. dbawel and Raggar 2 Quote Link to comment Share on other sites More sharing options...
Raggar Posted February 10, 2017 Author Share Posted February 10, 2017 Compiling the master branch somehow broke the bone rotation completely. Switched over from 2.5, so I don't think it's due to API changes. I'll check the simpler example from your PR when I get home. It was my fist time compiling from source, but everything else seem to work just fine. Quote Link to comment Share on other sites More sharing options...
adam Posted February 10, 2017 Share Posted February 10, 2017 Show me the code you are using to rotate a bone. Quote Link to comment Share on other sites More sharing options...
Raggar Posted February 10, 2017 Author Share Posted February 10, 2017 1 hour ago, adam said: Show me the code you are using to rotate a bone. mesh.skeleton.bones[boneIndex].setRotation(new BABYLON.Vector3(x, y, z), BABYLON.Space.LOCAL); The X, Y and Z values are based on the rotation of the bone in local space, from when the mesh was first cloned. Then altered of course. But the keyframe animations stopped working, too. So I'll do some hunting in the next couple of hours. Quote Link to comment Share on other sites More sharing options...
adam Posted February 10, 2017 Share Posted February 10, 2017 It's working for me, but I did have some trouble after viewing one of the examples for setRotation in the doc. The example had some code in it that wrote over the Bone.prototype.setRotation with a setRotation that used quaternions. I just submit a PR to update that doc. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 10, 2017 Share Posted February 10, 2017 PR validated and PG updated Raggar 1 Quote Link to comment Share on other sites More sharing options...
Raggar Posted February 11, 2017 Author Share Posted February 11, 2017 15 hours ago, Deltakosh said: PR validated and PG updated On 9/2/2017 at 6:16 PM, adam said: It is was bug. Here is the fix I came up with: https://github.com/BabylonJS/Babylon.js/pull/1759 When the playground is updated with this code, the dude on the right won't copy the other dude's head rotation: http://www.babylonjs-playground.com/#1ZBQR3#5 60 cloned dudes: http://www.babylonjs-playground.com/#1ZBQR3#7 It loads much faster than using import mesh. Rotating the bone manually seems to work, but the look control still seems to affect both the imported mesh as well as the clone. I hope my compilation somehow messed it up. Can you upload your version? Quote Link to comment Share on other sites More sharing options...
adam Posted February 11, 2017 Share Posted February 11, 2017 babylon.max.js Quote Link to comment Share on other sites More sharing options...
Raggar Posted February 11, 2017 Author Share Posted February 11, 2017 1 hour ago, adam said: babylon.max.js It's weird. Same thing as my own compiled version. Getters seem to respond, but no change whatsoever with the setters. With the 2.5 version, everything works fine, although the cloning issue is present. But with the newest version, keyframe animations stopped working, and neither of the setters seem to work. .rotate, .setRotation, .setYawPitchRoll etc. I guess I'll have to investigate what's wrong. The code is the same, with no changes. Btw. Have you checked your PG? Rotating the bone manually seems to work independently of the original mesh, but the look control seems to have the same issue, or at least one resembling it. Quote Link to comment Share on other sites More sharing options...
adam Posted February 11, 2017 Share Posted February 11, 2017 It's working for me locally with that file I uploaded. The PG doesn't have my latest changes to the Bone class. Quote Link to comment Share on other sites More sharing options...
adam Posted February 11, 2017 Share Posted February 11, 2017 I just added the latest Bone class to the end of this PG: http://www.babylonjs-playground.com/#1ZBQR3#8 dbawel 1 Quote Link to comment Share on other sites More sharing options...
Raggar Posted February 13, 2017 Author Share Posted February 13, 2017 Thank you for all the help. I've marked this thread as Solved, as I see the main issue as being resolved. Although using your babylon.max.js file, my own .js files and even the overwritten prototypes functions from your PG examples still produce some weird issues, I'll figure this out, eventually. For now, I'm back at importing models, but I'll make some time to look it over again at a later date. When using the dude model, I can manually set the rotation, as long as i DON'T run any animations at the same time. But my own model won't either animate nor manually rotate after updating babylon. Same thing with the overwritten prototypes. The model is only a placeholder, and took less than an hour as I didn't refine skin weights or anything. Therefore I won't completely rule out that the problem might be fixed when finishing a proper model. Attached is the model I've been using for reference. e.babylon 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.