diff options
Diffstat (limited to 'js/helper-classes/RDGE')
34 files changed, 1556 insertions, 245 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..c633f679 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 |
diff --git a/js/helper-classes/RDGE/GLRectangle.js b/js/helper-classes/RDGE/GLRectangle.js index 1334d7e6..1bb4bcac 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 | /////////////////////////////////////////////////////////////////////// |
diff --git a/js/helper-classes/RDGE/GLWorld.js b/js/helper-classes/RDGE/GLWorld.js index cc44da50..819f89db 100644 --- a/js/helper-classes/RDGE/GLWorld.js +++ b/js/helper-classes/RDGE/GLWorld.js | |||
@@ -65,6 +65,11 @@ function GLWorld( canvas, use3D ) | |||
65 | 65 | ||
66 | this._camera; | 66 | this._camera; |
67 | 67 | ||
68 | // keep a flag indicating whether a render has been completed. | ||
69 | // this allows us to turn off automatic updating if there are | ||
70 | // no animated materials | ||
71 | this._firstRender = true; | ||
72 | |||
68 | /////////////////////////////////////////////////////////////////////// | 73 | /////////////////////////////////////////////////////////////////////// |
69 | // Property accessors | 74 | // Property accessors |
70 | /////////////////////////////////////////////////////////////////////// | 75 | /////////////////////////////////////////////////////////////////////// |
@@ -103,6 +108,8 @@ function GLWorld( canvas, use3D ) | |||
103 | 108 | ||
104 | this.isWebGL = function() { return this._useWebGL; } | 109 | this.isWebGL = function() { return this._useWebGL; } |
105 | 110 | ||
111 | this.getRenderer = function() { return this.renderer; } | ||
112 | |||
106 | //////////////////////////////////////////////////////////////////////////////////// | 113 | //////////////////////////////////////////////////////////////////////////////////// |
107 | // RDGE | 114 | // RDGE |
108 | // local variables | 115 | // local variables |
@@ -114,6 +121,10 @@ function GLWorld( canvas, use3D ) | |||
114 | this.strokeShader = null; | 121 | this.strokeShader = null; |
115 | this.renderer = null; | 122 | this.renderer = null; |
116 | 123 | ||
124 | // keep an array of texture maps that need to be loaded | ||
125 | this._texMapsToLoad = []; | ||
126 | this._allMapsLoaded = true; | ||
127 | |||
117 | // this is the node to which objects get hung | 128 | // this is the node to which objects get hung |
118 | this._rootNode; | 129 | this._rootNode; |
119 | 130 | ||
@@ -214,18 +225,159 @@ function GLWorld( canvas, use3D ) | |||
214 | { | 225 | { |
215 | if (this._useWebGL) | 226 | if (this._useWebGL) |
216 | { | 227 | { |
217 | var ctx = g_Engine.getContext(); | 228 | if (this._allMapsLoaded) |