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/relief-tunnel-material.js | |
parent | db2bb0ab5d2747f0d07878e3b8a7d2d10c755110 (diff) | |
download | ninja-d4ca478ad313c6c20834e410ba14ad3a5e7b20bf.tar.gz |
Material cleanup & bug fixes.
Diffstat (limited to 'js/lib/rdge/materials/relief-tunnel-material.js')
-rw-r--r-- | js/lib/rdge/materials/relief-tunnel-material.js | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/js/lib/rdge/materials/relief-tunnel-material.js b/js/lib/rdge/materials/relief-tunnel-material.js index 4587b3fd..9404e359 100644 --- a/js/lib/rdge/materials/relief-tunnel-material.js +++ b/js/lib/rdge/materials/relief-tunnel-material.js | |||
@@ -16,37 +16,31 @@ var ReliefTunnelMaterial = function ReliefTunnelMaterial() | |||
16 | this._name = "ReliefTunnelMaterial"; | 16 | this._name = "ReliefTunnelMaterial"; |
17 | this._shaderName = "reliefTunnel"; | 17 | this._shaderName = "reliefTunnel"; |
18 | 18 | ||
19 | this._texMap = 'assets/images/rocky-normal.jpg'; | 19 | this._defaultTexMap = 'assets/images/rocky-normal.jpg'; |
20 | 20 | ||
21 | this._time = 0.0; | 21 | this._time = 0.0; |
22 | this._dTime = 0.01; | 22 | this._dTime = 0.01; |
23 | 23 | ||
24 | /////////////////////////////////////////////////////////////////////// | 24 | /////////////////////////////////////////////////////////////////////// |
25 | // Properties | 25 | // Material Property Accessors |
26 | /////////////////////////////////////////////////////////////////////// | 26 | /////////////////////////////////////////////////////////////////////// |
27 | // all defined in parent PulseMaterial.js | 27 | var u_tex0_index = 0, u_speed_index = 1; |
28 | // load the local default value | 28 | this._propNames = ["u_tex0", "u_speed" ]; |
29 | this._propValues[this._propNames[0]] = this._texMap.slice(0); | 29 | this._propLabels = ["Texture map", "Speed" ]; |
30 | this._propTypes = ["file", "float" ]; | ||
31 | this._propValues = []; | ||
32 | this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0); | ||
33 | this._propValues[this._propNames[u_speed_index]] = 1.0; | ||
34 | |||
30 | /////////////////////////////////////////////////////////////////////// | 35 | /////////////////////////////////////////////////////////////////////// |
31 | // Methods | 36 | // Material Property Accessors |
32 | /////////////////////////////////////////////////////////////////////// | 37 | /////////////////////////////////////////////////////////////////////// |
33 | // duplcate method requirde | 38 | this.isAnimated = function() { return true; }; |
34 | this.dup = function (world) { | 39 | this.getShaderDef = function() { return reliefTunnelMaterialDef; }; |
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 ReliefTunnelMaterial(); | ||
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 | 40 | ||
41 | /////////////////////////////////////////////////////////////////////// | ||
42 | // Methods | ||
43 | /////////////////////////////////////////////////////////////////////// | ||
50 | this.init = function (world) { | 44 | this.init = function (world) { |
51 | // save the world | 45 | // save the world |
52 | if (world) this.setWorld(world); | 46 | if (world) this.setWorld(world); |
@@ -65,11 +59,8 @@ var ReliefTunnelMaterial = function ReliefTunnelMaterial() | |||
65 | this._shader['default'].u_time.set([this._time]); | 59 | this._shader['default'].u_time.set([this._time]); |
66 | } | 60 | } |
67 | 61 | ||
68 | var texMapName = this._propValues[this._propNames[0]]; | ||
69 | this._glTex = new Texture( world, texMapName ); | ||
70 | |||
71 | // set the shader values in the shader | 62 | // set the shader values in the shader |
72 | this.updateTexture(); | 63 | this.setShaderValues(); |
73 | this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); | 64 | this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); |
74 | this.update(0); | 65 | this.update(0); |
75 | }; | 66 | }; |
@@ -104,6 +95,7 @@ var reliefTunnelMaterialDef = | |||
104 | { | 95 | { |
105 | 'u_tex0': { 'type': 'tex2d' }, | 96 | 'u_tex0': { 'type': 'tex2d' }, |
106 | 'u_time': { 'type': 'float' }, | 97 | 'u_time': { 'type': 'float' }, |
98 | 'u_speed': { 'type': 'float' }, | ||
107 | 'u_resolution': { 'type': 'vec2' } | 99 | 'u_resolution': { 'type': 'vec2' } |
108 | }, | 100 | }, |
109 | 101 | ||