From b89a7ee8b956c96a1dcee995ea840feddc5d4b27 Mon Sep 17 00:00:00 2001 From: Pierre Frisch Date: Thu, 22 Dec 2011 07:25:50 -0800 Subject: First commit of Ninja to ninja-internal Signed-off-by: Valerio Virgillito --- .../RDGE/src/core/script/shadowLight.js | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 js/helper-classes/RDGE/src/core/script/shadowLight.js (limited to 'js/helper-classes/RDGE/src/core/script/shadowLight.js') diff --git a/js/helper-classes/RDGE/src/core/script/shadowLight.js b/js/helper-classes/RDGE/src/core/script/shadowLight.js new file mode 100644 index 00000000..80d9331a --- /dev/null +++ b/js/helper-classes/RDGE/src/core/script/shadowLight.js @@ -0,0 +1,54 @@ +/* +This file contains proprietary software owned by Motorola Mobility, Inc.
+No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + +/* + * shadow light - a modified camera used to describe a shadow casting light + */ +shadowLight = function() +{ + // inherit from the base class + this.inheritedFrom = camera; + this.inheritedFrom(); + + // matrices needed for shadow projection + this.invViewMatrix=mat4.identity(); + this.mvpMatrix=mat4.identity(); + + // texture matrix + this.shadowMatrix=mat4.identity(); + this.shadowMatrix=mat4.scale(this.shadowMatrix,[0.5,0.5,0.5]); + this.shadowMatrix=mat4.translate(this.shadowMatrix,[0.5,0.5,0.5]); + + // cached references + this.renderer = null; + this.cameraManager = null; + + // shadow bias offset + this.shadowBias = 0.0195; + + this.init = function () + { + this.renderer = g_Engine.getContext().renderer; + this.cameraManager = this.renderer.cameraManager(); + } + + /* + * makes the light the current 'camera' + */ + this.activate = function() + { + this.cameraManager.pushCamera(this); + } + + /* + * restores the camera stack + */ + this.deactivate = function() + { + this.cameraManager.popCamera(); + } + +} -- cgit v1.2.3