Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
avatar image
0
Question by FoxUmkov · Nov 28, 2012 at 09:10 AM · meshverticesskinned

How can i get current state(position) of vertices of animated mesh(SkinnedMeshRenderer)?

Comment
Add comment · Show 6
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 FoxUmkov · Nov 28, 2012 at 10:42 AM 0
Share

The question is how can i get the positions. I don't need to calculate them in every frame. I need to calculate vertex-positions in definite frame of animation.

avatar image MrVerdoux FoxUmkov · Nov 28, 2012 at 10:49 AM 0
Share

Hmmmm I'm confused, Paulius says unity would not give you access to those, but if you copy the vertex directly from the mesh as I did and then read the coordinates... isn't that what you are looking for?

avatar image FoxUmkov FoxUmkov · Nov 28, 2012 at 10:55 AM 0
Share

This always returns me same vertex positions despite current animation frame. This is the problem. I need this to export scene, where some objects are animated.

avatar image Paulius-Liekis FoxUmkov · Nov 30, 2012 at 12:37 PM 0
Share

Please don't post question or comments as answers. Welcome to UnityAnswers!

avatar image superme2012 · Feb 06, 2013 at 09:30 PM 0
Share

Same problem here, "Skinned $$anonymous$$esh Remderer" Animated mesh, baked

 function Update(){
 
  var mesh = GetComponent("Skinned$$anonymous$$eshRenderer").shared$$anonymous$$esh;  
  vertices = mesh.vertices;
     
 }

I don't think that data is accessible, vertices remain in same place and mesh bends.. Any solution to this? Is there not a simple way to access the vertices new positions one update.

avatar image pcpc33 superme2012 · Oct 18, 2013 at 08:07 PM 0
Share

Yeah, I'm looking for a solution to this. Any updates?

4 Replies

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

Answer by pcpc33 · Oct 19, 2013 at 06:34 PM

I'm not sure if this has a solution in Unity 3. In unity 4 the following works for me:

 SkinnedMeshRenderer skin = model.GetComponent<SkinnedMeshRenderer>();
 Mesh baked = new Mesh();
 skin.BakeMesh(baked);

Baked will contain all the current vertex positions of the skinned and animated mesh. It seems to work slowly though, as far as I can tell, so be careful how often you call this.

Comment
Add comment · 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
0

Answer by Paulius-Liekis · Nov 28, 2012 at 09:46 AM

Unity doesn't give you access to those. The only thing you can do is to replicate the same code in scripts and calculate those vertex-positions. It's ok for simple things, but doing it every frame would be too expensive.

Edit: Look at this link: http://forum.unity3d.com/threads/14378-Raycast-without-colliders It has a sample how to update MeshCollider from SkinnedMeshRenderer manually in scripts. It does almost exactly what you need.

Comment
Add comment · Show 1 · 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 FoxUmkov · Nov 30, 2012 at 11:27 AM 0
Share

If i understood correct i can't get vertex positions in any way?

avatar image
0

Answer by MrVerdoux · Nov 28, 2012 at 10:42 AM

Well it depends on what vertex you are looking for. Do you want them all? If so you could make a copy of them by using your mesh component like this.

 Vector3 actualVertices;
 MeshFilter meshFilter = (MeshFilter) gameObject.GetComponent("MeshFilter");
 actualVertices = meshFilter.mesh.vertices;
Comment
Add comment · Show 1 · 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 Paulius-Liekis · Oct 19, 2013 at 01:57 PM 0
Share

The question is about Skinned$$anonymous$$eshRenderer, not about rigid meshes (i.e. $$anonymous$$eshFilter).

avatar image
0

Answer by angelonit · May 08 at 10:12 PM

Sorry to necro but this worked for me so here it is:

 Transform tOwner;
 SkinnedMeshRenderer skinnedMeshRenderer;
 List<Vector3> meshVertices = new List<Vector3>();
 public void GetVertices()
 {
     Mesh mesh = new Mesh();
     skinnedMeshRenderer.BakeMesh(mesh, true);
     mesh.GetVertices(meshVertices);
     tOwner = skinnedMeshRenderer.transform;
 }
 public Vector3 GetPositionFromVertex(int i)
 {
     Vector3 worldPosVertex = tOwner.localToWorldMatrix.MultiplyPoint3x4(meshVertices[i]);
     return worldPosVertex;
 }




Comment
Add comment · 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

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

15 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

Related Questions

Modify mesh on load 1 Answer

Changing Mesh Vertex Colors in editor 0 Answers

Creating a mesh out of a linerenderer - how do you convert revolved vertices set to triangles and uv's 1 Answer

Mirror vertices procedurally 2 Answers

Why does Unity use duplicate vertices in Mesh? 1 Answer


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