joshcamas Posted April 6, 2015 Author Share Posted April 6, 2015 All right. To simplify things, I have another question:How do you get the position of the bone as compared to the armature?Thanks! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 6, 2015 Share Posted April 6, 2015 It is not a position but a matrix. Every bone can give you the local matrix (bone.getLocalMatrix()) or the absolute one (bone.getAbsoluteMatrix()) Wingnut 1 Quote Link to comment Share on other sites More sharing options...
dbawel Posted April 7, 2015 Share Posted April 7, 2015 Hi, DK appears to have already pointed to one key reason why you might be observing unexpected behaviors of a meshs' vertices - and more problematically the mesh's local axis when animating a weighted mesh using one or more bones in a skeleton. But if I understand correctly, I might be able to explain what is happening on a larger scale. Most people generally aren't aware that the local axis of a mesh which is weighted to one or more bones is not being driven (or generally affected at all unless parented to the bone) by the bone(s) when these bone(s) are animated. Once weighted, bones only drive a mesh's vertices, and depending on which 3D software you used to bind the mesh to the bone, the local axis of any weighted mesh will behave differently from the axis of the bone to which it is weighted. So if you want to affect the local axis of any mesh by animating a bone, then it must be done through parenting - or if conditional behavior is required, then a proceedural process may be used for which this can dramatically vary from scene to scene, depending on many factors. Also, depending on which software you used to export your mesh or scene, there is always more than one matrix which is calculating pitch, roll, and yaw in cartesian space using quaternions which are displayed as x, y, and z. I know some of this is likely remedial info, but there is no way around the way in which bones move a mesh weighted to them, as it is generally quite predictable. You also generally want to either parent - or weight a mesh to a bone - but never both; and use extreme caution in how you set up your parenting if the mesh is weighted to any bones in any hierarchy. I almost never parent a weighted mesh to it's skeleton or any part of a skeleton hierarchy unless I'm simply using the bone to drive the mesh's local axis as a parent. So if you are experiencing odd behavior, it may be due to both wieighting a mesh to a bone which may also be set up as a parent of the mesh or the mesh's hierarchy. As previously mentioned, this is almost always a very bad thing to do. And in addition, there are often other dependancies which many programs have set up - often as a "feature" - which can cause indescribable object and vertex behavior. I know I keep promising to post documentation on the doc site addressing many of the practices, terminology, nuances, etc. of dimensional space and axis' as represented in most 3D software; and I promise I will find time to do so very soon, as this info is often directly related to many of the questions I see posted, and often try and explain such behaviors observed when animating or manipulating axis' (matrices) in cartesian space. Again, I hope this very general overview might help explain what you may be seeing in the behavior of your object. Cheers, DBawel Wingnut 1 Quote Link to comment Share on other sites More sharing options...
joshcamas Posted April 7, 2015 Author Share Posted April 7, 2015 Okay... I'm pretty sure I understand what you are saying.Basically moving bones only moves vertices, yes? If so, then good - I assumed this before. Also, it is impossible (as far as I know) to parent to a bone - so no problems there.However.... are you saying parenting to any mesh is bad? Here's a question - ok, so lets say you wanted to scale the skeleton. So a leg swings really far. To do this you simply scale the mesh, correct?Is there a local and global scale for a mesh? Also, attached the lab system to the pg: http://www.babylonjs-playground.com/#11BH6Z#12 Quote Link to comment Share on other sites More sharing options...
dbawel Posted April 7, 2015 Share Posted April 7, 2015 Nice walk cycle, by the way. Yes, when a mesh is weighted to a skeleton, bones will only affect transforms on mesh vertices (translate, rotate, scale), and not affect the mesh axis. The mesh axis will only be transformed by a bone if parented to a bone. This can be highly usable especially for translation and rotation without affecting deformation. Just make sure you're never both parenting to a bone and weighting (binding) to the same bone or skeleton hierarchy as well. If you want to parent to a bone and the software your using won't allow this, you may need to use software such as Maya or Motionbuilder which you can then write out an FBX file or export out the mesh parented to the bone and the mesh's local axis will transform with the bone's axis to which it is parented. This is very useful for props such as swords, weapons, etc - where you want the weapon to move with the hand, but remain rigid and not deform on the vertex level when bones are transformed. But you don't want to scale your mesh on it's local axis if it is weighted/bound to a skeleton. You want to transform the bones that the vertices are weighted/bound to. Also, you can transform most any object to either it's local or the global/world axis. However, if you want to scale "extend/extrude" a mesh such as a leg, then if you want to do this using scaling, you definately have to scale the bone to which the mesh is weighted on it's local axis, so the vertices transform along the bones local axis. Transforming a mesh to the global axis will be quite messy. Usually the z axis runs down the length of the bone - depending on which software you used to bind the mesh to the skeleton. So you most likely want to scale on only the z axis (or appropriate single axis running the length) of the bone in which the leg mesh is weighted - if you want to extend the leg to be longer un-naturally - using scale. However, depending on which bone you scale, this will also affect the bone's children which can look quite bad and really un-natural. So if you want to extend the leg for a kick that will make the leg un-naturally longer, then I wouldn't scale - I would set up your skeleton hierarchy in a way that allows you to physically translate the leg bones down their parent's z axis, and I would personally do this by using a null as a parent to the thigh bone and translate this in the direction of the axis that would extent the leg to make it appear longer - if you really wanted to do this. I would translate and scale on the bones themselves as little as possible, as this can cause unwanted deformations - especially since the leg is most likely bending as well - however, if parented to a null, it's far more controllable and you can orient your null parent any direction and on any axis that is optimal to transform. This also allows you to bend the leg at the same time without unwanted/un-natural vertex deformations. I hope this make sense. It takes a bit of playing around with different configurations of parenting to null objects or other small bones used only for the translation - and experimenting with different hierarchies to make it work optimally. Good luck. Quote Link to comment Share on other sites More sharing options...
dbawel Posted April 8, 2015 Share Posted April 8, 2015 Hey Joshcamas, I hope you were able to find a solution that works for your scene. Cheers, DBawel Quote Link to comment Share on other sites More sharing options...
joshcamas Posted April 18, 2015 Author Share Posted April 18, 2015 I haven't worked on this. Sadly I don't think I'll know how to do it, so if someone has the time/wants to do it, please do lol @dbawel - the problem is, you can't parent to the bone. It don't work. So we need to find a way to replicate the position/rotation/scaling of the bone, aka emulate parenting. How do you do this? I still don't know exactly how to get the correct position of the bone. Could someone make a playground of it if they know how? Thanks! Quote Link to comment Share on other sites More sharing options...
joshcamas Posted April 22, 2015 Author Share Posted April 22, 2015 Anyone know of how to get local position with an example? D: Quote Link to comment Share on other sites More sharing options...
Dad72 Posted April 23, 2015 Share Posted April 23, 2015 For mesh: mesh.getAbsolutePosition() For bone: bone.getAbsoluteMatrix() I have not experienced the movement of an object attached to a bone. Quote Link to comment Share on other sites More sharing options...
Gugis Posted May 15, 2015 Share Posted May 15, 2015 No solution yet? Quote Link to comment Share on other sites More sharing options...
Macbeth Posted June 22, 2015 Share Posted June 22, 2015 No solutions to this problem? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted June 22, 2015 Share Posted June 22, 2015 No there is not yet a suitable solution. you can attach an object to a bone, but it must be able to manage the movement of this object that follows the bone on which the object is attached. Relationship subject to the mesh does not work. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 22, 2015 Share Posted June 22, 2015 http://www.html5gamedevs.com/topic/3736-babylonboneprototypesetabsoluteposition/?p=28846 Not sure if pertinent, but what the heck. I'm looking for a very small, simple playground demo with a few bones and a mesh "weighted" onto them... but I'd prefer no importing. Basic babylon mesh hanging-on some basic bones... and I want to see it all in wireframe... and I want to bounce the bone, and play with the bindings, and gravity, and and and... ahem. Anyone seen one? When my gramma would stir soup in her kitchen, her big ol' chunk of hanging arm fat would weeble and wobble, and me and my brother would jump up there and clamp onto it with our teeth, and hang there... swinging back and forth. Fun! Quote Link to comment Share on other sites More sharing options...
Macbeth Posted June 25, 2015 Share Posted June 25, 2015 It's really such a shame this isn't possible with BabylonJS. I think many people will go with other frameworks because of this - since many people want to make some sort of RPG game which includes possibilities to change outfit and similair features. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted June 25, 2015 Share Posted June 25, 2015 It is possible but not easy. should be a function in babylon would simplify this task. I imagine that Deltakosh has a plan for that. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 25, 2015 Share Posted June 25, 2015 tadam!!! there is now a super simple solution (You need to get the 2.2-alpha) Just say mesh.parent = skeleton.bones[12] for instance This is still preliminary but it should work Dad72 and dbawel 2 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted June 25, 2015 Share Posted June 25, 2015 this is cool. Thank you DK Quote Link to comment Share on other sites More sharing options...
Dad72 Posted June 25, 2015 Share Posted June 25, 2015 I just tested: sphere.parent = skeleton.bones[12]; http://www.babylonjs-playground.com/#11BH6Z#7 return: Uncaught TypeError: this.parent.isEnabled is not a function This is perhaps not yet updated on the playground Quote Link to comment Share on other sites More sharing options...
reddozen Posted June 26, 2015 Share Posted June 26, 2015 I assume that this new change will take the set location of the child object and just keep that relationship with the parent bone as it moves? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 26, 2015 Share Posted June 26, 2015 Yep this is now online, fixed and validated:http://babylondoc.azurewebsites.net/page.php?p=22421 Sample here:http://www.babylonjs-playground.com/#11BH6Z#18 In a nutshell: just call ```sphere.attachToBone(skeleton.bones[34], dude);``` Dad72, jerome and iiceman 3 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted June 26, 2015 Share Posted June 26, 2015 Yes, this work. trop top cette nouvelle fonction. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
dbawel Posted June 27, 2015 Share Posted June 27, 2015 DK, You are awesome. I use bones and bone hierarchies as a religion to solve for so many varying issues in animation, as the behavior of bone chains in a hierarchy is unique and provides paractically any variation needed when animating objects and their children. As we've been reading in many posts recently, this can solve so many issues, however, most people associate bones with deformations and characters - when they are invaluable inserting in object hierarchies and animating. So without a formal request (at least from me,) you made life a whole lot easier for everyone. Thank you. Now we all need is to provide examples in using bones for other purposes than just surface deformations and animation. This will really make a difference to anyone who experiments a bit with "non-traditional" uses of bones and bone chains. BRAVO! Ahiru 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 29, 2015 Share Posted June 29, 2015 THanks! Quote Link to comment Share on other sites More sharing options...
Gugis Posted September 13, 2015 Share Posted September 13, 2015 Where did 2.2 alpha gone? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 13, 2015 Share Posted September 13, 2015 Here:https://github.com/BabylonJS/Babylon.js/tree/master/dist/preview%20release%20-%20beta 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.