diff options
author | Valerio Virgillito | 2012-02-09 13:41:45 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-09 13:41:45 -0800 |
commit | f5193cd04a2597051d88fced878efbc4802ea64c (patch) | |
tree | dc343dc98fa9f99133d9882bd9b92cfe81296d1a /js/helper-classes/RDGE/GLMaterial.js | |
parent | e2539230b8a297fa972af6d53fe9de3ef2ad43fa (diff) | |
parent | 666ae3e9119410cbf7fa974274d95336aaff091c (diff) | |
download | ninja-f5193cd04a2597051d88fced878efbc4802ea64c.tar.gz |
Merge branch 'refs/heads/master' into components
Diffstat (limited to 'js/helper-classes/RDGE/GLMaterial.js')
-rw-r--r-- | js/helper-classes/RDGE/GLMaterial.js | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/js/helper-classes/RDGE/GLMaterial.js b/js/helper-classes/RDGE/GLMaterial.js index 51c27ace..e72b7908 100644 --- a/js/helper-classes/RDGE/GLMaterial.js +++ b/js/helper-classes/RDGE/GLMaterial.js | |||
@@ -62,6 +62,10 @@ function GLMaterial( world ) | |||
62 | this.getShader = function() { return this._shader; } | 62 | this.getShader = function() { return this._shader; } |
63 | this.getMaterialNode = function() { return this._materialNode; } | 63 | this.getMaterialNode = function() { return this._materialNode; } |
64 | 64 | ||
65 | // a material can be animated or not. default is not. | ||
66 | // Any material needing continuous rendering should override this method | ||
67 | this.isAnimated = function() { return false; } | ||
68 | |||
65 | 69 | ||
66 | /////////////////////////////////////////////////////////////////////// | 70 | /////////////////////////////////////////////////////////////////////// |
67 | // Common Material Methods | 71 | // Common Material Methods |
@@ -174,6 +178,31 @@ function GLMaterial( world ) | |||
174 | // animated materials should implement the update method | 178 | // animated materials should implement the update method |
175 | } | 179 | } |
176 | 180 | ||
181 | this.registerTexture = function( texture ) | ||
182 | { | ||
183 | // the world needs to know about the texture map | ||
184 | var world = this.getWorld(); | ||
185 | if (!world) | ||
186 | console.log( "**** world not defined for registering texture map: " + texture.lookUpName ); | ||
187 | else | ||
188 | world.textureToLoad( texture ); | ||
189 | } | ||
190 | |||
191 | this.loadTexture = function( texMapName, wrap, mips ) | ||
192 | { | ||
193 | var tex; | ||
194 | var world = this.getWorld(); | ||
195 | if (!world) | ||
196 | console.log( "world not defined for material with texture map" ); | ||
197 | else | ||
198 | { | ||
199 | var renderer = world.getRenderer(); | ||
200 | tex = renderer.getTextureByName(texMapName, wrap, mips ); | ||
201 | this.registerTexture( tex ); | ||
202 | } | ||
203 | return tex; | ||
204 | } | ||
205 | |||
177 | this.export = function() | 206 | this.export = function() |
178 | { | 207 | { |
179 | // this function should be overridden by subclasses | 208 | // this function should be overridden by subclasses |
@@ -186,7 +215,7 @@ function GLMaterial( world ) | |||
186 | var endKey = "endMaterial\n"; | 215 | var endKey = "endMaterial\n"; |
187 | var index = importStr.indexOf( endKey ); | 216 | var index = importStr.indexOf( endKey ); |
188 | index += endKey.length; | 217 | index += endKey.length; |
189 | rtnStr = importStr.substr( index ); | 218 | var rtnStr = importStr.substr( index ); |
190 | 219 | ||
191 | return rtnStr; | 220 | return rtnStr; |
192 | } | 221 | } |