POV-Ray : Newsgroups : povray.general : Envelope deformation Server Time
9 Oct 2026 04:36:14 EDT (-0400)
  Envelope deformation (Message 1 to 28 of 28)  
From: Josh English
Subject: Envelope deformation
Date: 22 Jul 2025 17:04:18
Message: <687ffcd2$1@news.povray.org>
I think it has been asked here before but I can't think of the right 
term. In 2d vector graphics there is a function called envelope which 
allows you to take an object and distort it into any quadrangle.

I am trying the same thing in POV-Ray, but every transformation I can 
pull out of my hat and the include files maintains the original 
parallelogram. I tried slicing a box in half and transforming the two 
sides but it ended up with an ugly crease.

Am I fooling myself into thinking this is even possible in POV-Ray?

Uncle Josh


Post a reply to this message

From: Bald Eagle
Subject: Re: Envelope deformation
Date: 22 Jul 2025 21:30:00
Message: <web.68803ad427ff66201f9dae3025979125@news.povray.org>
Josh English <Jos### [at] joshuarenglishcom> wrote:
> I think it has been asked here before but I can't think of the right
> term. In 2d vector graphics there is a function called envelope which
> allows you to take an object and distort it into any quadrangle.
>
> I am trying the same thing in POV-Ray, but every transformation I can
> pull out of my hat and the include files maintains the original
> parallelogram. I tried slicing a box in half and transforming the two
> sides but it ended up with an ugly crease.
>
> Am I fooling myself into thinking this is even possible in POV-Ray?
>
> Uncle Josh

There was an object bender macro that basically took an object, turned it into a
zillion slices, and did things that way.

What you need to do is define you object as an isosurface, and then you can do
non-linear transformations on them:

http://news.povray.org/povray.binaries.images/thread/%3Cweb.5d4b7ce3a683fa3a4eec112d0%40news.povray.org%3E/

See at the top how I took a "box" and bent it.

Look through Mike Williams' Isosurface Tutorial, and you'll get an idea of what
you can do.

The control handles of the Bezier polygon in the 2D envelope tool is a neat
idea.
Would be super cool to incorporate that into a modeler....

- BE


Post a reply to this message

From: Josh English
Subject: Re: Envelope deformation
Date: 23 Jul 2025 00:46:42
Message: <68806932$1@news.povray.org>
On 7/22/2025 6:28 PM, Bald Eagle wrote:
> Josh English <Jos### [at] joshuarenglishcom> wrote:
>> 
>>
>> Am I fooling myself into thinking this is even possible in POV-Ray?
>>
> 
> There was an object bender macro that basically took an object, turned it into a
> zillion slices, and did things that way.
> 
> What you need to do is define you object as an isosurface, and then you can do
> non-linear transformations on them:
> 
>
http://news.povray.org/povray.binaries.images/thread/%3Cweb.5d4b7ce3a683fa3a4eec112d0%40news.povray.org%3E/
> 
> See at the top how I took a "box" and bent it.
> 
> Look through Mike Williams' Isosurface Tutorial, and you'll get an idea of what
> you can do.
> 
> The control handles of the Bezier polygon in the 2D envelope tool is a neat
> idea.
> Would be super cool to incorporate that into a modeler....
> 
> - BE
> 
I have a bezier patch modeling system, and I could probably work it to 
create a shape inside any demented cube, but I was hoping to be able to 
copy meshes and deform them, not draw each one individually.

But if that's what it takes, that's what it takes!

(Isosurfaces scare me. I have no idea how you bent a box.)

- Josh


Post a reply to this message

From: Bald Eagle
Subject: Re: Envelope deformation
Date: 23 Jul 2025 06:45:00
Message: <web.6880bc9227ff66201f9dae3025979125@news.povray.org>
Josh English <Jos### [at] joshuarenglishcom> wrote:

> I have a bezier patch modeling system, and I could probably work it to
> create a shape inside any demented cube, but I was hoping to be able to
> copy meshes and deform them, not draw each one individually.
>
> But if that's what it takes, that's what it takes!

Well, if you have a modeling system, then you can use the Bernstein polynomials
to access any point on the patch.
You could add a 3rd dimension with some finagling.

Then you take your mesh, find the bounding box min and max, convert all the 3D
coordinates to uv(w) coordinates, and use the Bezier splines to adjust the
coordinates of the mesh.


> (Isosurfaces scare me. I have no idea how you bent a box.)
>
> - Josh

The same way one "bends" a line to make a parabola.  When your shape is an
equation, one can feed anything into it as the input.
So when I take the equation of a box and substitute x*x for x, then I get a
parabolicly bent box.

We can tilt, rotate, twist, scale, _nonlinearly scale_, perturb the surface,
etc.

- BE


Post a reply to this message

From: Bald Eagle
Subject: Re: Envelope deformation
Date: 23 Jul 2025 12:20:00
Message: <web.68810a8e27ff6620a2cb7a7025979125@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

> Then you take your mesh, find the bounding box min and max, convert all the 3D
> coordinates to uv(w) coordinates, and use the Bezier splines to adjust the
> coordinates of the mesh.

Take a look at:

https://discussions.unity.com/t/deforming-a-mesh-to-bezier-curve/876635

https://www.youtube.com/watch?v=S_JQUDDAsQk

https://www.rose-hulman.edu/~finn/CCLI/Notes/day21.pdf

my guess is that there are several ways that people go about this, and there are
likely libraries on GitHub and elsewhere.

MY conception of a general way to go about this would be to define a Bezier
parallelpiped consisting of 64 control points - like 4 stacked Bezier patches
having 16 control points each.
The 8 corner points would control your 3D envelope, and all of the inner control
points would control "stretching".

We could expand existing macros to create extended Bernstein polynomials in i,
j, and k.

Cycling through all of the mesh vertices and dividing the coordinates by the
AABB dimensions, you'd get the i, j, k parameters, and could plug those into the
polynomial to get the adjusted mesh vertex coordinates.

Then you could do all sorts of stuff with a mesh.

Best would be to write something in Javascript or Processing to create a
modeler, and have it write out an .inc file for the new distorted mesh.



- BW


Post a reply to this message

From: Josh English
Subject: Re: Envelope deformation
Date: 23 Jul 2025 18:38:02
Message: <6881644a$1@news.povray.org>
On 7/23/2025 9:15 AM, Bald Eagle wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
> 
>> Then you take your mesh, find the bounding box min and max, convert all the 3D
>> coordinates to uv(w) coordinates, and use the Bezier splines to adjust the
>> coordinates of the mesh.
> 
> Take a look at:
> 
> https://discussions.unity.com/t/deforming-a-mesh-to-bezier-curve/876635
> 
> https://www.youtube.com/watch?v=S_JQUDDAsQk
> 
> https://www.rose-hulman.edu/~finn/CCLI/Notes/day21.pdf
> 
> my guess is that there are several ways that people go about this, and there are
> likely libraries on GitHub and elsewhere.
> 
> MY conception of a general way to go about this would be to define a Bezier
> parallelpiped consisting of 64 control points - like 4 stacked Bezier patches
> having 16 control points each.
> The 8 corner points would control your 3D envelope, and all of the inner control
> points would control "stretching".
> 
> We could expand existing macros to create extended Bernstein polynomials in i,
> j, and k.
> 
> Cycling through all of the mesh vertices and dividing the coordinates by the
> AABB dimensions, you'd get the i, j, k parameters, and could plug those into the
> polynomial to get the adjusted mesh vertex coordinates.
> 
> Then you could do all sorts of stuff with a mesh.
> 
> Best would be to write something in Javascript or Processing to create a
> modeler, and have it write out an .inc file for the new distorted mesh.
> 
> 
> 
> - BW
> 

Interesting stuff. My modeling system defines a modeling grid of points 
from which I generate the necessary bicubic patches. The idea is the 
points on the modeling grid are on the model, and then it calculates 
everything to make the patches to connect those points. The system 
requires a lot of arrays, as you can imagine, so the points are all 
there ready to be used and abused.

https://joshuarenglish.com/povray/bezdoc/index.html

Once I have all the modeling grids in a group, I can probably transform 
the individual points directly in the SDL. I'm not sure how the 
Berenstein polynomials would help with this particular transformation. I 
have to play with the application of them.

Right now I'm going through an incredibly clunky conversion in 2d:

#declare quad = array[4] {<1.95,0,-1>, <3,0,0>, <2.5,0,1.2>, <1.25, 0, 
-0.25> }

// outline the quad
#for(I,0,3,1)
   sphere { quad[I] 0.02 pigment { rgb 0 } }
   cylinder {quad[I] quad[mod((I+1),4)] 0.02 pigment { rgb 0 } }
pigment { rgb 0.5 } }
#end

#include "math.inc"
#declare res = <10,10>;

#declare left_vector = quad[3]-quad[0];
#declare right_vector = quad[2]-quad[1];

#declare DaTexture = texture {
   uv_mapping
   pigment { marble }
   }

mesh {
#for(V, 0, res.v-1,1)
   #declare start = Interpolate(V,0,res.v,quad[0], quad[3],1);
   #declare stop = Interpolate(V,0,res.v, quad[1], quad[2],1);
   #declare nstart = Interpolate(V+1, 0, res.v, quad[0], quad[3], 1);
   #declare nstop = Interpolate(V+1, 0, res.v, quad[1], quad[2], 1);

   #for(U,0, res.u-1, 1)
     #declare ll = Interpolate(U, 0, res.u, start, stop, 1);
     #declare lr = Interpolate(U+1, 0, res.u, start, stop, 1);
     #declare tl = Interpolate(U, 0, res.u, nstart, nstop, 1);
     #declare tr = Interpolate(U+1, 0, res.u, nstart, nstop, 1);

     triangle { ll, lr, tl
       uv_vectors <U/res.u, V/res.v> <(U+1)/res.u, V/res.v> <U/res.u, 
(V+1)/res.v>
       }
     triangle { lr, tl, tr
       uv_vectors <(U+1)/res.u, V/res.v> <U/res.u, (V+1)/res.v> 
<(U+1)/res.u, (V+1)/res.v>
       }

   #end // for U
#end // for V
  texture { DaTexture }
}

Are you suggesting there's an easier (and maybe faster way) to do this 
sort of thing? I'll have to wreck my brain on the problem.

Josh


Post a reply to this message

From: Bald Eagle
Subject: Re: Envelope deformation
Date: 23 Jul 2025 20:40:00
Message: <web.6881809c27ff66201f9dae3025979125@news.povray.org>
Josh English <Jos### [at] joshuarenglishcom> wrote:

> Are you suggesting there's an easier (and maybe faster way) to do this
> sort of thing? I'll have to wreck my brain on the problem.

Dunno if it's "easier" - that all depends upon your philosophy and code usage.
Might be faster.   I would say probably.

I would strongly suggest looking over my monograph on Bezier patches and
Bernstein polynomials to get the overview, and understand what the polynomial
method actually does, and why it's a more elegant way of doing things.

https://wiki.povray.org/content/User:BillW

Then I'd dig up some of TOK's threads, his GitHub libraries, and the threads
where he teaches me all sorts of stuff about making Bezier patches the "better"
way, and I finally hammer out how to stitch a load of bicubic patches into a
torus.

Once you see what it all does, you'll understand that every point on a bicubic
patch is just an interpolation (which you already know) - but it's the sum of
the contributions of _ALL 16_ control points at that particular u,v coordinate.

So, the idea is that if you start with a unit square (or you divide your mesh
coordinates by the bounding box extents to give u,v parameters, then you can
just plug in the coordinates of a vertex and directly calculate the new position
based on any (re)arrangement of the control points.

I'm just suggesting that this be done in 3D with a full complement of additional
control points for the spatial version.
So that would be 64 points with u,v,w coordinates.

There are only 64 control points, and assembling the polynomial equation(s)
shouldn't be too difficult.  I would imagine that the speed would depend mostly
on the number of triangles in your mesh.

The real challenge is visualizing what the result of moving the control points
is.  Thus, my suggestion for Javascript, Processing, etc.  Desmos might provide
a tedious way to do it, though possibly someone could write it for us.

- BE


Post a reply to this message

From: Bald Eagle
Subject: Re: Envelope deformation
Date: 24 Jul 2025 10:40:00
Message: <web.688244cd27ff6620a2cb7a7025979125@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

> So, the idea is that if you start with a unit square (or you divide your mesh
> coordinates by the bounding box extents to give u,v parameters, then you can
> just plug in the coordinates of a vertex and directly calculate the new position
> based on any (re)arrangement of the control points.
>
> I'm just suggesting that this be done in 3D with a full complement of additional
> control points for the spatial version.
> So that would be 64 points with u,v,w coordinates.
>
> There are only 64 control points, and assembling the polynomial equation(s)
> shouldn't be too difficult.  I would imagine that the speed would depend mostly
> on the number of triangles in your mesh.

I used the code from one of my monograph illustrations to form the basis for
rewriting an expanded Bernstein polynomial equation.
Set up the 64 control points.
Added an extra loop to show the extended control grid.

Seems to work when it just sits there and does nothing.  ;)

Need to get a low poly mesh and start moving control points around.

- BE


Post a reply to this message

From: jr
Subject: Re: Envelope deformation
Date: 24 Jul 2025 10:55:00
Message: <web.6882486327ff66207b8494536cde94f1@news.povray.org>
hi,

"Bald Eagle" <cre### [at] netscapenet> wrote:
> ...
> Seems to work when it just sits there and does nothing.  ;)
> Need to get a low poly mesh and start moving control points around.

"there you are" ;-).  (attached, 42 vectors, 80 faces)


regards, jr.


Post a reply to this message


Attachments:
Download '250724_ng.inc.txt' (3 KB)

From: Bald Eagle
Subject: Re: Envelope deformation
Date: 24 Jul 2025 18:35:00
Message: <web.6882b47a27ff66201f9dae3025979125@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:

> "there you are" ;-).  (attached, 42 vectors, 80 faces)

Rock, paper, scissors.

Bezier Parallelpiped crushes them all.

- BE


Post a reply to this message


Attachments:
Download 'bezier_3d_for_mesh.png' (109 KB)

Preview of image 'bezier_3d_for_mesh.png'
bezier_3d_for_mesh.png


 

From: Josh English
Subject: Re: Envelope deformation
Date: 24 Jul 2025 23:24:04
Message: <6882f8d4$1@news.povray.org>
On 7/24/2025 3:32 PM, Bald Eagle wrote:
> "jr" <cre### [at] gmailcom> wrote:
> 
>> "there you are" ;-).  (attached, 42 vectors, 80 faces)
> 
> Rock, paper, scissors.
> 
> Bezier Parallelpiped crushes them all.
> 
> - BE

Are you transforming the mesh as a whole or pulling the vertices out and 
transforming them?

Josh


Post a reply to this message

From: Bald Eagle
Subject: Re: Envelope deformation
Date: 25 Jul 2025 06:10:00
Message: <web.6883575e27ff66201f9dae3025979125@news.povray.org>
Josh English <Jos### [at] joshuarenglishcom> wrote:
> On 7/24/2025 3:32 PM, Bald Eagle wrote:
> > "jr" <cre### [at] gmailcom> wrote:
> >
> >> "there you are" ;-).  (attached, 42 vectors, 80 faces)
> >
> > Rock, paper, scissors.
> >
> > Bezier Parallelpiped crushes them all.
> >
> > - BE
>
> Are you transforming the mesh as a whole or pulling the vertices out and
> transforming them?
>
> Josh

Unfortunately, there's not a way (that I know of) to access the vertices in a
native mesh.

So I cut/pasted the vertices into an array, and put a loop into the mesh2 to
cycle through the array.

To be able to easily reuse the mesh2 definition, I set a flag to either use the
original vertices, or run a macro to apply the Bezier distortion.

#macro MakeMesh (Distorted)

 mesh2 {
  vertex_vectors {
  42,
  #for (V, 0, 41)
   #if (Distorted)
    DistortedVertex (MeshVertices [V]),
   #else
    MeshVertices [V],
   #end
  #end
  }
.. . . etc.

I know it would be great if we could just easily include any mesh, or run it
through a macro, but at present, I don't think that there's any way to do that.

I am pretty happy that it just required some "minor" modification to the formula
generating code, and this wasn't a major multiple-month project.

Anyway, it shows proof of concept.     :)

- BE

Attached please find all the gnarly, hastily modified code.


Post a reply to this message


Attachments:
Download 'bezier_3d_for_mesh.pov.txt' (19 KB)

From: Bald Eagle
Subject: Re: Envelope deformation
Date: 25 Jul 2025 12:20:00
Message: <web.6883addf27ff6620a2cb7a7025979125@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

> Unfortunately, there's not a way (that I know of) to access the vertices in a
> native mesh.
>
> So I cut/pasted the vertices into an array, and put a loop into the mesh2 to
> cycle through the array.

Perhaps a script could be written to convert mesh and mesh2 objects to arrays,
and then we can have a macro to define the mesh from those arrays.


> I know it would be great if we could just easily include any mesh, or run it
> through a macro, but at present, I don't think that there's any way to do that.

This hearkens back to the many discussions we've had about 4.0 and the
restructuring of the primitives and language structure.


I've seen some interesting discussions about taking something like a road or
brick wall, and using this approach to have the mesh follow the "spline".

Some pre-set deformations would be a nice thing to have, and one could simply
have a macro argument to control the degree of deformation.

Hourglass
Cylinder
Sphere
Twist
One face curving/collapsing to a point (like the following)
https://news.povray.org/povray.binaries.images/thread/%3Cweb.5e97c744fd34edcfb0b41570%40news.povray.org%3E/?ttop=444993
&toff=550
Two faces collapsing to points (like a lemon {} )
Two faces collapsing to points at different rates (like an ovus {} )
Bending into a square-cross-section U

- BE


Post a reply to this message

From: Josh English
Subject: Re: Envelope deformation
Date: 25 Jul 2025 16:30:56
Message: <6883e980$1@news.povray.org>
On 7/25/2025 9:16 AM, Bald Eagle wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:

> 
> 
> I've seen some interesting discussions about taking something like a road or
> brick wall, and using this approach to have the mesh follow the "spline".
> 

My modeling system does this sort of thing. It can generate the spline, 
do some copying and interpolation, and then build the wall. But it does 
this entirely with arrays. I would like to be able to convert some of 
these constructions into mesh2 objects, which will just take time, but I 
can only do this kind of transformation on the array.

Josh


Post a reply to this message

From: Josh English
Subject: Re: Envelope deformation
Date: 25 Jul 2025 16:33:01
Message: <6883e9fd$1@news.povray.org>
On 7/25/2025 9:16 AM, Bald Eagle wrote:
> Perhaps a script could be written to convert mesh and mesh2 objects to arrays,
> and then we can have a macro to define the mesh from those arrays.

We would need to be able to serialize the mesh objects, though. I don't 
know if 4.0 has any plans for that sort of thing. It would be nice to be 
able to export them after a complicated modeling job.

Then again, I have Python at hand and I suspect most of us know other 
coding languages that could do the same job. I'm trying to be an SDL 
purist, probably to my detriment.

Josh


Post a reply to this message

From: Bald Eagle
Subject: Re: Envelope deformation
Date: 25 Jul 2025 22:05:00
Message: <web.688437c627ff66201f9dae3025979125@news.povray.org>
Josh English <Jos### [at] joshuarenglishcom> wrote:
> On 7/25/2025 9:16 AM, Bald Eagle wrote:
> > Perhaps a script could be written to convert mesh and mesh2 objects to arrays,
> > and then we can have a macro to define the mesh from those arrays.
>
> We would need to be able to serialize the mesh objects, though. I don't
> know if 4.0 has any plans for that sort of thing. It would be nice to be
> able to export them after a complicated modeling job.
>
> Then again, I have Python at hand and I suspect most of us know other
> coding languages that could do the same job. I'm trying to be an SDL
> purist, probably to my detriment.
>
> Josh

Well, we have #read and #write.
I've written tens of thousands of bicubic patch objects to files that way.

So it shouldn't be that big of a problem to write a distorted mesh to a new
file.

- BE


Post a reply to this message

From: jr
Subject: Re: Envelope deformation
Date: 26 Jul 2025 08:30:00
Message: <web.6884ca1c27ff66207b8494536cde94f1@news.povray.org>
hi,

"Bald Eagle" <cre### [at] netscapenet> wrote:

I liked the "boulder" on the right, pretty amazing.


> Josh English <Jos### [at] joshuarenglishcom> wrote:
> > On 7/25/2025 9:16 AM, Bald Eagle wrote:
> > > Perhaps a script could be written to convert mesh and mesh2 objects to arrays,
> > > and then we can have a macro to define the mesh from those arrays.
> >
> > We would need to be able to serialize the mesh objects, though. I don't
> > know if 4.0 has any plans for that sort of thing. It would be nice to be
> > able to export them after a complicated modeling job.
> >
> > Then again, I have Python at hand and I suspect most of us know other
> > coding languages that could do the same job. I'm trying to be an SDL
> > purist, probably to my detriment.
> >
> > Josh
>
> Well, we have #read and #write.

a "crutch" at best.  unfortunately.


> I've written tens of thousands of bicubic patch objects to files that way.

and that knowledge, the experience, ought to be worth a "good wiki page".  and
the same really for this thread, the deformations.  I think that with a second
example perhaps and "fleshing out" your notes, this topic too would make a
useful/valuable reference in the wiki.


> So it shouldn't be that big of a problem to write a distorted mesh to a new
> file.

there's also the "upholstered crutch" :-), the 'Filed()' macro.


regards, jr.


Post a reply to this message

From: ingo
Subject: Re: Envelope deformation
Date: 27 Jul 2025 01:50:00
Message: <web.6885bd1827ff662017bac71e8ffb8ce3@news.povray.org>
Josh,

for mesh and bicubic patches deformations of pre-made models is hard. One can
use scripts to extract .obj files in to mesh.

When one creates mesh and patches, things are easier. You can "just" remodel the
object with different parameters. Think extruding, lofting, sor or even
parametrics. Very old code below for patch modelling and clock guided
deformation.

The use of deformation grids (cubes) in 3d works. Sorry, my experiments for that
are lost. It is basically not so different from "boning", you have to virtually
"attach" vertices to the cubes in a grid. In similar vain you can use a single
spline to deform a mesh. But, it all has to be done to arrays. That's why I
build arrays first and the mesh from that in the meshmaker macros. When you
adapt the array building system you can add springiness, like in cloth
generation systems to get gel like objects that deform.

ingo

---%<------%<------%<---
// Ingo Janssen
// 1999-04-22
// bicubic patch generation

#version 3.1;
global_settings{assumed_gamma 1.0}
light_source{<100,50,-500> rgb 1}

camera{
   location <0,0,-20.0>
   look_at  <0,0, 0.0>
}

#macro GetRadius1(R)
   #local Range=R*0.1;
   #local Variation=Range+(((-Range)-Range)*rand(S));
   #declare Rr=R+Variation;
#end

#macro BuildArray(H,R,NrBPH,NrBPC)
// H= height; R= radius
// NrBPH= number of patches in height
// NrBPC= number of patches in circumference
   #local PH=((NrBPH*4)-NrBPH)+1;
   #local PC=((NrBPC*4)-NrBPC)+1;
   #local Ystep=H/PH;
// need one extra element in the array for C1 continuity.
   #local BP_arr=array[PH+1][PC+1]
   #local Ypos=0;
   #local I=0;
   #local J=0;
   #while (I<PH+1)
      #while (J<PC-1)
         #local Phi=(J*(360/PC));//+(I*((-180+clock*360)/PH));
         GetRadius1(R)
         #declare BP_arr[I][J]=vrotate(<Rr,Ypos,0>,<0,Phi,0>);
         #local J=J+1;
      #end //while
// closed shape so last point is first point.
      #local BP_arr[I][J]= BP_arr[I][0];
// the last-plus-one point must be the same as the second point, too.
      #local BP_arr[I][J+1]= BP_arr[I][1];
      #local J=0;
      #local Ypos=Ypos+Ystep;
      #local I=I+1;
   #end //while
   #declare OutArray= BP_arr
#end //macro

#macro BuildPatch(InArray)
// the arrays were made an element larger, so here we must compensate.
   #local PH= dimension_size (InArray,1)-1;
   #local PC= dimension_size (InArray,2)-1;
   #local I= 0;
   #local J= 0;
   #while (I<PH-1)
      #while (J<PC-1)
         bicubic_patch {
            type 1
            u_steps 4
            v_steps 4,
            InArray[I][J],
            InArray[I][J+1],
// notice that the third point in each row is constrained such
// that it, the last point in the row, and the second point
// in the equivalent row in the next patch are in a straight line.(Ron Parker)
            2*InArray[I][J+3]-InArray[I][J+4],
            InArray[I][J+3],

            InArray[I+1][J],
            InArray[I+1][J+1],
            2*InArray[I+1][J+3]-InArray[I+1][J+4],
            InArray[I+1][J+3],

// notice, too, that each point in the entire third row is
// constrained in this way with respect to the last row and
// to the second row of the next patch.  Note the lack of any
// +2 terms in the whole patch definition.  We calculated them
// above, but we never use them because we no longer have as
// much freedom as we did before we wanted smoothness.(Ron Parker)

            2*InArray[I+3][J]-InArray[I+4][J],
            2*InArray[I+3][J+1]-InArray[I+4][J+1],

2*(2*InArray[I+3][J+3]-InArray[I+4][J+3])-(2*InArray[I+3][J+4]-InArray[I+4][J+4]),
            2*InArray[I+3][J+3]-InArray[I+4][J+3],

            InArray[I+3][J],
            InArray[I+3][J+1],
            2*InArray[I+3][J+3]-InArray[I+3][J+4],
            InArray[I+3][J+3]

            pigment {rgb 1}
         }
         #local J=J+3;
      #end //while
      #local J=0;
      #local I=I+3;
   #end //while
#end //macro


#macro ScaleArray(InArray)
   #local PH= dimension_size (InArray,1);
   #local PC= dimension_size (InArray,2);
   #local I= 0;
   #local J= 0;
   #local Phi= 0;
   #while (I<PH)
      #while (J<PC)

         #local Scale=sin(Phi)+0.5;
         #local InArray[I][J]=InArray[I][J]*<Scale,1,Scale>;

         #local J= J+1;
      #end //while
      #local J= 0;
      #local Phi=Phi+(pi/(PH-2));
      #local I= I+1;
   #end //while
   #declare OutArray= InArray
#end //macro


#declare S=seed(7);
BuildArray(15,5,25,15)
ScaleArray(OutArray)
union{
   BuildPatch(OutArray)
   rotate <0,0,90>
   translate <7.5,0,0>
}
---%<------%<------%<---


Post a reply to this message

From: Josh English
Subject: Re: Envelope deformation
Date: 27 Jul 2025 19:04:11
Message: <6886b06b$1@news.povray.org>
On 7/26/2025 10:46 PM, ingo wrote:
> Josh,
> 
> for mesh and bicubic patches deformations of pre-made models is hard. One can
> use scripts to extract .obj files in to mesh.
> 
> When one creates mesh and patches, things are easier. You can "just" remodel the
> object with different parameters. Think extruding, lofting, sor or even
> parametrics. Very old code below for patch modelling and clock guided
> deformation.
> 
> The use of deformation grids (cubes) in 3d works. Sorry, my experiments for that
> are lost. It is basically not so different from "boning", you have to virtually
> "attach" vertices to the cubes in a grid. In similar vain you can use a single
> spline to deform a mesh. But, it all has to be done to arrays. That's why I
> build arrays first and the mesh from that in the meshmaker macros. When you
> adapt the array building system you can add springiness, like in cloth
> generation systems to get gel like objects that deform.

My modeling system does this with a Modeling array and it then creates 
the array of Control points needed to create the array of bicubic 
patches I want.

I found Nathan Reed's page, quoting Inigo Quilez' 
https://iquilezles.org/articles/ibilinear/, on the same bilinear 
interpolation I've been doing on my modeling grids. What I hadn't been 
doing was all the algebra that allows for hopefully a faster calculation.

My bicubic modeling system can handle sheets and cylinders and box-like 
shapes, but so far I don't have an easy way to combine models into one 
modeling array that would allow for sharp corners. I have a few ideas 
brewing, but only sketches of how I could do it. I suspect for each 
element of a building I want to have I'll need to create a macro to 
generate the section, and then deform the control grid as needed. I'm 
still noodling on it.

Josh


Post a reply to this message

From: Bald Eagle
Subject: Re: Envelope deformation
Date: 27 Jul 2025 19:55:00
Message: <web.6886bbf327ff66201f9dae3025979125@news.povray.org>
Josh English <Jos### [at] joshuarenglishcom> wrote:
> . . . but so far I don't have an easy way to combine models into one
> modeling array that would allow for sharp corners.

https://news.povray.org/povray.binaries.images/thread/%3Cweb.5da27a2a65c96eb4eec112d0%40news.povray.org%3E/?ttop=445868
&toff=650&mtop=428668

Like the leftmost part?

https://news.povray.org/povray.binaries.images/attachment/%3Cweb.5da912bb21826f334eec112d0%40news.povray.org%3E/serpent
inebeltprism.png?ttop=445868&toff=650

- BW


Post a reply to this message

From: Josh English
Subject: Re: Envelope deformation
Date: 28 Jul 2025 11:41:35
Message: <68879a2f$1@news.povray.org>
On 7/25/2025 7:04 PM, Bald Eagle wrote:
> Josh English <Jos### [at] joshuarenglishcom> wrote:
>> On 7/25/2025 9:16 AM, Bald Eagle wrote:
>>> Perhaps a script could be written to convert mesh and mesh2 objects to arrays,
>>> and then we can have a macro to define the mesh from those arrays.
>>
>> We would need to be able to serialize the mesh objects, though. I don't
>> know if 4.0 has any plans for that sort of thing. It would be nice to be
>> able to export them after a complicated modeling job.
>>
>> Then again, I have Python at hand and I suspect most of us know other
>> coding languages that could do the same job. I'm trying to be an SDL
>> purist, probably to my detriment.
>>
>> Josh
> 
> Well, we have #read and #write.
> I've written tens of thousands of bicubic patch objects to files that way.
> 
> So it shouldn't be that big of a problem to write a distorted mesh to a new
> file.
> 
> - BE
> 
I do that, too. I create arrays that track arrays and shove them all 
into a mesh2 object. It would be nice to be able to take the created 
mesh2 object and serialize instead of creating everything, writing to a 
file, then importing it. But that's a high-level language thing.

I keep getting tripped up with my years of Python where everything is an 
object.


Post a reply to this message

From: ingo
Subject: Re: Envelope deformation
Date: 28 Jul 2025 12:00:00
Message: <web.68879e0927ff662017bac71e8ffb8ce3@news.povray.org>
but so far I don't have an easy way to combine models into one
> modeling array that would allow for sharp corners.

Mmmm, what about weighting the knots? for maximum smoothness than handles shoud
be equally long and have the exact opposite direction. Lets call that a weight
of 1.

Weight of 0 could be handle length 0.0. other weights are interpolation of the
two extrema.

This scheme is not exact, for example, it does not account for asymmetric
handles, but it could be a starting point for tinkering.

With a modeller, no idea if it is not build in.

ingo


Post a reply to this message

From: Bald Eagle
Subject: Re: Envelope deformation
Date: 28 Jul 2025 17:15:00
Message: <web.6887e74827ff66201f9dae3025979125@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:

> I think that with a second
> example perhaps and "fleshing out" your notes, this topic too would make a
> useful/valuable reference in the wiki.

Well, yes - however I was thinking about it today and tracking down some details
as a refresher, and any circle needs 4 bezier splines to get a good
approximation, so several of those shapes would really require 4-16 Bezier
Parallelpipeds to be stitched together.

Might not be so bad since I already worked that out and have example code but
.....  ugh.  Work.


I will add it to The List.

- BW


Post a reply to this message

From: Josh English
Subject: Re: Envelope deformation
Date: 28 Jul 2025 20:38:54
Message: <6888181e$1@news.povray.org>
On 7/28/2025 8:58 AM, ingo wrote:
>   but so far I don't have an easy way to combine models into one
>> modeling array that would allow for sharp corners.
> 
> Mmmm, what about weighting the knots? for maximum smoothness than handles shoud
> be equally long and have the exact opposite direction. Lets call that a weight
> of 1.
> 
> Weight of 0 could be handle length 0.0. other weights are interpolation of the
> two extrema.
> 
> This scheme is not exact, for example, it does not account for asymmetric
> handles, but it could be a starting point for tinkering.
> 
> With a modeller, no idea if it is not build in.
> 
> ingo
> 
> 
> 
My rough rough rough idea is to build a copy of the Modeling Grid (which 
is a 2D array) with a equally sized grid of <1,1,1,1> values (which 
would cover positive and negative U and positive and negative V 
weights). When I create the control point grid I create the internal 
control points as 1/3rd the distance towards the adjoining point by 
default.

So I could multiply that 1/3rd distance by the weight factor, or just 
default the weight (or smoothness) factor to 1/3 across the board and 
then tighten things up as necessary, making sure to not set any of them 
to 0 because that will collapse the bicubic patch. At least, I think it 
will break the bicubic patch.

I have to play with it down the road. I'm still trying to mimic  Oskar 
Stålberg's irregular grids from Townscaper for this project.

Josh


Post a reply to this message

From: Bald Eagle
Subject: Re: Envelope deformation
Date: 29 Jul 2025 13:55:00
Message: <web.68890ae927ff66205985c6de25979125@news.povray.org>
Josh English <Jos### [at] joshuarenglishcom> wrote:

> I have to play with it down the road. I'm still trying to mimic  Oskar
> Stålberg's irregular grids from Townscaper for this project.
>
> Josh

Is there a problem with simply butting 2 Bezier splines next to one another and
making a sharp bend that way?


There seem to be a number of people who have implemented Oskar Stålberg's
irregular grids, and provided tutorials.

I see where the Wavefront Collapse is going now.  :)

- BE


Post a reply to this message

From: Bald Eagle
Subject: Re: Envelope deformation
Date: 29 Jul 2025 14:15:00
Message: <web.68890e7f27ff66205985c6de25979125@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
 so several of those shapes would really require 4-16 Bezier
> Parallelpipeds to be stitched together.
>
> Might not be so bad since I already worked that out and have example code but
> .....  ugh.  Work.

However . . . I just recalled working out how to split a Bezier spline into 2 -
so I could do that recursively, and get a whole connected series of cubes, and
then just work out where the control points need to be for any given shape.

- BW


Post a reply to this message

From: Josh English
Subject: Re: Envelope deformation
Date: 31 Jul 2025 11:18:47
Message: <688b8957$1@news.povray.org>
On 7/29/2025 10:54 AM, Bald Eagle wrote:
> Josh English <Jos### [at] joshuarenglishcom> wrote:
> 
>> I have to play with it down the road. I'm still trying to mimic  Oskar
>> Stålberg's irregular grids from Townscaper for this project.
>>
>> Josh
> 
> Is there a problem with simply butting 2 Bezier splines next to one another and
> making a sharp bend that way?
> 
> 
> There seem to be a number of people who have implemented Oskar Stålberg's
> irregular grids, and provided tutorials.
> 
> I see where the Wavefront Collapse is going now.  :)
> 
> - BE
> 
> 
> 
My box modeler does this by extracting each face and generating the 
bicubic patches for each side.

The problem as I see it is how do I tell my modeling system "this bit is 
flat but that bit is round"?

As for the irregular grids, it's also not a matter of finding the 
quadrilaterals and drawing them, it's a matter of creating them and 
keeping track of them so I can traverse the irregular relaxed grid.

And yes, this is exactly all for this wave function collapse thing I'm 
building.

Josh


Post a reply to this message

From: Bald Eagle
Subject: Re: Envelope deformation
Date: 31 Jul 2025 11:55:00
Message: <web.688b91d027ff6620e6b881e925979125@news.povray.org>
Josh English <Jos### [at] joshuarenglishcom> wrote:

> My box modeler does this by extracting each face and generating the
> bicubic patches for each side.
>
> The problem as I see it is how do I tell my modeling system "this bit is
> flat but that bit is round"?

Need way more information and context to offer intelligent advice / solution.
Where is your input coming from?
Flat and round where?  On the edges?  On the face?
Can you use trace () ?
Maybe you need iterative interaction like I did with my analytical tangent
scene.
Details.

> As for the irregular grids, it's also not a matter of finding the
> quadrilaterals and drawing them, it's a matter of creating them and
> keeping track of them so I can traverse the irregular relaxed grid.

When I was making the Bezier stitched torus, I had my shape that was defined by
a set of parametric equations.  So I wrote macros to use where I was on the
parametric to find what patch I was on, and where in that patch I was.

Provide a workflow, diagrams, examples, etc - and there are surely solutions for
doing this.
If people are already doing it in other languages / software packages, we can
surely do it in POV-Ray.

> And yes, this is exactly all for this wave function collapse thing I'm
> building.

I see you like to bite off huge projects like I do  :D


Post a reply to this message

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