diff options
Diffstat (limited to 'js/helper-classes')
34 files changed, 1717 insertions, 252 deletions
diff --git a/js/helper-classes/RDGE/GLCircle.js b/js/helper-classes/RDGE/GLCircle.js index fc2e6460..8f7a5d30 100644 --- a/js/helper-classes/RDGE/GLCircle.js +++ b/js/helper-classes/RDGE/GLCircle.js | |||
@@ -63,14 +63,16 @@ function GLCircle() | |||
63 | 63 | ||
64 | this.m_world = world; | 64 | this.m_world = world; |
65 | 65 | ||
66 | |||
66 | if(strokeMaterial) | 67 | if(strokeMaterial) |
67 | { | ||
68 | this._strokeMaterial = strokeMaterial; | 68 | this._strokeMaterial = strokeMaterial; |
69 | } | 69 | else |
70 | this._strokeMaterial = new FlatMaterial(); | ||
71 | |||
70 | if(fillMaterial) | 72 | if(fillMaterial) |
71 | { | ||
72 | this._fillMaterial = fillMaterial; | 73 | this._fillMaterial = fillMaterial; |
73 | } | 74 | else |
75 | this._fillMaterial = new FlatMaterial(); | ||
74 | } | 76 | } |
75 | 77 | ||
76 | /////////////////////////////////////////////////////////////////////// | 78 | /////////////////////////////////////////////////////////////////////// |
diff --git a/js/helper-classes/RDGE/GLGeomObj.js b/js/helper-classes/RDGE/GLGeomObj.js index 72019703..e04b3283 100644 --- a/js/helper-classes/RDGE/GLGeomObj.js +++ b/js/helper-classes/RDGE/GLGeomObj.js | |||
@@ -99,6 +99,9 @@ function GLGeomObj() | |||
99 | } | 99 | } |
100 | } | 100 | } |
101 | } | 101 | } |
102 | |||
103 | var world = this.getWorld(); | ||
104 | if (world) world.restartRenderLoop(); | ||
102 | } | 105 | } |
103 | 106 | ||
104 | this.setFillColor = function(c) { this.setMaterialColor(c, "fill"); } | 107 | this.setFillColor = function(c) { this.setMaterialColor(c, "fill"); } |
diff --git a/js/helper-classes/RDGE/GLMaterial.js b/js/helper-classes/RDGE/GLMaterial.js index 51c27ace..07a98ab5 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.05; | ||
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 |
diff --git a/js/helper-classes/RDGE/GLRectangle.js b/js/helper-classes/RDGE/GLRectangle.js index 1334d7e6..e72b4488 100644 --- a/js/helper-classes/RDGE/GLRectangle.js +++ b/js/helper-classes/RDGE/GLRectangle.js | |||
@@ -80,13 +80,14 @@ function GLRectangle() | |||
80 | this._materialSpecular = [0.4, 0.4, 0.4, 1.0]; | 80 | this._materialSpecular = [0.4, 0.4, 0.4, 1.0]; |
81 | 81 | ||
82 | if(strokeMaterial) | 82 | if(strokeMaterial) |
83 | { | ||
84 | this._strokeMaterial = strokeMaterial; | 83 | this._strokeMaterial = strokeMaterial; |
85 | } | 84 | else |
85 | this._strokeMaterial = new FlatMaterial(); | ||
86 | |||
86 | if(fillMaterial) | 87 | if(fillMaterial) |
87 | { | ||
88 | this._fillMaterial = fillMaterial; | 88 | this._fillMaterial = fillMaterial; |
89 | } | 89 | else |
90 | this._fillMaterial = new FlatMaterial(); | ||
90 | } | 91 | } |
91 | 92 | ||
92 | /////////////////////////////////////////////////////////////////////// | 93 | /////////////////////////////////////////////////////////////////////// |
@@ -279,7 +280,7 @@ function GLRectangle() | |||
279 | 280 | ||
280 | // stroke | 281 | // stroke |
281 | var strokeMaterial = this.makeStrokeMaterial(); | 282 | var strokeMaterial = this.makeStrokeMaterial(); |
282 | prim = this.createStroke([x,y], 2*xFill, 2*yFill, strokeSize, tlRadius, blRadius, brRadius, trRadius, strokeMaterial) | 283 | prim = this.createStroke([x,y], 2*xFill, 2*yFill, strokeSize, tlRadius, blRadius, brRadius, trRadius); |
283 | this._primArray.push( prim ); | 284 | this._primArray.push( prim ); |
284 | this._materialNodeArray.push( strokeMaterial.getMaterialNode() ); | 285 | this._materialNodeArray.push( strokeMaterial.getMaterialNode() ); |
285 | 286 | ||
@@ -485,7 +486,7 @@ function GLRectangle() | |||
485 | this.createStroke = function(ctr, width, height, strokeWidth, tlRad, blRad, brRad, trRad, material) | 486 | this.createStroke = function(ctr, width, height, strokeWidth, tlRad, blRad, brRad, trRad, material) |
486 | { | 487 | { |
487 | // create the geometry | 488 | // create the geometry |
488 | var prim = RectangleStroke.create( ctr, width, height, strokeWidth, tlRad, blRad, brRad, trRad) | 489 | var prim = RectangleStroke.create( ctr, width, height, strokeWidth, tlRad, blRad, brRad, trRad, material) |
489 | return prim; | 490 | return prim; |
490 | } | 491 | } |
491 | 492 | ||
@@ -495,9 +496,9 @@ function GLRectangle() | |||
495 | // special the (common) case of no rounded corners | 496 | // special the (common) case of no rounded corners |
496 | var prim | 497 |