// #including this include file afte #including shapes.inc (or stdinc.inc) // will modify the HF macros so that they write Wavefront OBJ files instead of // MESH2 files. Note that you can't place the height_fields in your scene at // the same time, because POV-Ray can't understand the obj format. // Also, with this modification, the HF macros always write the data to a file, // so you must remember to specify a file name, for example "myobject.obj". // Version 1.0 (may contain bugs) // by Rune S. Johansen // August 2002 #macro HFCreate_ () #fopen _HFMACRO_OUTPUT_FILE FileName write #write(_HFMACRO_OUTPUT_FILE,"# vertex vectors\n", #local J = 1; #while (J<=xRes) #local K = 1; #while (K<=zRes) "v ",PArr[J][K].x," ",PArr[J][K].y," ",PArr[J][K].z,"\n", #declare K = K+1; #end #declare J = J+1; #end "\n") #if (Smooth) #write(_HFMACRO_OUTPUT_FILE,"# normal vectors\n", // CALCULATION OF NORMAL VECTOR // We don't vnormalize the vectors from the current center point // to its neightbor points because we want a weighted average // where bigger areas contribute more. This also means that the // center point can be left out completely of the calculations: #local J = 1; #while (J<=xRes) #local K = 1; #while (K<=zRes) #local Normal = vnormalize(vcross( PArr[J][K+1]-PArr[J][K-1], PArr[J+1][K]-PArr[J-1][K] )); "vn ",Normal.x," ",Normal.y," ",Normal.z,"\n", #declare K = K+1; #end #declare J = J+1; #end "\n") #end #if (UVtex) #write(_HFMACRO_OUTPUT_FILE,"# uv vectors\n", #local J = 1; #while (J<=xRes) #local K = 1; #while (K<=zRes) "vt ",(J-1)/(xRes-1)," ",(K-1)/(zRes-1),"\n", #declare K = K+1; #end #declare J = J+1; #end "\n") #end #write(_HFMACRO_OUTPUT_FILE,"# face indices\n", #local F1 = <0,zRes,zRes+1>; #local F2 = <0,zRes+1,1>; #local J = 0; #while (J