This lab demonstrates the effect that Alpha Sort order has on objects with transparency. When the sort order of all three
buckets is set to zero (the default), the closest object (determined by the distance to the object's center point)
will appear in front.
Click and drag within the scene to change the angle of the bucket stack.
When the camera is above the yellow bucket's centerpoint, the red bucket will be closer than
the yellow bucket (as in the illustration below),
but the yellow bucket should appear in front, since the red bucket is partially inside the yellow one. The effect this
produces looks like something out of an Escher print; the red bucket appears to be both inside and in front of the yellow
bucket.
To correct this problem, set the Alpha sort order of the red bucket to 1, the yellow one to 2, and the blue to 3. This
will cause the buckets to render in the proper order (the red bucket first, followed by the yellow one, and the blue
bucket last), regardless of their distance to the camera.
This use of setOption only applies to containers, groups, and actors; setOption has different uses for other
objects (such as WT::setOption, which is used to control garbage collection).
Remember that in 3d graphics we use the painter's algorithm: Objects rendered last will actually appear in front of
objects rendered first, rather than behind them, since they get rendered over the previous objects.
You've probably noticed that you can't see the bucket walls from the inside. The scene was constructed this way
because even though you can now manually sort Alpha polygons by object, you still can't sort them by polygon.
So, if the inner walls were visible, the yellow bucket's inner wall would appear to be in front of the red bucket's
outer wall (rather than behind it, as it should be). While the new setOption method gives you finer control of alpha
sorting, you must still be careful to avoid situations in which you need an object to be in front of another object in
one place, and behind it in another place. In situations like these, you should either divide the object in question into
smaller units, or see if your scene could use Colorkeyed polygons instead of Alpha.
When using Web Driver 2.2 or later, you can use negative values for the
sort buckets. This is handy because the default is 0 for all objects.