Compressed Mesh Macro File

for Persistence of Vision 3.1

Created by Chris Colefax, 23 September 1998

Updated 22 January 1999: Added mesh_texture, mesh_textures, apply_mesh_textures options; Added bend_mesh () deformation macro; Added cylinder_mesh (), triangle_mesh () creation macros.

Updated 13 May 1999: Added support for bicubic patch surfaces; Added hair_wind_rotation, hair_wind_speed animation options; Removed triangle_mesh () and triangle_morph_meshes () macros.

Updated 20 May 1999: Updated for Warp's Mesh Compressor 1.2a

Updated 28 Dec 1999: Updated for Warp's Mesh Compressor 2.1, adding support for extra-compressed meshes to PCM.MCR and PCMHAIR.MCR


Contents

  • Installation
  • Quick Start
  • Compressed Mesh Options Reference
  • General Options
  • Mesh Texturing Options
  • Bicubic Patch Options
  • Mesh Deformation Macros
  • Mesh Creation Macros
  • Hair Growth Options Reference
  • General Options
  • Hair Object Options and Macros
  • Hair Object Macro Options
  • Hair Coverage Options
  • Hair Rotation and Turbulence Options
  • Hair Texture and Material Options
  • Mesh Morphing Options Reference
  • General Options
  • Mesh Texturing Options
  • Morph Mesh Deformation Macros
  • Morph Mesh Creation Macros
  • Copyright Information
  • Contacting the Author

  • Installation

    To install the complete Compressed Mesh Macro File package, copy the three *.MCR files (PCM.MCR, PCMHAIR.MCR, and PCMMORPH.MCR) to one of the include file directories (folders) in your POV-Ray library path. Normally, this is the INCLUDE subdirectory of the directory you installed POV-Ray in, eg. (on a Windows 9x system):

    C:\Program Files\POV-Ray for Windows v3.1\Include

    If you don't want to install the files directly in POV-Ray's directories, you can create a separate directory in which to install the files. In this case, you should add that directory's full drive and path to your main POV-Ray INI file, eg. if you installed the *.MCR files in D:\POVFILES\MACRO you would add the following line to POVRAY.INI:

    Library_Path=D:\POVFILES\MACRO


    Quick Start

    The Compressed Mesh Macro File let you use triangle, smooth triangle, and bicubic patch surfaces compressed by Warp's POV-Ray Mesh Compressor. To read a compressed mesh file you first include the macro file (PCM.MCR) and then call the read_mesh macro with the filename, eg:

    #include "PCM.MCR" 
    object {read_mesh ("MyMesh.pcm") pigment {rgb 1} scale 2.5}

    If the mesh file contains more than one mesh you can replace the object keyword with a union. Note that to read extra mesh files, you don't need to include the macro file again - this file need only be included once at the beginning of the scene file.

    Meshes created in this way can be used in exactly the same way as uncompressed mesh files. In addition, you can use the options listed below to deform the mesh in various ways (including animated deformations) or replace the triangles/patches with other objects (eg. blobs, cylinders). With the Hair Growth Macro File you can cover the mesh surface with fur, hair, grass, dew-drops, etc., and you can morph between different mesh surfaces with the Mesh Morphing Macro File.

    A Note on Performance: The saving in disk space gained by using compressed mesh files does come at a cost - the time required for parsing the mesh files is increased. Using the more advanced features of the macros further increases parsing. As a general guide, using mesh deformations and mesh morphing is fastest with bicubic patch models, whereas mesh creation (including hair growth) is much faster to parse with triangle meshes (rather than patches which have to be subdivided into triangles first).


    Compressed Mesh Options Reference

    To use the following options you must define them with the desired values, before calling the read_mesh macro, eg:

    #declare debug_progress = true; 
    #macro deform_mesh () wave_mesh (0.5, 5, clock*3) #end 
    #declare mesh_textures = array[2] {texture {FirstTexture}, texture {SecondTexture}} 
    read_mesh ("MyMesh.pcm")

    General Options

    debug_progress
    When you set this option to true before calling read_mesh the macro will report information on the mesh as it parses the compressed mesh file. This is useful when you want to know how long each stage of the parsing process is taking. The default value is false.
    declare_only
    When you set this option to true the macro doesn't actually create the meshes in the compressed mesh file. Instead, each mesh in the file is declared as part of the Mesh array, eg. if the file contains three meshes the macro would create Mesh[0], Mesh[1], and Mesh[2]. Multiple copies of these declared meshes can then be placed in your scene, or each array index can be assigned to another variable (if a second compressed mesh file is read, the Mesh array will be overwritten). Note that if the file contains only one mesh, you can use #declare MeshObject = read_mesh ([FileName]) instead of the declare_only option. The default value is false.

    Mesh Texturing Options

    mesh_texture
    Rather than applying a texture as shown previously (using an object {} wrapper) you can use this option to declare a texture for all the meshes in a file, eg:

    #declare mesh_texture = texture {ShinyMetal}
    read_mesh ("MyMesh.pcm")

    You can also use this option within a compressed mesh file, so the texture is packaged with the mesh data. To do this, use #local mesh_texture = texture {...} to declare the entire texture at the beginning of the compressed mesh file (before the "PCM1" line). Note that if the file contains multiple meshes this texture will be applied to all meshes until the end of the file. You can, however, declare separate textures before the start of each new mesh in the file (denoted by the "PCM1"). This also makes it possible to append compressed meshes and textures together, texturing each part of the mesh separately.

    mesh_textures
    You can use this option to declare an array of textures to be used for multiple meshes in a single file. The first mesh in the file will use the first texture in the array, the second mesh will use the second texture, and so on. If there are more meshes than there are textures, the array will cycle back to the first texture when necessary. Like the previous option, this texture array can be declared using #local mesh_textures = array[... at the beginning of a compressed mesh file to package the textures with the meshes.
    apply_mesh_textures
    You can set this option to false to override any mesh_texture or mesh_textures options that are declared within a particular compressed mesh file. This way all such textures will be ignored, and you can apply your own textures as shown earlier (using an object {} or union {} wrapper).

    Bicubic Patch Options

    Version 1.2 of the POV-Ray Mesh Compressor adds support for the compression of bicubic patch surfaces, and all features of the Compressed Mesh Macro File have been updated as a result. Specifically, the following options have been added to allow you to override the patch properties stored in a compressed file:

    pcm_patch_type and pcm_patch_flatness
    Setting these options is most useful when a compressed patch mesh file has been saved with a certain patch type or flatness, and you wish to change these properties (for improved rendering or memory usage, for example). The POV-Ray documentation details suitable values for these options.
    pcm_patch_u_steps and pcm_patch_v_steps
    As with the previous options these two values can be used to override those stored in a compressed patch mesh file. In addition, these two values are used for the predefined create_mesh macros (including the Hair Growth Macro File). For these macros, each patch is divided into a set of subpatches or triangles (depending on the macro). POV-Ray itself subdivides the patch into 2 * 2u_steps * 2v_steps triangles. The create_mesh macros, on the other hand, only divide the patch into 2 * u_steps * v_steps triangles, so specifying pcm_patch_u_steps = 4; and pcm_patch_v_steps = 2; would divide the patch into 8 segments (16 triangles) for the mesh creation macros.

    Mesh Deformation Macros

    A compressed mesh file actually contains a list of all the vertices that make up the mesh surface. You can use the deform_mesh macro to manipulate these vertices in any way you like, including creating animated deformations. To set this option you actually define a macro with no parameters, inside of which you include the code to manipulate the mesh vertices. The Compressed Mesh Macro File includes the following such predefined deformation macros, which you can use like this (note the deform_mesh macro has no parameters, even though the inner macro does):

    #macro deform_mesh () wave_mesh (0.3, 4, clock*5) #end

    These predefined macros are:

    wave_mesh ( [WaveScale], [Frequency], [Phase] )
    This macro applies a sine wave to the mesh surface, travelling along the +y axis. The WaveScale value sets the amount in POV units that the mesh surface contracts and expands in the x-z plane.
    ripple_mesh ( [RippleAxis], [RippleAmount], [Frequency], [Phase] )
    This macro applies a sine ripple to the mesh surface, travelling in the direction of the RippleAxis. Unlike the previous macro, the ripple displaces the mesh surface (rather than scaling it in two-directions), giving a "side-to-side" ripple rather than a contracting and expanding wave.
    jitter_mesh ( [JitterScale], [JitterSeed] )
    This macro applies a completely random displacement to each mesh vertex, with the maximum displacement given by the JitterAmount value (in POV units). The JitterSeed is the positive or negative integer used to seed the random displacement.
    twist_mesh ( [TwistAngle], [TwistCentre] )
    This macro twists the mesh by the selected angle around the centre point given. The vector components of the TwistAngle value determine how much each vertex is twisted around each axis, eg. <0, 270, 0> would twist the mesh around the y-axis.
    bend_mesh ( [StartingPoint], [EndingPoint], [BendDirection], [BendAngle] )
    This macro bends the mesh surface in BendDirection by the degrees specified with BendAngle. StartingPoint and EndingPoint should specify the endpoints of the object's axis, at opposite ends of the mesh surface, with StartingPoint remaining fixed as the mesh is bent.

    To create your own deform_mesh macros, you actually need to program the macro to read the mesh vertices from the variable File, counting through PointCount X, Y, and Z values. These three float values can be manipulated as you like, before assigning them to a vector in the PointList array (the names of the three variables must be programmed exactly as shown), eg. for a simple displacement macro:

    #macro deform_mesh () 
      #local Counter = 0; #while (Counter < PointCount) 
        #read (File, X, Y, Z) 
        #declare PointList[Counter] = + [DisplacementAmount]; 
      #local Counter = Counter+1; #end 
    #end

    For more advanced examples see the deformation macros in PCM.MCR.

    Mesh Creation Macros

    Similar to the deformation macros, you can define a create_mesh macro that uses the mesh vertex data to create and object or objects in place of triangles, smooth triangles, or bicubic patches, eg:

    #macro create_mesh () spike_mesh (-1.75, .5) #end

    The Compressed Mesh Macro File includes the following predefined mesh creation macros. Note that for bicubic patch models each patch is subdivided into triangles (as described above) before the objects are created as detailed below:

    object_mesh ( [SingleObject] )
    This macro places a copy of the SingleObject at the centre of each triangle in the mesh, eg. you could use small spheres for a point-cloud, or larger objects to make a solid mesh.
    wire_mesh ( [Thickness] )
    In place of triangles, this macro creates cylinders (of radius Thickness) from the centre of each triangles to its vertices, generally creating an hexagonal-like wire mesh.
    blob_mesh ( [BlobSize], [Threshold], [Sturm] )
    This macro replaces each triangle with a similarly sized blob sphere, creating the entire mesh as a single blob structure. The BlobSize value sets the relative size of each blob sphere.
    spike_mesh ( [Length], [Thickness] )
    This macro creates the triangles and smooth triangles of the mesh, and then creates a cone centred on each triangle and protruding perpendicular to the mesh surface. The base radius and length of each cone is proportional to the size of the triangle it is created on, with the Length and Size options setting the relative scaling of the cone. A negative value can be used for Length to make the cones protrude from the opposite side of the mesh surface.
    cylinder_mesh ( [Thickness], [Edge1], [Edge2], [Edge3] )
    This macro creates cylinders of radius Thickness along the three edges of each triangle. The three edge variables are true/false values that determine whether or not a cylinder is placed along that particular edge of each triangle. Generally you will only set one or two of the edge options to true - otherwise, you will be creating duplicate cylinders along each edge. Depending on how the mesh data is defined, different combinations can create square, diamond, or triangular grids (rather than the hexagons of the wire_mesh macro).

    To design your own create_mesh macros, you need to define the macro to read from the File variable, and to support both triangle and bicubic patch mesh models you need to use the VerID value. A value of 1 indicates a triangle/smooth triangle model, for which you should count through three variables for TriangleCount triangles, and then six variables for SmoothTriangleCount smooth triangles. Each value you read from the file is actually the index of the PointList array vector to be used at the corner or normal of the triangle.

    A value of 2 indicates a bicubic patch model, for which you should count through PatchCount patches. For each patch you should call the PCM_read_patch_options () macro to read the patch's options, and then sixteen variables indicating the indexes of the PointList array vector for the patch control points. If you store these control points in an array you can then use the PCM_get_patch_point ([Control Point Array], [U Coordinate], [V Coordinate]) macro in PCM.MCR to return the surface value at U, V (this is most useful when you want to place objects randomly on the surface of the patch). Alternatively, you can use the PCM_get_patch_grid ([MakePatch]) macro to read all the values for you, and then subdivide the patch into an array of surface points PCM_patch_grid[U][V] (the resolution set by the u_steps and v_steps values defined in the file or with the override options, saved as PU and PV). Calling PCM_get_patch_grid (true) will also create the patch itself.

    As a guideline, the macro should look like:

    #macro create_mesh () 
      #local Counter = 0; #switch (VerID)
      #case (1) // Triangle models
        #while (Counter < (TriangleCount)
          #read (File, P1, P2, P3) 
    // Code to create objects using PointList[P1], PointList[P2], and PointList[P3] 
        #local Counter = Counter+1; #end 
        #local Counter = 0; #while (Counter < SmoothTriangleCount) 
          #read (File, P1, N1, P2, N2, P3, N3) 
    // Code to create objects using PointList[P1], PointList[N1], PointList[P2], PointList[N2], PointList[P3], and PointList[N3] 
        #local Counter = Counter+1; #end
        #break
    
      #case (2) // Bicubic patch models
        #while (Counter < PatchCount)
          PCM_get_patch_grid (true)
          #local U = 0; #while (U < PU) #local V = 0; #while (V < PV)
    // Code to create objects using PCM_patch_grid[U][V], PCM_patch_grid[U+1][V], PCM_patch_grid[U+1][V+1], PCM_patch_grid[U][V+1]
          #local V = V+1; #end #local U = U+1; #end
        #local Counter = Counter+1;
      #end
    #end

    For more detailed examples and guides, you can examine the predefined mesh creation macros in PCM.MCR.


    Hair Growth Options Reference

    To use the Hair Growth Macro File, include PCMHAIR.MCR before using the read_mesh macro in the usual way. Including this file will also include PCM.MCR if required, so it is not necessary to include both macro files. Also, including PCMHAIR.MCR will redefined any existing create_mesh macro.

    General Options

    debug_progress
    As for the Compressed Mesh Macro File, setting this option to true will cause details of the macros progress to be displayed while parsing.
    hair_objects_only
    Setting this option to true causes only the hair objects to be created, without creating the underlying mesh surface.
    hair_mesh_transform
    If declared, this transform {} option will be applied to each and every hair object created. This is often faster to render than transforming the completed union of the mesh surface and hair objects.

    Hair Object Options and Macros

    hair_object
    Declare this option as a single object to be used to cover the mesh surface. The object can include texture or interior properties, eg. you can give the hair object a normal and finish but no pigment, so that you can set each hair object copy's colour with the hair_pattern_pigment option.

    You can also give each hair object a patterned pigment or texture by first calling the desired hair object macro and then modifying it as desired, eg:

    #declare hair_thickness = 0.05;
    smooth_triangles_hair_object ()
    #declare hair_object = object {hair_object
       pigment {gradient y color_map {[0 rgb 1] [1 rgb 0]}}
       normal {bumps 0.1 scale <0.1, 1, 0.1>}}
    hair_objects
    Declare this option as an array of objects to use. The array is cycled through as objects are placed on the mesh surface.

    Calling any of the following options will create a #declared hair_object option. This hair_object can then be used as is, or modified, combined with other objects, declared as part of a hair_objects array, etc.

    smooth_triangle_hairs_object ()
    The default hair object, this creates a patch of multiple curved, tapered hairs using a smooth triangle mesh.
    clipped_sphere_hair_object ()
    Creates a single curved hair from a sphere clipped by a box. The hair is not tapered, and cannot be more than a hemi-sphere in length.
    triangle_patch_hairs_object ()
    Creates a patch of multiple straight, tapered hairs as a flat triangle mesh.
    triangle_cluster_hairs_object ()
    Creates multiple hairs like previous macro, but each hair is centred on the same point and hairs grow in all directions.

    Hair Object Macro Options

    The following options control the hair objects declared by the previous four macros, and so must be declared before calling the desired macro. Note that, as shown, not all the options apply to all the macros.

    hair_radius
    Controls the radius, in POV units, of the curvature of the first two hair object types. The default value is 1.
    hair_thickness
    Controls the thickness at the base of each hair for all four macros. Note that the triangular hair objects are tapered to 0 thickness at the hair ends. The default value is 0.02 units.
    hair_thickness_curvature
    Controls the relative curvature across the thickness of the first two types of hair objects. For the clipped_sphere_hair_object this causes the sphere to be scaled in one direction, so the actual shape of the hair changes. For the smooth_triangle_hairs_object only the apparent curvature is changed by altering the triangle normals. The default is 0.5, with 0 giving flat hairs and 1 giving highly curved hairs.
    hair_rotation
    Controls the rotation of the base of each hair. For the patch objects, this does not rotate the patch as a whole, but each hair within the patch. The initial direction for each hair type is +y, so rotating around the x-axis causes the hair to flatten, rotating around the y-axis causes the hair to spin in place, and rotating around the z-axis causes the hairs to roll.
    hair_triangle_smoothness
    Controls the number of triangles used for the smooth_triangle_hairs_object. The value actually sets the number of triangles used per 180 degree arc, making the result independent of the hairs' radii. The default value is 30 triangles per arc.
    hairs_per_patch
    Controls the number of individual hairs in each patch for the three triangle hair objects. The default for the smooth_triangle_hairs_object is 10 hairs, while the default for the flat triangle hair objects is 100 hairs.
    hair_patch_size
    For the two patch hair objects, this value sets the diameter of the patch base, ie. the spread of the distance between each hair. Generally the hairs are distributed so they are more dense towards the centre of the patch. The default value is 0.5 units.
    hair_patch_turb
    Controls the randomness of the three triangle hair objects. A zero-value creates identically sized and rotated hairs, the default value being 0.1.
    hair_arc
    Sets the arc of the two curved hair objects, with a value of 1 corresponding to 180 degrees. The default value is 0.25 (ie. 45 degrees).
    hair_length
    This value sets the length of each hair directly, for all the hair object types. As mentioned, the clipped_sphere_hair_object cannot be longer than 1 arc (ie. pi * hair_radius). For the two flat triangle hair objects the default value is 0.2 units.

    Hair Coverage Options

    Only one of the following options will be used, in order of importance (ie. the second option overrides the first). Note that for bicubic patch models each patch is subdivided into triangles (as described above), after which these options are applied:

    hair_objects_per_triangle
    Sets the average number of hair objects created per triangle, and can be fractional or less than 1. The default value is 1 hair object per triangle.
    hair_object_count
    Sets the total number of hair objects created, regardless of the number of triangles or patches in the mesh surface.
    hair_objects_per_unit
    Sets the number of hair objects created per square unit of mesh surface. This creates a more even distribution in meshes with a large range of triangle/patch sizes, as the number of hairs placed on a particular triangle is dependent on the size of that triangle.

    Hair Rotation and Turbulence Options

    hair_rotate_to_surface
    Setting this option to true causes the hairs to be orientated to the mesh surface normal at the base of the hair object. A negative true value can be used to flip the mesh normal directions (and hence, the direction of the hair objects).

    Vector values can also be used to control how much the hairs follow the normal along each axis, eg: #declare hair_rotate_to_surface = <1, 0, 1>; would mean the orientation of the hairs along the x and z axes would change, but the orientation along the y axis would remain constant. Note that these rotations apply before any changes to the hair_sky option, ie. also using #declare hair_sky = -x; would mean the rotations for the x and z axes would be applied first, and then each hair object would be rotated from +y to -x.

    hair_sky
    Causes all hair objects to be rotated from the default value of +y to the direction specified. Changing this option also modifies the results of the hair_rotate_to_surface option.
    hair_seed
    Sets the seed value used for all random aspects of the macro file. The default hair_seed is 0.
    hair_size_turb
    Adjusts the randomness of the sizes of each hair object. The default value is 0.1, with higher values giving a larger difference in hair object sizes.
    hair_rotation_turb
    Adjusts the randomness of the rotation of each hair object. The default value is 0.1. You can also use a vector, eg. #declare hair_rotation_turb = <0.1, 1, 0>; would mean slightly random rotation around the x-axis, and completely random rotation around the y-axis.
    hair_wind_rotation
    This option applies to the smooth_triangle_hairs_object and triangle_patch_hairs_object, and sets the angle of extra rotation added to give the effect of the hairs blowing in the wind. Each hair within the patch is rotated with a random elliptical motion, in the direction of its growth.
    hair_wind_speed
    By default the above option uses POV-Ray's internal clock to cycle the motion of each hair (so you can create a looping animation with the clock between 0 and 1). You can set this option to change the number of cycles per clock unit, if you want faster/slower motion.

    Hair Texture and Material Options

    hair_texture
    If declared, this texture is applied to each hair object after it has been positioned on the mesh surface, leaving the texture itself unmodified.
    hair_pattern_pigment
    Can be used alone or in combination with hair_texture to give each hair object the solid colour of the pattern pigment, at the point on the mesh where the base of the hair starts growing from the surface.
    hair_material
    Like the hair_texture option, if declared this material is applied to each hair object after positioning, with transforming the material. For media the hair object should be declared hollow, or the read_mesh macro call can be wrapped in an object {} statement marked hollow (which also makes the mesh surface itself hollow).
    apply_hair_materials_to_mesh
    If set to true, any of the above three options declared are applied to the triangles making up the mesh surface itself, overriding any other mesh textures that have been declared. The default value for this option is false.


    Mesh Morphing Options Reference

    To use the Mesh Morphing Macro File, include "PCMMORPH.MCR" and then call the morph_meshes macro as follows:

    object {
       morph_meshes ( [Mesh FileName List Array], [Current Morph Position] )
       [object modifiers]
       }

    The first macro option is a single dimensional array of strings, listing the filenames of the compressed meshes to morph between. The same filename can be used multiple times in the list, and the standard POV-Ray rules about relative and library paths apply.

    The second option is a float value specifying the morph position, with integer values corresponding to unmorphed meshes in the filename array, eg. a value of 0 would create the first mesh in the list, a value of 1.5 would create a mesh morphed halfway between the second and third meshes in the list. For animations this can be as simple as clock * [index of last file in list], or it can be a modified clock that cycles back and forward through the mesh file list.

    For the morphing to work each file in the list must have:

    1. the same number of meshes in the file (which can be one or more), in the same formats;
    2. each corresponding mesh in each file must contain the same number of triangles and smooth triangles, or the same number of bicubic patches.

    Note that the actual number of vertices in each file (which has the greatest effect on its compressed size) is not important. Also, the morphing is calculated for each triangle/patch as it is encountered in the files to be morphed between, so the order of the triangles/patches in the mesh should also correspond for the desired result. Generally, if you have used the Mesh Compressor to compress meshes exported purposely from another program all these requirements will be met without problems.

    General Options

    debug_progress
    Again, setting this option to true will cause the macro to send details of its progress to POV-Ray's debug stream during parsing.
    declare_only
    As for the Compressed Mesh Macro File, setting this option to true will cause the macro to declare the morphed meshes as part of the Mesh[] array, so that multiple copies of each mesh can be created, and transformed independently.
    morph_smoothing
    This float values sets the amount of acceleration and deceleration applied to the morphing process as one mesh is morphed into another. The default value of 1 gives linear transitions, with higher values smoothing the transitions between meshes.

    Mesh Texturing Options

    mesh_texture
    If this texture is declared it will be applied to all the meshes created by the morph_meshes macro. You can also declare the option within a compressed mesh file (before the "PCM1" line), in which case the textures found in each file in the mesh file list will be morphed as the mesh surfaces are morphed.
    mesh_textures
    If declared, this one dimensional array of textures will be cycled through for each mesh in each file (not for each file in the file list). Again, if the option is declared within each mesh file the textures will be morphed accordingly.
    morph_mesh_textures
    This option allows you to create automatically morphed textures without having to declare either of previous two options within each file. The option must be a two-dimensional array, with the first dimension equal to the number of files in the mesh file list and the second equal to the number of meshes in each file, eg:

    #declare morph_mesh_texture = array[2][2] {
       { texture {pigment {White}}, texture {pigment {Black}} },
       { texture {pigment {Yellow}}, texture {pigment {Red}} }

    If the first mesh file in the file list contained a sphere and box and the second contained a cone and cylinder, the result would be a white sphere morphing to a black cone, and a yellow box morphing to a red cylinder.

    apply_mesh_textures
    Setting this option to false causes all the above texturing options to be ignored, so you can apply textures yourself by wrapping the mesh in an object {} statement (or union {} for multiple meshes).

    Morph Mesh Deformation Macros

    As with the Compressed Mesh Macro File, it is possible to create macros that deform the mesh surface in various ways.

    In the case of the Mesh Morphing Macro File, the macro you must define is deform_morph_meshes (). There are no such macros predefined in the macro file, but to create your own you should use the following syntax (with all variable names as shown):

    #macro deform_morph_meshes ()
      #read (File1, PointCount) #if (PointCount > 0)
        #local PointList1 = array[PointCount]
        #local Counter = 0; #while (Counter < PointCount)
          #read (File1, X, Y, Z)
          #local PointList1[Counter] = <X, Y, Z>;
    // Code to deform mesh vertices
        #local Counter = Counter+1; #end
      #end
    
      #read (File2, PointCount) #if (PointCount > 0)
        #local PointList2 = array[PointCount]
        #local Counter = 0; #while (Counter < PointCount)
          #read (File2, X, Y, Z)
          #local PointList2[Counter] = <X, Y, Z>;
    // Code to deform mesh vertices
        #local Counter = Counter+1; #end
      #end
    #end

    Note that it is no longer necessary to also define a deform_mesh macro for handling single meshes when the deform_morph_meshes macro is defined.

    Morph Mesh Creation Macros

    The syntax for the create_morph_meshes macro is as follows (with all variable names as shown):

    #macro create_morph_meshes ()
      #local Counter = 0; #switch (VerID)
      #case (1) // Triangle models
        mesh { #while (Counter < TriangleCount)
            #read (File1, P1, P2, P3) #read (File2, P4, P5, P6)
    // Code to create objects using PointList1[P1]*Weight1 + PointList2[P4]*Weight2, PointList1[P2]*Weight1 + PointList2[P5]*Weight2, PointList1[P3]*Weight1 + PointList2[P6]*Weight2
          #local Counter = Counter+1; #end
          #local Counter = 0; #while (Counter < SmoothTriangleCount)
            #read (File1, P1, N1, P2, N2, P3, N3) #read (File2, P4, N4, P5, N5, P6, N6)
    // Code to create objects using PointList1[P1]*Weight1 + PointList2[P4]*Weight2, PointList1[N1]*Weight1 + PointList2[N4]*Weight2, PointList1[P2]*Weight1 + PointList2[P5]*Weight2, PointList1[N2]*Weight1 + PointList2[N5]*Weight2, PointList1[P3]*Weight1 + PointList2[P6]*Weight2, PointList1[N3]*Weight1 + PointList2[N6]*Weight2
          #local Counter = Counter+1; #end }
        #break
    
      #case (2) // Bicubic patch models
        union { #local PList = array[16] #while (Counter < PatchCount)
          PCM_read_morph_patch_options ()
          #declare Counter2 = 0; #while (Counter2 < 16)
            #read (File1, P1) #read (File2, P2)
            #local PList[Counter2] = PointList1[P1]*Weight1+PointList2[P2]*Weight2;
          #declare Counter2 = Counter2+1; #end
          #local U = .5; #while (U < PU) #local V = .5; #while (V < PV)
    // Code to create objects based on PCM_get_patch_point (PList, U/PU, V/PV)
          #local V = V+1; #end #local U = U+1; #end
        #local Counter = Counter+1; #end }
      #end
    #end

    As you can see, the triangle vertices and patch control points are linearly interpolated using Weight1 and Weight2. The create_morph_meshes macro can be used to create surfaces using objects other triangles and patches, and it can also be used to change the way the vertices are interpolated.

    There is one morph mesh creation macro defined in PCMMORPH.MCR:

    object_morph_meshes ([SingleObject])
    This macro corresponds to the object_mesh macro, placing a copy of SingleObject at the centre of each triangle in the morphed surface.


    Copyright Information

    The Compressed Mesh Macro File, including PCM.MCR, PCMHAIR.MCR, PCMMORPH.MCR, all associated documentation, sample scenes, and animations, are copyright 1998-1999, Chris Colefax. Full permission is granted to the user to modify any or all of the files for his/her own use. If modified versions are to be distributed the user should make clear the modifications that have been made by him/herself.

    The Compressed Mesh Macro File may be bundled with or without other software on CD-ROM collections, Bulletin Board systems and other file archives, providing that all associated files, including documentation and samples, are included. I would also request that persons intending to distribute the Compressed Mesh Macro File in this manner or otherwise would first contact me to ensure that they are in possession of the latest available version.

    Further, no restrictions of any sort are placed on the usage of the macro file itself, and scene files or images created using the macro file remain entirely the property of the user or users who have created them. I claim no liability or responsibility for damages or loss resulting from usage of the macro file, or any part of the macro file package.


    Contacting the Author

    If you wish to contact me with bug reports, bug fixes, criticisms, comments, suggested improvements, questions, etc. you can reach me by email at:

    ccolefax@geocities.com

    or by regular mail at:

    Chris Colefax
    PO Box 110
    Kuranda, Queensland
    Australia 4872


    POV-RayTM and Persistence of VisionTM are registered trademarks of the POV-Ray TeamTM