Koroldev Posted December 2, 2016 Share Posted December 2, 2016 Hi, all! I am trying posting questions not so often, but sometimes it is very need and I have to do it. I want to know a picking point of a mesh with playing an animation. But when I am using scene.pick or pickWithRay - it is function does picking relative a first frame of animation of a mesh, but my mesh it is a runing man and hands and legs and different parts of body every frame in different positions. How I can do this? Pick a mesh relative of current frame of animation. Thank! To be precise I want to know pickedPoint.getTextureCoordinations. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 3, 2016 Share Posted December 3, 2016 Hello you can ask as many questions as you need The problem you have is "expected": The animation is done on GPU side (for performance reason) so because picking is done on CPU you cannot reach the animated values Quote Link to comment Share on other sites More sharing options...
Koroldev Posted December 3, 2016 Author Share Posted December 3, 2016 15 hours ago, Deltakosh said: Hello you can ask as many questions as you need The problem you have is "expected": The animation is done on GPU side (for performance reason) so because picking is done on CPU you cannot reach the animated values Okay, I will be waiting for it, and now I will find another ways for my goal. Thank Quote Link to comment Share on other sites More sharing options...
adam Posted December 3, 2016 Share Posted December 3, 2016 You could attach pickable, invisible sphere or box meshes to the bones in the areas you'd like to pick. Quote Link to comment Share on other sites More sharing options...
Koroldev Posted December 3, 2016 Author Share Posted December 3, 2016 4 hours ago, adam said: You could attach pickable, invisible sphere or box meshes to the bones in the areas you'd like to pick. Yes, I know this method, but it dont work if you need to know a pickedPoint.getTextureCoordinates - it returns me texture coordinates of sphere but I need to know textureCoordinates of my animating model. Quote Link to comment Share on other sites More sharing options...
adam Posted December 3, 2016 Share Posted December 3, 2016 One thing that might work is getting the picked position relative to the bone when the invisible mesh is clicked. Then use that local position on a model that is at rest to get the world position and texture coordinates. Koroldev 1 Quote Link to comment Share on other sites More sharing options...
Koroldev Posted December 5, 2016 Author Share Posted December 5, 2016 On 03.12.2016 at 11:17 PM, adam said: One thing that might work is getting the picked position relative to the bone when the invisible mesh is clicked. Then use that local position on a model that is at rest to get the world position and texture coordinates. Good idea! I like and I am trying to do it, but I am stuck. How to get rotate of a bone, global rotate? Quote Link to comment Share on other sites More sharing options...
adam Posted December 5, 2016 Share Posted December 5, 2016 You have several options: bone.getRotation(BABYLON.Space.WORLD, mesh); bone.getRotationToRef(BABYLON.Space.WORLD, mesh, result); bone.getRotationQuaternion(BABYLON.Space.WORLD, mesh); bone.getRotationQuaternionToRef(BABYLON.Space.WORLD, mesh, result); bone.getRotationMatrix(BABYLON.Space.WORLD, mesh); bone.getRotationMatrixToRef(BABYLON.Space.WORLD, mesh, result); Quote Link to comment Share on other sites More sharing options...
adam Posted December 5, 2016 Share Posted December 5, 2016 I just submitted a PR for bone.getLocalPositionFromAbsolute https://github.com/BabylonJS/Babylon.js/pull/1559 and the Bone class already has getAbsolutePositionFromLocal. Koroldev 1 Quote Link to comment Share on other sites More sharing options...
Koroldev Posted December 6, 2016 Author Share Posted December 6, 2016 18 hours ago, adam said: I just submitted a PR for bone.getLocalPositionFromAbsolute https://github.com/BabylonJS/Babylon.js/pull/1559 and the Bone class already has getAbsolutePositionFromLocal. Okay, I have completed this step. I have picked position relative to the bone in any frame of animation, how I can get this point relative of the rest pose? Set an animation in the rest pose, then get a point and return an animation in current frame? I think it is not best way Quote Link to comment Share on other sites More sharing options...
adam Posted December 6, 2016 Share Posted December 6, 2016 17 minutes ago, negrant said: how I can get this point relative of the rest pose? I'd make a clone of the skeleton when it loads that you could use just for this. http://doc.babylonjs.com/tutorials/How_to_use_Bones_and_Skeletons#cloning-bones Koroldev 1 Quote Link to comment Share on other sites More sharing options...
Koroldev Posted December 7, 2016 Author Share Posted December 7, 2016 adam, and the last question. If I found picked position of the invisible mesh in the world space, how to find texture coordinates of the body mesh? becouse the picked position saved texture coordinates of the invisible mesh, but I need texture coordinates of body mesh. This picked position very close to the body mesh, but do not intersects with him and the picked position do not have informations about the texture coordinates of the body mesh. Thank! Quote Link to comment Share on other sites More sharing options...
adam Posted December 7, 2016 Share Posted December 7, 2016 I think you could do another pick using the new position info. Koroldev 1 Quote Link to comment Share on other sites More sharing options...
Koroldev Posted December 7, 2016 Author Share Posted December 7, 2016 3 minutes ago, adam said: I think you could do another pick using the new position info. Create the new ray? or change picked position of my current ray? becouse if I need to create a new ray then where I can know a direction of a new ray? Quote Link to comment Share on other sites More sharing options...
adam Posted December 7, 2016 Share Posted December 7, 2016 Right now there is a bone.getDirection function which takes a local direction and gives you the global direction. https://github.com/BabylonJS/Babylon.js/blob/master/src/Bones/babylon.bone.ts#L618 To get the local direction from the global, you need to invert mat before calling TransformNormalToRef. Maybe the bone class should have: Bone.getLocalDirectionFromWorld and Bone.getWorldDirectionFromLocal like it does for position (getAbsolutePositionFromLocal, getLocalPositionFromAbsolute). Koroldev 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.