Jump to content

Pick an animating mesh


Koroldev
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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).  

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...