 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
I was working on a 2025 Holiday scene, (which will probably be done in February
now...) and decided to add a gift wrapped in a patterned wrapping paper. After
several other attempts, I went back to my paper manipulation java libraries and
started working on getting folding to work correctly so I could create the
wrapping paper just as you would fold real paper.
I ended up rewriting a bunch of code that was just wrong from my earlier scenes
using the paper libraries, (which did not show up because I was curling paper,
not folding it at right angles). There are still a few glitches in how the
final fold of the two flaps on the front and back sides lay, but it's getting
close.
The attached image is a composite of the 13 steps (one is omitted since you
can't see the back corner anyway). I chose the default bozo pigment for the
exterior and gray for the interior_texture to better show that the uv-mapping is
working.
The box has a very slight rounding to it, rather than perfect 90-degree corners,
which is emulated in the folding code, as is the overlapping of paper and
doubling over of the valley folds at the corners. To get relatively smooth
edges on the folds, those sections of the paper are subdivided into very small
triangles, while the flat sections are fairly large. In total, there are 174K
vertices, and 322K faces.
Just thought it might be of interest. The code is still a bit messy and not
well commented, so I won't point you to the GitHub repo for it yet.
-- Chris R
Post a reply to this message
Attachments:
Download 'folding.png' (313 KB)
Preview of image 'folding.png'

|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Chris R" <car### [at] comcast net> wrote:
> Just thought it might be of interest.
Yes it is! :)
I've thought about, and looked into doing some "mathematical origami" here and
there. Never got around to writing any code for it though.
> The code is still a bit messy and not
> well commented, so I won't point you to the GitHub repo for it yet.
Still - great job!
I tried to "crush" a vertical edge of a box at one point, and would assume the
same sort of math and algorithms would apply. Do you think anything in your
library would be applicable to that?
- BE
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Bald Eagle" <cre### [at] netscape net> wrote:
> "Chris R" <car### [at] comcast net> wrote:
>
> > Just thought it might be of interest.
>
> Yes it is! :)
> I've thought about, and looked into doing some "mathematical origami" here and
> there. Never got around to writing any code for it though.
>
> > The code is still a bit messy and not
> > well commented, so I won't point you to the GitHub repo for it yet.
>
> Still - great job!
>
> I tried to "crush" a vertical edge of a box at one point, and would assume the
> same sort of math and algorithms would apply. Do you think anything in your
> library would be applicable to that?
>
> - BE
The java library consists of code for managing a grid of points in a 2D plane
that automatically generates triangles. There are other routines that then let
you subdivide the triangles for regions where you expect to be doing
transformations to make them smoother.
Once all of the subdivisions are done, there is code for creating 3D vertices
and triangular faces from the 2D plane. You can then search for vertices that
meet certain criteria, find all of the faces that are connected to that vertex,
and vice-versa; look for all faces that meet a certain criteria and get the
vertices for those faces.
Once you have that, you can do whatever you want to the vertices. There is
still code in there to do further subdivisions of the faces if it's easier to do
it on the 3D points rather than the original 2D points. You can adjust the
normals of the vertices and set UV coordinates.
For the paper wrapping application, I created a transformation that imitates
what would happen if you folded a piece of paper at any angle around a cylinder
with a fixed radius: if the point is within the arc-length of the angle around
the cylinder, the point maps to the relevant point on the cylinder, otherwise,
subtract off that arc-length from the distance of the point to the cylinder,
then rotate the subtracted point around the cylinder at the given angle, and
translate it to the point on the cylinder at that angle. The code allows for
cylinders with non-fixed radii as well, but I haven't tested that with the box
folding yet.
Once you are done, there is code to generate the mesh2 object in a .inc file.
The library code supports both smooth and flat triangles in the mesh, although
the specific app I wrote to create the wrapping paper uses all smooth triangles.
So, the short answer is, yes, you could pretty easily perturb the vertices of
your box object after it has been folded in a region that you want to crush.
You just need to define that region, make sure it has small enough triangles to
make your crushing pattern realistic, and then apply that pattern to all of the
vertices in the region.
I'm going to do a simple one with the wrapping paper application to make sure
that all works.
-- Chris R
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |