aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorhwc4872012-03-22 15:32:19 -0700
committerhwc4872012-03-22 15:32:19 -0700
commit31e924e1b8b8da8342b3ff2341c8284915486c0b (patch)
tree560ec8c2ffbd91d7f06d7ae9ad51b78ad7b07e76 /js
parent4cd4d29ae10b87f7b280d537b8980d207a22dd43 (diff)
downloadninja-31e924e1b8b8da8342b3ff2341c8284915486c0b.tar.gz
Added Paris and Raiders materials
Diffstat (limited to 'js')
-rw-r--r--js/io/system/ninjalibrary.json2
-rwxr-xr-xjs/lib/geom/geom-obj.js2
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js2
-rw-r--r--js/lib/rdge/materials/water-material.js84
-rwxr-xr-xjs/models/materials-model.js5
5 files changed, 89 insertions, 6 deletions
diff --git a/js/io/system/ninjalibrary.json b/js/io/system/ninjalibrary.json
index 00ee7ed2..a863a135 100644
--- a/js/io/system/ninjalibrary.json
+++ b/js/io/system/ninjalibrary.json
@@ -1,6 +1,6 @@
1{ 1{
2 "libraries": [ 2 "libraries": [
3 {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.6.0.0"}, 3 {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.6.0.0"},
4 {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.1.0"} 4 {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.1.2"}
5 ] 5 ]
6} \ No newline at end of file 6} \ No newline at end of file
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js
index 75b7808b..dbef4859 100755
--- a/js/lib/geom/geom-obj.js
+++ b/js/lib/geom/geom-obj.js
@@ -301,6 +301,7 @@ var GeomObj = function GLGeomObj() {
301 case "plasma": 301 case "plasma":
302 case "deform": 302 case "deform":
303 case "water": 303 case "water":
304 case "paris":
304 case "tunnel": 305 case "tunnel":
305 case "reliefTunnel": 306 case "reliefTunnel":
306 case "squareTunnel": 307 case "squareTunnel":
@@ -373,6 +374,7 @@ var GeomObj = function GLGeomObj() {
373 case "plasma": 374 case "plasma":
374 case "deform": 375 case "deform":
375 case "water": 376 case "water":
377 case "paris":
376 case "tunnel": 378 case "tunnel":
377 case "reliefTunnel": 379 case "reliefTunnel":
378 case "squareTunnel": 380 case "squareTunnel":
diff --git a/js/lib/rdge/materials/radial-blur-material.js b/js/lib/rdge/materials/radial-blur-material.js
index 91eebcff..f4a4baa2 100644
--- a/js/lib/rdge/materials/radial-blur-material.js
+++ b/js/lib/rdge/materials/radial-blur-material.js
@@ -275,7 +275,6 @@ var radialBlurMaterialDef =
275}; 275};
276 276
277 277
278/*
279var RaidersMaterial = function RaidersMaterial() 278var RaidersMaterial = function RaidersMaterial()
280{ 279{
281 // initialize the inherited members 280 // initialize the inherited members
@@ -295,7 +294,6 @@ if (typeof exports === "object")
295{ 294{
296 exports.RaidersMaterial = RaidersMaterial; 295 exports.RaidersMaterial = RaidersMaterial;
297} 296}
298*/
299 297
300 298
301RadialBlurMaterial.prototype = new Material(); 299RadialBlurMaterial.prototype = new Material();
diff --git a/js/lib/rdge/materials/water-material.js b/js/lib/rdge/materials/water-material.js
index 565055a1..b7413f55 100644
--- a/js/lib/rdge/materials/water-material.js
+++ b/js/lib/rdge/materials/water-material.js
@@ -117,7 +117,6 @@ var waterMaterialDef =
117 } 117 }
118}; 118};
119 119
120/*
121var ParisMaterial = function ParisMaterial() 120var ParisMaterial = function ParisMaterial()
122{ 121{
123 // initialize the inherited members 122 // initialize the inherited members
@@ -125,19 +124,98 @@ var ParisMaterial = function ParisMaterial()
125 this.inheritedFrom(); 124 this.inheritedFrom();
126 125
127 this._name = "ParisMaterial"; 126 this._name = "ParisMaterial";
128 this._shaderName = "water"; 127 this._shaderName = "paris";
129 128
130 this._texMap = 'assets/images/paris.png'; 129 this._texMap = 'assets/images/paris.png';
131 this._propValues[ this._propNames[0] ] = this._texMap.slice(0); 130 this._propValues[ this._propNames[0] ] = this._texMap.slice(0);
132 131
133 this._diffuseColor = [0.5, 0.5, 0.5, 0.5]; 132 this._diffuseColor = [0.5, 0.5, 0.5, 0.5];
134 this._propValues[ this._propNames[1] ] = this._diffuseColor.slice(); 133 this._propValues[ this._propNames[1] ] = this._diffuseColor.slice();
134
135 // duplcate method requirde
136 this.dup = function( world ) {
137 // allocate a new uber material
138 var newMat = new ParisMaterial();
139
140 // copy over the current values;
141 var propNames = [], propValues = [], propTypes = [], propLabels = [];
142 this.getAllProperties( propNames, propValues, propTypes, propLabels);
143 var n = propNames.length;
144 for (var i=0; i<n; i++)
145 newMat.setProperty( propNames[i], propValues[i] );
146
147 return newMat;
148 };
149
150 this.init = function( world ) {
151 // save the world
152 if (world) this.setWorld( world );
153
154 // set up the shader
155 this._shader = new jshader();
156 this._shader.def = parisMaterialDef;
157 this._shader.init();
158
159 // set up the material node
160 this._materialNode = createMaterialNode("parisMaterial" + "_" + world.generateUniqueNodeID());
161 this._materialNode.setShader(this._shader);
162
163 this._time = 0;
164 if (this._shader && this._shader['default']) {
165 this._shader['default'].u_time.set( [this._time] );
166 }
167
168 // set the shader values in the shader
169 this.updateTexture();
170 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] );
171 this.update( 0 );
172 }
135} 173}
174
136ParisMaterial.prototype = new PulseMaterial(); 175ParisMaterial.prototype = new PulseMaterial();
137if (typeof exports === "object") { 176if (typeof exports === "object") {
138 exports.ParisMaterial = ParisMaterial; 177 exports.ParisMaterial = ParisMaterial;
139} 178}
140*/ 179
180// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
181var parisMaterialDef =
182{'shaders':
183 {
184 'defaultVShader':"assets/shaders/Basic.vert.glsl",
185 'defaultFShader':"assets/shaders/Paris.frag.glsl"
186 },
187 'techniques':
188 {
189 'default':
190 [
191 {
192 'vshader' : 'defaultVShader',
193 'fshader' : 'defaultFShader',
194 // attributes
195 'attributes' :
196 {
197 'vert' : { 'type' : 'vec3' },
198 'normal' : { 'type' : 'vec3' },
199 'texcoord' : { 'type' : 'vec2' }
200 },
201 // parameters
202 'params' :
203 {
204 'u_tex0': { 'type' : 'tex2d' },
205 'u_time' : { 'type' : 'float' },
206 'u_resolution' : { 'type' : 'vec2' }
207 },
208
209 // render states
210 'states' :
211 {
212 'depthEnable' : true,
213 'offset':[1.0, 0.1]
214 }
215 }
216 ]
217 }
218};
141 219
142 220
143WaterMaterial.prototype = new PulseMaterial(); 221WaterMaterial.prototype = new PulseMaterial();
diff --git a/js/models/materials-model.js b/js/models/materials-model.js
index 291f7567..692ac09a 100755
--- a/js/models/materials-model.js
+++ b/js/models/materials-model.js
@@ -17,6 +17,7 @@ var RadialGradientMaterial = require("js/lib/rdge/materials/radial-gradient-mate
17var BumpMetalMaterial = require("js/lib/rdge/materials/bump-metal-material").BumpMetalMaterial; 17var BumpMetalMaterial = require("js/lib/rdge/materials/bump-metal-material").BumpMetalMaterial;
18var UberMaterial = require("js/lib/rdge/materials/uber-material").UberMaterial; 18var UberMaterial = require("js/lib/rdge/materials/uber-material").UberMaterial;
19var RadialBlurMaterial = require("js/lib/rdge/materials/radial-blur-material").RadialBlurMaterial; 19var RadialBlurMaterial = require("js/lib/rdge/materials/radial-blur-material").RadialBlurMaterial;
20var RaidersMaterial = require("js/lib/rdge/materials/radial-blur-material").RaidersMaterial;
20var PlasmaMaterial = require("js/lib/rdge/materials/plasma-material").PlasmaMaterial; 21var PlasmaMaterial = require("js/lib/rdge/materials/plasma-material").PlasmaMaterial;
21var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; 22var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial;
22var TunnelMaterial = require("js/lib/rdge/materials/tunnel-material").TunnelMaterial; 23var TunnelMaterial = require("js/lib/rdge/materials/tunnel-material").TunnelMaterial;
@@ -24,6 +25,7 @@ var ReliefTunnelMaterial = require("js/lib/rdge/materials/relief-tunnel-material
24var SquareTunnelMaterial = require("js/lib/rdge/materials/square-tunnel-material").SquareTunnelMaterial; 25var SquareTunnelMaterial = require("js/lib/rdge/materials/square-tunnel-material").SquareTunnelMaterial;
25var FlyMaterial = require("js/lib/rdge/materials/fly-material").FlyMaterial; 26var FlyMaterial = require("js/lib/rdge/materials/fly-material").FlyMaterial;
26var WaterMaterial = require("js/lib/rdge/materials/water-material").WaterMaterial; 27var WaterMaterial = require("js/lib/rdge/materials/water-material").WaterMaterial;
28var ParisMaterial = require("js/lib/rdge/materials/water-material").ParisMaterial;
27var ZInvertMaterial = require("js/lib/rdge/materials/z-invert-material").ZInvertMaterial; 29var ZInvertMaterial = require("js/lib/rdge/materials/z-invert-material").ZInvertMaterial;
28var DeformMaterial = require("js/lib/rdge/materials/deform-material").DeformMaterial; 30var DeformMaterial = require("js/lib/rdge/materials/deform-material").DeformMaterial;
29var StarMaterial = require("js/lib/rdge/materials/star-material").StarMaterial; 31var StarMaterial = require("js/lib/rdge/materials/star-material").StarMaterial;
@@ -48,6 +50,7 @@ exports.MaterialsModel = Montage.create(Component, {
48 this.addMaterial(new BumpMetalMaterial()); 50 this.addMaterial(new BumpMetalMaterial());
49 this.addMaterial(new UberMaterial()); 51 this.addMaterial(new UberMaterial());
50 this.addMaterial(new RadialBlurMaterial()); 52 this.addMaterial(new RadialBlurMaterial());
53 this.addMaterial(new RaidersMaterial());
51 this.addMaterial(new PlasmaMaterial()); 54 this.addMaterial(new PlasmaMaterial());
52 this.addMaterial(new PulseMaterial()); 55 this.addMaterial(new PulseMaterial());
53 this.addMaterial(new TunnelMaterial()); 56 this.addMaterial(new TunnelMaterial());
@@ -55,6 +58,7 @@ exports.MaterialsModel = Montage.create(Component, {
55 this.addMaterial(new SquareTunnelMaterial()); 58 this.addMaterial(new SquareTunnelMaterial());
56 this.addMaterial(new FlyMaterial()); 59 this.addMaterial(new FlyMaterial());