Tarquin's Extruder Tutorial Part 2

### The path in relative terms

By: Tarquin

tarquin@planetunreal.com

Tarquin's UT

Preliminaries
Use the latest build of the extruder (currently 080).
Make sure your red builder brush is reset.
Read part 1 of this tutorial!

## Example 2.1

We'll start by making an archway, similar to the one I left as an exercise at the end of part 1.
Check your red builder brush is reset, and the grid size is 64. Make sure the ShapeSource property to pSquare, and both Factor properties are set to 64.
Enter the following path points and press build.
`PathPoints[0] = ( 0 , 0 , 0 )
PathPoints[1] = ( 0 , 0 , 2 )
PathPoints[2] = ( 2 , 0 , 6 )
PathPoints[3] = ( 6 , 0 , 6 )
PathPoints[4] = ( 8 , 0 , 2 )
PathPoints[5] = ( 8 , 0 , 0 )`

The diagram shows the front view. The path points are marked in yellow, starting at the origin and going up, across and back down to the x-axis.

## Example 2.2

Now let's suppose we want to make our arch wider by 128 units. We could of course use vertex editing, but we're going to re-build our brush with different parameters.
We want points 3,4 and 5 of the path to move to the right — in other words, we want the x co-ordinate of those points to increase. Because we're working with PathFactor set to 64, all the vectors we're entering into PathPoints get multiplied up by 64. So 128 units is 2 x 64, which means we want the right-hand side of the arch to move by two grid squares, so we want to add 2 to the x co-ordinate of the vectors for points 3,4 and 5.
However, we're not going to do this, because there's an easier way.

Relative Paths
So far, each vector we've entered has represented a point measured from the origin. Another way of putting it is that each time we're counting from the origin, giving instructions like this:

> Point zero is at the origin.
> Point 1 is 2 North from the origin.
> Now go to the spot that is 6 North and 2 East of the origin... etc

There's another way of doing this. Think of treasure maps. The best ones usually say something like:

> Start at the origin (okay, so the pirates were mathematicians!)
> Go 2 North.
> Now go 4 North and 2 East... etc

This type of instruction tells you how far to go on from where you currently are.
So the path for the arch we've built in the previous example could be written in relative vectors like this (don't type these in!):
`PathPoints[0] = ( 0 , 0 , 0 )
PathPoints[1] = ( 0 , 0 , 2 )
PathPoints[2] = ( 2 , 0 , 4 )
PathPoints[3] = ( 4 , 0 , 0 )
PathPoints[4] = ( 2 , 0 , -4 )
PathPoints[5] = ( 0 , 0 , -2 )`

This says: start at the origin. Go up, go up & across, go across, go down & across, go down. When looking at the grid and trying to work out what to type in for points, this format is easier because there's less counting involved.
To make this arch wider all we would need to do is change the number 4 in PathPoints[3] — that says 'go across' — to a larger number.
We're not going to type in all the path points all over again in the new relative form though! This would be terribly tedious, and so we're going to let the Extruder convert them for us...

The Command Module
Scroll down the list of properties until you find _COMMAND. This property lets you give special commands to the builder.
Set this to C_ConvPath: this command converts the vectors in the PathPoints list from absolute to relative and vice-versa, and completely bypasses the building process. Check that PathSource is still set to Vect_Abs — the command module looks here to find out which format you are currently using.
Press build. The following things will happen, though note that the properties window doesn't redraw itself until you make it active.

- The red builder brush will not change

- The vectors in the PathPoints list will change to look like the list given earlier in this example.

- The PathSource property will change to Vect_Rel. This is as a convenience, so you don't need to remember to change it.

- The _COMMAND property will reset itself to C_None — the command module is back to neutral and will not be called into action next time the build button is pressed.

Now find PathPoints[3] and change the x value to 6, then press build.

Note that as well as describing the point's position relative to the previous point, you can also think as the first vector as describing point zero, and then the other vectors describe the sections of the path.
From now on path points will be given as relative vectors, unless stated otherwise.
I'll return to the command module in a later part of this tutorial.

## Example 2.3

We're still not happy with this arch. We want to change the sloped bits.
Change the following:
`PathPoints[0] = ( 0 , 0 , 0 )
PathPoints[1] = ( 0 , 0 , 2 )
PathPoints[2] = ( 2 , 0 , 2 )
PathPoints[3] = ( 4 , 0 , 0 )
PathPoints[4] = ( 2 , 0 , -2 )
PathPoints[5] = ( 0 , 0 , -2 )`

Note that with build 078 or later, you won't get the glitchy diagonal line that you can see in this screenshot in the horizontal section of the arch. These pics were made with an earlier build and I really can't be bothered to do them again.

## Example 2.4

...except now it's too short! To make it taller, we change the first and last sections. Those are given by points number 1 and 5:
`PathPoints[0] = ( 0 , 0 , 0 )
PathPoints[1] = ( 0 , 0 , 4 )
PathPoints[2] = ( 2 , 0 , 2 )
PathPoints[3] = ( 4 , 0 , 0 )
PathPoints[4] = ( 2 , 0 , -2 )
PathPoints[5] = ( 0 , 0 , -4 )`

## Conclusion

Like bad television, we end with all the characters having a jolly jape.
Like bad kids' television, we clumsily fit in something educational or moral.
The list of path points in the Extruder properties can represent an absolute path or a relative path. The Extruder doesn't know on its own which type you are using, you need to tell it by setting the PathSource property.
Absolute vectors are simple point vectors. Each tells you how to get from the origin to the point.
With a path described by relative vectors, the first vector gives the position of the first point from the origin. The 2nd vector tells you how to get to the 2nd point from where you curently are, and so on.

Suggestions and comments about this tutorial, and screenshots of things you've extruded for a gallery page are welcome: tarquin@planetunreal.com

© Tarquin 17 April 2001