diff options
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/shadowLight.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/shadowLight.js | 152 |
1 files changed, 76 insertions, 76 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/shadowLight.js b/js/helper-classes/RDGE/src/core/script/shadowLight.js index 010fe146..c1a40eb3 100755 --- a/js/helper-classes/RDGE/src/core/script/shadowLight.js +++ b/js/helper-classes/RDGE/src/core/script/shadowLight.js | |||
@@ -1,76 +1,76 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility, Inc |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | 4 | BSD License. |
5 | 5 | ||
6 | Redistribution and use in source and binary forms, with or without | 6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: | 7 | modification, are permitted provided that the following conditions are met: |
8 | 8 | ||
9 | - Redistributions of source code must retain the above copyright notice, | 9 | - Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. | 10 | this list of conditions and the following disclaimer. |
11 | - Redistributions in binary form must reproduce the above copyright | 11 | - Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the | 12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. | 13 | documentation and/or other materials provided with the distribution. |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 14 | - Neither the name of Motorola Mobility nor the names of its contributors |
15 | may be used to endorse or promote products derived from this software | 15 | may be used to endorse or promote products derived from this software |
16 | without specific prior written permission. | 16 | without specific prior written permission. |
17 | 17 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
28 | POSSIBILITY OF SUCH DAMAGE. | 28 | POSSIBILITY OF SUCH DAMAGE. |
29 | </copyright> */ | 29 | </copyright> */ |
30 | 30 | ||
31 | // RDGE namespaces | 31 | // RDGE namespaces |
32 | var RDGE = RDGE || {}; | 32 | var RDGE = RDGE || {}; |
33 | 33 | ||
34 | /* | 34 | /* |
35 | * shadow light - a modified camera used to describe a shadow casting light | 35 | * shadow light - a modified camera used to describe a shadow casting light |
36 | */ | 36 | */ |
37 | RDGE.shadowLight = function () { | 37 | RDGE.shadowLight = function () { |
38 | // inherit from the base class | 38 | // inherit from the base class |
39 | this.inheritedFrom = RDGE.camera; | 39 | this.inheritedFrom = RDGE.camera; |
40 | this.inheritedFrom(); | 40 | this.inheritedFrom(); |
41 | 41 | ||
42 | // matrices needed for shadow projection | 42 | // matrices needed for shadow projection |
43 | this.invViewMatrix = RDGE.mat4.identity(); | 43 | this.invViewMatrix = RDGE.mat4.identity(); |
44 | this.mvpMatrix = RDGE.mat4.identity(); | 44 | this.mvpMatrix = RDGE.mat4.identity(); |
45 | 45 | ||
46 | // texture matrix | 46 | // texture matrix |
47 | this.shadowMatrix = RDGE.mat4.identity(); | 47 | this.shadowMatrix = RDGE.mat4.identity(); |
48 | this.shadowMatrix = RDGE.mat4.scale(this.shadowMatrix, [0.5, 0.5, 0.5]); | 48 | this.shadowMatrix = RDGE.mat4.scale(this.shadowMatrix, [0.5, 0.5, 0.5]); |
49 | this.shadowMatrix = RDGE.mat4.translate(this.shadowMatrix, [0.5, 0.5, 0.5]); | 49 | this.shadowMatrix = RDGE.mat4.translate(this.shadowMatrix, [0.5, 0.5, 0.5]); |
50 | 50 | ||
51 | // cached references | 51 | // cached references |
52 | this.renderer = null; | 52 | this.renderer = null; |
53 | this.cameraManager = null; | 53 | this.cameraManager = null; |
54 | 54 | ||
55 | // shadow bias offset | 55 | // shadow bias offset |
56 | this.shadowBias = 0.0195; | 56 | this.shadowBias = 0.0195; |
57 | 57 | ||
58 | this.init = function () { | 58 | this.init = function () { |
59 | this.renderer = RDGE.globals.engine.getContext().renderer; | 59 | this.renderer = RDGE.globals.engine.getContext().renderer; |
60 | this.cameraManager = this.renderer.cameraManager(); | 60 | this.cameraManager = this.renderer.cameraManager(); |
61 | }; | 61 | }; |
62 | 62 | ||
63 | /* | 63 | /* |
64 | * makes the light the current 'camera' | 64 | * makes the light the current 'camera' |
65 | */ | 65 | */ |
66 | this.activate = function () { | 66 | this.activate = function () { |
67 | this.cameraManager.pushCamera(this); | 67 | this.cameraManager.pushCamera(this); |
68 | }; | 68 | }; |
69 | 69 | ||
70 | /* | 70 | /* |
71 | * restores the camera stack | 71 | * restores the camera stack |
72 | */ | 72 | */ |
73 | this.deactivate = function () { | 73 | this.deactivate = function () { |
74 | this.cameraManager.popCamera(); | 74 | this.cameraManager.popCamera(); |
75 | }; | 75 | }; |
76 | } | 76 | } |