POV-Ray : Newsgroups : povray.text.scene-files : Soma Cubes Server Time
31 Oct 2024 21:27:46 EDT (-0400)
  Soma Cubes (Message 1 to 2 of 2)  
From: PM 2Ring
Subject: Soma Cubes
Date: 11 May 2006 02:50:01
Message: <web.4462ddc58a973e5876ba2c900@news.povray.org>
Here is a basic scene file and an attached include files to make Soma Cube
shapes. See the thread in p.b.i for example images.

// Persistence of Vision Ray Tracer Scene Description File
// File: SomaG.pov
// Vers: 3.5
// Desc: Piet Hein's Soma Cube
// Date: 2005-11-09
// Auth: PM 2Ring
//
// -d +A0.2 +AM2 +R4
// -F -A0.4 +AM2 +R1
//
// -A0.3 +AM2 +R2 +KFF24 -F
//
// Render as anim to get shapes 1 to 24
// Render as single frame to get shape 0
//

global_settings {
  assumed_gamma 1
  //max_trace_level 7
}

#declare Reflect = 0.85;

#declare WorldRad = 640;

#declare CamLoc = <0, 5.25, -7> * 6.25;
//#declare CamLoc = <0, 4, -5> * 6;

camera {
  location CamLoc
  right x*image_width/image_height up y
  direction z
  angle 30
  look_at  y
}

light_source {
  <-0.75, 5, -3> * 12
  //rgb 1
  rgb 50 fade_distance 6 fade_power 2
}

light_source {CamLoc rgb .20}

//---Textures--------------------------------------------------------------

//Conway's colours for the Soma pieces
//Brown=B=1; Yellow=Y=2; Green=G=3; Orange=O=4; blUe=U=5; Red=R=6;
blAck=A=7.

//Taken/modified from "colors.inc"
#declare DarkBrown = rgb <0.36, 0.25, 0.20>;
#declare Yellow  = rgb <1,1,0>;
#declare Green   = rgb <0, 1, 0>;
#declare Orange  = rgb <1, 0.5, 0>;
#declare Red     = rgb <1, 0, 0>;
#declare Blue    = rgb <0, 0, 1>;
#declare Black   = rgb .075;
#declare White   = rgb .95;

#declare Pigments = array[8]
{
  White, DarkBrown, Yellow, Green, Orange, Blue, Red, Black
}

//For sky
#declare CMGray0 = color_map {[0.2 rgb 0.25][0.8 rgb .75]}

//For ground
#declare CMGray1 = color_map {[0 rgb .70][1 rgb 1.0]}

//Block finish
#declare FShiny =
finish{
  ambient 0.075
  specular .75 roughness 3e-4
  phong .5 phong_size 5
  reflection .1*Reflect diffuse .8
}

#declare TGround =
texture{
  pigment{granite scale 75 colour_map{CMGray1}}
  finish{
    ambient 0.175
    specular .75 roughness 3e-4
    reflection .15*Reflect diffuse .8
  }
}

#declare TSky =
texture{
  pigment {
    function{abs(y)}
    color_map{CMGray0}
  }
  finish{ambient 0.1 diffuse 0.85}
}

//---Macros-------------------------------------------

//Rounded unit cube
#declare Round = 0.2;
#macro Cube(V) superellipsoid{<Round, Round> scale .5+Round/4 translate
V+.5} #end

//Build figure from 3D array data
#macro MakeShape(A)
  #local MI = dimension_size(A,1);
  #local MJ = dimension_size(A,2);
  #local MK = dimension_size(A,3);

  union{
    #local I=0;
    #while(I<MI)
      #local J=0;
      #while(J<MJ)
        #local K=0;
        #while(K<MK)
          #local N=A[I][J][K];
          #if(N>0)
            object{
              Cube(<K, MJ-1-J, MI-1-I>)
              //Cube(<MK-1-K, MJ-1-J, I>)
              pigment{Pigments[N]}
              finish{FShiny}
            }
          #end
          #local K=K+1;
        #end
        #local J=J+1;
      #end
      #local I=I+1;
    #end

    translate -0.5*<MK, 0, MI>
    #declare Size = max(MI, MJ, MK);
  }
#end

//--------------------------The objects-------------------

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

#declare Sky =
sphere {0,1 inverse
  texture{TSky}
  scale WorldRad
}

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

#if(1)
  object{Sky}
#else
  background{rgb 0.75}
#end

object{Ground}

//Soma figures
#include "Soma2.inc"

#declare Shapes = Soma2;

object{
  MakeShape(Shapes[frame_number])

  rotate -25*y
  scale 10/Size
  //translate -z*3
}

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


Post a reply to this message


Attachments:
Download 'soma2.inc.txt' (9 KB)

From: PM 2Ring
Subject: Re: Soma Cubes
Date: 11 May 2006 03:00:00
Message: <web.4462e017159d182676ba2c900@news.povray.org>
Here is the include files to make the basic Soma shapes.


Post a reply to this message


Attachments:
Download 'soma0.inc.txt' (1 KB)

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