// Persistence of Vision Ray Tracer Scene Description File // File: lathe.pov // Vers: 3.5 // Desc: // Date: // Auth: Ingo Janssen #version 3.5; #macro BuildWriteMesh2(VecArr, NormArr, UVArr, U, V, FileName) #if(strlen(FileName)!=0) #local Write=1; #debug concat("\n\n Building mesh2 & Writing : '",FileName,"'\n - vertex_vectors\n") #fopen MeshFile FileName write #write( MeshFile, "#declare Surface = mesh2 {\n" ) #else #local Write=0; #debug concat("\n\n Building mesh2: \n - vertex_vectors\n") #end #local NumVertices=dimension_size(VecArr,1); #if(Write) #write( MeshFile, " vertex_vectors {\n", " ", NumVertices,"\n " ) #end mesh2 { vertex_vectors { NumVertices #local I=0; #while (I, #if(Write) #write(MeshFile,, ) #end #local J=J+1; #local H=H+1; #if(Write) #if(mod(H,5)=0) #write(MeshFile,"\n ") #end #end #end #local I=I+1; #end } #if(Write) #write(MeshFile, "\n }\n}") #fclose MeshFile #debug concat(" Done writing\n") #end } #end // Build a spline from an array with vectors. // Arr: vector array // SplType: typ e of spline to build #macro BuildSpline(Arr, SplType) #local N=dimension_size(Arr,1); #local Asc=asc(strupr(SplType)); #if(Asc!=67 & Asc!=76 & Asc!=81) #local Asc=76; #debug "\nWrong spline type defined (C/L/Q), using default linear_spline\n" #end spline { #switch (Asc) #case (67) //C cubic_spline #break #case (76) //L linear_spline // Extend the linear spline by one point #local Start=Arr[0]; // at the start and end of the spline, #local End=Arr[N-1]; // pick the points depending on whether #if(Start.x=End.x & Start.y=End.y & Start.z=End.z) // the spline is closed or not. #local First=Arr[N-2]; // The extra points are there to make sure #local Last=Arr[1]; // that one can step through the spline just #else // like with other splines. #local First=(Start-Arr[1])+Start; #local Last=(End-Arr[N-2])+End; #end #local N=N+2; #local Arr1=array[N] #local I=0; #while (I #local I=I+1; #local J=J+Add; #end } #end // Build a two-dimensional array with vectors and normals retrieved from a spline // Spl: spline to get the vectors and normals from // SplType: the type of spline // ResSpl: the amount of vectors to get from the spline #macro L_GetVN(Spl, SplType, ResSpl) #local Asc=asc(strupr(SplType)); #if(Asc!=67 & Asc!=76 & Asc!=81) #local Asc=76; #debug "\nWrong spline type defined (C/L/Q), using default linear_spline\n" #end #local I=0; #local A=array[ResSpl+1][2] #while (I<=ResSpl) #local P0=0+Spl(I/ResSpl); #if (P0.x=0 & P0.z=0) #local P0=<1e-25,P0.y,1e-25>; #end #if (I=0) #local P1=0+Spl(((I-0.5)/ResSpl)); #local P2=0+Spl(((I+0.5)/ResSpl)); #else #local P1=P2; #local P2=0+Spl(((I+0.5)/ResSpl)); #end #local P3=vrotate(P0,<0,1,0>); #local P4=vrotate(P0,<0,-1,0>); #local B1=P4-P0; #local B2=P2-P0; #local B3=P3-P0; #local B4=P1-P0; #local N1=vcross(B1,B2); #local N2=vcross(B2,B3); #local N3=vcross(B3,B4); #local N4=vcross(B4,B1); #local N=vnormalize((N1+N2+N3+N4)*-1); #local A[I][0]=P0; #local A[I][1]=N; #local I=I+1; #end A #end #macro Lathe (SplArr, SplType, Rot, ResRot, ResSpl, FileName) #if(strlen(FileName)>0) #if(file_exists(FileName)) #debug concat("\n Parsing mesh2 from file: ", FileName, "\n") #local Build=0; #include FileName object{Surface} #else #local Build=1; #end #else #local Build=1; #end #if(Build=1) #local Spl=BuildSpline(SplArr, SplType) #declare VNArr=L_GetVN (Spl, SplType, ResSpl) #local VecArr=array[(ResRot+1)*(ResSpl+1)] #local NormArr=array[(ResRot+1)*(ResSpl+1)] #local UVArr=array[(ResRot+1)*(ResSpl+1)] #local R=Rot/ResRot; #local Dim=dimension_size(VNArr,1); #local Count=0; #local I=0; #while (I<=ResRot) #local J=0; #while (J); #local NormArr[Count]=vrotate(VNArr[J][1],<0,R*I,0>); #local UVArr[Count]=; #local J=J+1; #local Count=Count+1; #end #local I=I+1; #end BuildWriteMesh2(VecArr, NormArr, UVArr, ResSpl, ResRot, FileName) #end #end //=================================SceneSection==== global_settings {assumed_gamma 1.0} camera {location <0,2,-5.5> look_at <0,2,0>} light_source {<500,500,-500> rgb <0.8,0.9,1>} light_source {<-10,3,0> rgb <1,1,0.8>} #declare A1=array[12]{ <-1.5,0,0> <0,0,0> <0.9,0,0> <1,0,0> <0.8,0.05,0> <0.2,0.1,0> <0.05,1,0> <0.15,1.7,0> <0.7,2,0> <1.5,3,0> <1,4,0> <0,5,0> } #declare MSH=Lathe(A1, "c", -250, 100, 100, "") object {MSH uv_mapping pigment{checker color rgb 1 color rgb 0 scale 0.025} } /*#declare I=0; #while(I}} #declare I=I+1; #end*/