POV-Ray : Newsgroups : povray.binaries.images : Mesh2 Tools : Re: Mesh2 Tools Server Time
20 Apr 2024 00:02:25 EDT (-0400)
  Re: Mesh2 Tools  
From: Chris R
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


 

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