## NW3D - Use of lathe and path objects

This applet demonstrates the use of lathe and path objects from within the objectfactory class. Demo first, explanation afterward.

The path class is used to store a series of x/y coordinates that can be joined in sequence to form a 2D outline. The lathe class takes a path and rotates it through 360 degrees around the y-axis to form a solid 3D object. Texture coordinates are calculated and a user-specified material applied. There is also a parameter to control whether multiple vertices with the same coordinates are considered to be the same, for the purposes of the shading algorithm. The torus in the above demo has this set to 'true' and as you can see this as the effect of creating a far smoother finish.

Going back a step, let's look firstly at how the cylinder was created. The instructions within the applet look like this:-

```  nw3d_material col2 = new nw3d_material(0.1f,0.7f,0.4f,20);
nw3d_path path3 = new nw3d_path(new float[] {0,3,1,3,1,-3,0,-3});
The first line creates a new greenish material, 'col2'. The second line creates a new path object comprising the 4 x/y coordinates necessary to define the cylinder. The third line uses the path object form the previous instruction as an input to create a new geometry. A quick note on the parameters: they are the path, the number of segments, the material to use, and the flag described above that denotes smooth shading. A higher number of segments creates a more detailed model. The coordinates can be visualised as follows:-

Similarly, the spinning top is defined as follows:-

```  nw3d_material col1 = new nw3d_material(0.7f,0.1f,1.0f,30);
nw3d_path path = new nw3d_path(new float[] {0,3,0.5f,3,0.5f,2.5f,4,1.5f,4,1.4f,1,0,0,-3});
```  nw3d_path path2 = nw3d_objectfactory.CirclePath(1,40);