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
1
Question by RyuMaster · Mar 22, 2013 at 03:30 PM · vertexfaceconnecting

Connect 2 verticies

Hi there! A need to connect red and blue vertecies, by creating additional triangles. alt text

So first thing I do, is get their positions; p1r, p2b Then, I calculate direction vector; _directin = p2b - p1r

Next step, I need to create new vertex in that edge I marked as green. I here I'm clueless how to proced.

Red vertex shares 4 triangles, I can get them, but I need to: 1. Determine, which triangle I need to use 2. And find new vertex position on the edge which is closes to the other blue vertex

And advice on how should I handle it?

I though of comparing vertices by their world positions, then get edge world position, somehow interpolate where new vertex should be put, then create it using TransformInverse, but maybe I can do it more efficiently, using some clever trigonometry or other solution I'm not aware of.

projectus.jpg (56.2 kB)
Comment
Add comment · Show 3
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 RyuMaster · Mar 22, 2013 at 03:44 PM 0
Share

Actually I realized, that I can abstract from 3D and do 2D/2D line intersection test here, one line segment is p1r p2b, other that green edge. Hopefulyl will work out, so I'll try code it in this direction right now

avatar image Bunny83 · Mar 22, 2013 at 04:00 PM 0
Share

Well, that only works if the mesh is completely flat, otherwise the two lines wouldn't intersect.

avatar image RyuMaster · Mar 22, 2013 at 05:11 PM 0
Share

Thank you, seems like now I managed to sort it all out in my head, and will proceed just with plain coding. Google helped to me to find info how to handle all kind of different line/line situations

1 Reply

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

Answer by Bunny83 · Mar 22, 2013 at 03:57 PM

Well, if it's a fully shared mesh it's very easy. Just determine all triangles which use the red vertex and the blue vertex. The red has 4 triangles the blue has 5. Just iterate through the red triangles and compare the other two vertices for each triangle with the outer vertices of the blue triangles. There are exact 3 triangle pairs which share at least one vertex with each other. Just pick the one where both outer vertices match.

This can be done entirely with the triangle list. So just compare the integer values.

If the vertices are not shared it's getting mor complicated. You have to compare them on a position base since neighbor triangles aren't connected. Never direct compare positions, always use an approximation.

Some additional hints:

To get the triangle index of a vertex index, divide the triangle index by 3.

The vertex indices of a triangle are:

 // C#
 int triangleIndex;
 int vert0 = triangleIndex*3 + 0;
 int vert1 = triangleIndex*3 + 1;
 int vert2 = triangleIndex*3 + 2;
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

12 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

Related Questions

How to get to know a mesh' faces normals? 0 Answers

Vertex color by face 1 Answer

Select a face of an object ingame 3 Answers

UV Mapping - by vertex or face? Weird banding 2 Answers

Shared vertices or vertices for each face? 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