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
0
Question by rajaleneweit · Aug 29, 2020 at 07:53 PM · modelingpainting

Lines to form?

Hello,

my problem is a little difficult since it's a bigger thing. I have created a program where the user can create lines and the lines can build any form, for example something like this:alt text

About the quads that are around the lines, they are points. The user can click on any point to create new lines. Now I want to add the ability to create meshes based on lines. But the lines should only be something like the border, the mesh (sorry if my English is bad, but I'm German) is inside of them. I already know how to create meshes in unity. I watched a few videos and created a cube on my own, so I know ho to use triangles. But this is something special.

First, I thought that I could sum up the lines to forms to make everything easier. I created a class named Form.cs. But this is the point where I dont get any further: The user can build any kind of form with the lines, so how does the system know which of the lines build forms together? One option would be to try creating a backtracking algorythmus that shell find out about that point. I already created a sudoku with backtracking. Every point has a list with all lines that are connected to it, so I can get the lines of a point with Point.connectedLines. But I can't see any way how to create an algorythmus that do that properly. Another option would be to use Camera.WorldToScreenPoint() to get the position on screen and than try something like this:

int[][] pixels = new int[screenwidth][screenheight];

And set the value of pixels[?][?] to 1 if there is a line at that point and set it to 0 if there is none. And than try to build forms from this array. But don't have any idea how to create the right algorythm. How do programs like MS Paint or Photoshop do that kind of thing?

Edit: My first idea was:

  private List<Line> lines;
  private bool CreateForms(Point p)
  {
      if (lines == null)
          lines = new List<Line>();
      foreach (Line l in p.connectedLines)
      {
          if (!lines.Contains(l))
          {
              lines.Add(l);
              if (CreateForms(GetOther(l, p)))
              {
                  lines.Remove(l);
              }
          }
      }
      return true;
  }
 // gets the other point of a line since each line has to points, one on one end and one on the other end
  private Point GetOther(Line l, Point p)
  {
      if (p == l.end)
          return l.start;
      return l.end;
  }

It starts with a point and takes all lines that the point is connected to. Then, it takes the other that the line is connected to and puts the line to a list of lines that have already been used so it won't be used twice. Now it takes another line that is connected to the second point and so on. Until it comes to a where there are no lines that haven't been used already. I know, this isn't really an idea, but no matter how much I think I can't work out an algorythm that is right for that kind of thing.

I already created a sudoku with backtracking, but how does the system know which lines build a form? For example, in the image above we have exact four forms build from lines.

forum-frage.png (8.6 kB)
Comment
Add comment · 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 tonialatalo · Aug 29, 2020 at 09:30 PM 0
Share

So you mean you want to like fill the areas that are closed between points?

Can't you just start a search from a point, follow the lines to the points connected to it, and continue from there to check if you get back to the same point? Without going back the same way obviously. Seems that shortest path back to the same point gives you the lines that form a shape there, so you can then make a mesh there. $$anonymous$$aybe this is what you mean with the backtracking.

avatar image rajaleneweit tonialatalo · Aug 29, 2020 at 10:27 PM 0
Share

I already thought about that idea! But look at the image. There multiple lines, and we have at least four different forms in that case. Where shell it know which lines are building a form together? But this is what it is supposed to find out. I don't care if it is a backtracking algorythm or not but without the right algorythm it might create more forms than necessary. And the more complex the forms are the more difficult it will for the program find the forms.

avatar image rajaleneweit tonialatalo · Aug 29, 2020 at 10:35 PM 0
Share

For example it might make a mistake like this: alt text

I have created that image with paint. In this image the program has found a new form but it has left out a line. This is what I mean, where does it know how build the correct forms?

avatar image rajaleneweit tonialatalo · Aug 29, 2020 at 10:40 PM 0
Share

Or maybe it will make something like this:alt text

forum-frage3.png (8.2 kB)

0 Replies

· Add your reply
  • Sort: 

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

132 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

Related Questions

What does Unity3D NOT do for you? What else do I need in the game creation process? 1 Answer

Shooting Game HELP PLEASE 0 Answers

Part of a model is visible while the rest is invisible. Glitch? 2 Answers

Designing a interior for horror game... Need help :C 2 Answers

Can I loft between two profiles in Probuilder 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