Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 commodore · Mar 17, 2015 at 04:19 PM · meshverticestriangles

contains two different ids for the same vertex

There are two triangles that contain a a vertex of id 157 but then another triangle that uses that same vertex has it set at 224. Both has the exact same position

I opened up the mesh in my modelling program just to make sure it wasn't just two vertices overlapping each other but that wasn't the case. Any idea what could be going wrong?

I've got this little script that sets ball4 to the position of the vertex in the mesh and prints its vertex id. I move the ball to about the same position in the editor, click the button to run the function and it positions itself on the vertex it's closest to and returns its id. Thing is, I only ever get the id 157. When I uncomment "closestVertIndex = 224;" it sets itself to the exact same position as vertex 157.

     int closestVertIndex = 0;
     float checkVertDis = 0.0f;
     float vertDistance = 10.0f;

     // Iterate through piece's vertices and find closest vertice
     for(int k = 0; k < meshOver.sharedMesh.vertexCount; k++)
     {
         // Check vertex distance. If there is a higher one, set verDistance to it
         checkVertDis = Vector3.Distance(ball4.transform.position, meshOver.sharedMesh.vertices[k]);

         // If we find a lower distance, set vertdistance to it
         if(checkVertDis < vertDistance)
         {
             vertDistance = checkVertDis;

             closestVertIndex = k;
         }
     }
     // closestVertIndex = 224;
     ball4.transform.position = meshOver.sharedMesh.vertices[closestVertIndex];
     print(closestVertIndex);

 
Comment
Add comment · Show 1
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 maccabbe · Mar 17, 2015 at 04:34 PM 0
Share

First check that the vertices are in fact at the same location and not just very close

 $$anonymous$$esh mesh=meshOver.shared$$anonymous$$esh;
 Vector3 vert1=mesh.vertices[157];
 Vector3 vert2=mesh.vertices[224];
 Debug.Log(vert1+" "+vert2+" "+(vert1==vert2));

If they are the same vertex then see if both have the same normal

 Vector3 normal1=mesh.normals[157];
 Vector3 normal2=mesh.normals[224];
 Debug.Log(normal1+" "+normal2+" "+(normal1==normal2));

If they have the same position and normal then there is no reason to have both. Find the vertices in the modeling program using their IDs (showing mesh element id's depends on the program, in blender you would need to start in debug mode).

0 Replies

· Add your reply
  • Sort: 

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

20 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

Related Questions

Why does the default Unity sphere have duplicate vertices? 1 Answer

Earth mesh rendering 1 Answer

Huge GC Overhead When Accessing Tris/Verts From Mesh? 2 Answers

Accessing Mesh: Triangle and Vertex array fields directly? 0 Answers

Extruding faces of a mold. Need to properly assign vertices to 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