POV-Ray : Newsgroups : povray.binaries.images : Rounded Prisms : Re: Rounded Prisms Server Time
28 Sep 2024 22:16:27 EDT (-0400)
  Re: Rounded Prisms  
From: PM 2Ring
Date: 25 Nov 2005 06:30:00
Message: <web.4386f1417ed7ae6c2eef1b3b0@news.povray.org>
"PM 2Ring" <nomail@nomail> wrote:
> Oops! Wrong image! Oh well, I did intend to post that one, too, eventually.

And here is a much more rounded version to accompany the polyomino scene
file and a polyomino include file for it.

//penta.inc
/* POV include file. Polyominos */

#declare Polyomino1 = array[11][12]
{
  {0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 0},
  {0,  1,  1,  1,  1,  1,  2,  2,  2,  2,  3, 0},
  {0,  4,  4,  4,  5,  8,  2, 12, 12,  3,  3, 0},
  {0,  4,  4,  5,  5,  8,  8,  8, 12, 12,  3, 0},
  {0, 17, 17,  5,  6,  8,  6, 16, 11, 12,  3, 0},
  {0,  7, 17,  5,  6,  6,  6, 16, 11, 11, 11, 0},
  {0,  7, 17, 17, 10, 10,  9, 16, 16, 11, 13, 0},
  {0,  7,  7,  7, 10,  9,  9,  9, 16, 18, 13, 0},
  {0, 15, 15, 10, 10, 14,  9, 18, 18, 18, 13, 0},
  {0, 15, 15, 15, 14, 14, 14, 14, 18, 13, 13, 0},
  {0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 0},
}

#declare Polyomino2 = array[11][12]
{
  {0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 0},
  {0,  1,  1,  1,  1,  1,  2,  2,  2,  2,  3, 0},
  {0,  4,  4,  4,  5,  8,  2, 12, 12,  3,  3, 0},
  {0,  4,  4,  5,  5,  8,  8,  8, 12, 12,  3, 0},
  {0, 17, 17,  5, 16,  8, 11, 11, 14, 12,  3, 0},
  {0,  7, 17,  5, 16, 11, 11, 14, 14, 14, 14, 0},
  {0,  7, 17, 17, 16, 16, 11, 18, 18,  6,  6, 0},
  {0,  7,  7,  7,  9, 16, 10, 10, 18, 18,  6, 0},
  {0, 15, 15,  9,  9,  9, 10, 13, 18,  6,  6, 0},
  {0, 15, 15, 15,  9, 10, 10, 13, 13, 13, 13, 0},
  {0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 0},
}


//-------------------------End of file-------------------------

Sorry, people, I haven't gotten around to cleaning this scene up &
adding more comments, but if you have any questions, please ask here!

// Persistence of Vision Ray Tracer Scene Description File
// File: RPrism
// Vers: 3.5
// Desc: Rounded prisms: polyominoes
// Date: 2005-11-09
// Auth: PM 2Ring
//
// -d +A0.2 +AM2 +R4
// -F -A0.4 +AM2 +R1
// +A0.1 +AM2 +R3
// -d +A0.1 +AM2 +R3
// +W1600 +H1200 +A0.1 +AM2 +R3 -d
//

#include "colors.inc"
#include "stones.inc"

global_settings {
  assumed_gamma 1
  //max_trace_level 10
  //hf_gray_16
  //radiosity{always_sample 0}
}

#declare SkyBlue = rgb<.035, .27, .67>*.6;              //For water & sky
#declare SkyRad = 2E3;

camera {
  location <0, 12, -12.0> * 3.25
  //location 48 * y * 1.25

  right x*image_width/image_height up y
  direction z
  angle 30
  look_at -.05*y
}

light_source {<1, 4, -3> * 9 rgb 150 fade_power 2 fade_distance 3}
//light_source {<-1, 4, 3> * 8 rgb 240*.875 fade_power 2 fade_distance 2}

//---Textures--------------------------------------------------------------
#declare RS = seed(0);

#declare CM_Clouds =
color_map {
    [0.0   rgb 1]
    [0.05  rgb 0.85]
    [0.20  rgb 0.75]
    [0.45 SkyBlue]
}

#declare T_Clouds =
texture{
  pigment {
    bozo
    color_map {CM_Clouds}

    warp{
      turbulence 0.175
      octaves 7
      omega 0.7
      lambda 2.25
    }
  }
  finish{ambient 0.9 diffuse 0.2}
}

#declare FShiny =
finish{
  //ambient 0.05 diffuse .85
  specular .75 roughness 3e-4
  //metallic
  phong .25 phong_size 1.5
  reflection .25 diffuse .75  ambient 0
  //reflection {0.45,.75 metallic 0} diffuse .35 ambient 0
}

#declare TGround =
texture{
  pigment{
    //crackle  //solid
    //cells
    wrinkles
    //color_map{[0 rgb 1][0.025 rgb .25][0.1 rgb .75][0.15 rgb <.85 .75
..65>][1 rgb 1]}
    color_map {[0 rgb 1][0.025 rgb .25][0.1 rgb .75][0.15 rgb .85][1 rgb 1]}
    scale 2 // 10
  }
  finish{
    ambient .05 diffuse .75
    specular .75 roughness 1e-3
    //reflection .05 diffuse .60 ambient 0
  }
}

#declare StoneMax=30;

#declare T_Stones = array[StoneMax]{
  T_Stone1, T_Stone2, T_Stone3, T_Stone4, T_Stone5,
  T_Stone6, T_Stone7, T_Stone8, T_Stone9, T_Stone10,
  T_Stone11, T_Stone12, T_Stone13, T_Stone14, T_Stone15,
  T_Stone16, T_Stone17, T_Stone18, T_Stone19, T_Stone20,
  T_Stone21, T_Stone22, T_Stone23, T_Stone24, T_Stone25,

  //T_Stone26, T_Stone27,
  T_Stone29, T_Stone30, T_Stone31,
  T_Stone32, T_Stone33,
}
//#declare StoneMax=35;

#declare Sat = 0.625;
#declare Val = 0.65;

#declare Sat = 0.55;
#declare Val = 0.60;

#declare Sat = 0.60;
#declare Val = 0.75;

#macro Tex(A)
  //texture{T_Stone17 scale 4*2 translate 10*rand(RS)}
  texture{
    pigment{color CHSV2RGB(<A*360, Sat, Val>)
      //filter .75 transmit 0.25
    }
    finish{FShiny}
  }
#end

//---Objects-------------------------------------------

#declare Ground = cylinder{-y, -1e-4*y, SkyRad/20 texture{TGround}}

//Convert 2D to 3D
#macro V3D(A, H)<A.u,H,A.v>#end

//Generalized Rounded Prism
#macro RPrism(Vtx, Sides, SH, SR)
  //merge{
  union{
  #if(1)
    prism{
      linear_spline 0, SH, Sides+1,
      #local I=0;
      #while(I<=Sides)
        Vtx[I]
        #local I=I+1;
      #end
    }
    #end

    #local SH1 = SH - SR;
    #local I=0;
    #while(I<Sides)
      #local II = mod(I+1,Sides);
      #local A0 = V3D(Vtx[I],0);
      #local A1 = V3D(Vtx[I],SH1);
      #local DV = Vtx[II]-Vtx[I];
      #local Ang = -atan2(DV.y,DV.x)*180/pi;

      sphere{A1, SR}
      cylinder{0, SH1*y, SR translate A0}
      cylinder{A1, V3D(Vtx[II],SH1), SR }

      //cylinder{A0, V3D(Vtx[II],0), SR pigment{rgb y}}
      //sphere{A0, SR}

      #local Panel = box{z*1e-3, <vlength(DV), SH1, SR>}   //Side panel
      object{Panel rotate y*Ang translate A0}

      #local I=I+1;
    #end
  }
#end

//Clear a 2D array to zeroes
#macro Clear_2D(A)
  #local MI=dimension_size(A, 1);
  #local MJ=dimension_size(A, 2);

  #local I=0;
  #while(I<MI)
    #local J=0;
    #while(J<MJ)
      #local A[I][J] = 0;
      #local J=J+1;
    #end
    #local I=I+1;
  #end
#end

//Build a new vertex for MakeList()
#macro NewVertex(DI, DJ)
  #if((A[I+DI][J]!=Num & A[I][J+DJ]!=Num) | (A[I+DI][J]=Num & A[I][J+DJ]=Num
& A[I+DI][J+DJ]!=Num))

    #declare V = V + 1;
    #local KI = 2*I+(DI>0);
    #local KJ = 2*J+(DJ>0);
    #declare Knr[KI][KJ] = V;

    #local KI = 2*I+(DI>0?2-SR:SR);
    #local KJ = 2*J+(DJ>0?2-SR:SR);
    #declare Vtx0[V] = <KJ-MJ, MI-KI>;
 #end
#end

//Build vertex list from cell array.
#macro MakeList(A, Num, SR)
  #local MI=dimension_size(A, 1);
  #local MJ=dimension_size(A, 2);

  #local Knr = array[2*MI][2*MJ]
  Clear_2D(Knr)

  #local MV = 4*(MI-2)*(MJ-2);
  #local Vtx0 = array[MV];

  //Find vertices
  #local V=0;
  #local I=1;
  #while(I<MI-1)
    #local J=1;
    #while(J<MJ-1)
      #if(A[I][J]=Num)
        NewVertex(-1, -1)  //top left
        NewVertex(-1,  1)  //top right
        NewVertex( 1,  1)  //bottom right
        NewVertex( 1, -1)  //bottom left
      #end
      #local J=J+1;
    #end
    #local I=I+1;
  #end

  #local MV = V + 1;
  #local EV = array[MV];
  #local EH = array[MV];
  #local Vtx = array[MV];

  #local KV = 0;
  #local KH = 0;

  //find horizontal edges
  #local I=2;
  #while(I<2*MI-2)
    #local inedge = 0;
    #local J=2;
    #while(J<2*MJ-2)
      #local Knum = Knr[I][J];
      #if(Knum)
        #if(inedge)
          #local EH[Knum] = Vnum;
          #local EH[Vnum] = Knum;
        #else
          #local Vnum = Knum;
        #end
        #local inedge = !inedge;
      #end
      #local J=J+1;
    #end
    #local I=I+1;
  #end

  //find vertical edges
  #local J=2;
  #while(J<2*MJ-2)
    #local inedge = 0;
    #local I=2;
    #while(I<2*MI-2)
      #local Knum = Knr[I][J];
      #if(Knum)
        #if(inedge)
          #local EV[Knum] = Vnum;
          #local EV[Vnum] = Knum;
        #else
          #local Vnum = Knum;
        #end
        #local inedge = !inedge;
      #end
      #local I=I+1;
    #end
    #local J=J+1;
  #end

  //Find perimeter, starting from vertex 1 following  horizontal direction
  #local Knum = 1;
  #local Vtx[0] = Vtx0[1];
  //#debug"1"
  #local I=1; #local Vert = 0;
  #while(I<MV)
    #local Knum = (Vert ? EV[Knum] : EH[Knum]);
    #local Vtx[I] = Vtx0[Knum];
    #local I=I+1; #local Vert = !Vert;
  #end

  Vtx
#end

#macro Polyominos(Polys, Num, SH, SR)
union{
  #local I=1;
  #while(I<=Num)
    #local Vtx = MakeList(Polys, I, SR)
    object{
      RPrism(Vtx, dimension_size(Vtx, 1)-1, SH, SR)
      texture{T_Stones[mod(11+floor(StoneMax*(I-1)/Num), StoneMax)] scale 8
translate 10*rand(RS)}
      //texture{T_Stones[(mod(I,2)?16:27)] scale 8 translate 10*rand(RS)}
      //Tex((I-1)/Num)
      //texture{T_Stone21 scale 34}
    }
    #local I=I+1;
  #end
}
#end

//--------------------------The actual scene-------------------

#declare CMGray = color_map {[0.2 rgb 0.25][0.8 rgb .75]}

#declare CMBlue = color_map {
  [0.0 rgb <.1, .15, .5>]
  [0.6 rgb <.8,.8,1>]
  [.8 rgb 1]
  [1 rgb <1,1,.9>]
}

#declare Sky0 =
sphere{-y*SkyRad*.9, SkyRad
  inverse
  no_shadow
  texture{
    T_Clouds
    scale <1 .85 1> * SkyRad/10 rotate 25*y
  }
}

#declare Sky1 =
sphere {0,1 inverse
  pigment {
    function{abs(y)}
    color_map {
      CMGray
      //CMBlue
    }
  }
  finish{ambient 0.1 diffuse 0.85}
  scale SkyRad
}

#if(1)
  object{Sky0}
#else
  //background{SkyBlue}
  background{rgb .5}
  //background{rgb 0}
#end

object{Ground}

//Raw polyomino array
#declare Polys = array[6][9]
{
  {0, 0, 0, 0, 0, 0, 0, 0, 0},
  {0, 1, 1, 1, 1, 2, 2, 2, 0},
  {0, 3, 3, 3, 4, 4, 2, 7, 0},
  {0, 3, 5, 5, 6, 4, 4, 7, 0},
  {0, 5, 5, 6, 6, 6, 7, 7, 0},
  {0, 0, 0, 0, 0, 0, 0, 0, 0},
}

//#include "SqSpiral1.inc"
//#include "tetM.inc"
//#include "432.inc"
#include "penta.inc"
//#include "5432.inc"

#declare H = 2.0;
#declare R = 0.5; // 0.75;

object{
  //Polyominos(Polys, 7, H, R)
  //Polyominos(Polyomino, 2, H, R)    //SqSpiral
  //Polyominos(Polyomino100, 10, H, R)    //tetM
  //Polyominos(Polyomino1, 10, H, R)    //432
  Polyominos(Polyomino2, 18, H, R)      //penta
  //Polyominos(Polyomino4, 27, H, R)      //5432

  //rotate -x*90
  //rotate y*-90
  //translate <-2, 0, 1>
}

//-------------------------End of file-------------------------


Post a reply to this message


Attachments:
Download 'rprismdi1s.jpg' (110 KB)

Preview of image 'rprismdi1s.jpg'
rprismdi1s.jpg


 

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