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
2
Question by QuantumCD · Mar 27, 2013 at 02:41 AM · c#meshdynamicalgorithmgeometry

How to Move Vertices from a Mesh to a Specific Location

I have a dynamic mesh that is mostly comprised of rectangles. So far, the actual system has gone smoothly. I'm getting to a stage where I want to start polishing the actual meshes off, and the topology is part of that. As I have it now, the meshes aren't able to be placed exactly. That is, there is a gap between the meshes--a very minuscule one at that.

In the past, I've done similar things outside of Unity. Basically, what I'm looking to do specifically is move a vertex near another vertex so that they are at exactly the same position. At the moment, I've already implemented a spatial hashing algorithm that can sort the hashed vertices into buckets and then I can get similar vertices by iterating over the buckets. However, I'm stuck at the part of actually determining and moving the vertices into their exact locations.

I'm assuming that I need to somehow take the two vertices in the bucket and make them exactly the same objects. How would/should I go about this in particular? On a side note, is there a better option than spatial hashing for Unity and this particular situation?

Here's some code outlining my general pipeline for this algorithm as of now:

 // Loop over all the vertices in a mesh
 foreach (Vector3 vertex in meshVertices)
 {
     // If there is a matching vertex somewhere within a given
     // threshold in the table, returns true.
     if (SpatialHash.DoesTableContainSimilar(vertex, 0.001f))
     {
         // Retrive similar hash here, and then change the vertex
         // location to match that of the other
     }
 }

As of now, the problem remains of how to actually take that other hash and turn it back into a Vector3, and then moving both of the vertices to the same location. As it stands, the actual Vector3 object is stored in the key, value pair in the hash table. Hypothetically, could I just take that other Vector3 and Lerp them until they meet a certain point (i.e. interpolate them), and then set both values to the new, interpolated values?

Comment
Add comment · Show 9
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 Benproductions1 · Mar 27, 2013 at 04:11 AM 0
Share

Are you looking at combining verticies or just placing them at the same position? I'm a bit confised?

avatar image QuantumCD · Mar 27, 2013 at 04:13 AM 0
Share

It's just moving them to the same position. I originally was going to combine them, however, I ran into problems with vertex color. If I think of a new idea for that I'll put it in a different question to keep things on topic anyway.

avatar image Benproductions1 · Mar 27, 2013 at 04:19 AM 0
Share

shouldn't you hash table save the index of the vertice it hashes? (I think I know how hash tables work :P)

If so, can't you make the similar function return a vector2 of each index, then you can use it to get the vertices and set their position (I'm guessing you know how to do that) :)

avatar image QuantumCD · Mar 27, 2013 at 04:21 AM 0
Share

Hmm... if I'm not mistaken my hash table stores the Vector3 and the hash in a key,value type pair. $$anonymous$$aybe I don't know either :P

I'll play around with it when I have time later.

avatar image Benproductions1 · Mar 27, 2013 at 04:24 AM 0
Share

It's a table right? Can't you add more columns? BTW is SpatialHash your own class? If so can you post it? It might help solve the issue :)

Show more comments

2 Replies

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

Answer by Fattie · Mar 27, 2013 at 10:49 AM

is it that you just want basic help in manipulating mesh in Unity ?

if so simply go here ...

http://answers.unity3d.com/questions/352162/optimized-vertex-manipulation.html

also here

http://answers.unity3d.com/questions/417483/is-there-a-way-to-assign-meshverticesi-directly.html

and so on.

http://answers.unity3d.com/questions/352513/ways-of-modificating-mesh-triangles.html

There are many -- priceless -- articles about mesh on this site. Just search.

If you have a specific question about hashes or the like, I guess that is a separate issue? I suggest just making a simple test project where you "move vertices" ... all teh code is given on the unity doco page...

http://docs.unity3d.com/Documentation/ScriptReference/Mesh.html

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 QuantumCD · Mar 27, 2013 at 02:16 PM 0
Share

Thanks! The second link helped a lot. I didn't think to search that, as it never came across before.

avatar image
-1

Answer by BergOnTheJob · Jul 10, 2020 at 04:54 PM

If anyone is looking, this tool allows you to move, rotate, and scale a mesh's vertices, edges, and faces.

https://assetstore.unity.com/packages/slug/166155

it also has a bunch of other tools for modeling in Unity if you need to further edit the mesh.

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

16 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

Related Questions

Combining two meshes 0 Answers

Distribute terrain in zones 3 Answers

Dynamic meshes: Triangulation methods and Alternatives 0 Answers

How can i get the center of intersection of two capsules 2 Answers

How to find centers of inner child of a quad (geometry guy needed)? 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