PageRenderTime 16ms CodeModel.GetById 9ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/src/away3d/lights/shadowmaps/PlanarShadowMapper.as

http://github.com/away3d/away3d-core-fp11
ActionScript | 44 lines | 32 code | 6 blank | 6 comment | 0 complexity | 1bf8df08514f117e0d5d254a2b4e81ef MD5 | raw file
 1/**
 2 * Author: David Lenaerts
 3 */
 4package away3d.lights.shadowmaps
 5{
 6	import away3d.arcane;
 7	import away3d.cameras.Camera3D;
 8	import away3d.containers.Scene3D;
 9	import away3d.core.render.DepthRenderer;
10	import away3d.lights.LightBase;
11
12	import flash.display3D.textures.TextureBase;
13	import flash.geom.Matrix3D;
14
15	use namespace arcane;
16
17	public class PlanarShadowMapper extends ShadowMapperBase
18	{
19		protected var _depthCamera : Camera3D;
20
21		public function PlanarShadowMapper(light : LightBase)
22		{
23			super(light);
24			_depthCamera = new Camera3D();
25		}
26
27		/**
28		 * Depth projection matrix that projects from scene space to depth map.
29		 */
30		override arcane function get depthProjection() : Matrix3D
31		{
32			return _depthCamera.viewProjection;
33		}
34
35		override protected function drawDepthMap(target : TextureBase, scene : Scene3D, renderer : DepthRenderer) : void
36		{
37			_casterCollector.clear();
38			_casterCollector.camera = _depthCamera;
39			scene.traversePartitions(_casterCollector);
40			renderer.render(_casterCollector, target);
41			_casterCollector.cleanUp();
42		}
43	}
44}