diff options
author | Eric Guzman | 2012-02-13 10:30:26 -0800 |
---|---|---|
committer | Eric Guzman | 2012-02-13 10:30:26 -0800 |
commit | 672e6f61647b1b8a5f6f5831284fa44bcb7be883 (patch) | |
tree | 0c15656f1f82f194bfcab68634a88f68fd3d42cb /js/helper-classes/RDGE/GLMaterial.js | |
parent | 586c3f7bbea04e62638e5ed8cdce9933e88c0b67 (diff) | |
parent | e142611e22718b1f1d1696902ad9161ec5f33f98 (diff) | |
download | ninja-672e6f61647b1b8a5f6f5831284fa44bcb7be883.tar.gz |
Merge branch 'refs/heads/master' into PresetsPanel
Diffstat (limited to 'js/helper-classes/RDGE/GLMaterial.js')
-rw-r--r-- | js/helper-classes/RDGE/GLMaterial.js | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/js/helper-classes/RDGE/GLMaterial.js b/js/helper-classes/RDGE/GLMaterial.js index 51c27ace..642fab05 100644 --- a/js/helper-classes/RDGE/GLMaterial.js +++ b/js/helper-classes/RDGE/GLMaterial.js | |||
@@ -31,6 +31,11 @@ function GLMaterial( world ) | |||
31 | 31 | ||
32 | this._texture; | 32 | this._texture; |
33 | 33 | ||
34 | // vertex deformation variables | ||
35 | this._hasVertexDeformation = false; | ||
36 | this._vertexDeformationRange = [0, 0, 1, 1]; // (xMin, yMin, xMax, yMax) | ||
37 | this._vertexDeformationTolerance = 0.1; | ||
38 | |||
34 | // RDGE variables | 39 | // RDGE variables |
35 | this._shader; | 40 | this._shader; |
36 | this._materialNode; | 41 | this._materialNode; |
@@ -62,6 +67,16 @@ function GLMaterial( world ) | |||
62 | this.getShader = function() { return this._shader; } | 67 | this.getShader = function() { return this._shader; } |
63 | this.getMaterialNode = function() { return this._materialNode; } | 68 | this.getMaterialNode = function() { return this._materialNode; } |
64 | 69 | ||
70 | // a material can be animated or not. default is not. | ||
71 | // Any material needing continuous rendering should override this method | ||
72 | this.isAnimated = function() { return false; } | ||
73 | |||
74 | // the vertex shader can apply deformations requiring refinement in | ||
75 | // certain areas. | ||
76 | this.hasVertexDeformation = function() { return this._hasVertexDeformation; } | ||
77 | this.getVertexDeformationRange = function() { return this._vertexDeformationRange.slice(); } | ||
78 | this.getVertexDeformationTolerance = function() { return this._vertexDeformationTolerance; } | ||
79 | |||
65 | 80 | ||
66 | /////////////////////////////////////////////////////////////////////// | 81 | /////////////////////////////////////////////////////////////////////// |
67 | // Common Material Methods | 82 | // Common Material Methods |
@@ -174,6 +189,31 @@ function GLMaterial( world ) | |||
174 | // animated materials should implement the update method | 189 | // animated materials should implement the update method |
175 | } | 190 | } |
176 | 191 | ||
192 | this.registerTexture = function( texture ) | ||
193 | { | ||
194 | // the world needs to know about the texture map | ||
195 | var world = this.getWorld(); | ||
196 | if (!world) | ||
197 | console.log( "**** world not defined for registering texture map: " + texture.lookUpName ); | ||
198 | else | ||
199 | world.textureToLoad( texture ); | ||
200 | } | ||
201 | |||
202 | this.loadTexture = function( texMapName, wrap, mips ) | ||
203 | { | ||
204 | var tex; | ||
205 | var world = this.getWorld(); | ||
206 | if (!world) | ||
207 | console.log( "world not defined for material with texture map" ); | ||
208 | else | ||
209 | { | ||
210 | var renderer = world.getRenderer(); | ||
211 | tex = renderer.getTextureByName(texMapName, wrap, mips ); | ||
212 | this.registerTexture( tex ); | ||
213 | } | ||
214 | return tex; | ||
215 | } | ||
216 | |||
177 | this.export = function() | 217 | this.export = function() |
178 | { | 218 | { |
179 | // this function should be overridden by subclasses | 219 | // this function should be overridden by subclasses |
@@ -186,7 +226,7 @@ function GLMaterial( world ) | |||
186 | var endKey = "endMaterial\n"; | 226 | var endKey = "endMaterial\n"; |
187 | var index = importStr.indexOf( endKey ); | 227 | var index = importStr.indexOf( endKey ); |
188 | index += endKey.length; | 228 | index += endKey.length; |
189 | rtnStr = importStr.substr( index ); | 229 | var rtnStr = importStr.substr( index ); |
190 | 230 | ||
191 | return rtnStr; | 231 | return rtnStr; |
192 | } | 232 | } |