diff options
Diffstat (limited to 'js/helper-classes')
-rw-r--r-- | js/helper-classes/RDGE/GLCircle.js | 13 | ||||
-rw-r--r-- | js/helper-classes/RDGE/GLGeomObj.js | 3 | ||||
-rw-r--r-- | js/helper-classes/RDGE/GLLine.js | 3 | ||||
-rw-r--r-- | js/helper-classes/RDGE/GLMaterial.js | 40 | ||||
-rw-r--r-- | js/helper-classes/RDGE/GLRectangle.js | 171 | ||||
-rw-r--r-- | js/helper-classes/RDGE/GLWorld.js | 238 | ||||
-rw-r--r-- | js/helper-classes/RDGE/rdge-compiled.js | 147 | ||||
-rw-r--r-- | js/helper-classes/RDGE/src/core/script/engine.js | 18 | ||||
-rw-r--r-- | js/helper-classes/RDGE/src/core/script/init_state.js | 7 | ||||
-rw-r--r-- | js/helper-classes/RDGE/src/core/script/jshader.js | 6 | ||||
-rw-r--r-- | js/helper-classes/RDGE/src/core/script/renderer.js | 32 | ||||
-rw-r--r-- | js/helper-classes/RDGE/src/core/script/run_state.js | 10 | ||||
-rw-r--r-- | js/helper-classes/RDGE/src/core/script/runtime.js | 2 |
13 files changed, 548 insertions, 142 deletions
diff --git a/js/helper-classes/RDGE/GLCircle.js b/js/helper-classes/RDGE/GLCircle.js index e6bcba89..08057778 100644 --- a/js/helper-classes/RDGE/GLCircle.js +++ b/js/helper-classes/RDGE/GLCircle.js | |||
@@ -55,14 +55,16 @@ function GLCircle() | |||
55 | 55 | ||
56 | this.m_world = world; | 56 | this.m_world = world; |
57 | 57 | ||
58 | |||
58 | if(strokeMaterial) | 59 | if(strokeMaterial) |
59 | { | ||
60 | this._strokeMaterial = strokeMaterial; | 60 | this._strokeMaterial = strokeMaterial; |
61 | } | 61 | else |
62 | this._strokeMaterial = new FlatMaterial(); | ||
63 | |||
62 | if(fillMaterial) | 64 | if(fillMaterial) |
63 | { | ||
64 | this._fillMaterial = fillMaterial; | 65 | this._fillMaterial = fillMaterial; |
65 | } | 66 | else |
67 | this._fillMaterial = new FlatMaterial(); | ||
66 | } | 68 | } |
67 | 69 | ||
68 | /////////////////////////////////////////////////////////////////////// | 70 | /////////////////////////////////////////////////////////////////////// |
@@ -131,6 +133,9 @@ function GLCircle() | |||
131 | if (!world) throw( "null world in buildBuffers" ); | 133 | if (!world) throw( "null world in buildBuffers" ); |
132 | 134 | ||
133 | if (!world._useWebGL) return; | 135 | if (!world._useWebGL) return; |
136 | |||
137 | // make sure RDGE has the correct context | ||
138 | g_Engine.setContext( world.getCanvas().uuid ); | ||
134 | 139 | ||
135 | // create the gl buffer | 140 | // create the gl buffer |
136 | var gl = world.getGLContext(); | 141 | var gl = world.getGLContext(); |
diff --git a/js/helper-classes/RDGE/GLGeomObj.js b/js/helper-classes/RDGE/GLGeomObj.js index 62fbf562..5d7497ad 100644 --- a/js/helper-classes/RDGE/GLGeomObj.js +++ b/js/helper-classes/RDGE/GLGeomObj.js | |||
@@ -103,6 +103,9 @@ function GLGeomObj() | |||
103 | } | 103 | } |
104 | } | 104 | } |
105 | } | 105 | } |
106 | |||
107 | var world = this.getWorld(); | ||
108 | if (world) world.restartRenderLoop(); | ||
106 | } | 109 | } |
107 | 110 | ||
108 | this.setFillColor = function(c) { this.setMaterialColor(c, "fill"); } | 111 | this.setFillColor = function(c) { this.setMaterialColor(c, "fill"); } |
diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js index bd3cbc26..f01e1610 100644 --- a/js/helper-classes/RDGE/GLLine.js +++ b/js/helper-classes/RDGE/GLLine.js | |||
@@ -109,6 +109,9 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro | |||
109 | var world = this.getWorld(); | 109 | var world = this.getWorld(); |
110 | if (!world) throw( "null world in buildBuffers" ); | 110 | if (!world) throw( "null world in buildBuffers" ); |
111 | if (!world._useWebGL) return; | 111 | if (!world._useWebGL) return; |
112 | |||
113 | // make sure RDGE has the correct context | ||
114 | g_Engine.setContext( world.getCanvas().uuid ); | ||
112 | 115 | ||
113 | // create the gl buffer | 116 | // create the gl buffer |
114 | var gl = world.getGLContext(); | 117 | var gl = world.getGLContext(); |
diff --git a/js/helper-classes/RDGE/GLMaterial.js b/js/helper-classes/RDGE/GLMaterial.js index e1a68abd..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 |
diff --git a/js/helper-classes/RDGE/GLRectangle.js b/js/helper-classes/RDGE/GLRectangle.js index b88ecc71..e34532d2 100644 --- a/js/helper-classes/RDGE/GLRectangle.js +++ b/js/helper-classes/RDGE/GLRectangle.js | |||
@@ -72,13 +72,14 @@ function GLRectangle() | |||
72 | this._materialSpecular = [0.4, 0.4, 0.4, 1.0]; | 72 | this._materialSpecular = [0.4, 0.4, 0.4, 1.0]; |
73 | 73 | ||
74 | if(strokeMaterial) | 74 | if(strokeMaterial) |
75 | { | ||
76 | this._strokeMaterial = strokeMaterial; | 75 | this._strokeMaterial = strokeMaterial; |
77 | } | 76 | else |
77 | this._strokeMaterial = new FlatMaterial(); | ||
78 | |||
78 | if(fillMaterial) | 79 | if(fillMaterial) |
79 | { | ||
80 | this._fillMaterial = fillMaterial; | 80 | this._fillMaterial = fillMaterial; |
81 | } | 81 | else |
82 | this._fillMaterial = new FlatMaterial(); | ||
82 | } | 83 | } |
83 | 84 | ||
84 | /////////////////////////////////////////////////////////////////////// | 85 | /////////////////////////////////////////////////////////////////////// |
@@ -209,8 +210,11 @@ function GLRectangle() | |||
209 | // get the world | 210 | // get the world |
210 | var world = this.getWorld(); | 211 | var world = this.getWorld(); |
211 | if (!world) throw( "null world in buildBuffers" ); | 212 | if (!world) throw( "null world in buildBuffers" ); |
212 | 213 | //console.log( "GLRectangle.buildBuffers " + world._worldCount ); | |
213 | if (!world._useWebGL) return; | 214 | if (!world._useWebGL) return; |
215 | |||
216 | // make sure RDGE has the correct context | ||
217 | g_Engine.setContext( world.getCanvas().uuid ); | ||
214 | 218 | ||
215 | // create the gl buffer | 219 | // create the gl buffer |
216 | var gl = world.getGLContext(); | 220 | var gl = world.getGLContext(); |
@@ -283,6 +287,7 @@ function GLRectangle() | |||
283 | xFill -= strokeSize; | 287 | xFill -= strokeSize; |
284 | yFill -= strokeSize; | 288 | yFill -= strokeSize; |
285 | var fillMaterial = this.makeFillMaterial(); | 289 | var fillMaterial = this.makeFillMaterial(); |
290 | //console.log( "fillMaterial: " + fillMaterial.getName() ); | ||
286 | var fillPrim = this.createFill([x,y], 2*xFill, 2*yFill, tlRadius, blRadius, brRadius, trRadius, fillMaterial); | 291 | var fillPrim = this.createFill([x,y], 2*xFill, 2*yFill, tlRadius, blRadius, brRadius, trRadius, fillMaterial); |
287 | this._primArray.push( fillPrim ); | 292 | this._primArray.push( fillPrim ); |
288 | this._materialNodeArray.push( fillMaterial.getMaterialNode() ); | 293 | this._materialNodeArray.push( fillMaterial.getMaterialNode() ); |
@@ -430,7 +435,7 @@ function GLRectangle() | |||
430 | this.createStroke = function(ctr, width, height, strokeWidth, tlRad, blRad, brRad, trRad, material) | 435 | this.createStroke = function(ctr, width, height, strokeWidth, tlRad, blRad, brRad, trRad, material) |
431 | { | 436 | { |
432 | // create the geometry | 437 | // create the geometry |
433 | var prim = RectangleStroke.create( ctr, width, height, strokeWidth, tlRad, blRad, brRad, trRad) | 438 | var prim = RectangleStroke.create( ctr, width, height, strokeWidth, tlRad, blRad, brRad, trRad, material) |
434 | return prim; | 439 | return prim; |
435 | } | 440 | } |
436 | 441 | ||
@@ -440,9 +445,9 @@ function GLRectangle() | |||
440 | // special the (common) case of no rounded corners | 445 | // special the (common) case of no rounded corners |