aboutsummaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
authorValerio Virgillito2012-04-04 15:53:29 -0700
committerValerio Virgillito2012-04-04 15:53:29 -0700
commite721a7c1009f298a1bd8fea583da14535e039880 (patch)
tree9415f5ba25ad643df678e561719d2708fd3ead5a /js/lib
parent8482e23cd9b8c4700b5130f2588e5eb24d376536 (diff)
parent7249d6377c8897b2f9d8115be99717be971a0981 (diff)
downloadninja-e721a7c1009f298a1bd8fea583da14535e039880.tar.gz
Merge pull request #156 from mayhewinator/WorkingBranch
Namespace and code cleanup for RDGE and related files
Diffstat (limited to 'js/lib')
-rwxr-xr-xjs/lib/drawing/world.js290
-rwxr-xr-xjs/lib/geom/brush-stroke.js12
-rwxr-xr-xjs/lib/geom/circle.js102
-rwxr-xr-xjs/lib/geom/geom-obj.js442
-rwxr-xr-xjs/lib/geom/line.js74
-rwxr-xr-xjs/lib/geom/rectangle.js118
-rw-r--r--js/lib/geom/shape-primitive.js4
-rwxr-xr-xjs/lib/rdge/materials/bump-metal-material.js64
-rw-r--r--js/lib/rdge/materials/cloud-material.js377
-rw-r--r--js/lib/rdge/materials/deform-material.js88
-rwxr-xr-xjs/lib/rdge/materials/flat-material.js141
-rw-r--r--js/lib/rdge/materials/fly-material.js9
-rw-r--r--js/lib/rdge/materials/julia-material.js8
-rw-r--r--js/lib/rdge/materials/keleidoscope-material.js8
-rwxr-xr-xjs/lib/rdge/materials/linear-gradient-material.js426
-rw-r--r--js/lib/rdge/materials/mandel-material.js8
-rwxr-xr-xjs/lib/rdge/materials/material-parser.js81
-rwxr-xr-xjs/lib/rdge/materials/material.js15
-rw-r--r--js/lib/rdge/materials/plasma-material.js12
-rw-r--r--js/lib/rdge/materials/pulse-material.js68
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js414
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js438
-rw-r--r--js/lib/rdge/materials/relief-tunnel-material.js132
-rw-r--r--js/lib/rdge/materials/square-tunnel-material.js133
-rw-r--r--js/lib/rdge/materials/star-material.js133
-rw-r--r--js/lib/rdge/materials/taper-material.js401
-rw-r--r--js/lib/rdge/materials/tunnel-material.js79
-rw-r--r--js/lib/rdge/materials/twist-material.js161
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js448
-rwxr-xr-xjs/lib/rdge/materials/uber-material.js1560
-rw-r--r--js/lib/rdge/materials/water-material.js275
-rw-r--r--js/lib/rdge/materials/z-invert-material.js132
32 files changed, 2681 insertions, 3972 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index e348f5e8..657c849f 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -144,45 +144,45 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
144 144
145 // post-load processing of the scene 145 // post-load processing of the scene
146 this.init = function() { 146 this.init = function() {
147 var ctx1 = g_Engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle), 147 var ctx1 = RDGE.globals.engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle),
148 ctx2 = g_Engine.getContext(); 148 ctx2 = RDGE.globals.engine.getContext();
149 if (ctx1 != ctx2) console.log( "***** different contexts *****" ); 149 if (ctx1 != ctx2) console.log( "***** different contexts *****" );
150 this.renderer = ctx1.renderer; 150 this.renderer = ctx1.renderer;
151 this.renderer._world = this; 151 this.renderer._world = this;
152 152
153 // create a camera, set its perspective, and then point it at the origin 153 // create a camera, set its perspective, and then point it at the origin
154 var cam = new camera(); 154 var cam = new RDGE.camera();
155 this._camera = cam; 155 this._camera = cam;
156 cam.setPerspective(this.getFOV(), this.getAspect(), this.getZNear(), this.getZFar()); 156 cam.setPerspective(this.getFOV(), this.getAspect(), this.getZNear(), this.getZFar());
157 cam.setLookAt([0, 0, this.getViewDistance()], [0, 0, 0], vec3.up()); 157 cam.setLookAt([0, 0, this.getViewDistance()], [0, 0, 0], RDGE.vec3.up());
158 158
159 // make this camera the active camera 159 // make this camera the active camera
160 this.renderer.cameraManager().setActiveCamera(cam); 160 this.renderer.cameraManager().setActiveCamera(cam);
161 161
162 // change clear color 162 // change clear color
163 //this.renderer.setClearFlags(g_Engine.getContext().DEPTH_BUFFER_BIT); 163 //this.renderer.setClearFlags(RDGE.globals.engine.getContext().DEPTH_BUFFER_BIT);
164 this.renderer.setClearColor([0.0, 0.0, 0.0, 0.0]); 164 this.renderer.setClearColor([0.0, 0.0, 0.0, 0.0]);
165 //this.renderer.NinjaWorld = this; 165 //this.renderer.NinjaWorld = this;
166 166
167 // create an empty scene graph 167 // create an empty scene graph
168 this.myScene = new SceneGraph(); 168 this.myScene = new RDGE.SceneGraph();
169 169
170 // create some lights 170 // create some lights
171 // light 1 171 // light 1
172 this.light = createLightNode("myLight"); 172 this.light = RDGE.createLightNode("myLight");
173 this.light.setPosition([0,0,1.2]); 173 this.light.setPosition([0,0,1.2]);
174 this.light.setDiffuseColor([0.75,0.9,1.0,1.0]); 174 this.light.setDiffuseColor([0.75,0.9,1.0,1.0]);
175 175
176 // light 2 176 // light 2
177 this.light2 = createLightNode("myLight2"); 177 this.light2 = RDGE.createLightNode("myLight2");
178 this.light2.setPosition([-0.5,0,1.2]); 178 this.light2.setPosition([-0.5,0,1.2]);
179 this.light2.setDiffuseColor([1.0,0.9,0.75,1.0]); 179 this.light2.setDiffuseColor([1.0,0.9,0.75,1.0]);
180 180
181 // create a light transform 181 // create a light transform
182 var lightTr = createTransformNode("lightTr"); 182 var lightTr = RDGE.createTransformNode("lightTr");
183 183
184 // create and attach a material - materials hold the light data 184 // create and attach a material - materials hold the light data
185 lightTr.attachMaterial(createMaterialNode("lights")); 185 lightTr.attachMaterial(RDGE.createMaterialNode("lights"));
186 186
187 // enable light channels 1, 2 - channel 0 is used by the default shader 187 // enable light channels 1, 2 - channel 0 is used by the default shader
188 lightTr.materialNode.enableLightChannel(1, this.light); 188 lightTr.materialNode.enableLightChannel(1, this.light);
@@ -195,9 +195,9 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
195 this.myScene.addNode(lightTr); 195 this.myScene.addNode(lightTr);
196 196
197 // Add the scene to the engine - necessary if you want the engine to draw for you 197 // Add the scene to the engine - necessary if you want the engine to draw for you
198 //g_Engine.AddScene("myScene" + this._canvas.id, this.myScene); 198 //RDGE.globals.engine.AddScene("myScene" + this._canvas.id, this.myScene);
199 var name = this._canvas.getAttribute( "data-RDGE-id" ); 199 var name = this._canvas.getAttribute( "data-RDGE-id" );
200 g_Engine.AddScene("myScene" + name, this.myScene); 200 RDGE.globals.engine.AddScene("myScene" + name, this.myScene);
201 }; 201 };
202 202
203 // main code for handling user interaction and updating the scene 203 // main code for handling user interaction and updating the scene
@@ -209,7 +209,7 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
209 209
210 if (this._useWebGL) { 210 if (this._useWebGL) {
211 // changed the global position uniform of light 0, another way to change behavior of a light 211 // changed the global position uniform of light 0, another way to change behavior of a light
212 rdgeGlobalParameters.u_light0Pos.set( [5*Math.cos(this.elapsed), 5*Math.sin(this.elapsed), 20]); 212 RDGE.rdgeGlobalParameters.u_light0Pos.set([5 * Math.cos(this.elapsed), 5 * Math.sin(this.elapsed), 20]);
213 213
214 // orbit the light nodes around the boxes 214 // orbit the light nodes around the boxes
215 this.light.setPosition([1.2*Math.cos(this.elapsed*2.0), 1.2*Math.sin(this.elapsed*2.0), 1.2*Math.cos(this.elapsed*2.0)]); 215 this.light.setPosition([1.2*Math.cos(this.elapsed*2.0), 1.2*Math.sin(this.elapsed*2.0), 1.2*Math.cos(this.elapsed*2.0)]);
@@ -226,8 +226,8 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
226 // defining the draw function to control how the scene is rendered 226 // defining the draw function to control how the scene is rendered
227 this.draw = function() { 227 this.draw = function() {
228 if (this._useWebGL) { 228 if (this._useWebGL) {
229 g_Engine.setContext( this._canvas.rdgeid ); 229 RDGE.globals.engine.setContext( this._canvas.rdgeid );
230 var ctx = g_Engine.getContext(); 230 var ctx = RDGE.globals.engine.getContext();
231 var renderer = ctx.renderer; 231 var renderer = ctx.renderer;
232 if (renderer.unloadedTextureCount <= 0) { 232 if (renderer.unloadedTextureCount <= 0) {
233 renderer.disableCulling(); 233 renderer.disableCulling();
@@ -365,9 +365,9 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
365 if (this._useWebGL) { 365 if (this._useWebGL) {
366 rdgeStarted = true; 366 rdgeStarted = true;
367 this._canvas.rdgeid = this._canvas.getAttribute( "data-RDGE-id" ); 367 this._canvas.rdgeid = this._canvas.getAttribute( "data-RDGE-id" );
368 g_Engine.unregisterCanvas( this._canvas ) 368 RDGE.globals.engine.unregisterCanvas( this._canvas );
369 g_Engine.registerCanvas(this._canvas, this); 369 RDGE.globals.engine.registerCanvas(this._canvas, this);
370 RDGEStart( this._canvas ); 370 RDGE.RDGEStart( this._canvas );
371 this._canvas.task.stop() 371 this._canvas.task.stop()
372 } 372 }
373}; 373};
@@ -396,13 +396,13 @@ World.prototype.updateObject = function (obj) {
396 if (nPrims > 0) { 396 if (nPrims > 0) {
397 ctrTrNode = obj.getTransformNode(); 397 ctrTrNode = obj.getTransformNode();
398 if (ctrTrNode == null) { 398 if (ctrTrNode == null) {
399 ctrTrNode = createTransformNode("objRootNode_" + this._nodeCounter++); 399 ctrTrNode = RDGE.createTransformNode("objRootNode_" + this._nodeCounter++);
400 this._rootNode.insertAsChild( ctrTrNode ); 400 this._rootNode.insertAsChild( ctrTrNode );
401 obj.setTransformNode( ctrTrNode ); 401 obj.setTransformNode( ctrTrNode );
402 } 402 }
403 403
404 ctrTrNode.meshes.forEach(function(thisMesh) { 404 ctrTrNode.meshes.forEach(function(thisMesh) {
405 g_meshMan.deleteMesh(thisMesh.mesh.name); 405 RDGE.globals.meshMan.deleteMesh(thisMesh.mesh.name);
406 }); 406 });
407 ctrTrNode.meshes = []; 407 ctrTrNode.meshes = [];
408 408
@@ -421,11 +421,11 @@ World.prototype.updateObject = function (obj) {
421 childTrNode = children[i-1].transformNode; 421 childTrNode = children[i-1].transformNode;
422 422
423 childTrNode.meshes.forEach(function(thisMesh) { 423 childTrNode.meshes.forEach(function(thisMesh) {
424 g_meshMan.deleteMesh(thisMesh.mesh.name); 424 RDGE.globals.meshMan.deleteMesh(thisMesh.mesh.name);
425 }); 425 });
426 childTrNode.meshes = []; 426 childTrNode.meshes = [];
427 } else { 427 } else {
428 childTrNode = createTransformNode("objNode_" + this._nodeCounter++); 428 childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++);
429 ctrTrNode.insertAsChild(childTrNode); 429 ctrTrNode.insertAsChild(childTrNode);
430 } 430 }
431 431
@@ -466,7 +466,7 @@ World.prototype.addObject = function( obj ) {
466 catch(e) { 466 catch(e) {
467 alert( "Exception in GLWorld.addObject " + e ); 467 alert( "E