Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Filling an area with a line

Discussion in 'Editor & General Support' started by LostALife, Dec 22, 2020.

  1. LostALife

    LostALife

    Joined:
    Jul 19, 2020
    Posts:
    30
    Im trying to make a 3D printer simulator sort of game, my plan is to make it very boring and more like a waiting simulator.

    What im trying to figure out is how to take a model, cut it into layers, then fill that model with lines going back and forth until it fills the shape. Once that is complete i will tell the extruder of the printer to follow that line and make it look like its printing.

    Only problem is... I dont know how to tell unity to draw a line until it reaches a wall and so on.
    Also dont know how to slice the model or tell the extruder to trace the line, but i can figure that out later.
    One step at a time right?

    Im pretty new to unity, only made one mini game before so probably shouldnt be trying something like this but whatever.

    Appreciate the help.
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
  3. LostALife

    LostALife

    Joined:
    Jul 19, 2020
    Posts:
    30
    Yeah i know, although its really just a project im working on for something to do. I dont plan on it becoming something i work on for a long time. Mainly just a test to see if its possible as im interested in 3d printing.

    As for the cross section software, i think that could be really useful but i will need to find out if its possible to move it with a script, if its a game object it shouldnt be to hard. I should just be able to move it up one layer or amount everytime the extruder have completed a path. Thats very usefull, thanks.
     
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    Yes you can definitely control those cross section things via script.
     
  5. LostALife

    LostALife

    Joined:
    Jul 19, 2020
    Posts:
    30
    Great, thanks.

    I found i can script line renderer to add points into the loop which would be able to make it so it would just go back and fourth each time it hit a wall of the model (In theory). I have decided that isnt the best idea since thats not how 3d printers work. Instead they print infill inside the model usually in a honeycomb or square shape (See link bellow). I was thinking if i make a honeycomb pattern in blender or something and then make it the size of the print bed and inport it into unity. Then i could simply place the honeycomb on the print bed and tell it to only render the part of the patten thats inside the model. Then find some way to get the extruder head to follow and trace every part of the model on that layer.

    https://miro.medium.com/max/1200/1*hInJmTLppnvvM5I2ffGVEQ.png

    Its probably more complicated than it needs to be so if you have any better ideas please tell me.
     
    Last edited: Dec 22, 2020
  6. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    The line renderer draws a line. It will draw whatever line you tell it to draw. You will need to calculate the path you want to draw somehow (basically a list of Vector3 positions) and feed it into the line renderer and anything else you want to follow that path.
     
  7. LostALife

    LostALife

    Joined:
    Jul 19, 2020
    Posts:
    30
    Yes thats why i dont think i will use line renderer. If I do that i wont be able to import models and the game automatically map it out.

    Thats why instead i want to put the honeycomb model over the entire print bed but cull or only render the vertices inside the model that im wanting to print. then i simply tell the cross section to move up one layer everytime the extruder completes its movement.

    Right now i just need to figure out how to make the extruder trace every part of one layer as if it was filling it in.

    Making the honeycomb model only visible in the second model and making the extruder trace the part is what i dont know what to do.