// Persistence Of Vision raytracer version 3.6 include file. // File by Burkhard Reike // Last updated: 2010.9.11 // Description: // Macros for convenient generation of movie frames from an image sequence, // providing smooth frame rate conversion. /* Example: // Mandatory: IS_SetName(Is,"pac") // The string before the index of the source images. IS_SetFirstIndex(Is,1) // The first index of the source images. IS_SetLastIndex(Is,1) // The last index of the source images. IS_SetDigits(Is,5) // The number of digits in the source image names. IS_SetType(Is,"jpeg") // The bitmap type of the source images (as string), eg. "gif" , "tga", "iff", // "ppm", "pgm", "png", "jpeg", "tiff", "sys" IS_SetExtension(Is,".jpg") // The file extension of the source images. IS_SetWidth(Is,640) // The width of the source images (in pixels). Default is image_width. IS_SetHeight(Is,480) // The height of the source images (in pixels). Default is image_height. IS_SetSourceFPS(Is,200) // The frame rate associated with the source images, eg. 15, 30, 50, 200... IS_SetTargetFPS(Is,30) // The frame rate by which this scene will be rendered. // Optional: IS_SetBlendedImages(Is,Num) // The mean number of source images blended into each target image. // By default, this value is equal to SourceFPS/TargetFPS. For example, if // the frame rate of the source images is 30 and the target frame rate // is 20, then the mean number of source images blended into one target image // is 30/20 = 1.5. // By chosing a higher value than the default, more images will be blended // into each target image, making the rendered images look more motion-blurred. // If you choose 0 for this value, no blending will occur; each target // image will consist of exactly one source image rather than a mix // of several source images. // This setting doesn't affect the target frame rate, just the // blurriness of the generated images. // This value must not be greater than 250. IS_SetOnce(Is,1) // Let the image be displayed only once. // Default is 0, ie. the image is repeated infinitely. IS_SetWidth(Is,640) // The width of the source images (in pixels). Default is image_width. IS_SetHeight(Is,480) // The height of the source images (in pixels). Default is image_height. IS_Pigment(Is,Time) // A pigment that displays the image sequence frame at time "Time" (in seconds). IS_StandardPigment(Is,Time) // Like IS_Pigment, but scaled to match the images' width and height. IS_StandardBox(Is,Time) // A box that displays IS_StandardPigment(Is,Time). IS_StandardCamera() // A suitable orthographic camera to display the image sequence pigment. */ #macro IS_CreateImageSequence() array[12]{array[1],array[1],array[1],array[1],array[1],array[1],array[1],array[1],array[1]{-1},array[1]{-1},array[1]{-1},array[1]{0}} #end #macro IS_SetFirstIndex(F,X) #declare F[0][0]=X; #end #macro IS_GetFirstIndex(F) F[0][0] #end #macro IS_SetLastIndex(F,X) #declare F[1][0]=X; #end #macro IS_GetLastIndex(F) F[1][0] #end #macro IS_SetDigits(F,X) #declare F[2][0]=X; #end #macro IS_GetDigits(F) F[2][0] #end #macro IS_SetType(F,X) #declare F[3][0]=X; #end #macro IS_GetType(F) F[3][0] #end #macro IS_SetName(F,X) #declare F[4][0]=X; #end #macro IS_GetName(F) F[4][0] #end #macro IS_SetExtension(F,X) #declare F[5][0]=X; #end #macro IS_GetExtension(F) F[5][0] #end #macro IS_SetSourceFPS(F,X) #declare F[6][0]=X; #end #macro IS_GetSourceFPS(F) F[6][0] #end #macro IS_SetTargetFPS(F,X) #declare F[7][0]=X; #end #macro IS_GetTargetFPS(F) F[7][0] #end #macro IS_SetWidth(F,X) #declare F[8][0]=X; #end #macro IS_GetWidth(F) #local Res=F[8][0]; #if(Res<0) #local Res = image_width; #end Res #end #macro IS_SetHeight(F,X) #declare F[9][0]=X; #end #macro IS_GetHeight(F) #local Res=F[9][0]; #if(Res<0) #local Res = image_height; #end Res #end #macro IS_SetBlendedImages(F,X) #declare F[10][0]=X; #end #macro IS_GetBlendedImages(F) #local Res=F[10][0]; #if(Res<0) #local Res = IS_GetSourceFPS(F)/IS_GetTargetFPS(F); #end Res #end #macro IS_SetOnce(F,X) #declare F[11][0]=X; #end #macro IS_GetOnce(F) F[11][0] #end #macro IS_GetImageType(IS_Str) #if(strcmp(IS_Str,"jpeg")=0) jpeg #else #if(strcmp(IS_Str,"png")=0) png #else #if(strcmp(IS_Str,"ppm")=0) ppm #else #if(strcmp(IS_Str,"gif")=0) gif #else #if(strcmp(IS_Str,"tga")=0) tga #else #if(strcmp(IS_Str,"iff")=0) iff #else #if(strcmp(IS_Str,"pgm")=0) pgm #else #if(strcmp(IS_Str,"sys")=0) sys #else #error concat("Unknown Bitmap Type: ",IS_Str,"\n") #end #end #end #end #end #end #end #end #end #macro IS_OnceString(F) #local Once=IS_GetOnce(F); #if(Once>0) once #end #end #macro IS_ImageMap(F,IFrame,Weight) #local Frame=IFrame; #local MaxFrame = IS_GetLastIndex(F)-IS_GetFirstIndex(F); #if(Frame>MaxFrame) #local Frame=MaxFrame; #end #if(Frame<0) #local Frame=0; #end #if(Weight>0.0) #local FullName = concat(IS_GetName(F),str(Frame+IS_GetFirstIndex(F),-IS_GetDigits(F),0),IS_GetExtension(F)); //#debug concat("[",str(Weight,0,3), " image_map ",IS_GetType(F)," ", FullName , " map_type 0]\n") [Weight image_map { IS_GetImageType(IS_GetType(F)) FullName IS_OnceString(F) map_type 0} ] #end #end #macro IS_Pigment(F,IClock) #local BFrames = IS_GetBlendedImages(F); #local SrcFps = IS_GetSourceFPS(F); #local AnimEnd = (IS_GetLastIndex(F)-IS_GetFirstIndex(F)+1)/SrcFps; #local DfTgtFrameLength = 1/IS_GetTargetFPS(F); #local Clock=IClock; #if(Clock>AnimEnd) #local Clock=AnimEnd; #end #debug concat("\nImage sequence ",IS_GetName(F),"\n") #debug concat("Clock: ",str(IClock,0,3),"\n") #debug concat("AnimEnd: ",str(AnimEnd,0,3),"\n") #debug concat("SourceFPS: ",str(IS_GetSourceFPS(F),0,3),"\n") #debug concat("TargetFPS: ",str(IS_GetTargetFPS(F),0,3),"\n") #if(BFrames<=0) #local Pig = pigment { average pigment_map { IS_ImageMap(F,floor(Clock*IS_GetSourceFPS(F)),1) } } #debug concat("BlendedImages: 0\n\n") #else #local TgtFrameLength = BFrames/SrcFps; #local SrcFrameBegin = SrcFps*Clock*(AnimEnd-TgtFrameLength)/AnimEnd; #local SrcFrameEnd = SrcFrameBegin+TgtFrameLength*SrcFps; #local PostFrame = floor(SrcFrameEnd); #local EndFrame = PostFrame-1; #if(PostFrame=SrcFrameEnd) #local PostFrame = EndFrame; #local PostWeight=0; #else #local PostWeight = SrcFrameEnd-PostFrame; #end #local PreFrame = floor(SrcFrameBegin); #if(PreFrame=SrcFrameBegin) #local StartFrame = PreFrame; #local PreWeight = 0; #else #local StartFrame = PreFrame+1; #local PreWeight = StartFrame-SrcFrameBegin; #end #debug concat("BlendedImages: ",str(BFrames,0,6),"\n\n") #local Pig = pigment { average pigment_map { IS_ImageMap(F,PreFrame,PreWeight) IS_ImageMap(F,PostFrame,PostWeight) #local I = StartFrame; #while(I<=EndFrame) IS_ImageMap(F,I,1) #local I=I+1; #end } } #end Pig #end #macro IS_StandardPigment(F,Clock) #local Pigm = pigment { IS_Pigment(F,Clock) #local Ratio = IS_GetWidth(F)/IS_GetHeight(F); scale translate <0.5*Ratio,0.5,0> } Pigm #end #macro IS_StandardBox(F,Clock) #local Ratio = IS_GetWidth(F)/IS_GetHeight(F); #local Obj = box { <-0.5*Ratio,-0.5,0> <0.5*Ratio,0.5,0.5> pigment { IS_StandardPigment(F,Clock) } finish { ambient 1 diffuse 0 reflection 0 specular 0 } } Obj #end #macro IS_StandardCamera() #local Cam = camera { orthographic right image_width/image_height * x location <0,0,-1000> } Cam #end