Engineered by Richard Swika
Comments?  chainmaker@comcast.net.

Rick's Chain Maker

Rick's Chain Maker is free tool for creating depth maps representing 3 dimensional frames of chain, in POVRAY (also FREE!) You can generate just about any chain frame shape you will ever need, at any resolution, by simply adjusting a few parameters. The depth maps are ideal for use by Carvewright and Sears Compucarve CNC machines, and in reduced polygon 3D surface modeling.

Instructions

Unzip RicksChainMaker.zip  to a folder on your hard disk. The zip file includes ChainMaker.inc, ChainMakerDefaults.inc, and many .pov example files. Load any of the example files into POVRAY, adjust the parameters to suit your needs,  and render. The hard part is all done for you in the ChainMaker.inc file.

Let's say you need to carve or model a 5”x7” picture frame made from chain. 

Just load this code into POVRAY then render the image.

Note, for use with the CarveWright software, render .png files by entering "Output_File_Type=N" on the POVRAY command line next to the resolution pick list, or by adding this to your presets .ini file. Also, for best results, use anti-aliasing (AA 0.3) or better when rendering.


//Basic 5x7 picture frame

#include "ChainMakerDefaults.inc"
#declare CornerCount = 4;
#declare CornerLinkCount = 1;
#declare StraightLinkCountEven = 5;
#declare StraightLinkCountOdd = 7;
#include "ChainMaker.inc"



Simple5x7Frame.pov

The output image is a gray scale depth map where the white level is proportional to the height at each point. CNC machines can use this as input to specify a precisely carved surface. Modelers can use this as a bump map to add background detail without increasing scene complexity.

There's actually 11 parameters you can adjust, but we'll just start out by using just 4 of them.

Controlling Corner Count and Link Count

The first thing you should learn is how to control the number of corners the frame has by setting CornerCount, and how many links of chain appear on the corners, by setting CornerLinkCount. For the straight sections, you can specify two values, StraightLinkCountEven  and StraightLinkCountOdd to be used alternately. The first straight section and every other even straight section have StraightLinkCountEven number of links. The second straight section and every other odd straight section have StraightLinkCountOdd number of links.

If you need a triangle frame, say 7 links x 7 links, with rounded corners of 3 links each, just set the CornerCount to 3, and decide how round you want the corners. In this example, I put 3 links on the corners and 7 links on each straight section:

//Basic 7x7 triangle frame with rounded corners

#include "ChainMakerDefaults.inc"
#declare CornerCount = 3; 
#declare CornerLinkCount = 3;
#declare StraightLinkCountEven = 7;
#declare StraightLinkCountOdd  = 7;
#include "ChainMaker.inc"



Basic 7x7 TriFrame with Rounded Corners.pov

If you need a pentagon with pointed corners, set the CornerCount to 5, and the CornerLinkCount to 0. Set StraightLinkCountEven and StraightLinkCountOdd to the same even value. Make sure you use an even value or you'll get a pentagon with ends that don't mesh perfectly.


//Pentagon

#include "ChainMakerDefaults.inc"
#declare CornerCount = 5; 
#declare CornerLinkCount = 0;
#declare StraightLinkCountEven = 4;
#declare StraightLinkCountOdd  = 4;
#include "ChainMaker.inc"



Pentagon.pov

Since chain maker uses full links of all the same size, it is possible to specify a design that doesn't join up completely, leading to awkward and unbalanced looking results. Sometimes you have to adjust the link count or other parameters to get a perfect mesh, if that is what you are going for.


//Pentagon that doesn't mesh

#include "ChainMakerDefaults.inc"
#declare CornerCount = 5; 
#declare CornerLinkCount = 0;
#declare StraightLinkCountEven = 5;
#declare StraightLinkCountOdd  = 5;
#include "ChainMaker.inc"



Pentagon that doesn't mesh.pov

Adjusting Link Dimensions

There are three parameters to control the dimensions of the individual links, including the overall length of the link, LinkLength, the radius of the cuved section of the link (outside diameter), LinkRadius, and the radius of the wire used to make the link, WireRadius. Here is the same 5x7 picture frame as in the first example above, but with a LinkLength of 1.95, as opposed to the default value of 1.5 used above. If you are using the default value for a property, as in the examples above, you can omit them from your .pov file.

//You can adjust link dimensions

#include "ChainMakerDefaults.inc"
#declare LinkLength = 1.95;
#declare LinkRadius = 0.5;
#declare WireRadius = 0.15;

#declare CornerCount = 4;
#declare CornerLinkCount = 1;
#declare StraightLinkCountEven = 5;
#declare StraightLinkCountOdd = 7;
#include "ChainMaker.inc"



You can adjust link dimensions.pov

Twisting the Chain

The next two parameters, InitialTwist and TwistDelta are perhaps the most interesting and powerful. The first of these, InitialTwist sets the starting twist angle of the first link. It default to 0, but other values such as 30, 45, and 60 can offten produce interesting effects.

//Offset 5x7 picture frame

#include "ChainMakerDefaults.inc"
#declare CornerCount = 4; 
#declare CornerLinkCount = 1;
#declare StraightLinkCountEven = 5;
#declare StraightLinkCountOdd  = 7;


//Special effects
#declare InitialTwist = 60;
#declare TwistDelta   = 90;
include "ChainMaker.inc"



Offset5x7Frame.pov

Up utill now, all of the examples have used a TwistDelta of 90 degrees. The means that each new link was rotated by 90 degrees, like an untwisted chain. To get the appearance of a twisted chain, you can use values for TwistDelta other than 90. If you want to get a perfect mesh, you may need to do some calculations or experimentation. Values like 15, 30, 45, 60, 75 often give interesting results, but it all depends on the number of links and corners. Twisted chain frames with rounded corners seem to work better then pointed corners, so for best results, try using a CornerLinkCount of 3 or more with TwistDeltas other than 90.

//Twisted 5x7 picture frame 

#include "ChainMakerDefaults.inc"
#declare CornerCount = 4; 
#declare CornerLinkCount = 2;
#declare StraightLinkCountEven = 3;
#declare StraightLinkCountOdd  = 5;


//Special effects
#declare InitialTwist = 0;
#declare TwistDelta   = 75;
include "ChainMaker.inc"



Twisted5x7Frame.pov

If you walk all the way around any of the above frames, you will have rotated by 360 degrees, regardless of the number of corners. The sum of all the corner angles is named the InteriorAngle and it defaults to 360 degrees. You make the chain cross over itself by making the InteriorAngle greater than 360. For example, if you set the InteriorAngle to 720, you will make two complete rotations. Then, as long as you use a Odd CornerCount, you'll get a star like shape.

//Chain Star Power     
#include "ChainMakerDefaults.inc"
#declare InitialTwist = 0;
#declare TwistDelta   = 90;

#declare CornerCount = 5; 
#declare CornerLinkCount = 0;
#declare StraightLinkCountEven = 12;
#declare StraightLinkCountOdd  = 12;
#declare TotalInterior = 180*4;
include "chainmaker.inc"



Chain Start Power.pov

Use a non-zero CornerCount if you want rounded tips.

//Chain Flower Power        
#include "ChainMakerDefaults.inc"
#declare InitialTwist = 10;
#declare TwistDelta   = 90;

#declare LinkLength = 1.45;
#declare LinkRadius = 0.5;
#declare WireRadius = 0.125;

#declare CornerCount =5; 
#declare CornerLinkCount = 7;
#declare StraightLinkCountEven = 11;
#declare StraightLinkCountOdd  = 11;
#declare TotalInterior = 180*6;

#declare Exposure = 1;
include "chainmaker.inc"



Chain Flower Power.pov

If you use an Even CornerCount, you'll end up traveling on the same path after the first revolution, so you can use TwistAngle to get multiple strands of twisted chain for some more possibilities.

//Chain Frame     
#include "ChainMakerDefaults.inc"
#declare InitialTwist = 0;
#declare TwistDelta   = 80;

#declare CornerCount = 16; 
#declare CornerLinkCount = 0;
#declare StraightLinkCountEven = 12;
#declare StraightLinkCountOdd  = 12;
#declare TotalInterior = 180*8;
include "chainmaker.inc"



Chain Frame.pov

Sometimes, not twisting at all can lead to interesting results.

//Spirograph        
#include "ChainMakerDefaults.inc"
#declare InitialTwist = 2;
#declare TwistDelta   = 0;

#declare LinkLength = 1.31;
#declare LinkRadius = 0.75;
#declare WireRadius = 0.1;

#declare CornerCount = 6; 
#declare CornerLinkCount = 10;
#declare StraightLinkCountEven = 22;
#declare StraightLinkCountOdd  = 22;
#declare TotalInterior = 180*9;
#declare Exposure = 8;
#declare Zoom = 0.9;
include "chainmaker.inc



Spirograph.pov

Braids, Weaves and Rope Like Effects

You can transcend the limitations of real chain by entering values that cause neighboring links to intersect, producing many interesting braids, weaves and rope like effects.

//A tight chain intersects itself

#include "ChainMakerDefaults.inc"

#declare LinkLength = 1.1;
#declare LinkRadius = 0.6;
#declare WireRadius = 0.45;

#declare CornerCount = 4;
#declare CornerLinkCount = 24;
#declare StraightLinkCountEven = 40;
#declare StraightLinkCountOdd  = 16;

#declare InitialTwist = 0;
#declare TwistDelta   = 42;
include "ChainMaker.inc"




Tight Chains.pov

//Looks like maggots

#include "ChainMakerDefaults.inc"

#declare LinkLength = 1.1;
#declare LinkRadius = 0.6;
#declare WireRadius = 0.45;

#declare CornerCount = 4;
#declare CornerLinkCount = 24;
#declare StraightLinkCountEven = 40;
#declare StraightLinkCountOdd  = 16;

#declare InitialTwist = 0;
#declare TwistDelta   = 12;
include "ChainMaker.inc"



Maggot Frame.pov


//Woven Ring                     
#include "ChainMakerDefaults.inc"

#include "ChainMakerDefaults.inc"
#declare LinkLength = 1.1;
#declare LinkRadius = 0.5;
#declare WireRadius = 0.4;

#declare CornerCount = 22;
#declare CornerLinkCount = 5;
#declare StraightLinkCountEven = 0;
#declare StraightLinkCountOdd  = 0;

#declare InitialTwist = 45;
#declare TwistDelta   = 60;
#include "ChainMaker.inc"



Putting it all Together.pov

Special Effects

You can get some very alien and unexpected looking results

//Strange Frame 
                 
#include "ChainMakerDefaults.inc"

#include "ChainMakerDefaults.inc"
#declare LinkLength = 1.01;
#declare LinkRadius = 0.5;
#declare WireRadius = 0.4;

#declare CornerCount = 5;
#declare CornerLinkCount = 27;
#declare StraightLinkCountEven = 0;
#declare StraightLinkCountOdd  = 0;

#declare InitialTwist = 0;
#declare TwistDelta   = 8;
#include "ChainMaker.inc"



Strange Frame.pov

Exposure

When you aren't getting a complete 90 twist on the link, such as in the following example where TwistDelta is 0, it is useful to boost the exposure to be greater than 1. This scales the gradient representing depth.

//A strange effect                  
#include "ChainMakerDefaults.inc"
#declare LinkLength = 1.11;
#declare LinkRadius = 0.6;
#declare WireRadius = 0.15;

#declare CornerCount = 6;
#declare CornerLinkCount = 2;
#declare StraightLinkCountEven = 3;
#declare StraightLinkCountOdd  = 3;

#declare InitialTwist = 12;
#declare TwistDelta   = 0;
#declare Exposure     = 2.25;
#include "ChainMaker.inc"



A strange effect.pov

//Interesting Texture         
#include "ChainMakerDefaults.inc"
#declare LinkLength = 1.11;
#declare LinkRadius = 0.6;
#declare WireRadius = 0.15;

#declare CornerCount = 4;
#declare CornerLinkCount = 2;
#declare StraightLinkCountEven = 3;
#declare StraightLinkCountOdd  = 3;

#declare InitialTwist = 19;
#declare TwistDelta   = 0;

#declare Exposure     = 2;
#declare Zoom         = 0.95;
include "ChainMaker.inc"



Interesting Texture.pov

If you keep increasing the exposure you will reach the point where gradient will cycle back to black, introducing even more interesting possibilities.

//Overexposed Interesting Texture        
#include "ChainMakerDefaults.inc"
#declare LinkLength = 1.11;
#declare LinkRadius = 0.6;
#declare WireRadius = 0.15;

#declare CornerCount = 4;
#declare CornerLinkCount = 2;
#declare StraightLinkCountEven = 3;
#declare StraightLinkCountOdd  = 3;

#declare InitialTwist = 19;
#declare TwistDelta   = 0;
#declare Exposure     = 5;
#declare Zoom         = 0.95;
include "ChainMaker.inc"



A strange effect.pov

Zoom

The chain maker macro attempts to auto scale the output for you, but sometimes whey you are doing unusually patterns, the image may be slightly under or oversized. In these cases you can adjust the Zoom parameter. If you make the Zoom greater than 1, you will magnify the image proportionally. If the image overflows the boundaries of the screen, use a Zoom value less than 1.

//Basket Weave        
#include "ChainMakerDefaults.inc"
#declare LinkLength = 1.1;
#declare LinkRadius = 0.7;
#declare WireRadius = 0.025;

#declare CornerCount = 2;
#declare CornerLinkCount = 8;
#declare StraightLinkCountEven = 0;
#declare StraightLinkCountOdd  = 0;

#declare InitialTwist = 20;
#declare TwistDelta   = 0;
#declare Zoom = 0.85;
#declare Exposure = 2.6;
include "ChainMaker.inc"



Basket Weave.pov

//Overexposed Basket Weave        
#include "ChainMakerDefaults.inc"
#declare LinkLength = 1.1;
#declare LinkRadius = 0.7;
#declare WireRadius = 0.025;

#declare CornerCount = 2;
#declare CornerLinkCount = 8;
#declare StraightLinkCountEven = 0;
#declare StraightLinkCountOdd  = 0;

#declare InitialTwist = 20;
#declare TwistDelta   = 0;
#declare Zoom = 0.85;
#declare Exposure = 5;
include "ChainMaker.inc"



Overexposed Basket Weave.pov

//Alien Opening       
#include "ChainMakerDefaults.inc"
#declare LinkLength = 1.1;
#declare LinkRadius = 0.8;
#declare WireRadius = 0.125;

#declare CornerCount = 2;
#declare CornerLinkCount = 3;
#declare StraightLinkCountEven = 0;
#declare StraightLinkCountOdd  = 0;

#declare InitialTwist = 20;
#declare TwistDelta   = 2.5;
#declare Zoom = 0.75;
#declare Exposure = 1.55;
include "ChainMaker.inc"



Alien Opening.pov

That should be enough to get you started if you think Chain Maker is for you. I have really have just scratched the surface of what is possible with procedural surface generation in POVRAY. If you come up with some neat patterns or discover some thing interesting using my Chain Maker, please send them to chainmaker@comcast.net.

Copyright 2008 by Richard Swika

Rick's Chain Maker is the copyrighted intellectual property of Richard Swika. You may use the output of Rick's Chain Maker in any way, but you may not legally resell or distribute the Chain Maker source code or the contents of this website without the express written permission of Richard Swika. You may not claim authorship to the chain maker concept or to be the original creator of the resulting artwork.

Thanks and acknowledgments to the POVRAY team for making tools like Chain Maker possible and free! Much respect. Forward all donations to POVRAY.