POV-Ray : Documentation : 1.4.1.10 How can I fill a glass with water or other objects?
  POV-Ray 3.6 Documentation Online View  
1.4.1.9 How do I make an object hollow?   1.4.1.11 How can I bend a object?

1.4.1.10 How can I fill a glass with water or other objects?

As described in the "hollow objects" question above, hollow objects have always two surfaces: an outer surface and an inner surface. If we take the same example, a simple glass would be like:

// A simple water glass made with a difference:
#declare MyGlass=
difference
{ cone { <0,0,0>,1,<0,5,0>,1.2 }
  cone { <0,.1,0>,.9,<0,5.1,0>,1.1 }
  texture { Glass }
}

The first cone limits the outer surface of the glass and the second cone limits the inner surface.

If we want to fill the glass with water, we have to make an object which coincides with the inner surface of the glass. Note that you have to avoid the coincident surfaces problem so you should scale the "water" object just a little bit smaller than the inner surface of the glass. So we make something like this:

#declare MyGlassWithWater=
union
{ object { MyGlass }
  cone
  { <0,.1,0>,.9,<0,5.1,0>,1.1
    scale .999
    texture { Water }
  }
}

Now the glass is filled with water. But there is one problem: There is too much water. The glass should be filled only up to certain level, which should be definable. Well, this can be easily made with a CSG operation:

#declare MyGlassWithWater=
union
{ object { MyGlass }
  intersection
  { cone { <0,.1,0>,.9,<0,5.1,0>,1.1 }
    plane { y,4 }
    scale .999
    texture { Water }
  }
}

Now the water level is at a height of 4 units.

1.4.1.9 How do I make an object hollow?   1.4.1.11 How can I bend a object?


Copyright 2003-2004 Persistence of Vision Raytracer Pty. Ltd.