Difference Object

        [name  objname]  difference
                  object1
                  object2
        end  [transformations]  [textures]
Figure 5-8

The difference operator "subtracts" the second object from the first.

The example below creates a wine glass. It is similar to the example included with the cone primitive; but this glass has a curving stem and bowl.

The diagrams below show how the object was created.

Figure 5-9 Figure 5-10 Figure 5-11

        /*
           winecup.ray
           wine-cup with a curving stem (created using CSG)
           Stephen Peter 11 july 1992
        */
        eyep 215 100 221
        lookp 0 0 62
        screen 640 480
        light 1 directional 400 0 300

        surface glass
            diffuse .08 .08 .08
            specular .2 .2 .2
            reflect  1
            transp   1
            body    .8 .8 .8
            index   1.3

        surface white
            ambient  .4 .4 .4
            diffuse  .6 .6 .6
            specular .5 .5 .5

        surface green
            ambient  .1 .1 .1
            diffuse  .2 .7 .3
            specular .2 .2 .2

        /*--------------- create the parts ----------------*/
        name base_inner
            sphere  2.5   0 0 0   scale  14 14 1

        name base_outer
            difference
                sphere  5.0   0 0 0    scale  8 8 1
                box    -50 -50 -10   50 50 0
            end

        name bowl_inner
            sphere  39   0 0 0
                scale 1 1 2 translate 0 0 132.74

        name bowl_outer
            difference
                sphere  40   0 0 0
                     scale 1 1 2 translate 0 0 132.74
                box -50 -50 120   50 50 250
            end

        name stem_cyl
            list
                disc     29.27   0 0 57.78   0 0 1
                cylinder 29.27   0 0 0   0 0 57.78
                disc     29.27   0 0 0      0 0 -1
            end

        name stem_cut
            torus   33.57  30.93   0 0 34.04  0 0 1

        /*----------- bring the parts together ------------*/
        name stem
            difference
                object stem_cyl
                list
                    object bowl_inner
                    object stem_cut
                    object base_inner
                end
            end

        name solid_cup
            union
                union
                    object bowl_outer
                    object stem
                end
                object base_outer
            end

        name cup
            difference
                object solid_cup
                union
                    object base_inner
                    object bowl_inner
                end
            end
        object glass cup

        plane white 0 0 0  0 0 1
            texture checker green
            scale 50 50 1 translate 0 0 .1

Go to next section:
CSG Problems.

Return to Contents.

THE END - Notes on Rayshade - 5 - Objects - Difference