// Persistence of Vision Ray Tracer Scene Description File // File: anemone.pov // Vers: 3.6 // Desc: A demo of a sea anemone macro // Date: 6/26/2007 // Auth: Tim Attwood // #version 3.6; #include "colors.inc" #include "rand.inc" #include "finish.inc" global_settings { assumed_gamma 1.0 max_trace_level 99 } // --- camera, lights & background ------------------------------------------ camera { location <0.0, 0.5, -4.0> direction 1.5*z right x*image_width/image_height look_at <0.0, 0.0, 0.0> } background {White} 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 { <-30, 30, -30> color rgb <1, 1, 1> area_light <5, 0, 0>, <0, 0, 5>, 5, 5 adaptive 1 jitter fade_distance 20 fade_power 1 } fog { distance 50 MidnightBlue turbulence 0.2 turb_depth 0.3 } // --- macros --------------------------------------------------------------- // usage: Object, random stream, float // Obj is the object to find a surface point on // rsd is a random stream // thresh is the theshold distance // smaller thresh numbers result in a more even random distribution #macro RandOnSurface(Obj, rsd, thresh) #local mn = min_extent(Obj)-thresh; #local mx = max_extent(Obj)+thresh; #local dist = 1000000; #while (dist>thresh) #local flag = 0; #while (flag = 0) #local rfrom = VRand_In_Box(mn, mx, rsd); #local rdir = VRand_On_Sphere(rsd); #declare Norm = <0, 0, 0>; #local hit = trace(Obj, rfrom, rdir, Norm); #if (vlength(Norm) != 0) #local flag = 1; #end #end #local dist = vlength( hit - rfrom); #end #local result = hit; (result) #end // usage: Object, Object, int // A, and B are the objects to check for collision // rez is the number of points to check // higher rez numbers result in fewer missed collisions #macro collision(A, B, rez) #local result = false; #if (((min_extent(A).x > max_extent(B).x ) | (min_extent(B).x > max_extent(A).x ) | (min_extent(A).y > max_extent(B).y ) | (min_extent(B).y > max_extent(A).y ) | (min_extent(A).z > max_extent(B).z ) | (min_extent(B).z > max_extent(A).z ))=false) #local AB = intersection{object{A} object{B}}; #local Mn = min_extent(AB); #local Mx = max_extent(AB); #local S1 = seed(1); #local Pt = VRand_In_Box(Mn, Mx, S1); #local cnt = 0; #while ((result = false) & (cnt < rez)) #local Pt = VRand_In_Box(Mn, Mx, S1); #if (inside(AB, Pt)) #local result = true; #end #local cnt = cnt + 1; #end #end result #end // usage: vector, vector, float, int, float, float, random stream // LOC is location of base // DIR is direction and magnitude of growth // A is the limit for a random angle of each segment // N is the number of segments // R1 is the base radius // R2 is the tip radius // rsd is a random stream to use #macro Tentacle(LOC, DIR, A, N, R1, R2, rsd) #local c = 0; #local loc = LOC; #local dir = DIR; blob { #while (c < 1 ) #local rad = R1*(1-c)+R2*c; #local dx = rand(rsd)*A*2-A; #local dy = rand(rsd)*A*2-A; #local dz = rand(rsd)*A*2-A; #local dir = vrotate(dir,); sphere {loc, rad, 1} #ifdef (lastloc) cylinder {lastloc, loc, rad, 1} #end #local lastloc = loc; #local lastrad = rad; #local loc = loc+dir; #local c = c+(1/N); #end } #end // usage: Object, int, random stream, float, float, int, float, float, int // Obj is the base object to grow tentacles from // Number is the number of tentacles // rsd is a random stream // D is the magnitude of the direction segement steps // A is the limit for a random angle of each segment // Seg is the number of segments // R1 is the base radius // R2 is the tip radius // tol is the number of failed attempts before exiting early #macro Random_Tenacles(Obj, Number, rsd, D, A, Seg, R1, R2, tol) #debug "Creating tentacles...\n" #local c = 0; #local Fail = false; #local TA = array[Number]; #while ((c(tol-1)) #local Fail = true; #end #local c = c+1; #end #end // warn on fail #if (Fail=true) #local tnum = c-1; #warning concat("Only ",str(tnum,-1,0)," tentacles created.") #else #local tnum = Number; #end // make tentacles #local c = 0; #while (c, <0.000000,0.009206>, <0.414277,0.009206>, <0.575384,0.009206>, <0.851569,0.009206>, <0.759507,0.147298>, <0.736492,0.285391>, <0.713477,0.377452>, <0.667446,0.469514>, <0.644430,0.607606>, <0.667446,0.722683>, <0.759507,0.837760>, <0.736492,0.952836>, <0.598400,0.998867>, <0.460307,0.929821>, <0.391261,0.699667>, <0.276184,0.676652>, <0.115077,0.791729>, <0.000000,0.699667>, <0.000000,0.584590> }; #declare ring = object { anemone_base clipped_by {cone {<0,-1,0>,1.4,<0,1,0>,0.65 inverse}} translate <0,-1,0> }; // --- scene ---------------------------------------------------------------- plane {y,-1 texture {ground_tex} } object {anemone_base texture {base_tex} translate <0,-1,0> } #declare S = seed(2); union { Random_Tenacles(ring, 60, S, 0.05, 7.5, 25, 0.1, 0.05, 15) texture {tent_tex} } #include "screen.inc" #declare Name = height_field { tga "name.tga" smooth water_level 0.05 texture { metal } scale <1,0.05,1/5> rotate <-90,0,0> scale <0.4,0.4,0.25> }; Set_Camera(<0.0, 0.5, -4.0>, <0,0,0>, 67.3) // set location, look_at and angle Set_Camera_Aspect(image_width,image_height) // set width in relation to height Set_Camera_Sky(<0,1,0>) // set the sky vector Screen_Object ( Name, <0,1>, <0.02,0.02>, true, 0.001 ) // http://news.povray.org/povray.binaries.images/thread/%3C4682017b%40news.povray.org%3E/