Macros

There are a few groups of macros in the include file.

The basic tactic is to declare a one- or two-dimensional array of points. I think of this as the “modeling grid”. These are the points that will be on the final shape, then call one of the generation macros to create the array I call the “Control Grid” or usually just “CPGrid” that will then be used to create the individual bicubic patches. Other macros allow you to generate and distort the normal vectors at your control points for the different shapes.

The code attempts to use the following conventions for macro parameter names

  • Array refers to a 1-dimensional POV-Ray array

  • Grid refers to a 2-dimensional POV-Ray array, usually representing a sheet-like shape.

  • Box Grid refers to a 2-dimensional array that defines a rectangular Prism, each face being a separate Grid. This preserves the sharpness of corners. Box Grids can be logically broken up into faces.

  • Cylindrical Grid referes to a 2-dimensional array that defines a cylider or cone.

  • Control Point Grid is a 2-dimensional array that can be subdivided into control points for bicubic-patches.

DrawPatches(Grid, Texture)
Grid

A 2-dimensional grid generated by CreateControlGrid or similar macro

Texture

The texture to apply to the patches. By default the texture is UV-mapped across all the individual bicubic patches

This macrco relies on a few global variable which it will check for and declare as needed.

Patch_UV_Mapping [yes/no] - defaults to yes

Switches on UV mapping of the texture

Patch_Type [0 or 1] - defaults to 0

This is passed to each generated bicubic patch

Patch_Flatness - defaults to 0

This is passed to each generated bicubic patch

Patch_U_Steps, Patch_V_Steps [integer] - defaults to 3

These are passed to each generated bicubic patch

Patch_UV_Min [<u, v>], Patch_UV_Max [<u, v>]

These allow the generated patches to show only a portion of the texture. Default values are <0, 0> and <1, 1>

The generated bicubic patches are grouped in a union and have the hollow keyword active.

As a reminder, this is the definition of a bicubic patch in POV-Ray:

BICUBIC_PATCH:
bicubic_patch
{
    PATCH_ITEMS...
    <Point_1>,<Point_2>,<Point_3>,<Point_4>,
    <Point_5>,<Point_6>,<Point_7>,<Point_8>,
    <Point_9>,<Point_10>,<Point_11>,<Point_12>,
    <Point_13>,<Point_14>,<Point_15>,<Point_16>
    [OBJECT_MODIFIERS...]
}
PATCH_ITEMS:
    type Patch_Type | u_steps Num_U_Steps | v_steps Num_V_Steps |
    flatness Flatness

Generation Macros

These macros transform arrays into other arrays.

ConnectPoints(Array, InitialAdjust, FinalAdjust)
Parameters

Array – A 1-dimensonal array of at least three vectors.

Array

A 1-dimensional array with at least three vectors.

InitialAdjust [0..1]

Adjusts the initial created control point.

FinalAdjust adjusts [0..1]

Adjusts the final created control point.

Returns a 1-dimensional array that can be split up into individual bezier curves. This is referred to as a Connected Spline

I think InitialAdjust and FinalAdjust work best with a 0 value For details see that document I haven’t written yet. (The math of bezier curves)

ConnectLoop(Array)
Array

A 1-dimensional array with at least three vectors.

This macro assumes the first and last point of the Array are the same. It does not confirm this or enforce it in any way.

CreateGridControlPoints(ModelGrid, Adjust)

ModelGrid is a 2-dimensional array with at least three vectors in each direction.

Returns a 2-dimensional array for that can be divided to create the individual bicubic patches

CreateCylindricalContolPoints(ModelGrid, Adjust)
ModelGrid

A 2-dimensional array of points defining a cone or cylinder

This creates Loops in each row of the grid.

Wireframe Macros

These macros generate unions of spheres and cylinders to create a wireframe or do draw a ConnectedSpline. Generated objects are wrapped in a union but no texture is applied.

DrawSegment(Array, Radius, Cap)
Array

A 1-dimensional array of vectors of length 4

Radius

The radius of the sphere’s and cylinders

Cap [yes/no]

If the last sphere should be drawn or not.

This macro relies on the BezIntervals global variable (which defaults to 20).

PlotPoints(Array, Radius)
Array

A 1-dimensional array of vectors

Radius

The radius of the spheres

Generates spheres of a given radius on the points in an 1-dimensional array.

PlotGrid(Array, Radius)
Array

A 2-dimensional array of vectors

Radius

The radius of the spheres

DrawWireFrame(ControlGrid, Radius)
ControlGrid

A 2-dimensional array of vectors

Radius

The radius of the spheres and cylinders

This calls DrawConnected() for each row and column in the grid, creating a wireframe.

Normal Transformation Macros

These macros can be used to generate and distort the normal vectors of a ControlPointGrid.

MakeNormals(Grid)
Grid

A 2-dimensional array of vectors of the modeling grid.

This returns a new array matching the same size as the input grid. All vectors are normalized.

MakeCylindricalNormals(Grid)
Grid

A 2-dimensional cylindrical array of vectors.

This returns a new array matching the same size as the input grid, assuming a base cylindrical shape. All vectors are normalized.

DrawNormals(Grid, Normals, Radius)
Grid

The source grid

Normals

The generated normals

Radius

The radius of the cylinders

This creates cylinders at each modeling grid point and the associated normals.

DistortNormals(Normals, Maximum, Loop)
Normals

The normal grid generated by MakeNormals() or MakeCylindricalNormals()

Maximum

The maximum angle (in degrees) to distort each normal vector

Loop

Set to True if grid was generated with MakeCylindricalGrid().

ApplyNormals(CPGrid, Normals, Loop)
GPGrid

the control point grid to be manipulated

Normals

The grid of normals that have been distorted

Loop

Set to True if the grid was generated with MakeCylindricalGrid().