aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/lightmanager.js
diff options
context:
space:
mode:
authorKris Kowal2012-07-06 12:34:53 -0700
committerKris Kowal2012-07-06 15:01:48 -0700
commit3644cb6def4f681c99959e5729e78ea353441fad (patch)
treef8a886f4829e507cc4956db37cff2580cae6003d /js/helper-classes/RDGE/src/core/script/lightmanager.js
parent04343eda8c2f870b0da55cfdc8003c99fe1cc4de (diff)
downloadninja-3644cb6def4f681c99959e5729e78ea353441fad.tar.gz
Normalize to unix line terminators
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/lightmanager.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/lightmanager.js238
1 files changed, 119 insertions, 119 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/lightmanager.js b/js/helper-classes/RDGE/src/core/script/lightmanager.js
index 2b20295c..74ab3e03 100755
--- a/js/helper-classes/RDGE/src/core/script/lightmanager.js
+++ b/js/helper-classes/RDGE/src/core/script/lightmanager.js
@@ -1,119 +1,119 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility, Inc
3All Rights Reserved. 3All Rights Reserved.
4BSD License. 4BSD License.
5 5
6Redistribution and use in source and binary forms, with or without 6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met: 7modification, 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
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28POSSIBILITY OF SUCH DAMAGE. 28POSSIBILITY OF SUCH DAMAGE.
29</copyright> */ 29</copyright> */
30 30
31// RDGE namespaces 31// RDGE namespaces
32var RDGE = RDGE || {}; 32var RDGE = RDGE || {};
33 33
34// manage light links 34// manage light links
35RDGE.LightManager = function (lightUniformList) { 35RDGE.LightManager = function (lightUniformList) {
36 // build a list of all light uniforms, contains a list of light uniform lists 36 // build a list of all light uniforms, contains a list of light uniform lists
37 this.lightUniforms = [[], [], [], []]; 37 this.lightUniforms = [[], [], [], []];
38 38
39 // bucket the uniforms lists 39 // bucket the uniforms lists
40 for (var l in lightUniformList) { 40 for (var l in lightUniformList) {
41 // starts with 41 // starts with
42 if (l.indexOf("u_light0") == 0) { 42 if (l.indexOf("u_light0") == 0) {
43 this.lightUniforms[0][l] = l; 43 this.lightUniforms[0][l] = l;
44 } 44 }
45 else if (l.indexOf("u_light1") == 0) { 45 else if (l.indexOf("u_light1") == 0) {
46 this.lightUniforms[1][l] = l; 46 this.lightUniforms[1][l] = l;
47 } 47 }
48 else if (l.indexOf("u_light2") == 0) { 48 else if (l.indexOf("u_light2") == 0) {
49 this.lightUniforms[2][l] = l; 49 this.lightUniforms[2][l] = l;
50 } 50 }
51 else if (l.indexOf("u_light3") == 0) { 51 else if (l.indexOf("u_light3") == 0) {
52 this.lightUniforms[3][l] = l; 52 this.lightUniforms[3][l] = l;
53 } 53 }
54 } 54 }
55 55
56 // maps (takes a string returns an object) 56 // maps (takes a string returns an object)
57 this.lightToMesh = []; // pass light name, returns light of meshes 57 this.lightToMesh = []; // pass light name, returns light of meshes
58 this.meshToLight = []; // pass mesh name, returns list of lights 58 this.meshToLight = []; // pass mesh name, returns list of lights
59 59
60 // list of light objects by type 60 // list of light objects by type
61 this.dirLights = []; 61 this.dirLights = [];
62 this.pointLights = []; 62 this.pointLights = [];
63 this.spotLights = []; 63 this.spotLights = [];
64 this.ambLights = []; 64 this.ambLights = [];
65 this.unknLights = []; 65 this.unknLights = [];
66 66
67 // light types 67 // light types
68 this.typePointLight = "point_light"; 68 this.typePointLight = "point_light";
69 this.typeSpotLight = "spot_light"; 69 this.typeSpotLight = "spot_light";
70 this.typeAmbLight = "amb_light"; 70 this.typeAmbLight = "amb_light";
71 this.typeDirLight = "dir_light"; 71 this.typeDirLight = "dir_light";
72 72
73 this.defaultLights = 73 this.defaultLights =
74 [ 74 [
75 RDGE.createLightNode("default0"), 75 RDGE.createLightNode("default0"),
76 RDGE.createLightNode("default1"), 76 RDGE.createLightNode("default1"),
77 RDGE.createLightNode("default2"), 77 RDGE.createLightNode("default2"),
78 RDGE.createLightNode("default3") 78 RDGE.createLightNode("default3")
79 ]; 79 ];
80}; 80};
81 81
82/* 82/*
83* configuration function called when loading the scene 83* configuration function called when loading the scene
84*/ 84*/
85RDGE.LightManager.prototype.setMapping = function (theLightNode, theLinks) { 85RDGE.LightManager.prototype.setMapping = function (theLightNode, theLinks) {
86 this.lightToMesh[theLightNode.name] = theLinks; 86 this.lightToMesh[theLightNode.name] = theLinks;
87 87
88 for (var lghtIdx = 0; lghtIdx < theLinks.length; lghtIdx++) { 88 for (var lghtIdx = 0; lghtIdx < theLinks.length; lghtIdx++) {
89 var lightList = this.meshToLight[theLinks[lghtIdx]]; // check if mapping list exists 89 var lightList = this.meshToLight[theLinks[lghtIdx]]; // check if mapping list exists
90 90
91 if (lightList !== undefined) { 91 if (lightList !== undefined) {
92 lightList.push(theLightNode); 92 lightList.push(theLightNode);
93 } else { 93 } else {
94 // create new light list and add light list mapping 94 // create new light list and add light list mapping
95 lightList = []; 95 lightList = [];
96 lightList.push(theLightNode); 96 lightList.push(theLightNode);
97 this.meshToLight[theLinks[lghtIdx]] = lightList; 97 this.meshToLight[theLinks[lghtIdx]] = lightList;
98 98
99 } 99 }
100 } 100 }
101 101
102 if (theLightNode.typeName == this.typePointLight) { 102 if (theLightNode.typeName == this.typePointLight) {
103 this.pointLights.push(theLightNode); 103 this.pointLights.push(theLightNode);
104 } else if (theLightNode.typeName == this.typeSpotLight) { 104 } else if (theLightNode.typeName == this.typeSpotLight) {
105 this.spotLights.push(theLightNode); 105 this.spotLights.push(theLightNode);
106 } else if (theLightNode.typeName == this.typeAmbLight) { 106 } else if (theLightNode.typeName == this.typeAmbLight) {
107 this.ambLights.push(theLightNode); 107 this.ambLights.push(theLightNode);
108 } else if (theLightNode.typeName == this.typeDirLight) { 108 } else if (theLightNode.typeName == this.typeDirLight) {
109 this.dirLights.push(theLightNode); 109 this.dirLights.push(theLightNode);
110 } else { 110 } else {
111 this.unknLights.push(theLightNode); 111 this.unknLights.push(theLightNode);
112 } 112 }
113 113
114 114
115}; 115};
116 116
117RDGE.LightManager.prototype.getLightsForMesh = function (mesh) { 117RDGE.LightManager.prototype.getLightsForMesh = function (mesh) {
118 return this.meshToLight[mesh]; 118 return this.meshToLight[mesh];
119}; 119};