aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/material.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials/material.js')
-rwxr-xr-xjs/lib/rdge/materials/material.js101
1 files changed, 70 insertions, 31 deletions
diff --git a/js/lib/rdge/materials/material.js b/js/lib/rdge/materials/material.js
index 65448c0c..e1d17aa8 100755
--- a/js/lib/rdge/materials/material.js
+++ b/js/lib/rdge/materials/material.js
@@ -1,7 +1,31 @@
1/* <copyright> 1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/> 2Copyright (c) 2012, Motorola Mobility, Inc
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> 3All Rights Reserved.
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4BSD License.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8
9 - Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11 - Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution.
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
16 without specific prior written permission.
17
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
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
28POSSIBILITY OF SUCH DAMAGE.
5</copyright> */ 29</copyright> */
6 30
7var Texture = require("js/lib/rdge/texture").Texture; 31var Texture = require("js/lib/rdge/texture").Texture;
@@ -177,6 +201,8 @@ var Material = function GLMaterial( world ) {
177 }; 201 };
178 202
179 this.validateProperty = function( prop, value ) { 203 this.validateProperty = function( prop, value ) {
204 if(prop === "gradient") return true;
205
180 var rtnVal = false; 206 var rtnVal = false;
181 try 207 try
182 { 208 {
@@ -240,33 +266,37 @@ var Material = function GLMaterial( world ) {
240 var material = this._materialNode; 266 var material = this._materialNode;
241 if (material) technique = material.shaderProgram[this.getTechniqueName()]; 267 if (material) technique = material.shaderProgram[this.getTechniqueName()];
242 268
243 switch (this.getPropertyType(prop)) 269 if(prop === "gradient") {
244 { 270 this.setGradientData(value);
245 case "angle": 271 } else {
246 case "float": 272 switch (this.getPropertyType(prop))
247 this._propValues[prop] = value; 273 {
248 if (technique) technique[prop].set( [value] ); 274 case "angle":
249 break; 275 case "float":
250 276 this._propValues[prop] = value;
251 case "file": 277 if (technique) technique[prop].set( [value] );
252 this._propValues[prop] = value.slice(); 278 break;
253 if (technique) 279
254 { 280 case "file":
255 var glTex = new Texture( this.getWorld(), value ); 281 this._propValues[prop] = value.slice();
256 this._glTextures[prop] = glTex; 282 if (technique)
257 glTex.render(); 283 {
258 var tex = glTex.getTexture(); 284 var glTex = new Texture( this.getWorld(), value );
259 if (tex) technique[prop].set( tex ); 285 this._glTextures[prop] = glTex;
260 } 286 glTex.render();
261 break; 287 var tex = glTex.getTexture();
262 288 if (tex) technique[prop].set( tex );
263 case "color": 289 }
264 case "vector2d": 290 break;
265 case "vector3d": 291
266 this._propValues[prop] = value.slice(); 292 case "color":
267 if (technique) technique[prop].set( value ); 293 case "vector2d":
268 break; 294 case "vector3d":
269 } 295 this._propValues[prop] = value.slice();
296 if (technique) technique[prop].set( value );
297 break;
298 }
299 }
270 }; 300 };
271 301
272 this.setShaderValues = function() 302 this.setShaderValues = function()
@@ -398,8 +428,17 @@ var Material = function GLMaterial( world ) {
398 return tex; 428 return tex;
399 }; 429 };
400 430
431 this.gradientType = null;
432
433 this.getGradientData = function() {
434 return null;
435 };
436
437 this.setGradientData = function() {
438 // override in linear-gradient-material and radial-gradient-material
439 };
401}; 440};
402 441
403if (typeof exports === "object") { 442if (typeof exports === "object") {
404 exports.Material = Material; 443 exports.Material = Material;
405} \ No newline at end of file 444}