aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/pulse-material.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials/pulse-material.js')
-rw-r--r--js/lib/rdge/materials/pulse-material.js55
1 files changed, 49 insertions, 6 deletions
diff --git a/js/lib/rdge/materials/pulse-material.js b/js/lib/rdge/materials/pulse-material.js
index f26aa16c..eedccf71 100644
--- a/js/lib/rdge/materials/pulse-material.js
+++ b/js/lib/rdge/materials/pulse-material.js
@@ -4,13 +4,21 @@
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */ 5 </copyright> */
6 6
7var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser;
8var Material = require("js/lib/rdge/materials/material").Material; 7var Material = require("js/lib/rdge/materials/material").Material;
8var Texture = require("js/lib/rdge/texture").Texture;
9
9/////////////////////////////////////////////////////////////////////// 10///////////////////////////////////////////////////////////////////////
10// Class GLMaterial 11// Class GLMaterial
11// RDGE representation of a material. 12// RDGE representation of a material.
12/////////////////////////////////////////////////////////////////////// 13///////////////////////////////////////////////////////////////////////
13var PulseMaterial = function PulseMaterial() { 14var PulseMaterial = function PulseMaterial()
15{
16 var MaterialLibrary = require("js/models/materials-model").MaterialsModel;
17
18 // initialize the inherited members
19 this.inheritedFrom = Material;
20 this.inheritedFrom();
21
14 /////////////////////////////////////////////////////////////////////// 22 ///////////////////////////////////////////////////////////////////////
15 // Instance variables 23 // Instance variables
16 /////////////////////////////////////////////////////////////////////// 24 ///////////////////////////////////////////////////////////////////////
@@ -18,6 +26,8 @@ var PulseMaterial = function PulseMaterial() {
18 this._shaderName = "pulse"; 26 this._shaderName = "pulse";
19 27
20 this._texMap = 'assets/images/cubelight.png'; 28 this._texMap = 'assets/images/cubelight.png';
29 //this._texMap = 'assets/images/cloud10.png';
30 //this._texMap = 'texture';
21 31
22 this._time = 0.0; 32 this._time = 0.0;
23 this._dTime = 0.01; 33 this._dTime = 0.01;
@@ -107,6 +117,9 @@ var PulseMaterial = function PulseMaterial() {
107 this._shader['default'].u_time.set( [this._time] ); 117 this._shader['default'].u_time.set( [this._time] );
108 } 118 }
109 119
120 // set up the texture
121 var texMapName = this._propValues[this._propNames[0]];
122 this._glTex = new Texture( world, texMapName );
110 123
111 // set the shader values in the shader 124 // set the shader values in the shader
112 this.updateTexture(); 125 this.updateTexture();
@@ -120,9 +133,14 @@ var PulseMaterial = function PulseMaterial() {
120 var technique = material.shaderProgram['default']; 133 var technique = material.shaderProgram['default'];
121 var renderer = RDGE.globals.engine.getContext().renderer; 134 var renderer = RDGE.globals.engine.getContext().renderer;
122 if (renderer && technique) { 135 if (renderer && technique) {
123 var texMapName = this._propValues[this._propNames[0]];
124 var wrap = 'REPEAT', mips = true; 136 var wrap = 'REPEAT', mips = true;
125 var tex = this.loadTexture( texMapName, wrap, mips ); 137 var tex;
138 if (this._glTex)
139 {
140 if (this._glTex.isAnimated())
141 this._glTex.render();
142 tex = this._glTex.getTexture();
143 }
126 144
127 if (tex) { 145 if (tex) {
128 technique.u_tex0.set( tex ); 146 technique.u_tex0.set( tex );
@@ -131,6 +149,20 @@ var PulseMaterial = function PulseMaterial() {
131 } 149 }
132 }; 150 };
133 151
152
153 this.updateTextures = function()
154 {
155 if (this._glTex)
156 {
157 if (!this._glTex.isAnimated())
158 {
159 this._glTex.render();
160 this.updateTexture();
161 }
162 }
163 }
164
165
134 this.update = function( time ) 166 this.update = function( time )
135 { 167 {
136 var material = this._materialNode; 168 var material = this._materialNode;
@@ -138,7 +170,18 @@ var PulseMaterial = function PulseMaterial() {
138 { 170 {
139 var technique = material.shaderProgram['default']; 171 var technique = material.shaderProgram['default'];
140 var renderer = RDGE.globals.engine.getContext().renderer; 172 var renderer = RDGE.globals.engine.getContext().renderer;
141 if (renderer && technique) { 173 if (renderer && technique)
174 {
175 if (this._glTex)
176 {
177 //this.updateTexture();
178 if (this._glTex.isAnimated())
179 this._glTex.render();
180 tex = this._glTex.getTexture();
181 if (tex)
182 technique.u_tex0.set( tex );
183 }
184
142 if (this._shader && this._shader['default']) { 185 if (this._shader && this._shader['default']) {
143 this._shader['default'].u_time.set( [this._time] ); 186 this._shader['default'].u_time.set( [this._time] );
144 } 187 }
@@ -235,7 +278,7 @@ var pulseMaterialDef =
235 } 278 }
236}; 279};
237 280
238PulseMaterial.prototype = new Material(); 281//PulseMaterial.prototype = new Material();
239 282
240if (typeof exports === "object") { 283if (typeof exports === "object") {
241 exports.PulseMaterial = PulseMaterial; 284 exports.PulseMaterial = PulseMaterial;