// Persistence of Vision Ray Tracer Scene Description File // File: isotest.pov // Vers: 3.5 // Desc: Simple morphing using Isosurface // Date: 10-5-04 // Auth: Nicolas Alvarez, Smooth formula by Ian Witham #include "colors.inc" #include "functions.inc" camera { location <1.5, 2, -3> look_at 0 angle 60 } sky_sphere { pigment { gradient y color_map { [0.0 rgb <0.6,0.7,1.0>] [0.7 rgb <0.0,0.1,0.8>] } } } light_source { <-100, 213.886, -204.386> color rgb 3/4 } light_source { <206.254, 154.169, -124.354> color rgb 1/4 } plane { y, -(1-(1e-3)) texture { pigment { checker color White color Blue } finish { diffuse 0.8 ambient 0.1 } } } /* Usage: function { Linear_morph | Smooth_morph (Stren, fnA(x,y,z), fnB(x,y,z)) } Stren is a value going from 0 to 1, usually clock. Example: Smooth_morph(clock, f_torus(x,y,z, 1/2, 1/4) , f_sphere(x,y,z, 1/2) ) */ //Morph: #declare Linear_morph = function(Stren,A,B) { A*(1-Stren) + B*Stren } #declare Smooth_morph = function(Stren,A,B) { A*((cos(Stren*pi)+1)/2) + B*(1-(cos(Stren*pi)+1)/2) } //CSG: #declare Merge = function(A,B) { min(A, B) } #declare Intersection = function(A,B) { max(A, B) } #declare Difference = function(A,B) { max(A,-B) } #declare Blob = function(A,B,Blob_threshold) { (1+Blob_threshold) -pow(Blob_threshold, A) -pow(Blob_threshold, B) } //Shapes: #declare Box = function(x,y,z,X1,Y1,Z1,X2,Y2,Z2) { Intersection ( Intersection ( Intersection ( +(x+X1), -(x+X2) ), Intersection ( +(y+Y1), -(y+Y2) ) ), Intersection ( +(z+Z1), -(z+Z2) ) ) } //End functions #declare Size=<1.5,1,1.5>; #declare V1=-<0.5, 0, 0.5>*Size-y; #declare V2= <0.5, 1, 0.5>*Size; isosurface { function { Smooth_morph(clock, Box ( x*2,y*2,z*2, -1,-1,-1, +1,+1,+1 ), f_sphere(x, y, z, 2/3) ) } contained_by { box { V1, V2 } } accuracy 0.01 // accuracy of calculation [0.001] //evaluate 3, 1.2, 0.95 max_gradient 1.7 pigment { color (Green*1.25)*(1-clock) + (Orange*1.5)*clock } finish { phong 0.3 ambient 0.2 diffuse 0.7 } } #if (1) #include "shapes.inc" object { Wire_Box_Union(V1, V2, 1/50) pigment { color Red } finish { phong 0.1 ambient 0.5 diffuse 0.7 } } #end