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