diff options
Diffstat (limited to 'js/lib/rdge/materials/relief-tunnel-material.js')
-rw-r--r-- | js/lib/rdge/materials/relief-tunnel-material.js | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/js/lib/rdge/materials/relief-tunnel-material.js b/js/lib/rdge/materials/relief-tunnel-material.js index 06b0cf46..ab6b142e 100644 --- a/js/lib/rdge/materials/relief-tunnel-material.js +++ b/js/lib/rdge/materials/relief-tunnel-material.js | |||
@@ -6,44 +6,44 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
6 | 6 | ||
7 | 7 | ||
8 | var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; | 8 | var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; |
9 | var Texture = require("js/lib/rdge/texture").Texture; | ||
9 | 10 | ||
10 | var ReliefTunnelMaterial = function ReliefTunnelMaterial() { | 11 | var ReliefTunnelMaterial = function ReliefTunnelMaterial() |
12 | { | ||
11 | /////////////////////////////////////////////////////////////////////// | 13 | /////////////////////////////////////////////////////////////////////// |
12 | // Instance variables | 14 | // Instance variables |
13 | /////////////////////////////////////////////////////////////////////// | 15 | /////////////////////////////////////////////////////////////////////// |
14 | this._name = "ReliefTunnelMaterial"; | 16 | this._name = "Relief Tunnel"; |
15 | this._shaderName = "reliefTunnel"; | 17 | this._shaderName = "reliefTunnel"; |
16 | 18 | ||
17 | this._texMap = 'assets/images/rocky-normal.jpg'; | 19 | this._defaultTexMap = 'assets/images/rocky-normal.jpg'; |
18 | 20 | ||
19 | this._time = 0.0; | 21 | this._time = 0.0; |
20 | this._dTime = 0.01; | 22 | this._dTime = 0.01; |
21 | 23 | ||
24 | // array textures indexed by shader uniform name | ||
25 | this._glTextures = []; | ||
26 | |||
22 | /////////////////////////////////////////////////////////////////////// | 27 | /////////////////////////////////////////////////////////////////////// |
23 | // Properties | 28 | // Material Property Accessors |
24 | /////////////////////////////////////////////////////////////////////// | 29 | /////////////////////////////////////////////////////////////////////// |
25 | // all defined in parent PulseMaterial.js | 30 | var u_tex0_index = 0, u_speed_index = 1; |
26 | // load the local default value | 31 | this._propNames = ["u_tex0", "u_speed" ]; |
27 | this._propValues[this._propNames[0]] = this._texMap.slice(0); | 32 | this._propLabels = ["Texture map", "Speed" ]; |
33 | this._propTypes = ["file", "float" ]; | ||
34 | this._propValues = []; | ||
35 | this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0); | ||
36 | this._propValues[this._propNames[u_speed_index]] = 1.0; | ||
37 | |||
28 | /////////////////////////////////////////////////////////////////////// | 38 | /////////////////////////////////////////////////////////////////////// |
29 | // Methods | 39 | // Material Property Accessors |
30 | /////////////////////////////////////////////////////////////////////// | 40 | /////////////////////////////////////////////////////////////////////// |
31 | // duplcate method requirde | 41 | this.isAnimated = function() { return true; }; |
32 | this.dup = function (world) { | 42 | this.getShaderDef = function() { return reliefTunnelMaterialDef; }; |
33 | // allocate a new uber material | ||
34 | var newMat = new ReliefTunnelMaterial(); | ||
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 | 43 | ||
44 | /////////////////////////////////////////////////////////////////////// | ||
45 | // Methods | ||
46 | /////////////////////////////////////////////////////////////////////// | ||
47 | this.init = function (world) { | 47 | this.init = function (world) { |
48 | // save the world | 48 | // save the world |
49 | if (world) this.setWorld(world); | 49 | if (world) this.setWorld(world); |
@@ -63,7 +63,7 @@ var ReliefTunnelMaterial = function ReliefTunnelMaterial() { | |||
63 | } | 63 | } |
64 | 64 | ||
65 | // set the shader values in the shader | 65 | // set the shader values in the shader |
66 | this.updateTexture(); | 66 | this.setShaderValues(); |
67 | this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); | 67 | this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); |
68 | this.update(0); | 68 | this.update(0); |
69 | }; | 69 | }; |
@@ -98,6 +98,7 @@ var reliefTunnelMaterialDef = | |||
98 | { | 98 | { |
99 | 'u_tex0': { 'type': 'tex2d' }, | 99 | 'u_tex0': { 'type': 'tex2d' }, |
100 | 'u_time': { 'type': 'float' }, | 100 | 'u_time': { 'type': 'float' }, |
101 | 'u_speed': { 'type': 'float' }, | ||
101 | 'u_resolution': { 'type': 'vec2' } | 102 | 'u_resolution': { 'type': 'vec2' } |
102 | }, | 103 | }, |
103 | 104 | ||