aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/water-material.js
diff options
context:
space:
mode:
authorhwc4872012-06-06 16:34:41 -0700
committerhwc4872012-06-06 16:34:41 -0700
commit6c994c4b90023cecf4fd0caafb404b859fe28f54 (patch)
tree75a4d813441ca6a3eb529dc88a749776459bb76e /js/lib/rdge/materials/water-material.js
parent920436977433ea55c01ce1e73895d1db0a6abac1 (diff)
downloadninja-6c994c4b90023cecf4fd0caafb404b859fe28f54.tar.gz
material cleanup and rearchitecture
Diffstat (limited to 'js/lib/rdge/materials/water-material.js')
-rw-r--r--js/lib/rdge/materials/water-material.js45
1 files changed, 28 insertions, 17 deletions
diff --git a/js/lib/rdge/materials/water-material.js b/js/lib/rdge/materials/water-material.js
index 1f0aa46e..8dbb3233 100644
--- a/js/lib/rdge/materials/water-material.js
+++ b/js/lib/rdge/materials/water-material.js
@@ -50,22 +50,6 @@ var WaterMaterial = function WaterMaterial() {
50 /////////////////////////////////////////////////////////////////////// 50 ///////////////////////////////////////////////////////////////////////
51 // Methods 51 // Methods
52 /////////////////////////////////////////////////////////////////////// 52 ///////////////////////////////////////////////////////////////////////
53 // duplcate method requirde
54 this.dup = function (world) {
55 // get the current values;
56 var propNames = [], propValues = [], propTypes = [], propLabels = [];
57 this.getAllProperties(propNames, propValues, propTypes, propLabels);
58
59 // allocate a new material
60 var newMat = new WaterMaterial();
61
62 // copy over the current values;
63 var n = propNames.length;
64 for (var i = 0; i < n; i++)
65 newMat.setProperty(propNames[i], propValues[i]);
66
67 return newMat;
68 };
69 53
70 this.setProperty = function( prop, value ) { 54 this.setProperty = function( prop, value ) {
71 // make sure we have legitimate imput 55 // make sure we have legitimate imput
@@ -142,6 +126,32 @@ var WaterMaterial = function WaterMaterial() {
142 this.updateTexture(); 126 this.updateTexture();
143 } 127 }
144 128
129 this.updateTexture = function() {
130
131 var texMapName = this._propValues[this._propNames[0]];
132 this._glTex = new Texture( this.getWorld(), texMapName );
133
134 var material = this._materialNode;
135 if (material) {
136 var technique = material.shaderProgram['default'];
137 var renderer = RDGE.globals.engine.getContext().renderer;
138 if (renderer && technique) {
139 var wrap = 'REPEAT', mips = true;
140 var tex;
141 if (this._glTex)
142 {
143 if (this._glTex.isAnimated())
144 this._glTex.render();
145 tex = this._glTex.getTexture();
146 }
147
148 if (tex) {
149 technique.u_tex0.set( tex );
150 }
151 }
152 }
153 };
154
145 this.setEmboss = function( value ) 155 this.setEmboss = function( value )
146 { 156 {
147 this._emboss = value; 157 this._emboss = value;
@@ -251,6 +261,7 @@ var waterMaterialDef =
251 } 261 }
252}; 262};
253 263
264/*
254var ParisMaterial = function ParisMaterial() { 265var ParisMaterial = function ParisMaterial() {
255 // initialize the inherited members 266 // initialize the inherited members
256 this.inheritedFrom = WaterMaterial; 267 this.inheritedFrom = WaterMaterial;
@@ -349,7 +360,7 @@ var parisMaterialDef =
349 ] 360 ]
350 } 361 }
351}; 362};
352 363*/
353 364
354WaterMaterial.prototype = new PulseMaterial(); 365WaterMaterial.prototype = new PulseMaterial();
355 366