aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/tunnel-material.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-04-04 15:53:29 -0700
committerValerio Virgillito2012-04-04 15:53:29 -0700
commite721a7c1009f298a1bd8fea583da14535e039880 (patch)
tree9415f5ba25ad643df678e561719d2708fd3ead5a /js/lib/rdge/materials/tunnel-material.js
parent8482e23cd9b8c4700b5130f2588e5eb24d376536 (diff)
parent7249d6377c8897b2f9d8115be99717be971a0981 (diff)
downloadninja-e721a7c1009f298a1bd8fea583da14535e039880.tar.gz
Merge pull request #156 from mayhewinator/WorkingBranch
Namespace and code cleanup for RDGE and related files
Diffstat (limited to 'js/lib/rdge/materials/tunnel-material.js')
-rw-r--r--js/lib/rdge/materials/tunnel-material.js79
1 files changed, 39 insertions, 40 deletions
diff --git a/js/lib/rdge/materials/tunnel-material.js b/js/lib/rdge/materials/tunnel-material.js
index fe0fbd51..83bf9021 100644
--- a/js/lib/rdge/materials/tunnel-material.js
+++ b/js/lib/rdge/materials/tunnel-material.js
@@ -11,64 +11,63 @@ var TunnelMaterial = function TunnelMaterial() {
11 /////////////////////////////////////////////////////////////////////// 11 ///////////////////////////////////////////////////////////////////////
12 // Instance variables 12 // Instance variables
13 /////////////////////////////////////////////////////////////////////// 13 ///////////////////////////////////////////////////////////////////////
14 this._name = "TunnelMaterial"; 14 this._name = "TunnelMaterial";
15 this._shaderName = "tunnel"; 15 this._shaderName = "tunnel";
16 16
17 this._texMap = 'assets/images/rocky-normal.jpg'; 17 this._texMap = 'assets/images/rocky-normal.jpg';
18 18
19 this._time = 0.0; 19 this._time = 0.0;
20 this._dTime = 0.001; 20 this._dTime = 0.001;
21 21
22 /////////////////////////////////////////////////////////////////////// 22 ///////////////////////////////////////////////////////////////////////
23 // Properties 23 // Properties
24 /////////////////////////////////////////////////////////////////////// 24 ///////////////////////////////////////////////////////////////////////
25 // all defined in parent PulseMaterial.js 25 // all defined in parent PulseMaterial.js
26 // load the local default value 26 // load the local default value
27 this._propValues[ this._propNames[0] ] = this._texMap.slice(0); 27 this._propValues[this._propNames[0]] = this._texMap.slice(0);
28 28
29 /////////////////////////////////////////////////////////////////////// 29 ///////////////////////////////////////////////////////////////////////
30 // Methods 30 // Methods
31 /////////////////////////////////////////////////////////////////////// 31 ///////////////////////////////////////////////////////////////////////
32 // duplcate method requirde 32 // duplcate method requirde
33 this.dup = function( world ) { 33 this.dup = function (world) {
34 // allocate a new uber material 34 // allocate a new uber material
35 var newMat = new TunnelMaterial(); 35 var newMat = new TunnelMaterial();
36 36
37 // copy over the current values; 37 // copy over the current values;
38 var propNames = [], propValues = [], propTypes = [], propLabels = []; 38 var propNames = [], propValues = [], propTypes = [], propLabels = [];
39 this.getAllProperties( propNames, propValues, propTypes, propLabels); 39 this.getAllProperties(propNames, propValues, propTypes, propLabels);
40 var n = propNames.length; 40 var n = propNames.length;
41 for (var i=0; i<n; i++) { 41 for (var i = 0; i < n; i++) {
42 newMat.setProperty( propNames[i], propValues[i] ); 42 newMat.setProperty(propNames[i], propValues[i]);
43 } 43 }
44 44
45 return newMat; 45 return newMat;
46 }; 46 };
47 47
48 this.init = function( world ) 48 this.init = function (world) {
49 { 49 // save the world
50 // save the world 50 if (world) this.setWorld(world);
51 if (world) this.setWorld( world );
52 51
53 // set up the shader 52 // set up the shader
54 this._shader = new jshader(); 53 this._shader = new RDGE.jshader();
55 this._shader.def = tunnelMaterialDef; 54 this._shader.def = tunnelMaterialDef;
56 this._shader.init(); 55 this._shader.init();
57 56
58 // set up the material node 57 // set up the material node
59 this._materialNode = createMaterialNode("tunnelMaterial" + "_" + world.generateUniqueNodeID()); 58 this._materialNode = RDGE.createMaterialNode("tunnelMaterial" + "_" + world.generateUniqueNodeID());
60 this._materialNode.setShader(this._shader); 59 this._materialNode.setShader(this._shader);
61 60
62 this._time = 0; 61 this._time = 0;
63 if (this._shader && this._shader['default']) { 62 if (this._shader && this._shader['default']) {
64 this._shader['default'].u_time.set( [this._time] ); 63 this._shader['default'].u_time.set([this._time]);
65 } 64 }
66 65
67 // set the shader values in the shader 66 // set the shader values in the shader
68 this.updateTexture(); 67 this.updateTexture();
69 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); 68 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]);
70 this.update( 0 ); 69 this.update(0);
71 } 70 };
72}; 71};
73 72
74/////////////////////////////////////////////////////////////////////////////////////// 73///////////////////////////////////////////////////////////////////////////////////////