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 $$anonymous$$ · Nov 29, 2014 at 10:49 AM · meshverticesvertextriangleswireframe

Mesh triangles don't match wireframe view?

So I have a mesh of a sphere made out of lots of fairly evenly shaped triangles. When I switch the scene view to "wireframe", I can easily see the triangles of my mesh.

I assumed that if I got the mesh.triangles, it would provide me with... those triangles I can see in wireframe view.

But that doesn't seem to be the case. As I loop through the triangles... the majority of the time, yes, it's giving me the three corners of a triangle, which I can find using my eyes looking at the wireframe mesh, if I find them on the mesh.

But once in a while mesh.triangles is giving me three vector3 positions that do NOT make up any sort of triangle at all, at least none that I can see looking at the wireframe. It's usually three vertices that are fairly close together, but sometimes they form more like a line, not a triangle. Other times, one of the three points will jump a whole triangle away, and there is no way that vertex is part of any triangle, there is no "edge" that connects that vertex to the others, it's not a valid triangle on the mesh, at least not according to what I see looking at the wireframe.

Can anyone explain why mesh.triangles is giving me this?

Here's my code:

     Mesh mesh = transform.GetComponent<MeshCollider>().sharedMesh;
     int[] tri = new int[mesh.triangles.Length];
     Vector3[] ver = new Vector3[mesh.vertices.Length];

     mesh.vertices.CopyTo (ver, 0);
     mesh.triangles.CopyTo (tri, 0);
                 
     int vertlen = ver.Length;
     int trilen = tri.Length;

     int[] UnfinishedVerts_Index = new int[vertlen];
     for (int a = 0; a <= vertlen - 1; a++) {
         UnfinishedVerts_Index[a] = a;
     }

     for (int triangle_loop = 0; triangle_loop <= UnfinishedTriangles_Index.Length - 1; triangle_loop += 3) {
 
         int TriVert_Index1 = tri[UnfinishedTriangles_Index[triangle_loop + 0]];
         int TriVert_Index2 = tri[UnfinishedTriangles_Index[triangle_loop + 1]];
         int TriVert_Index3 = tri[UnfinishedTriangles_Index[triangle_loop + 2]];

         Vector3 Trivertex1 = ver[TriVert_Index1];
         Vector3 Trivertex2 = ver[TriVert_Index2];
         Vector3 Trivertex3 = ver[TriVert_Index3];
 
     }


In the above code, Trivertex1, Trivertex2 and Trivertex3 should be the three vertices of the triangle. And they usually are. But once in a while one of them jumps a whole triangle away, or something like that.

I thought it was my mesh, like maybe my mesh was "bugged". But, I can clearly see the triangles on my mesh when I look at it with wireframe view. If it was my mesh, I should see an "edge" connect to these out-of-place vertices, right? I see only perfect triangles in wireframe view. And mesh.triangles isn't giving me the same perfect triangles I see.

Comment
Add comment · Show 2
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 tanoshimi · Nov 29, 2014 at 10:52 AM 0
Share

Each element in $$anonymous$$esh.triangles gives you the indices into the vertices array for a given triangle. Please post the code you use for inspecting the vertices of a particular triangle - sounds like there might be a bug in it.

avatar image $$anonymous$$ · Nov 29, 2014 at 06:45 PM 0
Share

I added my code.

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

1 Person is following this question.

avatar image

Related Questions

Mesh extrusion overlapping triangles problem 0 Answers

Problem drawing a mesh with Graphics.DrawMeshNow 1 Answer

Mesh.vertices are all 0? 1 Answer

Having trouble implementing edge collapse operation with half-edge data structure 0 Answers

Holes in procedural mesh 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