DezOnlyOne Posted January 28, 2016 Share Posted January 28, 2016 I am using an animated character with different meshes for the head, body, body part markers etc. I am trying to create an arrow that points to a given body part marker,which is created in max and exported as part of the character animation, but when I get the position, it is always incorrect. If I just create a box in code and move it to the same place as the head let's say, it's position is wildly different than the position that is returned from "head.position". When I use the debug layer and check clickable labels, I get a perfectly placed label in the middle of the mesh. How do I get that location from the mesh itself? What am I missing. When I create a box: var box = BABYLON.Mesh.CreateBox('box', 5, scene); box.position works great as well. When I load my animated character, the bones have mesh representations, which I dispose of, but they all have the correct positions. It seems to be the meshes that are attached to the skeletons that has an issue. How do I get the position that the debugLayer uses? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 28, 2016 Share Posted January 28, 2016 A small PG? Quote Link to comment Share on other sites More sharing options...
DezOnlyOne Posted January 28, 2016 Author Share Posted January 28, 2016 11 minutes ago, Deltakosh said: A small PG? Playground? I can't make a babylon js playground from it, because I have no way of linking my babylon file. I uploaded it so you can have a look if you would like. http://www.desmondebuwa.com/transfer/arrowTest.zip Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 28, 2016 Share Posted January 28, 2016 You can reference external files in the PG without any problem: http://www.babylonjs-playground.com/#1273GZ#1 Quote Link to comment Share on other sites More sharing options...
DezOnlyOne Posted January 28, 2016 Author Share Posted January 28, 2016 33 minutes ago, Deltakosh said: You can reference external files in the PG without any problem: http://www.babylonjs-playground.com/#1273GZ#1 I feel like an idiot here, but I still get the cross domain errors and it won't load http://www.babylonjs-playground.com/#1HZPNI#0 Quote Link to comment Share on other sites More sharing options...
DezOnlyOne Posted January 28, 2016 Author Share Posted January 28, 2016 I figured it out. It took a little bit of reading, but now I got it. http://www.babylonjs-playground.com/#1HZPNI#8 In line 31 I send the position of the head to the console. mesh.position which is essentially scene.getMeshByName('HEAD').position ...but I get the wrong location. {x: -46.1542, y: 0, z: 33.9001} As you can see from the lines 18-21, the box is at the location (-106, 54, 38) which is in the same space where the head is. the head position should give me a similar location as the box that is covering the character's face. The debug clickable layers work perfectly, how do they calculate position differently than using the mesh.position value? Thank you in advance for all your help on this stuff. Quote Link to comment Share on other sites More sharing options...
adam Posted January 28, 2016 Share Posted January 28, 2016 Please let us know how you solved this issue. Other users who have this same problem will want to know. Thanks Quote Link to comment Share on other sites More sharing options...
DezOnlyOne Posted January 28, 2016 Author Share Posted January 28, 2016 1 hour ago, adam said: Please let us know how you solved this issue. Other users who have this same problem will want to know. Thanks Definitely Quote Link to comment Share on other sites More sharing options...
Temechon Posted January 28, 2016 Share Posted January 28, 2016 Use mesh.getAbsolutePosition() : http://doc.babylonjs.com/classes/2.2/AbstractMesh#getabsoluteposition-rarr-vector3-classes-2-2-vector3- Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 28, 2016 Share Posted January 28, 2016 This is because your mesh is not centered at the origin. To get the value, you should then use the bounding box: http://www.babylonjs-playground.com/#1HZPNI#9 DezOnlyOne and adam 2 Quote Link to comment Share on other sites More sharing options...
DezOnlyOne Posted January 28, 2016 Author Share Posted January 28, 2016 1 hour ago, Deltakosh said: This is because your mesh is not centered at the origin. To get the value, you should then use the bounding box: http://www.babylonjs-playground.com/#1HZPNI#9 That is the answer. That works great for me and I am integrating into my app now. I really appreciate it. You guys are really awesome. GameMonetize 1 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.