aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/square-tunnel-material.js
diff options
context:
space:
mode:
authorArmen Kesablyan2012-06-20 15:00:34 -0700
committerArmen Kesablyan2012-06-20 15:00:34 -0700
commit38f571d1fdf02d36c3816637af7b2ca2493809da (patch)
tree69b97839be8b2b6fb65e9150d4dc02856041fb1d /js/lib/rdge/materials/square-tunnel-material.js
parentf7c14e54c52bce8875cde81db621dde6f4ff1e34 (diff)
parent120e31dcf1e11eed11ee430d77c438e7b073e9f8 (diff)
downloadninja-38f571d1fdf02d36c3816637af7b2ca2493809da.tar.gz
Merge branch 'refs/heads/master' into binding
Diffstat (limited to 'js/lib/rdge/materials/square-tunnel-material.js')
-rw-r--r--js/lib/rdge/materials/square-tunnel-material.js45
1 files changed, 22 insertions, 23 deletions
diff --git a/js/lib/rdge/materials/square-tunnel-material.js b/js/lib/rdge/materials/square-tunnel-material.js
index 73df4073..1f049a2c 100644
--- a/js/lib/rdge/materials/square-tunnel-material.js
+++ b/js/lib/rdge/materials/square-tunnel-material.js
@@ -5,45 +5,43 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
5</copyright> */ 5</copyright> */
6 6
7var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; 7var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial;
8var Texture = require("js/lib/rdge/texture").Texture;
8 9
9var SquareTunnelMaterial = function SquareTunnelMaterial() { 10var SquareTunnelMaterial = function SquareTunnelMaterial() {
10 /////////////////////////////////////////////////////////////////////// 11 ///////////////////////////////////////////////////////////////////////
11 // Instance variables 12 // Instance variables
12 /////////////////////////////////////////////////////////////////////// 13 ///////////////////////////////////////////////////////////////////////
13 this._name = "SquareTunnelMaterial"; 14 this._name = "Square Tunnel";
14 this._shaderName = "squareTunnel"; 15 this._shaderName = "squareTunnel";
15 16
16 this._texMap = 'assets/images/rocky-normal.jpg'; 17 this._defaultTexMap = 'assets/images/rocky-normal.jpg';
17 18
18 this._time = 0.0; 19 this._time = 0.0;
19 this._dTime = 0.01; 20 this._dTime = 0.01;
20 21
22 // array textures indexed by shader uniform name
23 this._glTextures = [];
24
21 /////////////////////////////////////////////////////////////////////// 25 ///////////////////////////////////////////////////////////////////////
22 // Properties 26 // Material Property Accessors
23 /////////////////////////////////////////////////////////////////////// 27 ///////////////////////////////////////////////////////////////////////
24 // all defined in parent PulseMaterial.js 28 var u_tex0_index = 0, u_speed_index = 1;
25 // load the local default value 29 this._propNames = ["u_tex0", "u_speed" ];
26 this._propValues[this._propNames[0]] = this._texMap.slice(0); 30 this._propLabels = ["Texture map", "Speed" ];
31 this._propTypes = ["file", "float" ];
32 this._propValues = [];
33 this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0);
34 this._propValues[this._propNames[u_speed_index]] = 1.0;
27 35
28 /////////////////////////////////////////////////////////////////////// 36 ///////////////////////////////////////////////////////////////////////
29 // Methods 37 // Material Property Accessors
30 /////////////////////////////////////////////////////////////////////// 38 ///////////////////////////////////////////////////////////////////////
31 // duplcate method requirde 39 this.isAnimated = function() { return true; };
32 this.dup = function (world) { 40 this.getShaderDef = function() { return squareTunnelMaterialDef; };
33 // allocate a new uber material
34 var newMat = new SquareTunnelMaterial();
35
36 // copy over the current values;
37 var propNames = [], propValues = [], propTypes = [], propLabels = [];
38 this.getAllProperties(propNames, propValues, propTypes, propLabels);
39 var n = propNames.length;
40 for (var i = 0; i < n; i++) {
41 newMat.setProperty(propNames[i], propValues[i]);
42 }
43
44 return newMat;
45 };
46 41
42 ///////////////////////////////////////////////////////////////////////
43 // Methods
44 ///////////////////////////////////////////////////////////////////////
47 this.init = function (world) { 45 this.init = function (world) {
48 // save the world 46 // save the world
49 if (world) this.setWorld(world); 47 if (world) this.setWorld(world);
@@ -63,7 +61,7 @@ var SquareTunnelMaterial = function SquareTunnelMaterial() {
63 } 61 }
64 62
65 // set the shader values in the shader 63 // set the shader values in the shader
66 this.updateTexture(); 64 this.setShaderValues();
67 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); 65 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]);
68 this.update(0); 66 this.update(0);
69 }; 67 };
@@ -98,6 +96,7 @@ var squareTunnelMaterialDef =
98 { 96 {
99 'u_tex0': { 'type': 'tex2d' }, 97 'u_tex0': { 'type': 'tex2d' },
100 'u_time': { 'type': 'float' }, 98 'u_time': { 'type': 'float' },
99 'u_speed': { 'type': 'float' },
101 'u_resolution': { 'type': 'vec2' } 100 'u_resolution': { 'type': 'vec2' }
102 }, 101 },
103 102