// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 // Copyright 2001-2003 by Tor Olav Kristensen // Email: t o r . o l a v . k [_A_T_] g m a i l . c o m // http://subcube.com // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 #version 3.5; #include "colors.inc" global_settings { radiosity { recursion_limit 4 brightness 1.4 normal on error_bound 0.2 pretrace_start 0.08 pretrace_end 0.002 } } #declare Nihil = 1e-5; // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 #macro Tilt_Trans(vTilt) #local v0 = vnormalize(vTilt); #local X = v0.x; #local Y = v0.y; #local Z = v0.z; #if (abs(Y) = 1) #if (Y = 1) #local Transform = transform { } #else #local Transform = transform { rotate 180*z } #end // if #else #local T = (Y - 1)/(X*X + Z*Z); #local Transform = transform { matrix } #end // if transform { Transform } #end // macro Tilt_Trans #macro CosSin(AA, BB, CC) #local Cos = (AA*AA + BB*BB - CC*CC)/(2*AA*BB); #local Sin = sqrt(1 - Cos*Cos); #end // macro CosSin #macro ExCircle(AA, BB, CC) #local vCS = CosSin(AA, BB, CC); (/2) #end // macro ExCircle #macro CirclesTouch(Type, R1, R2, R3, Dist, pCirIntSct, pCtr3, pTouch13, pTouch23, pCtr45, Rad45) #switch (Type) #case (1) #local Ra = R1 + R3; #local Rc = R2 + R3; #break // case #case (2) #local Ra = R1 - R3; #local Rc = R2 - R3; #break // case #case (3) #local Ra = R1 + R3; #local Rc = R2 - R3; #break // case #case (4) #local Ra = R1 - R3; #local Rc = R2 + R3; #break // case #else #error "Macro CirclesTouch: Wrong Type number given." #end // switch #local vABC = CosSin(Ra, Dist, Rc); #local vRBR = CosSin(R1, Dist, R2); //#local pCtr1 = <0, 0>; #local pCtr2 = ; #declare pCtr3 = Ra*vABC; #declare pCirIntSct = R1*vRBR; #declare pTouch13 = R1*vABC; #declare pTouch23 = pCtr2 + R2/Rc*(pCtr3 - pCtr2); #local vDir = ExCircle( vlength(pCirIntSct - pTouch13), vlength(pTouch23 - pCirIntSct), vlength(pTouch13 - pTouch23) ); #local pMid = (pTouch13 + pCirIntSct)/2; #local vCtr = vDir.v*vnormalize( - ); #switch (Type) #range (1, 2) #declare pCtr45 = pMid + vCtr; #break #range (3, 4) #declare pCtr45 = pMid - vCtr; #break #end // switch #declare Rad45 = vlength(vDir); #end // macro CirclesTouch #macro CSG_Select(Type, MainObject1, MainObject2, SmallObject, MatObject) intersection { object { MatObject } object { SmallObject inverse } #switch (Type) #case (1) object { MainObject1 inverse } object { MainObject2 inverse } #break #case (2) object { MainObject1 } object { MainObject2 } #break #case (3) object { MainObject1 inverse } object { MainObject2 } #break #case (4) object { MainObject1 } object { MainObject2 inverse } #break #else #debug "Macro CSG_Select: Wrong Type number given." #end // switch } #end // macro CSG_Select #macro BetweenTori(Type, Outer, Rmin1, Rmaj1, pCtr1, Rmin2, Rmaj2, pCtr2, Rmin3, Rmaj3, pCtr3) #local vD = pCtr2 - pCtr1; #local DD = vlength(vD); #local vF = vnormalize(vD); #local RR = Rmaj2 - Rmaj1; #local EE = vlength(); #local SS = DD/EE; #local RR = RR/EE; #local p2Isect = <0, 0>; // Dummy #local p2Ctr3 = <0, 0>; #local p2Touch1 = <0, 0>; // Dummy #local p2Touch2 = <0, 0>; // Dummy #local p2CtrM = <0, 0>; #local RM = 0; CirclesTouch( Type, Rmin1, Rmin2, Rmin3, EE, p2Isect, p2Ctr3, p2Touch1, p2Touch2, p2CtrM, RM ) #local Sign = (Outer ? 1 : -1); #local pCtrM = vdot(p2CtrM, )*y; #local RmajM = vdot(p2CtrM, ) + Rmaj1; #declare pCtr3 = vdot(p2Ctr3, )*y; #declare Rmaj3 = vdot(p2Ctr3, ) + Rmaj1; #if (Rmaj1 = 0) #local Obj1 = sphere { 0*y, Rmin1 } #else #local Obj1 = torus { Rmaj1, Rmin1 } #end // if #if (Rmaj2 = 0) #local Obj2 = sphere { DD*y, Rmin2 } #else #local Obj2 = torus { Rmaj2, Rmin2 translate DD*y } #end // if #if (Rmaj3 = 0) #local Obj3 = sphere { pCtr3, Rmin3 } #else #local Obj3 = torus { Rmaj3, Rmin3 translate pCtr3 } #end // if #if (RmajM = 0) #local ObjM = sphere { pCtrM, RM } #else #local ObjM = torus { RmajM, RM translate pCtrM } #end // if object { CSG_Select(Type, Obj1, Obj2, Obj3, ObjM) Tilt_Trans(vF) translate pCtr1 } #end // macro BetweenTori // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 #declare Smaller = 1 - Nihil; #declare Bigger = 1 + Nihil; #macro MakeSpoke(pCtr1, Rad1, pCtr2, Rad2, Rstem, RadF) #local pCtrT = (Rad1 + Rad2)/2*y; #local pCtrT = pCtrT + 1.3*y; // #local RmajT = 8.0; // #local RminT = RmajT - Rstem; #local pCtrM = <0, 0, 0>; // Dummy #local RadM = 0; // Dummy union { intersection { sphere { pCtr1, Rad1 } sphere { pCtr2, Rad2 inverse } torus { RmajT, RminT*Smaller inverse translate pCtrT } plane { -y, 0 } } BetweenTori( 2, false, Rad1, 0, pCtr1, RminT, RmajT, pCtrT, RadF, RadM, pCtrM ) BetweenTori( 3, false, Rad2, 0, pCtr2, RminT, RmajT, pCtrT, RadF, RadM, pCtrM ) } #end // macro MakeSpoke // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 #declare pCenter1 = 2*y; #declare Radius1 = 3.0; #declare pCenter2 = 0*y; #declare Radius2 = 3.0; #declare FilletRadius = 0.5; #declare StemRadius = 0.6; #declare Stem = MakeSpoke(pCenter1, Radius1, pCenter2, Radius2, StemRadius, FilletRadius) #declare pCenter3 = 4*y; #declare Radius3 = 2.6; #declare pCenterM = <0, 0, 0>; // Dummy #declare RadiusM = 0; // Dummy #declare Hat = difference { sphere { pCenter3, Radius3*Smaller } sphere { pCenter1, Radius1*Bigger } BetweenTori( 3, true, Radius1, 0, pCenter1, Radius3, 0, pCenter3, FilletRadius, RadiusM, pCenterM ) } #declare Fung = union { object { Hat } object { Stem } } #declare PtsInCube = 4; // 8; #declare Cube = array[PtsInCube] { < 1, 1, 1>, <-1, 1, 1>, <-1, 1, -1>, < 1, 1, -1> }; #declare AllFungs = union { #declare Cnt = 0; #while (Cnt < PtsInCube) object { Fung Tilt_Trans(Cube[Cnt]) } #declare Cnt = Cnt + 1; #end // while } #declare Mushy = union { object { AllFungs } object { AllFungs scale <1, -1, 1> rotate 45*y } sphere { pCenter2, Radius2 } } object { Mushy texture { pigment { bozo color_map { [ 0 color White*0.7 ] [ 1 color White*1.3 ] } } normal { agate 0.8 scale <3, 3, 3> } finish { ambient color -0.3*White diffuse 0.8 specular 0.1 roughness 0.1 metallic brilliance 1 } scale <1, 1, 1>*0.5 } } // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 sky_sphere { pigment { gradient y color_map { [ 0 color White ] [ 1 color rgb <0.22, 0.41, 0.79> ] } } } camera { location <14.2, 9.0, -14.2> look_at <0, 0, 0> angle 47 } light_source { <-1, 6, 1>*200 color rgb <0.95, 0.78, 0.42> area_light 100*x 100*z, 5, 5 jitter orient } // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10