POV-Ray : Newsgroups : povray.general : Envelope deformation : Re: Envelope deformation Server Time
8 Aug 2025 15:33:25 EDT (-0400)
  Re: Envelope deformation  
From: ingo
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

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