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 /
  • Help Room /
avatar image
0
Question by ComradeVanti · Apr 14, 2017 at 12:25 PM · meshalgorithmpointspolygonconnecting

Create fluid polygons

Hello everybody.

So heres my situation: I have a bunch of GameObjects with Rigidbodies on them, just flying through space. They should look like water or some other fluid that is beeing shot from some hose.

Kinda like this:

alt text

Now I want to connect them, so that I can give the fluid a mesh and a collider. This is all 2D of course.

I have tried a convex polygon which results in the blue polygon.

Thats great and all, but not what im looking for. Notice how the lower side of the fluid is completely ignored. Id like to achieve something like the green one.

alt text

Do you guys know any algorithms for this or a place where I can look for them? I have already searched around quite a bit but cant seem to find anything.

Thanks in advance :D

2.png (5.6 kB)
1.png (2.5 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 v01pe_ · Apr 14, 2017 at 04:38 PM 0
Share

This in not an algorithm per se, just an idea: How about searching for convex hull points not in all points, but just for points close to the current one?

avatar image ComradeVanti v01pe_ · Apr 15, 2017 at 05:55 PM 0
Share

Ye, I tried that.

Problem is that if there is no point close enough, the system just cancels the search and loops back to the first point. So i and up with this:

alt text

And if I increase the distance a point can have, so this doesnt happen, I just get a convex polygon again :/

92006-1.png (3.0 kB)
avatar image v01pe_ · Apr 16, 2017 at 02:05 PM 0
Share

I see... how about first finding the convex hull, then for each edge, find the closest point and see if the angle to this point is close enough to the one to the convex edge. If yes (from both sides) switch the edge with the 2 that connect to the point. Repeat until no point is found that meets the criterium. Depending on the threshold you'd get a very "spiky" shape w/ a high threshold or stay at the convex shape with a low threshold.

1 Reply

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

Answer by Baroque · Apr 15, 2017 at 06:58 PM

There are a couple of approaches depending on how accurate vs fast you need the algorithm to be. It may not be immediately obvious but there a huge variety of possible bounding polygons: research Alpha Shapes for the full nitty-gritty details.

You could explore algorithms like Delaunay Triangulation (slow!). I would search the edge of the graph for the next vertex that minimizes the angle between the previous generated edge. Consider that the two lines below are perfectly valid "outer edges" for a concave shape:

alt text

Alternatively, if you just want something that looks cool then I'd go completely the other direction and abandon polygons entirely. Look into "2D metaballs" for an approach that works well and on modern hardware is very cheap to evaluate.

Essentially you'd render a circular blob at each point using additive blending into a render texture. This results in a blobby-looking field representing a function of the distance to the nearest point. You can then draw that render texture using a threshold filter, giving you solid pixels anywhere the distance is below a certain value.

Here's an example (it uses XNA but the approach would work in Unity): http://nullcandy.com/2d-metaballs-in-xna/

Here's a DirectX example of the same approach: http://developer.download.nvidia.com/presentations/2010/gdc/Direct3D_Effects.pdf


boundary.png (2.5 kB)
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 ComradeVanti · Apr 22, 2017 at 05:36 PM 0
Share

Aaaaaaaaaalright...

So I have already tried multiple aproaches to this issue in the meantime and didnt find anything good so I'll just look into this metaball thing :D

Thanks alot friend, you helped a great deal :)

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

105 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

Related Questions

Add mesh to a scene in Runtime takes too long 0 Answers

How to attach a custom mesh to UI element 0 Answers

Can anybody tell me what i am doing wrong in bowyer-watson algorithm implementation? 0 Answers

"Tile" a 2D polygon 0 Answers

Imported point cloud - section view 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