// Macro to interpolate two sets of MESH2 data. // Version 1.0.1 by Hugo Asm for POV3.5 // Edited by Kitsune_e // May 2003. Freeware. // // The macro takes three parameters // percent - how far to interpolate // file_01 - name used in the first // files variables // file_02 - name used in the second // files variables // Percent is a float, files are // strings. // Example: // Interpolate_Mesh2(clock,"KeyFrame01","KeyFrame02") #macro Interpolate_Mesh2(Percent,file_01,file_02) #local Opposite_Percent= 1-Percent; #ifndef (Number_of_Normals) #local Number_of_Normals=1; #end //check for normals #ifndef (Number_of_UVs) #local Number_of_UVs=1; #end //check for UV-coords // Interpolate data #declare New_Vertices=array[ Number_of_Vertices ]; #declare New_Normals=array[ Number_of_Normals ]; #declare New_UVs=array[ Number_of_UVs ]; #declare Count=0; #declare Count_Ends=Number_of_Vertices; // this probably isn't the best solution, but it is the // only way I could think of to let the macro change // variable names dynamicly. Besides dosn't everyone // want a program that can edit itself? #fopen data "frame_interpolate.inc" write #write (data, "//frame interpolation include writen byinterpolate_mesh2.inc\n\n") #write (data, "#while( Count < Count_Ends )\n\n") #write (data, " #declare New_Vertices[Count]=\n") #write (data, concat(" ", file_01, "_Vertices[Count] * Percent\n")) #write (data, concat(" + ", file_02, "_Vertices[Count] * Opposite_Percent;\n\n")) #write (data, " #if (Number_of_Normals > 1)\n") #write (data, " #declare New_Normals[Count]=\n") #write (data, concat(" ", file_01, "_Normals[Count] * Percent\n")) #write (data, concat(" + ", file_02, "_Normals[Count] * Opposite_Percent;\n")) #write (data, "#end\n\n") #write (data, " #if (Number_of_UVs > 1)\n") #write (data, " #declare New_UVs[Count]=\n") #write (data, concat(" ", file_01, "_UVs[Count] * Percent\n")) #write (data, concat(" + ", file_02, "_UVs[Count] * Opposite_Percent;\n")) #write (data, "#end\n\n") #write (data, "#declare Count=Count+1;\n") #write (data, "#end") #fclose data #include "frame_interpolate.inc" // Data ready! // Create new object mesh2 { // Paste vertices vertex_vectors { Number_of_Vertices #local Count=0; #local Count_End=Number_of_Vertices; #while( Count < Count_End ) New_Vertices[Count] #local Count=Count+1; #end } // Paste normals if present #if (Number_of_Normals > 1) normal_vectors { Number_of_Normals #local Count=0; #local Count_End=Number_of_Normals; #while( Count < Count_End ) New_Normals[Count] #local Count=Count+1; #end } #end // Paste UV-coords if present #if (Number_of_UVs > 1) uv_vectors { Number_of_UVs #local Count=0; #local Count_End=Number_of_UVs; #while( Count < Count_End ) New_UVs[Count] #local Count=Count+1; #end } #end // Paste faces face_indices { Number_of_Faces #local Count=0; #local Count_End=Number_of_Faces; #while( Count < Count_End ) KeyFrame_Faces[Count] #local Count=Count+1; #end } // Paste normals normal_indices { Number_of_normalis #local Count=0; #local Count_End=Number_of_normalis; #while( Count < Count_End ) KeyFrame_normalis[Count] #local Count=Count+1; #end } // Paste UV_indices uv_indices { Number_of_UVis #local Count=0; #local Count_End=Number_of_UVis; #while( Count < Count_End ) KeyFrame_UVis[Count] #local Count=Count+1; #end } } #undef New_Vertices #undef New_Normals #undef New_UVs #undef Count // Returns with new object #end