aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge')
-rwxr-xr-xjs/lib/rdge/materials/bump-metal-material.js52
-rw-r--r--js/lib/rdge/materials/cloud-material.js300
-rw-r--r--js/lib/rdge/materials/deform-material.js2
-rwxr-xr-xjs/lib/rdge/materials/flat-material.js48
-rw-r--r--js/lib/rdge/materials/fly-material.js2
-rw-r--r--js/lib/rdge/materials/julia-material.js8
-rw-r--r--js/lib/rdge/materials/keleidoscope-material.js2
-rwxr-xr-xjs/lib/rdge/materials/linear-gradient-material.js55
-rw-r--r--js/lib/rdge/materials/mandel-material.js8
-rw-r--r--js/lib/rdge/materials/plasma-material.js57
-rw-r--r--js/lib/rdge/materials/pulse-material.js55
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js82
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js61
-rw-r--r--js/lib/rdge/materials/relief-tunnel-material.js2
-rw-r--r--js/lib/rdge/materials/square-tunnel-material.js2
-rw-r--r--js/lib/rdge/materials/star-material.js2
-rw-r--r--js/lib/rdge/materials/taper-material.js35
-rw-r--r--js/lib/rdge/materials/tunnel-material.js2
-rw-r--r--js/lib/rdge/materials/twist-material.js2
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js34
-rwxr-xr-xjs/lib/rdge/materials/uber-material.js389
-rw-r--r--js/lib/rdge/materials/water-material.js105
-rw-r--r--js/lib/rdge/materials/z-invert-material.js2
23 files changed, 1216 insertions, 91 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";
diff --git a/js/lib/rdge/materials/cloud-material.js b/js/lib/rdge/materials/cloud-material.js
new file mode 100644
index 00000000..85088f91
--- /dev/null
+++ b/js/lib/rdge/materials/cloud-material.js
@@ -0,0 +1,300 @@
1/* <copyright>
2 This 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/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6
7var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser;
8var Material = require("js/lib/rdge/materials/material").Material;
9///////////////////////////////////////////////////////////////////////
10// Class GLMaterial
11// RDGE representation of a material.
12///////////////////////////////////////////////////////////////////////
13var CloudMaterial = function CloudMaterial() {
14 ///////////////////////////////////////////////////////////////////////
15 // Instance variables
16 ///////////////////////////////////////////////////////////////////////
17 this._name = "CloudMaterial";
18 this._shaderName = "cloud";
19
20 this._texMap = 'assets/images/cloud2.jpg';
21 this._diffuseColor = [0.5, 0.5, 0.5, 0.5];
22
23 this._time = 0.0;
24 this._dTime = 0.01;
25
26 ///////////////////////////////////////////////////////////////////////
27 // Property Accessors
28 ///////////////////////////////////////////////////////////////////////
29 this.getName = function() { return this._name; };
30 this.getShaderName = function() { return this._shaderName; };
31
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(); };
34
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; };
37
38 this.isAnimated = function() { return true; };
39
40 ///////////////////////////////////////////////////////////////////////
41 // Material Property Accessors
42 ///////////////////////////////////////////////////////////////////////
43 this._propNames = ["texmap", "diffusecolor"];
44 this._propLabels = ["Texture map", "Diffuse Color"];
45 this._propTypes = ["file", "color"];
46 this._propValues = [];
47
48 this._propValues[ this._propNames[0] ] = this._texMap.slice(0);
49 this._propValues[ this._propNames[1] ] = this._diffuseColor.slice();
50
51 this.setProperty = function( prop, value )
52 {
53 if (prop === 'color') prop = 'diffusecolor';
54
55 // make sure we have legitimate imput
56 var ok = this.validateProperty( prop, value );
57 if (!ok) {
58 console.log( "invalid property in Radial Gradient Material:" + prop + " : " + value );
59 }
60
61 switch (prop)
62 {
63 case "texmap":
64 this.setTextureMap(value);
65 break;
66
67 case "diffusecolor":
68 this.setDiffuseColor( value );
69 break;
70
71 case "color":
72 break;
73 }
74 };
75 ////////////////////////////////////////////////////////////