diff options
author | hwc487 | 2012-04-04 16:32:53 -0700 |
---|---|---|
committer | hwc487 | 2012-04-04 16:32:53 -0700 |
commit | 6ee8b65742fbe61b4429dc8c7dc9ca33a3e43600 (patch) | |
tree | f267e05f623ed90d1cc841b8c79a338d6d8e807c /js/helper-classes/RDGE/src/core/script/lightmanager.js | |
parent | 16f62ca09cc428043e8fef8bdeea11a989e62bc0 (diff) | |
parent | 17ca01f54591187f5c0812c0fd2cb7260afa9639 (diff) | |
download | ninja-6ee8b65742fbe61b4429dc8c7dc9ca33a3e43600.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into Snapping
Conflicts:
js/panels/presets/animations-presets.reel/animations-presets.js
js/panels/presets/style-presets.reel/style-presets.js
js/panels/presets/transitions-presets.reel/transitions-presets.js
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/lightmanager.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/lightmanager.js | 148 |
1 files changed, 73 insertions, 75 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/lightmanager.js b/js/helper-classes/RDGE/src/core/script/lightmanager.js index 7d76ef90..f92017ce 100755 --- a/js/helper-classes/RDGE/src/core/script/lightmanager.js +++ b/js/helper-classes/RDGE/src/core/script/lightmanager.js | |||
@@ -4,94 +4,92 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | // RDGE namespaces | ||
8 | var RDGE = RDGE || {}; | ||
9 | |||
7 | // manage light links | 10 | // manage light links |
11 | RDGE.LightManager = function (lightUniformList) { | ||
12 | // build a list of all light uniforms, contains a list of light uniform lists | ||
13 | this.lightUniforms = [[], [], [], []]; | ||
14 | |||
15 | // bucket the uniforms lists | ||
16 | for (var l in lightUniformList) { | ||
17 | // starts with | ||
18 | if (l.indexOf("u_light0") == 0) { | ||
19 | this.lightUniforms[0][l] = l; | ||
20 | } | ||
21 | else if (l.indexOf("u_light1") == 0) { | ||
22 | this.lightUniforms[1][l] = l; | ||
23 | } | ||
24 | else if (l.indexOf("u_light2") == 0) { | ||
25 | this.lightUniforms[2][l] = l; | ||
26 | } | ||
27 | else if (l.indexOf("u_light3") == 0) { | ||
28 | this.lightUniforms[3][l] = l; | ||
29 | } | ||
30 | } | ||
8 | 31 | ||
9 | function LightManager( lightUniformList ) | 32 | // maps (takes a string returns an object) |
10 | { | 33 | this.lightToMesh = []; // pass light name, returns light of meshes |
11 | // build a list of all light uniforms, contains a list of light uniform lists | 34 | this.meshToLight = []; // pass mesh name, returns list of lights |
12 | this.lightUniforms = [ [], [], [], [] ]; | ||
13 | |||
14 | // bucket the uniforms lists | ||
15 | for(var l in lightUniformList) | ||
16 | { | ||
17 | // starts with | ||
18 | if(l.indexOf("u_light0") == 0) | ||
19 | { | ||
20 | this.lightUniforms[0][l] = l; | ||
21 | } | ||
22 | else if(l.indexOf("u_light1") == 0) | ||
23 | { | ||
24 | this.lightUniforms[1][l] = l; | ||
25 | } | ||
26 | else if(l.indexOf("u_light2") == 0) | ||
27 | { | ||
28 | this.lightUniforms[2][l] = l; | ||
29 | } | ||
30 | else if(l.indexOf("u_light3") == 0) | ||
31 | { | ||
32 | this.lightUniforms[3][l] = l; | ||
33 | } | ||
34 | } | ||
35 | |||
36 | // maps (takes a string returns an object) | ||
37 | this.lightToMesh =[]; // pass light name, returns light of meshes | ||
38 | this.meshToLight =[]; // pass mesh name, returns list of lights | ||
39 | 35 | ||
40 | // list of light objects by type | 36 | // list of light objects by type |
41 | this.dirLights=[]; | 37 | this.dirLights = []; |
42 | this.pointLights=[]; | 38 | this.pointLights = []; |
43 | this.spotLights = []; | 39 | this.spotLights = []; |
44 | this.ambLights = []; | 40 | this.ambLights = []; |
45 | this.unknLights = []; | 41 | this.unknLights = []; |
46 | 42 | ||
47 | // light types | 43 | // light types |
48 | this.typePointLight = "point_light"; | 44 | this.typePointLight = "point_light"; |
49 | this.typeSpotLight = "spot_light"; | 45 | this.typeSpotLight = "spot_light"; |
50 | this.typeAmbLight = "amb_light"; | 46 | this.typeAmbLight = "amb_light"; |
51 | this.typeDirLight = "dir_light"; | 47 | this.typeDirLight = "dir_light"; |
52 | 48 | ||
53 | this.defaultLights = | 49 | this.defaultLights = |
54 | [ | 50 | [ |
55 | createLightNode("default0"), | 51 | RDGE.createLightNode("default0"), |
56 | createLightNode("default1"), | 52 | RDGE.createLightNode("default1"), |
57 | createLightNode("default2"), | 53 | RDGE.createLightNode("default2"), |
58 | createLightNode("default3") | 54 | RDGE.createLightNode("default3") |
59 | ]; | 55 | ]; |
60 | } | 56 | }; |
61 | 57 | ||
62 | /* | 58 | /* |
63 | * configuration function called when loading the scene | 59 | * configuration function called when loading the scene |
64 | */ | 60 | */ |
65 | LightManager.prototype.setMapping = function(theLightNode, theLinks) { | 61 | RDGE.LightManager.prototype.setMapping = function (theLightNode, theLinks) { |
66 | this.lightToMesh[theLightNode.name] = theLinks; | 62 | this.lightToMesh[theLightNode.name] = theLinks; |
67 | 63 | ||
68 | for (var lghtIdx = 0; lghtIdx < theLinks.length; lghtIdx++) { | 64 | for (var lghtIdx = 0; lghtIdx < theLinks.length; lghtIdx++) { |
69 | var lightList = this.meshToLight[theLinks[lghtIdx]]; // check if mapping list exists | 65 | var lightList = this.meshToLight[theLinks[lghtIdx]]; // check if mapping list exists |
70 | 66 | ||
71 | if (lightList !== undefined) { | 67 | if (lightList !== undefined) { |
72 | lightList.push(theLightNode); | 68 | lightList.push(theLightNode); |
73 | } else { | 69 | } else { |
74 | // create new light list and add light list mapping | 70 | // create new light list and add light list mapping |
75 | lightList = []; | 71 | lightList = []; |
76 | lightList.push(theLightNode); | 72 | lightList.push(theLightNode); |
77 | this.meshToLight[theLinks[lghtIdx]] = lightList; | 73 | this.meshToLight[theLinks[lghtIdx]] = lightList; |
78 | 74 | ||
75 | } | ||
76 | } | ||
77 | |||
78 | if (theLightNode.typeName == this.typePointLight) { | ||
79 | this.pointLights.push(theLightNode); | ||
80 | } else if (theLightNode.typeName == this.typeSpotLight) { | ||
81 | this.spotLights.push(theLightNode); | ||
82 | } else if (theLightNode.typeName == this.typeAmbLight) { | ||
83 | this.ambLights.push(theLightNode); | ||
84 | } else if (theLightNode.typeName == this.typeDirLight) { | ||
85 | this.dirLights.push(theLightNode); | ||
86 | } else { | ||
87 | this.unknLights.push(theLightNode); | ||
79 | } | 88 | } |
80 | } | ||
81 | 89 | ||
82 | if (theLightNode.typeName == this.typePointLight) { | ||
83 | this.pointLights.push(theLightNode); | ||
84 | } else if (theLightNode.typeName == this.typeSpotLight) { | ||
85 | this.spotLights.push(theLightNode); | ||
86 | } else if (theLightNode.typeName == this.typeAmbLight) { | ||
87 | this.ambLights.push(theLightNode); | ||
88 | } else if (theLightNode.typeName == this.typeDirLight) { | ||
89 | this.dirLights.push(theLightNode); | ||
90 | }else{ | ||
91 | this.unknLights.push(theLightNode); | ||
92 | } | ||
93 | |||
94 | 90 | ||
95 | } | 91 | }; |
96 | 92 | ||
97 | LightManager.prototype.getLightsForMesh = function(mesh) { return this.meshToLight[mesh]; } | 93 | RDGE.LightManager.prototype.getLightsForMesh = function (mesh) { |
94 | return this.meshToLight[mesh]; | ||
95 | }; | ||