Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 hassanyawar · Oct 04, 2018 at 07:07 AM · collisionmeshcollidertrianglescontact

Is there any way to find the mesh triangles which are colliding with another mesh?

I'm working on a task which requires me to highlight the perimeter of collision and the perimeter will change according the collision depth. For that I need to find the mesh triangles which are colliding with another mesh. Keeping in mind that both colliders are mesh colliders with convex property on. Can someone suggest me how to approach this problem?

I'm attaching some reference screenshots of a particular shader from this site. Initially this seemed to work fine but I had two issues. First is that I'm using orthographic camera and this shader works for perspective camera. Secondly even in perspective camera mode if I apply it to all models they tend fail at rendering the intersection contour. I don't know why because I don't have any experience with shader writing.

So any suggestion?

alt text alt text

screen-shot-2018-10-04-at-115507-am.png (76.1 kB)
screen-shot-2018-10-04-at-115528-am.png (87.8 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Oct 04, 2018 at 10:25 AM

No, Unity doesn't have anything build in to determine this through the physics system. A convex mesh collider usually does no longer represent the actual mesh. It represents the (or a) convex hull of the original mesh. However you could work it out yourself. Though this is not trivial, especially for non convex meshes like yours.


Every triangle can be seen as plane (mathematically infinite plane). You can calculate the intersection points of another triangle that is cut by that plane. However after you have the intersection points you have to do an in-bounds check since we only want to cut a triangle by a triangle and not the whole plane. Since we would need to do that with every triangle from mesh one and testing against every triangle from mesh two this gets very expensive if the meshes are quite complex. It's most likely worth to first generate an octree where you sort in all the triangles. That way it's very easy to determine which triangles potentially overlap.


What is mainly required is the Line-Plane intersection. If you are not familiar with geometry you could also use Unity's Plane struct for the intersection part.


To determine if an intersection ponit is actually inside the triangle that formed the plane you can use barycentric coordinates. For this you can use this helper struct.


Apart from determining the intersection points for complex meshes it's also quite difficult to keep track of the order of those points. In the end the main question is what you actually want to do. Note that the shader you're referring to does not reallly have to do anything with the intersection but it just shades the area of the two objects which are close together on the z axis. So if two triangles are right on top of each other the shader will shade it red if it's drawn slightly behind the top one. The further away in the z direction they are, the less red it will be drawn. Typically an intersection involves an area where one object is on top of another and quite close. However it will also shade anything red that is overlapping and close enought together.


So what do you actually need? Do you just want a visual representation of the intersection seam? So you want to split / carve / intersect the meshes at that seam?


If you're looking for a CSG (constructive solid geometry) solution you may have a look at some of the AssetStore solutions like this or this or maybe this free solution. I haven't used any of those but all claim to be able to perform boolean operations on the meshes. Though as i said we don't know what you're after.

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 hassanyawar · Oct 04, 2018 at 11:39 AM 0
Share

To answer your question, I just need visual representation of the intersection seam. I don't actually want to split, carve or deform the mesh at intersection. To give you a little more insight. The above meshes are models of human teeth. If I want to move a tooth, I want to give visual representation to the user that how much tooth A is intersecting tooth B through the seam.

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

146 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Very Confused About Convex Mesh Collider Result 0 Answers

Collision with no contact? 2 Answers

Implementing Meshless Deformation 0 Answers

Sphere collider with continuous dynamic and mesh collider issue. 0 Answers

Collisions aren't colliding all the time 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