aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge')
-rw-r--r--js/lib/rdge/materials/flag-material.js81
-rw-r--r--js/lib/rdge/materials/pulse-material.js2
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js7
-rwxr-xr-xjs/lib/rdge/materials/uber-material.js12
4 files changed, 83 insertions, 19 deletions
diff --git a/js/lib/rdge/materials/flag-material.js b/js/lib/rdge/materials/flag-material.js
index 312ca1c1..fa844cc3 100644
--- a/js/lib/rdge/materials/flag-material.js
+++ b/js/lib/rdge/materials/flag-material.js
@@ -21,8 +21,9 @@ var FlagMaterial = function FlagMaterial() {
21 this._time = 0.0; 21 this._time = 0.0;
22 this._dTime = 0.1; 22 this._dTime = 0.1;
23 23
24 this._defaultWaveWidth = 1.0; 24 this._speed = 1.0;
25 this._defaultWaveHeight = 1.0; 25 this._waveWidth = 1.0;
26 this._waveHeight = 1.0;
26 27
27 this._hasVertexDeformation = true; 28 this._hasVertexDeformation = true;
28 29
@@ -31,14 +32,16 @@ var FlagMaterial = function FlagMaterial() {
31 /////////////////////////////////////////////////////////////////////// 32 ///////////////////////////////////////////////////////////////////////
32 // all defined in parent PulseMaterial.js 33 // all defined in parent PulseMaterial.js
33 // load the local default value 34 // load the local default value
34 this._propNames = ["texmap", "wavewidth", "waveheight" ]; 35 this._propNames = ["texmap", "wavewidth", "waveheight", "speed" ];
35 this._propLabels = ["Texture map", "Wave Width", "Wave Height" ]; 36 this._propLabels = ["Texture map", "Wave Width", "Wave Height", "Speed" ];
36 this._propTypes = ["file", "float", "float" ]; 37 this._propTypes = ["file", "float", "float", "float" ];
37 this._propValues = []; 38 this._propValues = [];
38 39
39 this._propValues[ this._propNames[0] ] = this._texMap.slice(0); 40 this._propValues[ this._propNames[0] ] = this._texMap.slice(0);
40 this._propValues[ this._propNames[1] ] = this._defaultWaveWidth; 41 this._propValues[ this._propNames[1] ] = this._waveWidth;
41 this._propValues[ this._propNames[2] ] = this._defaultWaveHeight; 42 this._propValues[ this._propNames[2] ] = this._waveHeight;
43 this._propValues[ this._propNames[3] ] = this._speed;
44
42 45
43 // a material can be animated or not. default is not. 46 // a material can be animated or not. default is not.
44 // Any material needing continuous rendering should override this method 47 // Any material needing continuous rendering should override this method
@@ -65,6 +68,68 @@ var FlagMaterial = function FlagMaterial() {
65 return newMat; 68 return newMat;
66 }; 69 };
67 70
71 this.setProperty = function( prop, value )
72 {
73 // make sure we have legitimate imput
74 var ok = this.validateProperty( prop, value );
75 if (!ok) {
76 console.log( "invalid property in Radial Gradient Material:" + prop + " : " + value );
77 }
78
79 switch (prop)
80 {
81 case "texmap":
82 this.setTextureMap(value);
83 break;
84
85 case "wavewidth":
86 this._waveWidth = value;
87 this._propValues[ this._propNames[1] ] = this._waveWidth;
88 this.updateParameters();
89 break;
90
91 case "waveheight":
92 this._waveHeight = value;
93 this._propValues[ this._propNames[2] ] = this._waveHeight;
94 this.updateParameters();
95 break;
96
97 case "speed":
98 this._speed = value;
99 this._propValues[ this._propNames[3] ] = this._speed;
100 this.updateParameters();
101 break;
102
103 case "color":
104 break;
105 }
106 };
107
108
109 this.updateParameters = function()
110 {
111 this._propValues[ this._propNames[1] ] = this._waveWidth;
112 this._propValues[ this._propNames[2] ] = this._waveHeight;
113 this._propValues[ this._propNames[3] ] = this._speed;
114
115 var material = this._materialNode;
116 if (material)
117 {
118 var technique = material.shaderProgram['default'];
119 var renderer = RDGE.globals.engine.getContext().renderer;
120 if (renderer && technique)
121 {
122
123 if (this._shader && this._shader['default']) {
124 this._shader['default'].u_speed.set( [this._speed] );
125 this._shader['default'].u_waveWidth.set( [this._waveWidth] );
126 this._shader['default'].u_waveHeight.set( [this._waveHeight] );
127 }
128 }
129 }
130 };
131
132
68 this.init = function( world ) 133 this.init = function( world )
69 { 134 {
70 // save the world 135 // save the world
@@ -91,6 +156,7 @@ var FlagMaterial = function FlagMaterial() {
91 this._glTex = new Texture( world, texMapName ); 156 this._glTex = new Texture( world, texMapName );
92 157
93 // set the shader values in the shader 158 // set the shader values in the shader
159 this.updateParameters();
94 this.updateTexture(); 160 this.updateTexture();
95 this.update( 0 ); 161 this.update( 0 );
96 } 162 }
@@ -125,6 +191,7 @@ var flagMaterialDef =
125 { 191 {
126 'u_tex0': { 'type' : 'tex2d' }, 192 'u_tex0': { 'type' : 'tex2d' },
127 'u_time' : { 'type' : 'float' }, 193 'u_time' : { 'type' : 'float' },
194 'u_speed' : { 'type' : 'float' },
128 'u_waveWidth' : { 'type' : 'float' }, 195 'u_waveWidth' : { 'type' : 'float' },
129 'u_waveHeight' : { 'type' : 'float' } 196 'u_waveHeight' : { 'type' : 'float' }
130 }, 197 },
diff --git a/js/lib/rdge/materials/pulse-material.js b/js/lib/rdge/materials/pulse-material.js
index 56c10f21..28f3ee5e 100644
--- a/js/lib/rdge/materials/pulse-material.js
+++ b/js/lib/rdge/materials/pulse-material.js
@@ -224,8 +224,6 @@ var PulseMaterial = function PulseMaterial()
224 this._shader['default'].u_time.set( [this._time] ); 224 this._shader['default'].u_time.set( [this._time] );
225 } 225 }
226 this._time += this._dTime; 226 this._time += this._dTime;
227
228 if (this._time > 200.0) this._time = 0.0;
229 } 227 }
230 } 228 }
231 }; 229 };
diff --git a/js/lib/rdge/materials/radial-gradient-material.js b/js/lib/rdge/materials/radial-gradient-material.js
index 65679429..083b7371 100755
--- a/js/lib/rdge/materials/radial-gradient-material.js
+++ b/js/lib/rdge/materials/radial-gradient-material.js
@@ -147,9 +147,9 @@ var RadialGradientMaterial = function RadialGradientMaterial() {
147 /////////////////////////////////////////////////////////////////////// 147 ///////////////////////////////////////////////////////////////////////
148 // Material Property Accessors 148 // Material Property Accessors
149 /////////////////////////////////////////////////////////////////////// 149 ///////////////////////////////////////////////////////////////////////
150 this._propNames = ["color1", "color2", "color3", "color4", "colorStop1", "colorStop2", "colorStop3", "colorStop4", "angle"]; 150 this._propNames = ["color1", "color2", "color3", "color4", "colorStop1", "colorStop2", "colorStop3", "colorStop4" ];
151 this._propLabels = ["Color 1", "Color 2", "Color 3", "Color 4", "Color Stop 1", "Color Stop 2", "Color Stop 3", "Color Stop 4", "Angle"]; 151 this._propLabels = ["Color 1", "Color 2", "Color 3", "Color 4", "Color Stop 1", "Color Stop 2", "Color Stop 3", "Color Stop 4" ];
152 this._propTypes = ["color", "color", "color", "color", "float", "float", "float", "float", "float"]; 152 this._propTypes = ["color", "color", "color", "color", "float", "float", "float", "float" ];
153 this._propValues = []; 153 this._propValues = [];
154 154
155 this._propValues[this._propNames[0]] = this._color1.slice(0); 155 this._propValues[this._propNames[0]] = this._color1.slice(0);
@@ -180,7 +180,6 @@ var RadialGradientMaterial = function RadialGradientMaterial() {
180 case "colorStop2": this.setColorStop2(value); break; 180 case "colorStop2": this.setColorStop2(value); break;
181 case "colorStop3": this.setColorStop3(value); break; 181 case "colorStop3": this.setColorStop3(value); break;
182 case "colorStop4": this.setColorStop4(value); break; 182 case "colorStop4": this.setColorStop4(value); break;
183 case "angle": this.setAngle(value); break;
184 } 183 }
185 184
186 //this.updateValuesInShader(); 185 //this.updateValuesInShader();
diff --git a/js/lib/rdge/materials/uber-material.js b/js/lib/rdge/materials/uber-material.js
index 6de74495..0fef78f6 100755
--- a/js/lib/rdge/materials/uber-material.js
+++ b/js/lib/rdge/materials/uber-material.js
@@ -247,9 +247,9 @@ var UberMaterial = function UberMaterial() {
247 var technique = material.shaderProgram.defaultTechnique; 247 var technique = material.shaderProgram.defaultTechnique;
248 var renderer = RDGE.globals.engine.getContext().renderer; 248 var renderer = RDGE.globals.engine.getContext().renderer;
249 if (renderer && technique) { 249 if (renderer && technique) {
250 var tex = renderer.getTextureByName(value, caps.environmentMap.wrap); 250 var tex = renderer.getTextureByName(value, this._ubershaderCaps.environmentMap.wrap);
251 this.registerTexture(tex); 251 this.registerTexture(tex);
252 technique.s_environmentMap.set(tex); 252 technique.s_envMap.set(tex);
253 } 253 }
254 } 254 }
255 } 255 }
@@ -276,7 +276,7 @@ var UberMaterial = function UberMaterial() {
276 var technique = material.shaderProgram.defaultTechnique; 276 var technique = material.shaderProgram.defaultTechnique;
277 var renderer = RDGE.globals.engine.getContext().renderer; 277 var renderer = RDGE.globals.engine.getContext().renderer;
278 if (renderer && technique) { 278 if (renderer && technique) {
279 this._diffuseTexture = new Texture( this.getWorld(), value, caps.diffuseMap.wrap ); 279 this._diffuseTexture = new Texture( this.getWorld(), value, this._ubershaderCaps.diffuseMap.wrap );
280 var tex = this._diffuseTexture.getTexture(); 280 var tex = this._diffuseTexture.getTexture();
281 technique.s_diffuseMap.set( tex ); 281 technique.s_diffuseMap.set( tex );
282 } 282 }
@@ -304,7 +304,7 @@ var UberMaterial = function UberMaterial() {
304 var technique = material.shaderProgram.defaultTechnique; 304 var technique = material.shaderProgram.defaultTechnique;
305 var renderer = RDGE.globals.engine.getContext().renderer; 305 var renderer = RDGE.globals.engine.getContext().renderer;
306 if (renderer && technique) { 306 if (renderer && technique) {
307 var tex = renderer.getTextureByName(value, caps.specularMap.wrap); 307 var tex = re