aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/z-invert-material.js
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-06-19 10:25:16 -0700
committerJose Antonio Marquez2012-06-19 10:25:16 -0700
commit4d2a5acd1631f0cf4e38f127c886f481668ddce0 (patch)
tree3bc8f2b21826c0ee6d37bc77753d45a882783cbf /js/lib/rdge/materials/z-invert-material.js
parent616b31a644ee221edcbc19f821b2194e8edf9fad (diff)
parent483ad57efcd6475776f580c3af5b60e6deeaf781 (diff)
downloadninja-4d2a5acd1631f0cf4e38f127c886f481668ddce0.tar.gz
Merge branch 'refs/heads/Ninja-Internal' into FileIO
Diffstat (limited to 'js/lib/rdge/materials/z-invert-material.js')
-rw-r--r--js/lib/rdge/materials/z-invert-material.js50
1 files changed, 26 insertions, 24 deletions
diff --git a/js/lib/rdge/materials/z-invert-material.js b/js/lib/rdge/materials/z-invert-material.js
index fc7632eb..b8870eb4 100644
--- a/js/lib/rdge/materials/z-invert-material.js
+++ b/js/lib/rdge/materials/z-invert-material.js
@@ -6,44 +6,45 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
6 6
7 7
8var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; 8var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial;
9var Texture = require("js/lib/rdge/texture").Texture;
9 10
10var ZInvertMaterial = function ZInvertMaterial() { 11var ZInvertMaterial = function ZInvertMaterial() {
11 /////////////////////////////////////////////////////////////////////// 12 ///////////////////////////////////////////////////////////////////////
12 // Instance variables 13 // Instance variables
13 /////////////////////////////////////////////////////////////////////// 14 ///////////////////////////////////////////////////////////////////////
14 this._name = "ZInvertMaterial"; 15 this._name = "Z-Invert";
15 this._shaderName = "zinvert"; 16 this._shaderName = "zinvert";
16 17
17 this._texMap = 'assets/images/rocky-normal.jpg'; 18 this._defaultTexMap = 'assets/images/rocky-normal.jpg';
18 19
19 this._time = 0.0; 20 this._time = 0.0;
20 this._dTime = 0.01; 21 this._dTime = 0.01;
21 22
22 /////////////////////////////////////////////////////////////////////// 23 // array textures indexed by shader uniform name
23 // Properties 24 this._glTextures = [];
24 /////////////////////////////////////////////////////////////////////// 25
25 // all defined in parent PulseMaterial.js 26 this.isAnimated = function() { return true; };
26 // load the local default value 27 this.getShaderDef = function() { return zInvertMaterialDef; };
27 this._propValues[this._propNames[0]] = this._texMap.slice(0); 28
29 ///////////////////////////////////////////////////////////////////////
30 // Properties
31 ///////////////////////////////////////////////////////////////////////
32 // all defined in parent PulseMaterial.js
33 // load the local default value
34 this._propNames = ["u_tex0", "u_speed"];
35 this._propLabels = ["Texture map", "Speed"];
36 this._propTypes = ["file", "float"];
37
38 var u_tex_index = 0,
39 u_speed_index = 1;
40
41 this._propValues = [];
42 this._propValues[ this._propNames[u_tex_index ] ] = this._defaultTexMap.slice(0);
43 this._propValues[ this._propNames[u_speed_index ] ] = 1.0;
28 44
29 /////////////////////////////////////////////////////////////////////// 45 ///////////////////////////////////////////////////////////////////////
30 // Methods 46 // Methods
31 /////////////////////////////////////////////////////////////////////// 47 ///////////////////////////////////////////////////////////////////////
32 // duplicate method required
33 this.dup = function (world) {
34 // allocate a new uber material
35 var newMat = new ZInvertMaterial();
36
37 // copy over the current values;
38 var propNames = [], propValues = [], propTypes = [], propLabels = [];
39 this.getAllProperties(propNames, propValues, propTypes, propLabels);
40 var n = propNames.length;
41 for (var i = 0; i < n; i++) {
42 newMat.setProperty(propNames[i], propValues[i]);
43 }
44
45 return newMat;
46 };
47 48
48 this.init = function (world) { 49 this.init = function (world) {
49 // save the world 50 // save the world
@@ -64,7 +65,7 @@ var ZInvertMaterial = function ZInvertMaterial() {
64 } 65 }
65 66
66 // set the shader values in the shader 67 // set the shader values in the shader
67 this.updateTexture(); 68 this.setShaderValues();
68 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); 69 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]);
69 this.update(0); 70 this.update(0);
70 }; 71 };
@@ -99,6 +100,7 @@ var zInvertMaterialDef =
99 { 100 {
100 'u_tex0': { 'type': 'tex2d' }, 101 'u_tex0': { 'type': 'tex2d' },
101 'u_time': { 'type': 'float' }, 102 'u_time': { 'type': 'float' },
103 'u_speed': { 'type': 'float' },
102 'u_resolution': { 'type': 'vec2' } 104 'u_resolution': { 'type': 'vec2' }
103 }, 105 },
104 106