aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/radial-gradient-material.js
diff options
context:
space:
mode:
authorJohn Mayhew2012-04-02 16:28:39 -0700
committerJohn Mayhew2012-04-02 16:28:39 -0700
commitb4155fb4c33675a8a7cd37473513718043fdf0ba (patch)
tree3d8c802473f2395d53d599ec9d8b70b60a4db50c /js/lib/rdge/materials/radial-gradient-material.js
parent5ba9aeac94c86049423fd5d4b37b277263939c13 (diff)
parentc6de22bf42be90b403491b5f87b1818d9020310c (diff)
downloadninja-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/radial-gradient-material.js')
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js61
1 files changed, 58 insertions, 3 deletions
diff --git a/js/lib/rdge/materials/radial-gradient-material.js b/js/lib/rdge/materials/radial-gradient-material.js
index faac7f1b..28a66a2c 100755
--- a/js/lib/rdge/materials/radial-gradient-material.js
+++ b/js/lib/rdge/materials/radial-gradient-material.js
@@ -158,7 +158,8 @@ var RadialGradientMaterial = function RadialGradientMaterial() {
158 this._propValues[ this._propNames[6] ] = this._colorStop3; 158 this._propValues[ this._propNames[6] ] = this._colorStop3;
159 this._propValues[ this._propNames[7] ] = this._colorStop4; 159 this._propValues[ this._propNames[7] ] = this._colorStop4;
160 160
161 this.setProperty = function( prop, value ) { 161 this.setProperty = function( prop, value )
162 {
162 if (prop === "color") prop = "color1"; 163 if (prop === "color") prop = "color1";
163 164
164 // make sure we have legitimate imput 165 // make sure we have legitimate imput
@@ -193,14 +194,17 @@ var RadialGradientMaterial = function RadialGradientMaterial() {
193 return new RadialGradientMaterial(); 194 return new RadialGradientMaterial();
194 }; 195 };
195 196
196 this.init = function() { 197 this.init = function( world )
198 {
199 this.setWorld( world );
200
197 // set up the shader 201 // set up the shader
198 this._shader = new RDGE.jshader(); 202 this._shader = new RDGE.jshader();
199 this._shader.def = radialGradientMaterialDef; 203 this._shader.def = radialGradientMaterialDef;
200 this._shader.init(); 204 this._shader.init();
201 205
202 // set up the material node 206 // set up the material node
203 this._materialNode = RDGE.createMaterialNode("radialGradientMaterial"); 207 this._materialNode = RDGE.createMaterialNode("radialGradientMaterial" + "_" + world.generateUniqueNodeID());
204 this._materialNode.setShader(this._shader); 208 this._materialNode.setShader(this._shader);
205 209
206 // set the shader values in the shader 210 // set the shader values in the shader
@@ -233,6 +237,57 @@ var RadialGradientMaterial = function RadialGradientMaterial() {
233 } 237 }
234 }; 238 };
235 239
240 this.exportJSON = function()
241 {
242 var jObj =
243 {
244 'material' : this.getShaderName(),
245 'name' : this.getName(),
246
247 'color1' : this.getColor1(),
248 'color2' : this.getColor2(),
249 'color3' : this.getColor3(),
250 'color4' : this.getColor4(),
251 'colorStop1' : this.getColorStop1(),
252 'colorStop2' : this.getColorStop2(),
253 'colorStop3' : this.getColorStop3(),
254 'colorStop4' : this.getColorStop4()
255 };
256
257 return jObj;
258 };
259
260 this.importJSON = function( jObj )
261 {
262 if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" );
263 this.setName( jObj.name );
264
265 try
266 {
267 var color1 = jObj.color1,
268 color2 = jObj.color2,
269 color3 = jObj.color3,
270 color4 = jObj.color4,
271 colorStop1 = jObj.colorStop1,
272 colorStop2 = jObj.colorStop2,
273 colorStop3 = jObj.colorStop3,
274 colorStop4 = jObj.colorStop4;
275
276 this.setProperty( "color1", color1 );
277 this.setProperty( "color2", color2 );
278 this.setProperty( "color3", color3 );
279 this.setProperty( "color4", color4 );
280 this.setProperty( "colorStop1", colorStop1 );
281 this.setProperty( "colorStop2", colorStop2 );
282 this.setProperty( "colorStop3", colorStop3 );
283 this.setProperty( "colorStop4", colorStop4 );
284 }
285 catch (e)
286 {
287 throw new Error( "could not import material: " + importStr );
288 }
289 };
290
236 this.export = function() { 291 this.export = function() {
237 // every material needs the base type and instance name 292 // every material needs the base type and instance name
238 var exportStr = "material: " + this.getShaderName() + "\n"; 293 var exportStr = "material: " + this.getShaderName() + "\n";