// Persistence of Vision Ray Tracer Scene Description File // File: multisline.pov // Vers: 3.1 // Desc: Extends bezier splines to be created through mutiple points // Date: original lost -- recreated 8/20/01 // Auth: jre // #ifndef(HelloBezier) #include "bezier.inc" #end #declare HelloMultispline = true; #macro PlotList(lst) #declare c=0; #while ( c < dimension_size(lst,1) ) sphere { lst[c] BezRad pigment { rgb <0,1,0> } finish { phong 1 } } #if ( c > 0 ) cylinder { lst[c-1] lst[c] BezRad/3 pigment { rgb <0,0.5,0> } finish { phong 1 } } #end #declare c = c + 1; #end #end #macro MakeLongSpline(lst,ia,fa) #declare l = dimension_size(lst,1); //#render concat(str(l,0,0)," ") #declare L = l*3 - 2; //#render concat(str(L,0,0),"\n") #declare longlist = array [L] #declare longlist[0] = lst[0]; #declare len = vlength(lst[1]-lst[0]); #declare init = vnormalize(lst[1]-lst[0])*len/3; #declare init = init - (lst[2] - lst[1])*ia/3; #declare longlist[1] = longlist[0]+init; //sphere { longlist[1] 0.08 pigment { rgb <0,1,1> } } #declare cnt = 1; #while ( (cnt + 1) < l) #declare C = cnt*3; //#render concat(str(cnt,0,0) , ", " , str(C,0,0)+"\n") #declare longlist[C] = lst[cnt]; //sphere { longlist[C] 0.08 pigment { rgbf <1,1,1,0> } } #local this = lst[cnt+1] - lst[cnt-1]; //cone { <0,0,0> 0.1 this 0 pigment { rgb <1,1,0> } } #declare longlist[C-1] = longlist[C] - vnormalize(this)*vlength(lst[cnt]-lst[cnt-1])/3; //sphere { longlist[C-1] 0.08 pigment { rgb <1,0,1> } } #declare longlist[C+1] = longlist[C] + vnormalize(this)*vlength(lst[cnt]-lst[cnt+1])/3; //sphere { longlist[C-1] 0.08 pigment { rgb <0,1,1> } } #declare cnt = cnt + 1; #end #declare longlist[L-1] = lst[l-1]; #declare len = vlength(lst[l-2]-lst[l-1]); #declare init = vnormalize(lst[l-2]-lst[l-1])*len/3; #declare init = init - (lst[l-3] - lst[l-2])*fa/3; #declare longlist[L-2] = longlist[L-1]+init; //sphere { longlist[L-2] 0.08 pigment { rgb <1,0,1> } } longlist #end #macro DrawLongSpline(lst) //#local FullCurve = true; #local cnt = 0; #while ( (cnt +3)< dimension_size(lst,1)) //#render str(cnt,0,0) #local spl = array[4] { lst[cnt] lst[cnt+1] lst[cnt+2] lst[cnt+3] } //#local BezTex = texture { pigment { color rgb cnt/dimension_size(lst,1) } } DrawSpline(spl) #local cnt = cnt + 3; #end #end // 9-18-01 // Find total length of spline #macro LongSplineLength(lst) //#local FullCurve = true; #local total = 0; #local cnt = 0; #while ( (cnt +3)< dimension_size(lst,1)) //#render str(cnt,0,0) #local spl = array[4] { lst[cnt] lst[cnt+1] lst[cnt+2] lst[cnt+3] } #local total = total + SplineLength2(spl); #local cnt = cnt + 3; #end #debug concat("\nLength is ", str(total,6,6)) total #end // SplineLength returns a rough estimate of the length of the spline #macro SplineLength2(id) #local c = 0; #local len = 0; #while ( c < 1 ) #local temp = ReturnPosition(id,c); #local next = ReturnPosition(id,(c + 0.05)); #local len = len + vlength(next-temp); #local c = c + 0.05; #end len #end // Given the length of the spline, create an array of the progressive lengths\ // tlen is the total length of spline #macro FractionalLengths(lspl,total2) #local L = dimension_size(lspl,1); //#render str(L,5,5) #local n = (L+2)/3; //#render str(n,5,5) #local flen = array[n] #local flen[0] = 0; //#local flen[n-1] = 1; #local onshort = 0; #local rlen = 0; // running length //#render concat("\nTotal length is : " + str(total2,5,5) + "\n") #while ( onshort+1 < n ) //#render concat("\nTotal length is : " + str(total2,5,5) + "\n") #local onlong = onshort*3; #local sspl = array[4] { lspl[onlong] lspl[onlong+1] lspl[onlong+2] lspl[onlong+3] } #local thislength = SplineLength2(sspl); #local rlen = rlen + thislength; #local thisfrac = rlen/total2; //#render concat("\nNode " + str(onshort+1,4,0) + "\tRunning length:" + str(rlen,5,5)) //#render concat("\tFractonal Length:" + str(thisfrac,5,5) + "\tTotal Length:" + str(total2,5,5)) //#render concat("\nTotal length is : " + str(total2,5,5) + "\n") #local flen[onshort+1] = thisfrac; #local onshort = onshort + 1; #end flen #end #macro PositionOnLongSpline(lspl,stps,pos) #local sp = 0; #while ( pos > stps[sp]) #local sp = sp + 1; #end #if ( pos = 0 ) #local sp = 1; #end #debug concat("\nPosition " , str(pos,4,4) , " on subspline ", str(sp,2,2)) #local localpos = (pos-stps[sp-1])/(stps[sp]-stps[sp-1]); //#render concat(" Local Position : " + str(localpos,4,4)) #local onlong = (sp-1)*3; #local sspl = array[4] { lspl[onlong] lspl[onlong+1] lspl[onlong+2] lspl[onlong+3] } #local here = ReturnPosition(sspl,localpos); here #end #macro MoveString(Spl,vct) #local lim = dimension_size(Spl,1); #local tempstring = array [lim ] #declare tcnt = 0; #while ( tcnt < lim) #local tempstring[tcnt] = Spl[tcnt] + vct; #declare tcnt = tcnt + 1; #end tempstring #end #macro ConnectLongSplines(id1,id2,st1,st2) mesh { #local c = 0; #while ( c < 0.999 ) #local p1 = PositionOnLongSpline(id1,st1,c); #local p2 = PositionOnLongSpline(id1,st1,(c+1/NumberofPoints)); #local p3 = PositionOnLongSpline(id2,st2,c); #local p4 = PositionOnLongSpline(id2,st2,(c+1/NumberofPoints)); triangle { p1,p2,p3 } triangle { p2,p4,p3 } #declare c = c + (1/NumberofPoints); #end texture { BezTex } } // end mesh #end