Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

BakeMesh

Discussion in 'Editor & General Support' started by vandenberg-thijs, Jul 31, 2013.

  1. vandenberg-thijs

    vandenberg-thijs

    Joined:
    Jul 31, 2013
    Posts:
    13
    Dear all,

    I'm trying to access the vertex positions of a mesh that is animated. SkinnedMeshRenderer.BakeMesh is supposed to help in such situations, but unfortunately the mesh that it returns is an exact copy of sharedMesh, even though the animation is playing. Can anybody tell me what I might be doing wrong? Is BakeMesh a pro-only function maybe?

    Many thanks,
    Thijs


    function Update () {

    var bmesh : Mesh = new Mesh();
    var skin : SkinnedMeshRenderer = this.GetComponent(SkinnedMeshRenderer);
    skin.BakeMesh(bmesh);
    Debug.Log(" ### Vector " + bmesh.vertices[10].x + " " + bmesh.vertices[10].y + " " + bmesh.vertices[10].z + " ");
    }
     
  2. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Code looks fine.

    Please double check that you are in fact baking the correct SkinnedMeshRenderer. Also verify that the vertex at index 10 is actually moving. Be aware that the baked mesh is still relative to the SkinnedMeshRenderer so root motion will never show.

    If everything is set up correctly you should file a bug report.
     
  3. vandenberg-thijs

    vandenberg-thijs

    Joined:
    Jul 31, 2013
    Posts:
    13
    Thanks UnLogick! Wrote some code to check all the vertices of the baked mesh against the sharedMesh; they're the same every frame. I'll report a bug.

    Thanks,
    Thijs
     
  4. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    i have try


    Mesh bmesh = new Mesh();
    SkinnedMeshRenderer skin= objskin.GetComponent<SkinnedMeshRenderer>();
    Mesh mesh= skin.sharedMesh;

    Mesh NewMesh = skin.BakeMesh(bmesh);



    annot implicitly convert type `void' to `UnityEngine.Mesh'


    but i can think's anymore i need pause