POV-Ray : Newsgroups : povray.binaries.images : Mesh2 Tools Server Time
22 Dec 2024 23:39:27 EST (-0500)
  Mesh2 Tools (Message 1 to 10 of 15)  
Goto Latest 10 Messages Next 5 Messages >>>
From: Chris R
Subject: Mesh2 Tools
Date: 29 Jun 2022 16:20:00
Message: <web.62bcb3bb5efcd90d833fbc6f5cc1b6e@news.povray.org>
For a new project, I wanted to model pieces of paper with curled edges, so I
started looking at mesh2 objects, and how I could generate them
programmatically.

I decided to write a bunch of Java code that I should be able to extend for
generating meshes for other types of objects as well.  I imagine all of it could
be done as SDL macros, but the debugging tools for Java are much better, and I'm
not so much a purist about the tools I use anymore.

The first mesh2 tool I wrote models sheets of paper as a grid of vertices in the
XZ plane.  I give it a size and the number of vertices in each direction, and it
creates the vertex_vectors, the face_indices, and a set of uv_indices assuming
the texture to be applied will be the same size as the grid.  It also assigns
each vertex a vertical normal.

I then wrote some code that can take an arbitrary line across the grid and a
"curling radius", and the direction of the curl.  It then moves the points that
are "below" the curl (or above based on the curl direction), lines them up with
a point on the curling axis, and creates a rotation of that point around the
curling axis using the curling radius.

Finally, there is code that will go and assign new normals to the vertices by
averaging the computed normals of all of the faces in the mesh after the
vertices have been moved.

In the example below, the texture is provided from a png image of a piece of
sheet music that I translated and scaled to match the size of the paper.  I use
an interior_texture with a gray pigment so the image doesn't bleed through.

I think it looks right, so I think I'm doing the right thing with uv vectors and
normals.  The sample was created as a 100x100 unit sheet of paper, with 100x100
vertices, and to my eyes it looks pretty smooth.

The code isn't completely done yet.  The example cheats in that the paper never
curls around into a spiral.  I need to figure out how to do that effectively,
and then I could have some nice partially open scrolls for my scene.  I'd also
like to work on some transformations that could "wrinkle" the paper in
interesting ways as well.

-- Chris R.


Post a reply to this message


Attachments:
Download 'meshtest.png' (612 KB)

Preview of image 'meshtest.png'
meshtest.png


 

From: Chris R
Subject: Re: Mesh2 Tools
Date: 29 Jun 2022 16:55:00
Message: <web.62bcbb22e9de8f10833fbc6f5cc1b6e@news.povray.org>
"Chris R" <car### [at] comcastnet> wrote:
> For a new project, I wanted to model pieces of paper with curled edges, so I
> started looking at mesh2 objects, and how I could generate them
> programmatically.
>
> I decided to write a bunch of Java code that I should be able to extend for
> generating meshes for other types of objects as well.  I imagine all of it could
> be done as SDL macros, but the debugging tools for Java are much better, and I'm
> not so much a purist about the tools I use anymore.
>
> The first mesh2 tool I wrote models sheets of paper as a grid of vertices in the
> XZ plane.  I give it a size and the number of vertices in each direction, and it
> creates the vertex_vectors, the face_indices, and a set of uv_indices assuming
> the texture to be applied will be the same size as the grid.  It also assigns
> each vertex a vertical normal.
>
> I then wrote some code that can take an arbitrary line across the grid and a
> "curling radius", and the direction of the curl.  It then moves the points that
> are "below" the curl (or above based on the curl direction), lines them up with
> a point on the curling axis, and creates a rotation of that point around the
> curling axis using the curling radius.
>
> Finally, there is code that will go and assign new normals to the vertices by
> averaging the computed normals of all of the faces in the mesh after the
> vertices have been moved.
>
> In the example below, the texture is provided from a png image of a piece of
> sheet music that I translated and scaled to match the size of the paper.  I use
> an interior_texture with a gray pigment so the image doesn't bleed through.
>
> I think it looks right, so I think I'm doing the right thing with uv vectors and
> normals.  The sample was created as a 100x100 unit sheet of paper, with 100x100
> vertices, and to my eyes it looks pretty smooth.
>
> The code isn't completely done yet.  The example cheats in that the paper never
> curls around into a spiral.  I need to figure out how to do that effectively,
> and then I could have some nice partially open scrolls for my scene.  I'd also
> like to work on some transformations that could "wrinkle" the paper in
> interesting ways as well.
>
> -- Chris R.

I figured out the code to spiral for longer curls...

-- Chris R.


Post a reply to this message


Attachments:
Download 'meshtest.png' (559 KB)

Preview of image 'meshtest.png'
meshtest.png


 

From: Thomas de Groot
Subject: Re: Mesh2 Tools
Date: 30 Jun 2022 02:18:53
Message: <62bd404d$1@news.povray.org>
Op 29/06/2022 om 22:50 schreef Chris R:
> "Chris R" <car### [at] comcastnet> wrote:
>> For a new project, I wanted to model pieces of paper with curled edges, so I
>> started looking at mesh2 objects, and how I could generate them
>> programmatically.
>>

Impressive! Well done indeed. Have you looked at Ingo's Meshmaker code? 
It is part of POV-Ray's include folder and is a great help when you need 
to make or convert to mesh2 objects.


-- 
Thomas


Post a reply to this message

From: Paolo Gibellini
Subject: Re: Mesh2 Tools
Date: 30 Jun 2022 03:03:34
Message: <62bd4ac6@news.povray.org>
Il 29/06/2022 22:50, Chris R ha scritto:

 >> The code isn't completely done yet.  The example cheats in that the 
paper never
 >> curls around into a spiral.  I need to figure out how to do that 
effectively,
 >> and then I could have some nice partially open scrolls for my scene. 
  I'd also
 >> like to work on some transformations that could "wrinkle" the paper in
 >> interesting ways as well.
 >>
 >> -- Chris R.
 >
 > I figured out the code to spiral for longer curls...
 >
 > -- Chris R.

Both the images are interesting, with a few work you can also generate 
parchment scrolls.

Paolo


Post a reply to this message

From: jr
Subject: Re: Mesh2 Tools
Date: 30 Jun 2022 05:00:00
Message: <web.62bd653be9de8f101be3cd4b6cde94f1@news.povray.org>
hi,

"Chris R" <car### [at] comcastnet> wrote:
> For a new project, I wanted to model pieces of paper with curled edges, ...

v nice.


> I'd also
> like to work on some transformations that could "wrinkle" the paper in
> interesting ways as well.

or "fold", am thinking origami.  (I'd be interested in the corresponding code
:-))


regards, jr.


Post a reply to this message

From: Chris R
Subject: Re: Mesh2 Tools
Date: 30 Jun 2022 10:50:00
Message: <web.62bdb792e9de8f10833fbc6f5cc1b6e@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> hi,
>
> "Chris R" <car### [at] comcastnet> wrote:
> > For a new project, I wanted to model pieces of paper with curled edges, ...
>
> v nice.
>
>
> > I'd also
> > like to work on some transformations that could "wrinkle" the paper in
> > interesting ways as well.
>
> or "fold", am thinking origami.  (I'd be interested in the corresponding code
> :-))
>
>
> regards, jr.

I added a primitive "folding" capability to the code.  Right now it really only
works for one fold at a time in a given region.  I need to play around with it
so you can fold already folded regions.

As you can see, the smaller the bending radius, the more points you need in the
mesh2 grid to avoid jagged edges along the fold.  I need to explore a more
efficient representation of the mesh and some code for sub-dividing the faces in
just those regions to avoid having a million faces in a single sheet of paper.

-- Chris R.


Post a reply to this message


Attachments:
Download 'meshtest.png' (445 KB)

Preview of image 'meshtest.png'
meshtest.png


 

From: Bald Eagle
Subject: Re: Mesh2 Tools
Date: 30 Jun 2022 14:10:00
Message: <web.62bde5dee9de8f101f9dae3025979125@news.povray.org>
"Chris R" <car### [at] comcastnet> wrote:

> > > I'd also
> > > like to work on some transformations that could "wrinkle" the paper in
> > > interesting ways as well.

Certainly you could experiment with applying some of the native pattern
perturbations like crackle or ... wrinkles.

> I added a primitive "folding" capability to the code.  Right now it really only
> works for one fold at a time in a given region.  I need to play around with it
> so you can fold already folded regions.
>
> As you can see, the smaller the bending radius, the more points you need in the
> mesh2 grid to avoid jagged edges along the fold.  I need to explore a more
> efficient representation of the mesh and some code for sub-dividing the faces in
> just those regions to avoid having a million faces in a single sheet of paper.

I see where you're going with this, and it is indeed challenging.

Perhaps you could define your sheet in terms of bezier patches.
Then you could determine what patches are crossed by folds, and subdivide those
patches to give more localized control if you have multiple folds.

I think some of this may be headed straight for NURBS territory.

I also recall seeing a lot of interesting computer graphics origami work that I
just didn't have the time or energy to dive into.  That might be the way to go
since the heavy lifting has already been done.

https://langorigami.com/article/computational-origami/

https://graphics.stanford.edu/~niloy/research/folding/paper_docs/folding_sig_08.pdf

https://news.mit.edu/2017/algorithm-origami-patterns-any-3-D-structure-0622
https://origami.c.u-tokyo.ac.jp/~tachi/software/

http://masc.cs.gmu.edu/wiki/Origami

https://dam-prod.media.mit.edu/x/files/thesis/2013/ysterman-ms.pdf

.... and it goes on and on


Post a reply to this message

From: Chris R
Subject: Re: Mesh2 Tools
Date: 30 Jun 2022 14:50:00
Message: <web.62bdef83e9de8f10833fbc6f5cc1b6e@news.povray.org>
"Chris R" <car### [at] comcastnet> wrote:
> "jr" <cre### [at] gmailcom> wrote:
> > hi,
> >
> > "Chris R" <car### [at] comcastnet> wrote:
> > > For a new project, I wanted to model pieces of paper with curled edges, ...
> >
> > v nice.
> >
> >
> > > I'd also
> > > like to work on some transformations that could "wrinkle" the paper in
> > > interesting ways as well.
> >
> > or "fold", am thinking origami.  (I'd be interested in the corresponding code
> > :-))
> >
> >
> > regards, jr.
>
> I added a primitive "folding" capability to the code.  Right now it really only
> works for one fold at a time in a given region.  I need to play around with it
> so you can fold already folded regions.
>
> As you can see, the smaller the bending radius, the more points you need in the
> mesh2 grid to avoid jagged edges along the fold.  I need to explore a more
> efficient representation of the mesh and some code for sub-dividing the faces in
> just those regions to avoid having a million faces in a single sheet of paper.
>
> -- Chris R.

One last update and I'll stop for the holiday weekend.  I created a Perlin noise
generator and applied it to the paper's grid of vertices before applying the
curling functions.

-- Chris R.


Post a reply to this message


Attachments:
Download 'meshtest.png' (555 KB)

Preview of image 'meshtest.png'
meshtest.png


 

From: Chris R
Subject: Re: Mesh2 Tools
Date: 30 Jun 2022 14:55:00
Message: <web.62bdf099e9de8f10833fbc6f5cc1b6e@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Chris R" <car### [at] comcastnet> wrote:
>
> > > > I'd also
> > > > like to work on some transformations that could "wrinkle" the paper in
> > > > interesting ways as well.
>
> Certainly you could experiment with applying some of the native pattern
> perturbations like crackle or ... wrinkles.
>
> > I added a primitive "folding" capability to the code.  Right now it really only
> > works for one fold at a time in a given region.  I need to play around with it
> > so you can fold already folded regions.
> >
> > As you can see, the smaller the bending radius, the more points you need in the
> > mesh2 grid to avoid jagged edges along the fold.  I need to explore a more
> > efficient representation of the mesh and some code for sub-dividing the faces in
> > just those regions to avoid having a million faces in a single sheet of paper.
>
> I see where you're going with this, and it is indeed challenging.
>
> Perhaps you could define your sheet in terms of bezier patches.
> Then you could determine what patches are crossed by folds, and subdivide those
> patches to give more localized control if you have multiple folds.
>
> I think some of this may be headed straight for NURBS territory.
>
> I also recall seeing a lot of interesting computer graphics origami work that I
> just didn't have the time or energy to dive into.  That might be the way to go
> since the heavy lifting has already been done.
>
> https://langorigami.com/article/computational-origami/
>
> https://graphics.stanford.edu/~niloy/research/folding/paper_docs/folding_sig_08.pdf
>
> https://news.mit.edu/2017/algorithm-origami-patterns-any-3-D-structure-0622
> https://origami.c.u-tokyo.ac.jp/~tachi/software/
>
> http://masc.cs.gmu.edu/wiki/Origami
>
> https://dam-prod.media.mit.edu/x/files/thesis/2013/ysterman-ms.pdf
>
> .... and it goes on and on

With some minor tweaks I got some rudimentary folding of folds to work, but you
still have to deal with the resolution of the faces.

Thanks for the links to the computational origami papers.  That looks exactly
like the kind of rabbit hole I could find myself diving into for weeks on end.
:-)

For now, with the addition of the noise generation functions I probably have
enough to work on the scene.  If I can get the code cleaned up enough afterwards
I'll post it for any Java-heads who would be interested.

-- Chris R.


Post a reply to this message

From: Chris R
Subject: Re: Mesh2 Tools
Date: 1 Jul 2022 12:00:00
Message: <web.62bf190ae9de8f10833fbc6f5cc1b6e@news.povray.org>
Paolo Gibellini <p.g### [at] gmailcom> wrote:
> Il 29/06/2022 22:50, Chris R ha scritto:
>
>  >> The code isn't completely done yet.  The example cheats in that the
> paper never
>  >> curls around into a spiral.  I need to figure out how to do that
> effectively,
>  >> and then I could have some nice partially open scrolls for my scene.
>   I'd also
>  >> like to work on some transformations that could "wrinkle" the paper in
>  >> interesting ways as well.
>  >>
>  >> -- Chris R.
>  >
>  > I figured out the code to spiral for longer curls...
>  >
>  > -- Chris R.
>
> Both the images are interesting, with a few work you can also generate
> parchment scrolls.
>
> Paolo

A very simple version of parchment.  I also added the ability to create bends in
the paper that are only partial, (i.e. not completely folded over).  With the
noise function added in, and a texture overlay that adds the aging, it looks
pretty good.

Still need to work on subdividing faces in the smaller creases...


-- Chris R.


Post a reply to this message


Attachments:
Download 'meshtest.png' (408 KB)

Preview of image 'meshtest.png'
meshtest.png


 

Goto Latest 10 Messages Next 5 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.