aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/tunnel-material.js
diff options
context:
space:
mode:
authorhwc4872012-06-12 10:28:26 -0700
committerhwc4872012-06-12 10:28:26 -0700
commitd4ca478ad313c6c20834e410ba14ad3a5e7b20bf (patch)
tree28e44c5ab1b2f9dbfd32aedba51402ac2d26a0ff /js/lib/rdge/materials/tunnel-material.js
parentdb2bb0ab5d2747f0d07878e3b8a7d2d10c755110 (diff)
downloadninja-d4ca478ad313c6c20834e410ba14ad3a5e7b20bf.tar.gz
Material cleanup & bug fixes.
Diffstat (limited to 'js/lib/rdge/materials/tunnel-material.js')
-rw-r--r--js/lib/rdge/materials/tunnel-material.js44
1 files changed, 17 insertions, 27 deletions
diff --git a/js/lib/rdge/materials/tunnel-material.js b/js/lib/rdge/materials/tunnel-material.js
index 9e70a6f8..b833a251 100644
--- a/js/lib/rdge/materials/tunnel-material.js
+++ b/js/lib/rdge/materials/tunnel-material.js
@@ -15,38 +15,31 @@ var TunnelMaterial = function TunnelMaterial() {
15 this._name = "TunnelMaterial"; 15 this._name = "TunnelMaterial";
16 this._shaderName = "tunnel"; 16 this._shaderName = "tunnel";
17 17
18 this._texMap = 'assets/images/rocky-normal.jpg'; 18 this._defaultTexMap = 'assets/images/rocky-normal.jpg';
19 19
20 this._time = 0.0; 20 this._time = 0.0;
21 this._dTime = 0.001; 21 this._dTime = 0.001;
22 22
23 /////////////////////////////////////////////////////////////////////// 23 ///////////////////////////////////////////////////////////////////////
24 // Properties 24 // Material Property Accessors
25 /////////////////////////////////////////////////////////////////////// 25 ///////////////////////////////////////////////////////////////////////
26 // all defined in parent PulseMaterial.js 26 var u_tex0_index = 0, u_speed_index = 1;
27 // load the local default value 27 this._propNames = ["u_tex0", "u_speed" ];
28 this._propValues[this._propNames[0]] = this._texMap.slice(0); 28 this._propLabels = ["Texture map", "Speed" ];
29 this._propTypes = ["file", "float" ];
30 this._propValues = [];
31 this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0);
32 this._propValues[this._propNames[u_speed_index]] = 1.0;
29 33
30 /////////////////////////////////////////////////////////////////////// 34 ///////////////////////////////////////////////////////////////////////
31 // Methods 35 // Material Property Accessors
32 /////////////////////////////////////////////////////////////////////// 36 ///////////////////////////////////////////////////////////////////////
33 // duplcate method requirde 37 this.isAnimated = function() { return true; };
34 this.dup = function (world) { 38 this.getShaderDef = function() { return tunnelMaterialDef; };
35 // get the current values;
36 var propNames = [], propValues = [], propTypes = [], propLabels = [];
37 this.getAllProperties(propNames, propValues, propTypes, propLabels);
38
39 // allocate a new material
40 var newMat = new TunnelMaterial();
41
42 // copy over the current values;
43 var n = propNames.length;
44 for (var i = 0; i < n; i++)
45 newMat.setProperty(propNames[i], propValues[i]);
46
47 return newMat;
48 };
49 39
40 ///////////////////////////////////////////////////////////////////////
41 // Methods
42 ///////////////////////////////////////////////////////////////////////
50 this.init = function (world) { 43 this.init = function (world) {
51 // save the world 44 // save the world
52 if (world) this.setWorld(world); 45 if (world) this.setWorld(world);
@@ -65,12 +58,8 @@ var TunnelMaterial = function TunnelMaterial() {
65 this._shader['default'].u_time.set([this._time]); 58 this._shader['default'].u_time.set([this._time]);
66 } 59 }
67 60
68 // set up the texture
69 var texMapName = this._propValues[this._propNames[0]];
70 this._glTex = new Texture( world, texMapName );
71
72 // set the shader values in the shader 61 // set the shader values in the shader
73 this.updateTexture(); 62 this.setShaderValues();
74 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); 63 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]);
75 this.update(0); 64 this.update(0);
76 }; 65 };
@@ -105,6 +94,7 @@ var tunnelMaterialDef =
105 { 94 {
106 'u_tex0': { 'type' : 'tex2d' }, 95 'u_tex0': { 'type' : 'tex2d' },
107 'u_time' : { 'type' : 'float' }, 96 'u_time' : { 'type' : 'float' },
97 'u_speed' : { 'type' : 'float' },
108 'u_resolution' : { 'type' : 'vec2' } 98 'u_resolution' : { 'type' : 'vec2' }
109 }, 99 },
110 100