aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials')
-rw-r--r--js/lib/rdge/materials/cloud-material.js390
-rw-r--r--js/lib/rdge/materials/deform-material.js88
-rwxr-xr-xjs/lib/rdge/materials/flat-material.js151
-rw-r--r--js/lib/rdge/materials/fly-material.js5
-rw-r--r--js/lib/rdge/materials/julia-material.js2
-rw-r--r--js/lib/rdge/materials/keleidoscope-material.js2
-rwxr-xr-xjs/lib/rdge/materials/linear-gradient-material.js489
-rw-r--r--js/lib/rdge/materials/mandel-material.js2
-rwxr-xr-xjs/lib/rdge/materials/material-parser.js81
-rw-r--r--js/lib/rdge/materials/pulse-material.js10
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js446
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js495
-rw-r--r--js/lib/rdge/materials/relief-tunnel-material.js132
-rw-r--r--js/lib/rdge/materials/square-tunnel-material.js133
-rw-r--r--js/lib/rdge/materials/star-material.js133
-rw-r--r--js/lib/rdge/materials/taper-material.js439
-rw-r--r--js/lib/rdge/materials/tunnel-material.js79
-rw-r--r--js/lib/rdge/materials/twist-material.js161
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js486
-rwxr-xr-xjs/lib/rdge/materials/uber-material.js1721
-rw-r--r--js/lib/rdge/materials/water-material.js275
-rw-r--r--js/lib/rdge/materials/z-invert-material.js132
22 files changed, 2857 insertions, 2995 deletions
diff --git a/js/lib/rdge/materials/cloud-material.js b/js/lib/rdge/materials/cloud-material.js
index 85088f91..092553ce 100644
--- a/js/lib/rdge/materials/cloud-material.js
+++ b/js/lib/rdge/materials/cloud-material.js
@@ -1,8 +1,8 @@
1/* <copyright> 1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/> 2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> 3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
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
7var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser; 7var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser;
8var Material = require("js/lib/rdge/materials/material").Material; 8var Material = require("js/lib/rdge/materials/material").Material;
@@ -14,275 +14,263 @@ var CloudMaterial = function CloudMaterial() {
14 /////////////////////////////////////////////////////////////////////// 14 ///////////////////////////////////////////////////////////////////////
15 // Instance variables 15 // Instance variables
16 /////////////////////////////////////////////////////////////////////// 16 ///////////////////////////////////////////////////////////////////////
17 this._name = "CloudMaterial"; 17 this._name = "CloudMaterial";
18 this._shaderName = "cloud"; 18 this._shaderName = "cloud";
19 19
20 this._texMap = 'assets/images/cloud2.jpg'; 20 this._texMap = 'assets/images/cloud2.jpg';
21 this._diffuseColor = [0.5, 0.5, 0.5, 0.5]; 21 this._diffuseColor = [0.5, 0.5, 0.5, 0.5];
22 22
23 this._time = 0.0; 23 this._time = 0.0;
24 this._dTime = 0.01; 24 this._dTime = 0.01;
25 25
26 /////////////////////////////////////////////////////////////////////// 26 ///////////////////////////////////////////////////////////////////////
27 // Property Accessors 27 // Property Accessors
28 /////////////////////////////////////////////////////////////////////// 28 ///////////////////////////////////////////////////////////////////////
29 this.getName = function() { return this._name; }; 29 this.getName = function () { return this._name; };
30 this.getShaderName = function() { return this._shaderName; }; 30 this.getShaderName = function () { return this._shaderName; };
31 31
32 this.getTextureMap = function() { return this._propValues[this._propNames[0]] ? this._propValues[this._propNames[0]].slice() : null }; 32 this.getTextureMap = function () { return this._propValues[this._propNames[0]] ? this._propValues[this._propNames[0]].slice() : null };
33 this.setTextureMap = function(m) { this._propValues[this._propNames[0]] = m ? m.slice(0) : null; this.updateTexture(); }; 33 this.setTextureMap = function (m) { this._propValues[this._propNames[0]] = m ? m.slice(0) : null; this.updateTexture(); };
34 34
35 this.setDiffuseColor = function(c) { this._propValues[this._propNames[1]] = c.slice(0); this.updateColor(); }; 35 this.setDiffuseColor = function (c) { this._propValues[this._propNames[1]] = c.slice(0); this.updateColor(); };
36 this.getDiffuseColor = function() { return this._propValues[this._propNames[1]] ? this._propValues[this._propNames[1]].slice() : null; }; 36 this.getDiffuseColor = function () { return this._propValues[this._propNames[1]] ? this._propValues[this._propNames[1]].slice() : null; };
37 37
38 this.isAnimated = function() { return true; }; 38 this.isAnimated = function () { return true; };
39 39
40 /////////////////////////////////////////////////////////////////////// 40 ///////////////////////////////////////////////////////////////////////
41 // Material Property Accessors 41 // Material Property Accessors
42 /////////////////////////////////////////////////////////////////////// 42 ///////////////////////////////////////////////////////////////////////
43 this._propNames = ["texmap", "diffusecolor"]; 43 this._propNames = ["texmap", "diffusecolor"];
44 this._propLabels = ["Texture map", "Diffuse Color"]; 44 this._propLabels = ["Texture map", "Diffuse Color"];
45 this._propTypes = ["file", "color"]; 45 this._propTypes = ["file", "color"];
46 this._propValues = []; 46 this._propValues = [];
47 47
48 this._propValues[ this._propNames[0] ] = this._texMap.slice(0); 48 this._propValues[this._propNames[0]] = this._texMap.slice(0);
49 this._propValues[ this._propNames[1] ] = this._diffuseColor.slice(); 49 this._propValues[this._propNames[1]] = this._diffuseColor.slice();
50 50
51 this.setProperty = function( prop, value ) 51 this.setProperty = function (prop, value) {
52 { 52 if (prop === 'color') prop = 'diffusecolor';
53 if (prop === 'color') prop = 'diffusecolor';
54 53
55 // make sure we have legitimate imput 54 // make sure we have legitimate imput
56 var ok = this.validateProperty( prop, value ); 55 var ok = this.validateProperty(prop, value);
57 if (!ok) { 56 if (!ok) {
58 console.log( "invalid property in Radial Gradient Material:" + prop + " : " + value ); 57 console.log("invalid property in Radial Gradient Material:" + prop + " : " + value);
59 } 58 }
60 59
61 switch (prop) 60 switch (prop) {
62 { 61 case "texmap":
63 case "texmap": 62 this.setTextureMap(value);
64 this.setTextureMap(value); 63 break;
65 break; 64
66 65 case "diffusecolor":
67 case "diffusecolor": 66 this.setDiffuseColor(value);
68 this.setDiffuseColor( value ); 67 break;
69 break; 68
70 69 case "color":
71 case "color": 70 break;
72 break; 71 }
73 } 72 };
74 };
75 /////////////////////////////////////////////////////////////////////// 73 ///////////////////////////////////////////////////////////////////////
76 74
77 75
78 /////////////////////////////////////////////////////////////////////// 76 ///////////////////////////////////////////////////////////////////////
79 // Methods 77 // Methods
80 /////////////////////////////////////////////////////////////////////// 78 ///////////////////////////////////////////////////////////////////////
81 // duplcate method requirde 79 // duplicate method required
82 this.dup = function( world ) 80 this.dup = function (world) {
83 { 81 // save the world
84 // save the world 82 if (world) this.setWorld(world);
85 if (world) this.setWorld( world ); 83
86 84 // allocate a new uber material
87 // allocate a new uber material 85 var newMat = new CloudMaterial();
88 var newMat = new CloudMaterial(); 86
89 87 // copy over the current values;
90 // copy over the current values; 88 var propNames = [], propValues = [], propTypes = [], propLabels = [];
91 var propNames = [], propValues = [], propTypes = [], propLabels = []; 89 this.getAllProperties(propNames, propValues, propTypes, propLabels);
92 this.getAllProperties( propNames, propValues, propTypes, propLabels); 90 var n = propNames.length;
93 var n = propNames.length; 91 for (var i = 0; i < n; i++) {
94 for (var i=0; i<n; i++) { 92 newMat.setProperty(propNames[i], propValues[i]);
95 newMat.setProperty( propNames[i], propValues[i] );
96 } 93 }
97 94
98 return newMat; 95 return newMat;
99 }; 96 };
100 97
101 this.init = function( world ) 98 this.init = function (world) {
102 { 99 // save the world
103 // save the world 100 if (world) this.setWorld(world);
104 if (world) this.setWorld( world );
105
106 // this variable declared above is inherited set to a smaller delta.
107 // the cloud material runs a little faster
108 this._dTime = 0.01;
109
110 // set up the shader
111 this._shader = new jshader();
112 this._shader.def = cloudMaterialDef;
113 this._shader.init();
114
115 // set up the material node
116 this._materialNode = createMaterialNode("cloudMaterial" + "_" + world.generateUniqueNodeID());
117 this._materialNode.setShader(this._shader);
118
119 this._time = 0;
120 if (this._shader && this._shader['default']) {
121 this._shader['default'].u_time.set( [this._time] );
122 this._shader['default'].u_DiffuseColor.set( this._diffuseColor );
123 }
124 101