Open elfprince13 opened 4 years ago
I've thought about it in the past, but it's not clear to me how the path generation code in lsynth extends to 2D surface creation. However I haven't really looked at it in a long while, so maybe... Placing constraints seems like it'd be a challenge. Meanwhile, I could swear there was a net generator tool that used constraints in an excel spreadsheet. A spreadsheet gives a 2D interface for free, so that approach seems intuitive.
I was thinking about the constraints problem and the thing that makes the most sense to me is having a sequence of source constraints (corresponding to locations on the original piece) and a sequence of destination constraints (corresponding to locations in the model), and you just require a 1-1 correspondence. -- ~Thomas
That seems like a lot of manual labor. A more interactive draping tool would be better. Picture something like this that could import/export ldraw fabric part files:
https://aatishb.com/drape/ https://github.com/aatishb/drape
Play with the controls in the upper right to get some idea what additional controls/constraints you might want .
I have not looked at the javascript code, but I suspect it may use the spring mesh technique: https://www.cs.umd.edu/class/fall2019/cmsc828X/LEC/Wei_Cloth.pdf
I think there are two different questions - how the constraints are encoded / serialized for a command-line tool like lsynth, and how a user interface is exposed through a modeling program like BrickSmith or MLCad.
I don't think having a standalone GUI tool is the right approach since it doesn't integrate with the existing modeling workflow.
Ok, back to reality. So how would we do this...
I'd start with a known template part. Say an 11x11 grid of balls laid out in a regular grid with the exact dimensions of the knots in a lego pirate net part. Might as well, so we can use the same template to generate nets as well.
Next take the grid of knots, give it a color (red?) and place it over your fabric part, say a cape. Then move all the knots to key locations on the part. This is your cape template.
Next make a copy of the cape template in another color (green?) and move the knots to where you want to generate the fancy draped cape.
Run some new magic version of lsynth on the green knots and generate a bspline mesh. Someone has to write that code. But if we could find the existing ldraw net generator excel spreadsheet somewhere on the internet, we could use that right now to get an idea how it would look. Then migrate the code from spreadsheet VisualBasic to C code in lsynth. This should be able to leverage the spline code already in lsynth.
Finally, someone writes some magic texture mapping type triangle warping to move the geometry (and any patterned surface?) from the original part to the newly synthesized mesh. This represents a completely new process for lsynth. But hey, it's just math, right?
I guess it could work.
I had to search through the ancient lugnet archives, but I found a pointer to the net generator spreadsheet.
Yeah, I think the interface you describe roughly makes sense.
I downloaded the spreadsheet from that link, but couldn't find evidence of any visualbasic code in it, although it's been ~15 years since I've used VBA, so it's entirely possible I missed something in the new user interface. Hopefully the math isn't just encoded in the spreadsheet cells...
I don't think the patterned surface needs to be handled definitely from moving the other geometry, since the patterns are just more geometry(?).
I would also suggest a final step which is applying some mesh simplification to try and reduce the number of triangles in the output if there are sections of the fabric with relatively low curvature.
Darn it. The math is in the cells on the map tab. Not sure why I remembered it as VBA. Oh well.
So, I did step 0 in my plan and used the net generator spreadsheet to create a template part.
Wanna tackle the next 2 steps and create a simple sample test harness model with a cape and everything posed and ready to pass on to magic new version of lsynth?
Hmm, hit a snag with the cape. I made a really rough test model and realized that it requires a fold in addition the draping. Not sure how that fits into my plan. Maybe it'd be better to start with a sail...
A sail definitely seems like a simpler test case, but assuming the cape is modeled as having a cut there, it seems like folding should be handled by draping + constraints?
(also - I'll try to download the knots template and take a look tomorrow or early this week)
I've been thinking for a while it would be cool to be able to handle 2D bendable surfaces like capes and sails. Thought I'd open an issue to discuss possible for avenues for implementation.
I think you'd have to specify an existing flat version of the part, attachment points and over/under constraints, and then do some energy minimization to try and preserve surface area while minimize curvature.