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