aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/shadowLight.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/shadowLight.js')
-rw-r--r--js/helper-classes/RDGE/src/core/script/shadowLight.js54
1 files changed, 54 insertions, 0 deletions
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 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */
6
7/*
8 * shadow light - a modified camera used to describe a shadow casting light
9 */
10shadowLight = function()
11{
12 // inherit from the base class
13 this.inheritedFrom = camera;
14 this.inheritedFrom();
15
16 // matrices needed for shadow projection
17 this.invViewMatrix=mat4.identity();
18 this.mvpMatrix=mat4.identity();
19
20 // texture matrix
21 this.shadowMatrix=mat4.identity();
22 this.shadowMatrix=mat4.scale(this.shadowMatrix,[0.5,0.5,0.5]);
23 this.shadowMatrix=mat4.translate(this.shadowMatrix,[0.5,0.5,0.5]);
24
25 // cached references
26 this.renderer = null;
27 this.cameraManager = null;
28
29 // shadow bias offset
30 this.shadowBias = 0.0195;
31
32 this.init = function ()
33 {
34 this.renderer = g_Engine.getContext().renderer;
35 this.cameraManager = this.renderer.cameraManager();
36 }
37
38 /*
39 * makes the light the current 'camera'
40 */
41 this.activate = function()
42 {
43 this.cameraManager.pushCamera(this);
44 }
45
46 /*
47 * restores the camera stack
48 */
49 this.deactivate = function()
50 {
51 this.cameraManager.popCamera();
52 }
53
54}