• 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
Question by cidmodder · Jan 20, 2012 at 02:33 AM · c#mesharrayvertex

Array of Verticies

Quick question. If i have all of the verticies of a sphere saved in an array how would I know which vertex is which in the array? For instance, if I had say the vert at the top of the sphere how could I get all the ones on the circle around it from that array? [ say the top vert is vertex[0] would the ones around it be vertex[1], vertex[2] . . . etc or more like vertex[0] vertex[23] vertex[45] etc etc] and documentation would be helpful.

Comment

People who like this

0 Show 4
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 syclamoth · Jan 20, 2012 at 03:07 AM 1
Share

You can't know just from the index. There's nothing to say they're arranged in any sensible fashion. It all depends on how the triangles are put together.

avatar image cidmodder · Jan 20, 2012 at 03:14 AM 0
Share

so there's no order at all to how it makes the index? is there another way to get nearby vertices?

avatar image syclamoth · Jan 20, 2012 at 03:35 AM 0
Share

Where are you getting this array of vertices from? Are they from a Mesh object?

avatar image cidmodder · Jan 20, 2012 at 06:37 PM 0
Share

Yes. Very similar to the mesh filter documentation. Just storing them in an array

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Fattie · Jan 20, 2012 at 08:58 AM

There is no simple way.

You have to, quite simply, look at every other vertex, see where it is, and make your decisions based on that.

You are probably thinking that the rendering pipeline, or perhaps the physics system, "has this information" in some way. unfortunately that is absolutely not the case. There is a huge discussion about it here:

http://answers.unity3d.com/questions/193695/in-unity-is-there-a-fast-way-to-find-nearby-triang.html

I urge you to download the attached demo programs, example models, and so on.

There is also a very important point: there is a common misconception among people new to fooling with 3D models that in some sense verts "must not be" or alternately "must be" shared-where-possible. This is utterly incorrect, as explained at vast length on that page.

(If you have not yet reached the point of knowing about shared verts - bear it in mind for the future!)

Anyway in answer to your very specific question:

"so there's no order at all to how it makes the index?"

that is absolutely correct: there is absolutely no order - whatsoever - at all - to the vertices in a 3D model.

"is there another way to get nearby vertices?"

again correct, there is absolutely no way, whatsoever - at all - to get nearby vertices. you may find this strange if you're new to the topic, but it's true.

prepare to loop a lot :)

Note that if you spend your life working with the mesh, it becomes hugely about spatial hashing .. systems for you to essentially speed up the process of finding verts in certain physical areas. For now, just loop and measure the distance :)

Many systems completely avoid this problem by storing the model conceptually in a totally different manner - our italian friends at meshlab for example more or less work on half-edges for example, not triangles. But the answer to your question is no, you just have to loop, loop, loop.

Comment
Jessy
Lo0NuhtiK

People who like this

2 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 cidmodder · Jan 20, 2012 at 02:29 PM 0
Share

i think i get it. Still need some time to dig through all that. You wouldn't happen to know of any methods like the Octree that was mentioned would you?

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

6 People are following this question.

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

Related Questions

Changing Y Value in Vertex Array? 1 Answer

What is the order/connection of array elements in mesh.vertices? 2 Answers

Few problems with arrays 1 Answer

Using compute shader, how to take every vertex of a mesh and make a cube spawn and move to each one? 0 Answers

Multiple Cars not working 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