This little interactive applet demonstrates possibilities of new MediumAttributes class to create partially opaque medium effects such as fog.
The class will be available in next 3.0.2 release, but you already can use it with current SVN version.
Here is the code for Flash CS3 document class. Create new FLA file, set it to 550×300, 24 fps, add any texture you want and set its class to FogDemoBox_GIF in its linkage properties dialog. Set the document class to FogDemo, and you're done.
package { import flash.display.Sprite; import flash.events.Event; import sandy.core.World3D; import sandy.core.data.Vector; import sandy.core.scenegraph.Camera3D; import sandy.core.scenegraph.Group; import sandy.materials.Appearance; import sandy.materials.BitmapMaterial; import sandy.materials.attributes.MaterialAttributes; import sandy.materials.attributes.MediumAttributes; import sandy.primitive.Box; public class FogDemo extends Sprite { private var boxes:Array = []; private var world:World3D = World3D.getInstance (); private var medium:MediumAttributes; public function FogDemo () { world.container = this; world.camera = new Camera3D (550, 300); // create a single attributes instance for all objects medium = new MediumAttributes (); var appearance:Appearance = new Appearance ( new BitmapMaterial (new FogDemoBox_GIF (1, 1), new MaterialAttributes (medium), 3)); var scene:Group = new Group ("root"); for (var i:int = 0; i < 16; i++) { boxes [i] = new Box ("box" + i, 25, 25, 25); boxes [i].appearance = appearance; boxes [i].x = 20 * (i - 8); boxes [i].y = 200 * (Math.random () - Math.random ()); boxes [i].z = 1000 * (Math.random () - Math.random ()); boxes [i].rotateX = 360 * Math.random (); boxes [i].rotateY = 360 * Math.random (); boxes [i].rotateZ = 360 * Math.random (); scene.addChild (boxes [i]); } scene.addChild (world.camera); world.root = scene; addEventListener (Event.ENTER_FRAME, onEnterFrame); } private function onEnterFrame (event:Event):void { var a:Number = Math.PI * (mouseX - (550/2)) / (550/2); world.camera.setPosition ( 400 * Math.sin (a), 300 - 2 * mouseY, -400 * Math.cos (a)); world.camera.lookAt (0, 0, 0); // all MediumAttributes parameters can be changed at runtime // here we change amount of blur applied to our objects medium.blurAmount = 1 + mouseY / 10; for (var i:int = 0; i < boxes.length; i++) { boxes [i].z -= 10; if (boxes [i].z < -500) boxes [i].z = 500; } world.render (); } } }