Hi,
I have a shader/mesh space related question this time:
I just want to figure out the mesh local position of a world space point (on a skinned mesh)
I bake a mesh by a calling skinnedMeshRenderer.BakeMesh().
the skinnedMeshRenderer transform itself stays at position 0 during the game, while the bones are driven in world space.
the documentation about the BakeMesh() method says:
The vertices are relative to the SkinnedMeshRenderer Transform component.
using the regular transform the skinnedMeshRenderer belongs to - to use InverseTransformPoint - doesn't work.
The documentation says, that for those purposes, https://docs.unity3d.com/ScriptReference/Renderer-worldToLocalMatrix.html should be used.
I then basically tried to do:
Vector3 meshLocalPoint = renderer.worldToLocalMatrix.MultiplyPoint(globalPoint);
which didn't work either
So, for the setup, the skinnedMeshRenderer gameObject transform stays at position 0, it has the lossy scale of 200, if that information helps,
the bones that drive the skinned mesh animation move around in the world, but have the same scaling.