aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-03-12 16:25:28 -0700
committerNivesh Rajbhandari2012-03-12 16:25:28 -0700
commit5fb358d9e80a364d5f300d60b7a9fe0f773741e7 (patch)
tree2c4d5292b19c91697dffb542f369ec9dcb340f77 /js/lib/rdge
parent5f9b67be3b8bdb391d021103c6bcee6be2f6cdf4 (diff)
parent69d90467865a1384725b2301901be2180c5a841f (diff)
downloadninja-5fb358d9e80a364d5f300d60b7a9fe0f773741e7.tar.gz
Merge branch 'refs/heads/ninja-internal' into ToolFixes
Diffstat (limited to 'js/lib/rdge')
-rwxr-xr-xjs/lib/rdge/materials/bump-metal-material.js314
-rw-r--r--js/lib/rdge/materials/deform-material.js127
-rwxr-xr-xjs/lib/rdge/materials/flat-material.js159
-rw-r--r--js/lib/rdge/materials/fly-material.js119
-rw-r--r--js/lib/rdge/materials/julia-material.js136
-rw-r--r--js/lib/rdge/materials/keleidoscope-material.js144
-rwxr-xr-xjs/lib/rdge/materials/linear-gradient-material.js434
-rw-r--r--js/lib/rdge/materials/mandel-material.js147
-rwxr-xr-xjs/lib/rdge/materials/material-parser.js73
-rwxr-xr-xjs/lib/rdge/materials/material.js346
-rw-r--r--js/lib/rdge/materials/plasma-material.js132
-rw-r--r--js/lib/rdge/materials/pulse-material.js258
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js244
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js351
-rw-r--r--js/lib/rdge/materials/relief-tunnel-material.js122
-rw-r--r--js/lib/rdge/materials/square-tunnel-material.js120
-rw-r--r--js/lib/rdge/materials/star-material.js124
-rw-r--r--js/lib/rdge/materials/taper-material.js223
-rw-r--r--js/lib/rdge/materials/tunnel-material.js125
-rw-r--r--js/lib/rdge/materials/twist-material.js139
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js248
-rwxr-xr-xjs/lib/rdge/materials/uber-material.js614
-rw-r--r--js/lib/rdge/materials/water-material.js126
-rw-r--r--js/lib/rdge/materials/z-invert-material.js125
24 files changed, 4950 insertions, 0 deletions
diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js
new file mode 100755
index 00000000..61126952
--- /dev/null
+++ b/js/lib/rdge/materials/bump-metal-material.js
@@ -0,0 +1,314 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<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.
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 BumpMetalMaterial = function BumpMetalMaterial() {
14 ///////////////////////////////////////////////////////////////////////
15 // Instance variables
16 ///////////////////////////////////////////////////////////////////////
17 this._name = "BumpMetalMaterial";
18 this._shaderName = "bumpMetal";
19
20 this._lightDiff = [0.3, 0.3, 0.3, 1.0];
21 this._diffuseTexture = "assets/images/metal.png";
22 this._specularTexture = "assets/images/silver.png";
23 this._normalTexture = "assets/images/normalMap.png";
24
25 ///////////////////////////////////////////////////////////////////////
26 // Property Accessors
27 ///////////////////////////////////////////////////////////////////////
28 this.getName = function() {
29 return this._name;
30 };
31
32 this.getShaderName = function() {
33 return this._shaderName;
34 };
35
36 this.getLightDiff = function() {
37 return this._lightDiff;
38 };
39
40 this.setLightDiff = function(ld) {
41 this._lightDiff = ld;
42 // Bad property name. Commenting for now
43
44 if (this._shader && this._shader['default']){
45 this._shader['default'].u_light0Diff.set( ld );
46 }
47
48 };
49
50 this.getDiffuseTexture = function() { return this._propValues[this._propNames[1]] ? this._propValues[this._propNames[1]].slice() : null };
51 this.setDiffuseTexture = function(m) { this._propValues[this._propNames[1]] = m ? m.slice(0) : null; this.updateTexture(1); };
52
53 this.getNormalTexture = function() { return this._propValues[this._propNames[2]] ? this._propValues[this._propNames[2]].slice() : null };
54 this.setNormalTexture = function(m) { this._propValues[this._propNames[2]] = m ? m.slice(0) : null; this.updateTexture(2); };
55
56 this.getSpecularTexture = function() { return this._propValues[this._propNames[3]] ? this._propValues[this._propNames[3]].slice() : null };
57 this.setSpecularTexture = function(m) { this._propValues[this._propNames[3]] = m ? m.slice(0) : null; this.updateTexture(3); };
58
59 this.isAnimated = function() { return true; };
60
61 ///////////////////////////////////////////////////////////////////////
62 // Material Property Accessors
63 ///////////////////////////////////////////////////////////////////////
64 this._propNames = ["lightDiff", "diffuseTexture", "normalMap", "specularTexture"];
65 this._propLabels = ["Diffuse Color", "Diffuse Map", "Bump Map", "Specular Map"];
66 this._propTypes = ["color", "file", "file", "file"];
67 this._propValues = [];
68
69 this._propValues[ this._propNames[0] ] = this._lightDiff.slice(0);
70 this._propValues[ this._propNames[1] ] = this._diffuseTexture.slice(0);
71 this._propValues[ this._propNames[2] ] = this._normalTexture.slice(0);
72 this._propValues[ this._propNames[3] ] = this._specularTexture.slice(0);
73
74 // TODO - shader techniques are not all named the same, i.e., FlatMaterial uses "colorMe" and BrickMaterial uses "default"
75 this.setProperty = function( prop, value )
76 {
77 // every material should do something with the "color" property
78 if (prop === "color") prop = "lightDiff";
79
80 // make sure we have legitimate imput
81 var ok = this.validateProperty( prop, value );
82 if (!ok)
83 {
84 console.log( "invalid property in Bump Metal Materia;" + prop + " : " + value );
85 return;
86 }
87
88 switch (prop)
89 {
90 case "lightDiff": this.setLightDiff( value ); break;
91 case "diffuseTexture": this.setDiffuseTexture( value ); break;
92 case "specularTexture": this.setSpecularTexture( value ); break;
93 case "normalMap": this.setNormalTexture( value ); break;
94
95 default:
96 console.log( "invalid property to Bump Metal Material: " + prop + ", value: " + value );
97 break;
98 }
99 };
100
101 ///////////////////////////////////////////////////////////////////////
102 // Methods
103 ///////////////////////////////////////////////////////////////////////
104 // duplcate method requirde
105 this.dup = function() { return new BumpMetalMaterial(); };
106
107 this.init = function( world )
108 {
109 // save the world
110 if (world) this.setWorld( world );
111
112 // set up the shader
113 this._shader = new jshader();
114 this._shader.def = bumpMetalMaterialDef;
115 this._shader.init();
116 this._shader['default'].u_light0Diff.set( this.getLightDiff() );
117
118 // set up the material node
119 this._materialNode = createMaterialNode( this.getShaderName() );
120 this._materialNode.setShader(this._shader);
121
122 // set some image maps
123 this.updateTexture(1);
124 this.updateTexture(2);
125 this.updateTexture(3);
126 };
127
128 this.updateTexture = function( index )
129 {
130 var material = this._materialNode;
131 if (material)
132 {
133 var technique = material.shaderProgram['default'];
134 var renderer = g_Engine.getContext().renderer;
135 if (renderer && technique)
136 {
137 var texMapName = this._propValues[this._propNames[index]];
138 var wrap = 'REPEAT', mips = true;
139 var tex = this.loadTexture( texMapName, wrap, mips );
140
141 if (tex)
142 {
143 switch (index)
144 {
145 case 1: technique.u_colMap.set( tex ); break;
146 case 2: technique.u_normalMap.set( tex ); break;
147 case 3: technique.u_glowMap.set( tex ); break;
148 default: console.log( "invalid map index in BumpMetalMaterial, " + index );
149 }
150 }
151 }
152 }
153 };
154
155 this.export = function()
156 {
157 // every material needs the base type and instance name
158 var exportStr = "material: " + this.getShaderName() + "\n";
159 exportStr += "name: " + this.getName() + "\n";
160
161 exportStr += "lightDiff: " + this.getLightDiff() + "\n";
162 exportStr += "diffuseTexture: " + this.getDiffuseTexture() + "\n";
163 exportStr += "specularTexture: " + this.getSpecularTexture() + "\n";
164 exportStr += "normalMap: " + this.getNormalTexture() + "\n";
165
166 // every material needs to terminate like this
167 exportStr += "endMaterial\n";
168
169 return exportStr;
170 };
171
172 this.import = function( importStr )
173 {
174 var pu = new MaterialParser( importStr );
175