diff options
author | John Mayhew | 2012-04-02 16:28:39 -0700 |
---|---|---|
committer | John Mayhew | 2012-04-02 16:28:39 -0700 |
commit | b4155fb4c33675a8a7cd37473513718043fdf0ba (patch) | |
tree | 3d8c802473f2395d53d599ec9d8b70b60a4db50c /js/lib/rdge/materials/bump-metal-material.js | |
parent | 5ba9aeac94c86049423fd5d4b37b277263939c13 (diff) | |
parent | c6de22bf42be90b403491b5f87b1818d9020310c (diff) | |
download | ninja-b4155fb4c33675a8a7cd37473513718043fdf0ba.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into WorkingBranch
Conflicts:
js/helper-classes/RDGE/rdge-compiled.js
js/helper-classes/RDGE/runtime/GLRuntime.js
js/helper-classes/RDGE/src/core/script/MeshManager.js
js/helper-classes/RDGE/src/core/script/engine.js
js/helper-classes/RDGE/src/core/script/fx/ssao.js
js/helper-classes/RDGE/src/core/script/init_state.js
js/helper-classes/RDGE/src/core/script/run_state.js
js/helper-classes/RDGE/src/core/script/scenegraphNodes.js
js/helper-classes/RDGE/src/core/script/utilities.js
js/helper-classes/RDGE/src/tools/compile-rdge-core.bat
js/helper-classes/RDGE/src/tools/compile-rdge-core.sh
js/helper-classes/RDGE/src/tools/rdge-compiled.js
js/lib/drawing/world.js
js/lib/rdge/materials/bump-metal-material.js
js/lib/rdge/materials/deform-material.js
js/lib/rdge/materials/flat-material.js
js/lib/rdge/materials/fly-material.js
js/lib/rdge/materials/julia-material.js
js/lib/rdge/materials/keleidoscope-material.js
js/lib/rdge/materials/linear-gradient-material.js
js/lib/rdge/materials/mandel-material.js
js/lib/rdge/materials/plasma-material.js
js/lib/rdge/materials/pulse-material.js
js/lib/rdge/materials/radial-blur-material.js
js/lib/rdge/materials/radial-gradient-material.js
js/lib/rdge/materials/relief-tunnel-material.js
js/lib/rdge/materials/square-tunnel-material.js
js/lib/rdge/materials/star-material.js
js/lib/rdge/materials/taper-material.js
js/lib/rdge/materials/tunnel-material.js
js/lib/rdge/materials/twist-material.js
js/lib/rdge/materials/twist-vert-material.js
js/lib/rdge/materials/uber-material.js
js/lib/rdge/materials/water-material.js
js/lib/rdge/materials/z-invert-material.js
js/preloader/Preloader.js
Diffstat (limited to 'js/lib/rdge/materials/bump-metal-material.js')
-rwxr-xr-x | js/lib/rdge/materials/bump-metal-material.js | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js index e0ca8d4a..d764de66 100755 --- a/js/lib/rdge/materials/bump-metal-material.js +++ b/js/lib/rdge/materials/bump-metal-material.js | |||
@@ -75,7 +75,7 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
75 | this.setProperty = function( prop, value ) | 75 | this.setProperty = function( prop, value ) |
76 | { | 76 | { |
77 | // every material should do something with the "color" property | 77 | // every material should do something with the "color" property |
78 | if (prop === "color") prop = "lightDiff"; | 78 | if (prop === "color") return; |
79 | 79 | ||
80 | // make sure we have legitimate imput | 80 | // make sure we have legitimate imput |
81 | var ok = this.validateProperty( prop, value ); | 81 | var ok = this.validateProperty( prop, value ); |
@@ -107,7 +107,9 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
107 | this.init = function( world ) | 107 | this.init = function( world ) |
108 | { | 108 | { |
109 | // save the world | 109 | // save the world |
110 | if (world) this.setWorld( world ); | 110 | if (world) { |
111 | this.setWorld( world ); | ||
112 | } | ||
111 | 113 | ||
112 | // set up the shader | 114 | // set up the shader |
113 | this._shader = new RDGE.jshader(); | 115 | this._shader = new RDGE.jshader(); |
@@ -116,7 +118,7 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
116 | this._shader['default'].u_light0Diff.set( this.getLightDiff() ); | 118 | this._shader['default'].u_light0Diff.set( this.getLightDiff() ); |
117 | 119 | ||
118 | // set up the material node | 120 | // set up the material node |
119 | this._materialNode = RDGE.createMaterialNode(this.getShaderName()); | 121 | this._materialNode = RDGE.createMaterialNode( this.getShaderName() + "_" + world.generateUniqueNodeID() ); |
120 | this._materialNode.setShader(this._shader); | 122 | this._materialNode.setShader(this._shader); |
121 | 123 | ||
122 | // set some image maps | 124 | // set some image maps |
@@ -152,12 +154,56 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
152 | } | 154 | } |
153 | }; | 155 | }; |
154 | 156 | ||
157 | this.exportJSON = function() | ||
158 | { | ||
159 | var jObj = | ||
160 | { | ||
161 | 'material' : this.getShaderName(), | ||
162 | 'name' : this.getName(), | ||
163 | 'lightDiff' : this.getLightDiff(), | ||
164 | 'diffuseTexture' : this.getDiffuseTexture(), | ||
165 | 'specularTexture' : this.getSpecularTexture(), | ||
166 | 'normalMap' : this.getNormalTexture() | ||
167 | }; | ||
168 | |||
169 | return jObj; | ||
170 | }; | ||
171 | |||
172 | this.importJSON = function( jObj ) | ||
173 | { | ||
174 | if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" ); | ||
175 | this.setName( jObj.name ); | ||
176 | |||
177 | try | ||
178 | { | ||
179 | var lightDiff = jObj.lightDiff, | ||
180 | dt = jObj.diffuseTexture, | ||
181 | st = jObj.specularTexture, | ||
182 | nt = jObj.normalMap; | ||
183 | |||
184 | this.setProperty( "lightDiff", lightDiff); | ||
185 | this.setProperty( "diffuseTexture", dt ); | ||
186 | this.setProperty( "specularTexture", st ); | ||
187 | this.setProperty( "normalMap", nt ); | ||
188 | } | ||
189 | catch (e) | ||
190 | { | ||
191 | throw new Error( "could not import BumpMetal material: " + jObj ); | ||
192 | } | ||
193 | |||
194 | return; | ||
195 | }; | ||
196 | |||
155 | this.export = function() | 197 | this.export = function() |
156 | { | 198 | { |
157 | // every material needs the base type and instance name | 199 | // every material needs the base type and instance name |
158 | var exportStr = "material: " + this.getShaderName() + "\n"; | 200 | var exportStr = "material: " + this.getShaderName() + "\n"; |
159 | exportStr += "name: " + this.getName() + "\n"; | 201 | exportStr += "name: " + this.getName() + "\n"; |
160 | 202 | ||
203 | var world = this.getWorld(); | ||
204 | if (!world) | ||
205 | throw new Error( "no world in material.export, " + this.getName() ); | ||
206 | |||
161 | exportStr += "lightDiff: " + this.getLightDiff() + "\n"; | 207 | exportStr += "lightDiff: " + this.getLightDiff() + "\n"; |
162 | exportStr += "diffuseTexture: " + this.getDiffuseTexture() + "\n"; | 208 | exportStr += "diffuseTexture: " + this.getDiffuseTexture() + "\n"; |
163 | exportStr += "specularTexture: " + this.getSpecularTexture() + "\n"; | 209 | exportStr += "specularTexture: " + this.getSpecularTexture() + "\n"; |