Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by BadAssGames · Jun 23, 2016 at 02:52 AM · meshskinnedmeshrenderermesh-deformation

How do I adjust the vertices of a skinned mesh seamlessly?

I'm currently working on an avatar editor for a game. The Avatar Editor has sets of controls which allow me to manually tweak the vertices of a skinned "Male Base Mesh". The code all generally works properly up until the point where I adjust the actual vertices of the Skinned Mesh. Once this happens, the mesh no longer orients properly to the rig.

The code I'm using to update the mesh is as follows:

     private void UpdateMesh()
     {
         Mesh mesh = new Mesh();//This is the new mesh we'll make changes to
         SkinnedMeshRenderer sceneMeshRenderer = spawnedPrefab.transform.Find("Avatar_Male_Body_Geo").GetComponent<SkinnedMeshRenderer>();
 
         sceneMeshRenderer.sharedMesh = selectedData.baseMesh;//Assign the base Mesh to the skinnedmeshRenderer
         sceneMeshRenderer.BakeMesh(mesh);//Bake the mesh's data into our new mesh
 
         Vector3[] vertices = mesh.vertices;
 
         for (int ix = 0; ix < bodySliders.Count; ix++)
         {//once we get here, go through all the vertices in the mesh and update their positions based on the controls
             for (int i = 0; i < vertices.Length; i++)
             {//This is where all the changes are made to the vertices
                 vertices[i] += bodySliders[ix].control.position.cur * bodySliders[ix].control.weightTable[i].weight;
             }
         }
 
         mesh.vertices = vertices;//Assign the new vertex positions
         sceneMeshRenderer.sharedMesh = mesh;//Reassign the mesh
     }


As you can see from the following image, after this code executes, the mesh is no longer properly oriented to the rig and I don't know why. The mesh still animates properly and the changed vertices are even updated properly on the mesh. It seems to be the mesh itself is just changing orientation for some unclear reason.

alt text

I'm sure the answer is something simple, but I don't know what it is.

adjusting-skinned-mesh.png (415.8 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Endless_Aftermath · Jun 23, 2016 at 03:17 AM

If your mesh script is attached to another gameObject that is a child of another, the mesh object may be orienting itself to its parent orientation. In order to fix this (if this parenting is the case) you have to remove the mesh object, reset the transform of the rig, add the mesh object, THEN rotate your rig object to its proper orientation. I dealt with this problem with weapons and instantiating them into a hand instead of attaching them before animation and just disabling them. It's a pain, but that's just the way Unity works.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image BadAssGames · Jun 23, 2016 at 10:02 AM 0
Share

The eventual solution to my issue was a little more complicated and had to do with how the transforms were set up before I exported to Unity, but you were generally on the right track. Thanks for the help!

avatar image Endless_Aftermath BadAssGames · Jun 24, 2016 at 06:31 PM 0
Share

Awesome that you figured it out. I knew it had to be something with the transform. Best wishes to you and your project. $$anonymous$$odel looks good, btw.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

47 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity 5.6.0: Mesh only rotates if I rotate the root bone of the skinned mesh renderer 0 Answers

I want to make the DepthImage of Kinect.V2 Renderer Mesh Skinned. 0 Answers

Missing a lot of faces 0 Answers

Getting the vertex position of a skinnedmeshrenderer after blendshape? 1 Answer

Empty mesh with vertices and triangles 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges