From e065244ac75d1d0f25fd5c75cb58e714a13fe16b Mon Sep 17 00:00:00 2001 From: Jonathan Duran Date: Wed, 14 Mar 2012 08:59:17 -0700 Subject: Squashed commit of the following: merge master into timeline Signed-off-by: Jonathan Duran --- assets/canvas-runtime.js | 1376 ++++++++++++++++ assets/descriptor.json | 41 +- assets/rdge-compiled.js | 90 +- assets/shaders/plasma.frag.glsl | 4 +- images/cursors/penAdd.png | Bin 0 -> 3043 bytes images/picker/FileType-DirectoryOpen.png | Bin 0 -> 1827 bytes images/picker/css_file.png | Bin 3184 -> 2300 bytes images/picker/doc_file.png | Bin 11398 -> 2315 bytes images/picker/file.png | Bin 27869 -> 1551 bytes images/picker/folder.png | Bin 276680 -> 1622 bytes images/picker/html_file.png | Bin 3677 -> 2293 bytes images/picker/js_file.png | Bin 3080 -> 2088 bytes images/picker/json_file.png | Bin 0 -> 2299 bytes images/picker/php_file.png | Bin 5182 -> 2280 bytes images/picker/pl_file.png | Bin 0 -> 2094 bytes images/picker/py_file.png | Bin 0 -> 2067 bytes images/picker/rb_file.png | Bin 0 -> 2301 bytes images/picker/txt_file.png | Bin 13898 -> 2198 bytes .../gradientpicker.reel/gradientpicker.js | 22 +- .../brush-properties.reel/brush-properties.html | 56 +- .../brush-properties.reel/brush-properties.js | 26 +- .../treeview/ninja-leaf.reel/ninja-leaf.css | 14 +- js/components/ui/icon-list-basic/icon.reel/icon.js | 14 +- .../ui/tree-basic/treeItem.reel/treeItem.js | 14 +- js/controllers/document-controller.js | 50 +- js/controllers/elements/element-controller.js | 32 +- js/controllers/elements/shapes-controller.js | 140 +- js/controllers/selection-controller.js | 19 +- js/controllers/styles-controller.js | 10 +- js/data/menu-data.js | 6 + js/document/html-document.js | 149 +- js/helper-classes/3D/draw-utils.js | 140 +- js/helper-classes/3D/math-utils.js | 5 +- js/helper-classes/3D/snap-manager.js | 12 +- js/helper-classes/RDGE/rdge-compiled.js | 64 +- .../RDGE/runtime/CanvasDataManager.js | 98 -- js/helper-classes/RDGE/runtime/GLRuntime.js | 159 -- js/helper-classes/RDGE/src/core/script/engine.js | 15 + js/helper-classes/RDGE/src/core/script/fx/ssao.js | 2 +- .../RDGE/src/core/script/init_state.js | 12 +- js/helper-classes/RDGE/src/core/script/jshader.js | 8 +- js/helper-classes/RDGE/src/core/script/renderer.js | 1 + .../RDGE/src/core/script/scenegraphNodes.js | 2 +- .../RDGE/src/core/script/utilities.js | 4 +- js/helper-classes/RDGE/src/tools/rdge-compiled.js | 64 +- js/helper-classes/backup-delete/GLBrushStroke.js | 174 +- js/helper-classes/backup-delete/GLCircle.js | 3 +- js/helper-classes/backup-delete/GLGeomObj.js | 46 + js/helper-classes/backup-delete/GLRectangle.js | 2 + js/helper-classes/backup-delete/GLSubpath.js | 147 +- js/helper-classes/backup-delete/GLWorld.js | 71 +- .../backup-delete/Materials/BumpMetalMaterial.js | 39 +- .../backup-delete/Materials/DeformMaterial.js | 2 +- .../backup-delete/Materials/FlatMaterial.js | 34 +- .../backup-delete/Materials/FlyMaterial.js | 2 +- .../backup-delete/Materials/JuliaMaterial.js | 2 +- .../Materials/KeleidoscopeMaterial.js | 2 +- .../Materials/LinearGradientMaterial.js | 2 +- .../backup-delete/Materials/MandelMaterial.js | 2 +- .../backup-delete/Materials/PlasmaMaterial.js | 2 +- .../backup-delete/Materials/PulseMaterial.js | 5 +- .../backup-delete/Materials/RadialBlurMaterial.js | 2 +- .../Materials/RadialGradientMaterial.js | 6 +- .../Materials/ReliefTunnelMaterial.js | 2 +- .../Materials/SquareTunnelMaterial.js | 2 +- .../backup-delete/Materials/StarMaterial.js | 2 +- .../backup-delete/Materials/TaperMaterial.js | 4 +- .../backup-delete/Materials/TunnelMaterial.js | 2 +- .../backup-delete/Materials/TwistMaterial.js | 2 +- .../backup-delete/Materials/TwistVertMaterial.js | 2 +- .../backup-delete/Materials/UberMaterial.js | 73 +- .../backup-delete/Materials/WaterMaterial.js | 4 +- .../backup-delete/Materials/ZInvertMaterial.js | 2 +- js/io/system/ninjalibrary.js | 10 +- js/io/system/ninjalibrary.json | 2 +- js/io/ui/file-picker/file-picker-controller.js | 2 +- js/io/ui/file-picker/file-picker-model.js | 6 + .../picker-navigator.reel/picker-navigator.js | 7 +- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 4 +- js/lib/NJUtils.js | 34 +- js/lib/drawing/world.js | 102 +- js/lib/geom/brush-stroke.js | 329 ++-- js/lib/geom/circle.js | 103 +- js/lib/geom/geom-obj.js | 210 ++- js/lib/geom/line.js | 57 +- js/lib/geom/rectangle.js | 111 +- js/lib/geom/sub-path.js | 86 +- js/lib/rdge/materials/bump-metal-material.js | 10 +- js/lib/rdge/materials/deform-material.js | 2 +- js/lib/rdge/materials/flat-material.js | 41 +- js/lib/rdge/materials/fly-material.js | 2 +- js/lib/rdge/materials/julia-material.js | 2 +- js/lib/rdge/materials/keleidoscope-material.js | 2 +- js/lib/rdge/materials/linear-gradient-material.js | 2 +- js/lib/rdge/materials/mandel-material.js | 2 +- js/lib/rdge/materials/plasma-material.js | 37 +- js/lib/rdge/materials/pulse-material.js | 11 +- js/lib/rdge/materials/radial-blur-material.js | 9 +- js/lib/rdge/materials/radial-gradient-material.js | 7 +- js/lib/rdge/materials/relief-tunnel-material.js | 2 +- js/lib/rdge/materials/square-tunnel-material.js | 2 +- js/lib/rdge/materials/star-material.js | 2 +- js/lib/rdge/materials/taper-material.js | 8 +- js/lib/rdge/materials/tunnel-material.js | 2 +- js/lib/rdge/materials/twist-material.js | 2 +- js/lib/rdge/materials/twist-vert-material.js | 6 +- js/lib/rdge/materials/uber-material.js | 109 +- js/lib/rdge/materials/water-material.js | 2 +- js/lib/rdge/materials/z-invert-material.js | 2 +- js/mediators/element-mediator.js | 15 +- js/mediators/io-mediator.js | 93 +- js/models/color-model.js | 3 + js/panels/Color/colorbutton-manager.js | 44 - .../ColorPanelPopup.scssc | Bin 15335 -> 0 bytes .../ColorPanelPopup.scssc | Bin 17879 -> 0 bytes .../ColorPanelBase.scssc | Bin 23592 -> 0 bytes .../Color/colorchippopup.reel/colorchippopup.html | 63 - .../Color/colorchippopup.reel/colorchippopup.js | 590 ------- js/panels/Color/colorchippopup.reel/config.rb | 9 - .../colorchippopup.reel/css/colorchippopup.css | 239 --- .../colorchippopup.reel/css/colorchippopup.scss | 240 --- .../Color/colorchippopup.reel/img/icon_bitmap.png | Bin 3072 -> 0 bytes .../colorchippopup.reel/img/icon_colorwheel.png | Bin 3420 -> 0 bytes .../colorchippopup.reel/img/icon_gradient.png | Bin 2815 -> 0 bytes .../Color/colorchippopup.reel/img/icon_nofill.png | Bin 2951 -> 0 bytes js/panels/Color/colorchippopup.reel/img/knob.png | Bin 1036 -> 0 bytes js/panels/Color/colorpanel.js | 53 - .../Color/colorpanelbase.reel/colorpanelbase.html | 76 - .../Color/colorpanelbase.reel/colorpanelbase.js | 1654 -------------------- js/panels/Color/colorpanelbase.reel/config.rb | 9 - .../colorpanelbase.reel/css/colorpanelbase.css | 332 ---- .../colorpanelbase.reel/css/colorpanelbase.scss | 339 ---- .../Color/colorpanelbase.reel/img/icon_default.png | Bin 3011 -> 0 bytes .../Color/colorpanelbase.reel/img/icon_nocolor.png | Bin 3036 -> 0 bytes .../Color/colorpanelbase.reel/img/icon_swap.png | Bin 2961 -> 0 bytes js/panels/Color/colorpanelbase.reel/img/knob.png | Bin 1036 -> 0 bytes .../colorpanelpopup.reel/colorpanelpopup.html | 68 - .../Color/colorpanelpopup.reel/colorpanelpopup.js | 466 ------ js/panels/Color/colorpanelpopup.reel/config.rb | 9 - .../colorpanelpopup.reel/css/colorpanelpopup.css | 239 --- .../colorpanelpopup.reel/css/colorpanelpopup.scss | 240 --- .../Color/colorpanelpopup.reel/img/icon_bitmap.png | Bin 3072 -> 0 bytes .../colorpanelpopup.reel/img/icon_colorwheel.png | Bin 3420 -> 0 bytes .../colorpanelpopup.reel/img/icon_gradient.png | Bin 2815 -> 0 bytes .../Color/colorpanelpopup.reel/img/icon_nofill.png | Bin 2951 -> 0 bytes js/panels/Color/colorpanelpopup.reel/img/knob.png | Bin 1036 -> 0 bytes js/panels/Color/colorpopup-manager.js | 529 ------- .../Color/colortoolbar.reel/colortoolbar.html | 54 - js/panels/Color/colortoolbar.reel/colortoolbar.js | 138 -- js/panels/Color/colortoolbar.reel/config.rb | 9 - .../Color/colortoolbar.reel/css/colortoolbar.css | 45 - .../Color/colortoolbar.reel/css/colortoolbar.scss | 52 - js/panels/color/colorbutton-manager.js | 44 + .../color/colorchippopup.reel/colorchippopup.html | 63 + .../color/colorchippopup.reel/colorchippopup.js | 590 +++++++ js/panels/color/colorchippopup.reel/config.rb | 9 + .../colorchippopup.reel/css/colorchippopup.css | 239 +++ .../colorchippopup.reel/css/colorchippopup.scss | 240 +++ .../color/colorchippopup.reel/img/icon_bitmap.png | Bin 0 -> 3072 bytes .../colorchippopup.reel/img/icon_colorwheel.png | Bin 0 -> 3420 bytes .../colorchippopup.reel/img/icon_gradient.png | Bin 0 -> 2815 bytes .../color/colorchippopup.reel/img/icon_nofill.png | Bin 0 -> 2951 bytes js/panels/color/colorchippopup.reel/img/knob.png | Bin 0 -> 1036 bytes js/panels/color/colorpanel.js | 53 + .../color/colorpanelbase.reel/colorpanelbase.html | 76 + .../color/colorpanelbase.reel/colorpanelbase.js | 1654 ++++++++++++++++++++ js/panels/color/colorpanelbase.reel/config.rb | 9 + .../colorpanelbase.reel/css/colorpanelbase.css | 332 ++++ .../colorpanelbase.reel/css/colorpanelbase.scss | 339 ++++ .../color/colorpanelbase.reel/img/icon_default.png | Bin 0 -> 3011 bytes .../color/colorpanelbase.reel/img/icon_nocolor.png | Bin 0 -> 3036 bytes .../color/colorpanelbase.reel/img/icon_swap.png | Bin 0 -> 2961 bytes js/panels/color/colorpanelbase.reel/img/knob.png | Bin 0 -> 1036 bytes .../colorpanelpopup.reel/colorpanelpopup.html | 68 + .../color/colorpanelpopup.reel/colorpanelpopup.js | 466 ++++++ js/panels/color/colorpanelpopup.reel/config.rb | 9 + .../colorpanelpopup.reel/css/colorpanelpopup.css | 239 +++ .../colorpanelpopup.reel/css/colorpanelpopup.scss | 240 +++ .../color/colorpanelpopup.reel/img/icon_bitmap.png | Bin 0 -> 3072 bytes .../colorpanelpopup.reel/img/icon_colorwheel.png | Bin 0 -> 3420 bytes .../colorpanelpopup.reel/img/icon_gradient.png | Bin 0 -> 2815 bytes .../color/colorpanelpopup.reel/img/icon_nofill.png | Bin 0 -> 2951 bytes js/panels/color/colorpanelpopup.reel/img/knob.png | Bin 0 -> 1036 bytes js/panels/color/colorpopup-manager.js | 529 +++++++ .../color/colortoolbar.reel/colortoolbar.html | 54 + js/panels/color/colortoolbar.reel/colortoolbar.js | 138 ++ js/panels/color/colortoolbar.reel/config.rb | 9 + .../color/colortoolbar.reel/css/colortoolbar.css | 45 + .../color/colortoolbar.reel/css/colortoolbar.scss | 52 + js/panels/presets/content.reel/content.css | 4 +- js/panels/properties.reel/properties.js | 4 +- js/preloader/Preloader.js | 2 + js/stage/layout.js | 10 +- js/stage/stage-view.reel/stage-view.js | 5 +- js/tools/BrushTool.js | 41 +- js/tools/EyedropperTool.js | 133 +- js/tools/PenTool.js | 18 +- js/tools/SelectionTool.js | 28 +- js/tools/Translate3DToolBase.js | 1 - js/tools/TranslateObject3DTool.js | 2 +- js/tools/modifier-tool-base.js | 12 +- 201 files changed, 9370 insertions(+), 6609 deletions(-) create mode 100644 assets/canvas-runtime.js create mode 100644 images/cursors/penAdd.png create mode 100755 images/picker/FileType-DirectoryOpen.png create mode 100755 images/picker/json_file.png create mode 100755 images/picker/pl_file.png create mode 100755 images/picker/py_file.png create mode 100755 images/picker/rb_file.png delete mode 100644 js/helper-classes/RDGE/runtime/CanvasDataManager.js delete mode 100644 js/helper-classes/RDGE/runtime/GLRuntime.js delete mode 100755 js/panels/Color/colorbutton-manager.js delete mode 100755 js/panels/Color/colorchippopup.reel/.sass-cache/2fbca323ccf38cf180e7675ba0d8d3e07adeffea/ColorPanelPopup.scssc delete mode 100755 js/panels/Color/colorchippopup.reel/.sass-cache/6f8390f69a31f1a976968b9c18d0824d78460db2/ColorPanelPopup.scssc delete mode 100755 js/panels/Color/colorchippopup.reel/.sass-cache/de22270a8ac487505e8876f1cd16286e094a5127/ColorPanelBase.scssc delete mode 100755 js/panels/Color/colorchippopup.reel/colorchippopup.html delete mode 100755 js/panels/Color/colorchippopup.reel/colorchippopup.js delete mode 100755 js/panels/Color/colorchippopup.reel/config.rb delete mode 100755 js/panels/Color/colorchippopup.reel/css/colorchippopup.css delete mode 100755 js/panels/Color/colorchippopup.reel/css/colorchippopup.scss delete mode 100755 js/panels/Color/colorchippopup.reel/img/icon_bitmap.png delete mode 100755 js/panels/Color/colorchippopup.reel/img/icon_colorwheel.png delete mode 100755 js/panels/Color/colorchippopup.reel/img/icon_gradient.png delete mode 100755 js/panels/Color/colorchippopup.reel/img/icon_nofill.png delete mode 100755 js/panels/Color/colorchippopup.reel/img/knob.png delete mode 100755 js/panels/Color/colorpanel.js delete mode 100755 js/panels/Color/colorpanelbase.reel/colorpanelbase.html delete mode 100755 js/panels/Color/colorpanelbase.reel/colorpanelbase.js delete mode 100755 js/panels/Color/colorpanelbase.reel/config.rb delete mode 100755 js/panels/Color/colorpanelbase.reel/css/colorpanelbase.css delete mode 100755 js/panels/Color/colorpanelbase.reel/css/colorpanelbase.scss delete mode 100755 js/panels/Color/colorpanelbase.reel/img/icon_default.png delete mode 100755 js/panels/Color/colorpanelbase.reel/img/icon_nocolor.png delete mode 100755 js/panels/Color/colorpanelbase.reel/img/icon_swap.png delete mode 100755 js/panels/Color/colorpanelbase.reel/img/knob.png delete mode 100755 js/panels/Color/colorpanelpopup.reel/colorpanelpopup.html delete mode 100755 js/panels/Color/colorpanelpopup.reel/colorpanelpopup.js delete mode 100755 js/panels/Color/colorpanelpopup.reel/config.rb delete mode 100755 js/panels/Color/colorpanelpopup.reel/css/colorpanelpopup.css delete mode 100755 js/panels/Color/colorpanelpopup.reel/css/colorpanelpopup.scss delete mode 100755 js/panels/Color/colorpanelpopup.reel/img/icon_bitmap.png delete mode 100755 js/panels/Color/colorpanelpopup.reel/img/icon_colorwheel.png delete mode 100755 js/panels/Color/colorpanelpopup.reel/img/icon_gradient.png delete mode 100755 js/panels/Color/colorpanelpopup.reel/img/icon_nofill.png delete mode 100755 js/panels/Color/colorpanelpopup.reel/img/knob.png delete mode 100755 js/panels/Color/colorpopup-manager.js delete mode 100755 js/panels/Color/colortoolbar.reel/colortoolbar.html delete mode 100755 js/panels/Color/colortoolbar.reel/colortoolbar.js delete mode 100755 js/panels/Color/colortoolbar.reel/config.rb delete mode 100755 js/panels/Color/colortoolbar.reel/css/colortoolbar.css delete mode 100755 js/panels/Color/colortoolbar.reel/css/colortoolbar.scss create mode 100755 js/panels/color/colorbutton-manager.js create mode 100755 js/panels/color/colorchippopup.reel/colorchippopup.html create mode 100755 js/panels/color/colorchippopup.reel/colorchippopup.js create mode 100755 js/panels/color/colorchippopup.reel/config.rb create mode 100755 js/panels/color/colorchippopup.reel/css/colorchippopup.css create mode 100755 js/panels/color/colorchippopup.reel/css/colorchippopup.scss create mode 100755 js/panels/color/colorchippopup.reel/img/icon_bitmap.png create mode 100755 js/panels/color/colorchippopup.reel/img/icon_colorwheel.png create mode 100755 js/panels/color/colorchippopup.reel/img/icon_gradient.png create mode 100755 js/panels/color/colorchippopup.reel/img/icon_nofill.png create mode 100755 js/panels/color/colorchippopup.reel/img/knob.png create mode 100755 js/panels/color/colorpanel.js create mode 100755 js/panels/color/colorpanelbase.reel/colorpanelbase.html create mode 100755 js/panels/color/colorpanelbase.reel/colorpanelbase.js create mode 100755 js/panels/color/colorpanelbase.reel/config.rb create mode 100755 js/panels/color/colorpanelbase.reel/css/colorpanelbase.css create mode 100755 js/panels/color/colorpanelbase.reel/css/colorpanelbase.scss create mode 100755 js/panels/color/colorpanelbase.reel/img/icon_default.png create mode 100755 js/panels/color/colorpanelbase.reel/img/icon_nocolor.png create mode 100755 js/panels/color/colorpanelbase.reel/img/icon_swap.png create mode 100755 js/panels/color/colorpanelbase.reel/img/knob.png create mode 100755 js/panels/color/colorpanelpopup.reel/colorpanelpopup.html create mode 100755 js/panels/color/colorpanelpopup.reel/colorpanelpopup.js create mode 100755 js/panels/color/colorpanelpopup.reel/config.rb create mode 100755 js/panels/color/colorpanelpopup.reel/css/colorpanelpopup.css create mode 100755 js/panels/color/colorpanelpopup.reel/css/colorpanelpopup.scss create mode 100755 js/panels/color/colorpanelpopup.reel/img/icon_bitmap.png create mode 100755 js/panels/color/colorpanelpopup.reel/img/icon_colorwheel.png create mode 100755 js/panels/color/colorpanelpopup.reel/img/icon_gradient.png create mode 100755 js/panels/color/colorpanelpopup.reel/img/icon_nofill.png create mode 100755 js/panels/color/colorpanelpopup.reel/img/knob.png create mode 100755 js/panels/color/colorpopup-manager.js create mode 100755 js/panels/color/colortoolbar.reel/colortoolbar.html create mode 100755 js/panels/color/colortoolbar.reel/colortoolbar.js create mode 100755 js/panels/color/colortoolbar.reel/config.rb create mode 100755 js/panels/color/colortoolbar.reel/css/colortoolbar.css create mode 100755 js/panels/color/colortoolbar.reel/css/colortoolbar.scss diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js new file mode 100644 index 00000000..655e52fa --- /dev/null +++ b/assets/canvas-runtime.js @@ -0,0 +1,1376 @@ +/* +This file contains proprietary software owned by Motorola Mobility, Inc.
+No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + +/////////////////////////////////////////////////////////////////////// +//Loading webGL/canvas data +function initWebGl (rootElement, directory) { + var cvsDataMngr, ninjaWebGlData = JSON.parse((document.querySelectorAll(['script[data-ninja-webgl]'])[0].innerHTML.replace('(', '')).replace(')', '')); + if (ninjaWebGlData && ninjaWebGlData.data) { + for (var n=0; ninjaWebGlData.data[n]; n++) { + ninjaWebGlData.data[n] = unescape(ninjaWebGlData.data[n]); + } + } + //Creating data manager + cvsDataMngr = new CanvasDataManager(); + //Loading data to canvas(es) + cvsDataMngr.loadGLData(rootElement, ninjaWebGlData.data, directory); +} + +/////////////////////////////////////////////////////////////////////// +// Class ShapeRuntime +// Manages runtime shape display +/////////////////////////////////////////////////////////////////////// +function CanvasDataManager() +{ + this.loadGLData = function(root, valueArray, assetPath ) + { + this._assetPath = assetPath.slice(); + + var value = valueArray; + var nWorlds = value.length; + for (var i=0; i= 0) + { + var endIndex = importStr.indexOf( "\n", startIndex ); + if (endIndex > 0) + { + var id = importStr.substring( startIndex+4, endIndex ); + var canvas = this.findCanvasWithID( id, root ); + if (canvas) + { + var rt = new GLRuntime( canvas, importStr, assetPath ); + } + } + } + } + } + + this.collectGLData = function( elt, dataArray ) + { + if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) + { + var data = elt.elementModel.shapeModel.GLWorld.export( true ); + dataArray.push( data ); + } + + if (elt.children) + { + var nKids = elt.children.length; + for (var i=0; i= 0) + { + this._useWebGL = true; + + var rdgeStr = importStr.substr( index+11 ); + var endIndex = rdgeStr.indexOf( "endscene\n" ); + if (endIndex < 0) throw new Error( "ill-formed WebGL data" ); + var len = endIndex - index + 11; + rdgeStr = rdgeStr.substr( 0, endIndex ); + + this.myScene.importJSON( rdgeStr ); + this.importObjects( importStr ); + this.linkMaterials( this._geomRoot ); + this.initMaterials(); + } + else + { + this._context = this._canvas.getContext( "2d" ); + this.importObjects( importStr ); + this.render(); + } + } + + this.init = function() + { + var ctx1 = g_Engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle), + ctx2 = g_Engine.getContext(); + if (ctx1 != ctx2) console.log( "***** different contexts *****" ); + this.renderer = ctx1.renderer; + + // create a camera, set its perspective, and then point it at the origin + var cam = new camera(); + this._camera = cam; + cam.setPerspective(this.getFOV(), this.getAspect(), this.getZNear(), this.getZFar()); + cam.setLookAt([0, 0, this.getViewDistance()], [0, 0, 0], vec3.up()); + + // make this camera the active camera + this.renderer.cameraManager().setActiveCamera(cam); + + // change clear color + this.renderer.setClearColor([1.0, 1.0, 1.0, 0.0]); + + // create an empty scene graph + this.myScene = new SceneGraph(); + + // load the scene graph data + this.loadScene(); + + // Add the scene to the engine - necessary if you want the engine to draw for you + var name = "myScene" + this._canvas.getAttribute( "data-RDGE-id" ); + g_Engine.AddScene(name, this.myScene); + + this._initialized = true; + } + + // main code for handling user interaction and updating the scene + this.update = function(dt) + { + if (this._initialized) + { + if (!dt) dt = 0.2; + + dt = 0.01; // use our own internal throttle + this.elapsed += dt; + + // changed the global position uniform of light 0, another way to change behavior of a light + rdgeGlobalParameters.u_light0Pos.set( [5*Math.cos(this.elapsed), 5*Math.sin(this.elapsed), 20]); + + // orbit the light nodes around the boxes + //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)]); + //this.light2.setPosition([-1.2*Math.cos(this.elapsed*2.0), 1.2*Math.sin(this.elapsed*2.0), -1.2*Math.cos(this.elapsed)]); + + this.updateMaterials(); + + // now update all the nodes in the scene + this.myScene.update(dt); + } + } + + this.updateMaterials = function() + { + var nMats = this._materials.length; + for (var i=0; i= 0) + { + // update the string to the current object + importStr = importStr.substr( index+7 ); + + // read the next object + var obj = this.importObject( importStr, parent ); + + // determine if we have children + var endIndex = importStr.indexOf( "ENDOBJECT\n" ), + childIndex = importStr.indexOf( "OBJECT\n" ); + if (endIndex < 0) throw new Error( "ill-formed object data" ); + if ((childIndex >= 0) && (childIndex < endIndex)) + { + importStr = importStr.substr( childIndex + 7 ); + importStr = this.importObjects( importStr, obj ); + endIndex = importStr.indexOf( "ENDOBJECT\n" ) + } + + // remove the string for the object(s) just created + importStr = importStr.substr( endIndex ); + + // get the location of the next object + index = importStr.indexOf( "OBJECT\n", endIndex ); + } + + return importStr; + } + + this.importObject = function( objStr, parent ) + { + var type = Number( getPropertyFromString( "type: ", objStr ) ); + + var obj; + switch (type) + { + case 1: + obj = new RuntimeRectangle(); + obj.import( objStr, parent ); + break; + + case 2: // circle + obj = new RuntimeOval(); + obj.import( objStr, parent ); + break; + + case 3: // line + obj = new RuntimeLine(); + obj.import( objStr, parent ); + break; + + default: + throw new Error( "Attempting to load unrecognized object type: " + type ); + break; + } + + if (obj) + this.addObject( obj ); + + return obj; + } + + this.addObject = function( obj, parent ) + { + if (!obj) return; + obj.setWorld( this ); + + if (parent == null) + this._geomRoot = obj; + else + parent.addChild( obj ); + } + + this.linkMaterials = function( obj ) + { + if (!obj) return; + + // get the array of materials from the object + var matArray = obj._materials; + var nMats = matArray.length; + for (var i=0; i= 0) + { + rtnPath = url.substr( index + searchStr.length ); + rtnPath = this._assetPath + rtnPath; + } + return rtnPath; + } + + this.findMaterialNode = function( nodeName, node ) + { + if (node.transformNode) + node = node.transformNode; + + if (node.materialNode) + { + if (nodeName === node.materialNode.name) return node.materialNode; + } + + if (node.children) + { + var nKids = node.children.length; + for (var i=0; i= 0); + if (this._useWebGL) + { + var id = canvas.getAttribute( "data-RDGE-id" ); + canvas.rdgeid = id; + g_Engine.registerCanvas(canvas, this); + RDGEStart( canvas ); + } + else + { + this.loadScene(); + } +} + +/////////////////////////////////////////////////////////////////////// +// Class RuntimeGeomObj +// Super class for all geometry classes +/////////////////////////////////////////////////////////////////////// +function RuntimeGeomObj() +{ + /////////////////////////////////////////////////////////////////////// + // Constants + /////////////////////////////////////////////////////////////////////// + this.GEOM_TYPE_RECTANGLE = 1; + this.GEOM_TYPE_CIRCLE = 2; + this.GEOM_TYPE_LINE = 3; + this.GEOM_TYPE_PATH = 4; + this.GEOM_TYPE_CUBIC_BEZIER = 5; + this.GEOM_TYPE_UNDEFINED = -1; + + /////////////////////////////////////////////////////////////////////// + // Instance variables + /////////////////////////////////////////////////////////////////////// + this._children; + + // stroke and fill colors + this._strokeColor = [0,0,0,0]; + this._fillColor = [0,0,0,0]; + + // array of materials + this._materials = []; + + /////////////////////////////////////////////////////////////////////// + // Property accessors + /////////////////////////////////////////////////////////////////////// + + this.geomType = function() { return this.GEOM_TYPE_UNDEFINED; } + + this.setWorld = function(w) { this._world = w; } + this.getWorld = function() { return this._world; } + + /////////////////////////////////////////////////////////////////////// + // Methods + /////////////////////////////////////////////////////////////////////// + this.makeStrokeMaterial = function() + { + } + + this.makeFillMaterial = function() + { + } + + + this.render = function() + { + } + + this.addChild = function( child ) + { + if (!this._children) this._children = []; + this._children.push( child ); + } + + this.import = function() + { + } + + this.importMaterials = function(importStr) + { + var nMaterials = Number( getPropertyFromString( "nMaterials: ", importStr ) ); + for (var i=0; i= 0.001) + { + var scale = len/sum; + rtnVec = []; + for (var i=0; i= 0) + rtnStr = rtnStr.substr(0, index); + + return rtnStr; +} + +/////////////////////////////////////////////////////////////////////// +// Class RuntimeRectangle +/////////////////////////////////////////////////////////////////////// +function RuntimeRectangle() +{ + // inherit the members of RuntimeGeomObj + this.inheritedFrom = RuntimeGeomObj; + this.inheritedFrom(); + + this.import = function( importStr ) + { + this._xOffset = Number( getPropertyFromString( "xoff: ", importStr ) ); + this._yOffset = Number( getPropertyFromString( "yoff: ", importStr ) ); + this._width = Number( getPropertyFromString( "width: ", importStr ) ); + this._height = Number( getPropertyFromString( "height: ", importStr ) ); + this._strokeWidth = Number( getPropertyFromString( "strokeWidth: ", importStr ) ); + this._innerRadius = Number( getPropertyFromString( "innerRadius: ", importStr ) ); + this._strokeStyle = Number( getPropertyFromString( "strokeStyle: ", importStr ) ); + var strokeMaterialName = getPropertyFromString( "strokeMat: ", importStr ); + var fillMaterialName = getPropertyFromString( "fillMat: ", importStr ); + this._strokeStyle = getPropertyFromString( "strokeStyle: ", importStr ); + this._fillColor = eval( "[" + getPropertyFromString( "fillColor: ", importStr ) + "]" ); + this._strokeColor = eval( "[" + getPropertyFromString( "strokeColor: ", importStr ) + "]" ); + this._tlRadius = Number( getPropertyFromString( "tlRadius: ", importStr ) ); + this._trRadius = Number( getPropertyFromString( "trRadius: ", importStr ) ); + this._blRadius = Number( getPropertyFromString( "blRadius: ", importStr ) ); + this._brRadius = Number( getPropertyFromString( "brRadius: ", importStr ) ); + + this.importMaterials( importStr ); + } + + this.renderPath = function( inset, ctx ) + { + // various declarations + var pt, rad, ctr, startPt, bPts; + var width = Math.round(this._width), + height = Math.round(this._height); + + pt = [inset, inset]; // top left corner + + var tlRad = this._tlRadius; //top-left radius + var trRad = this._trRadius; + var blRad = this._blRadius; + var brRad = this._brRadius; + + if ((tlRad <= 0) && (blRad <= 0) && (brRad <= 0) && (trRad <= 0)) + { + ctx.rect(pt[0], pt[1], width - 2*inset, height - 2*inset); + } + else + { + // get the top left point + rad = tlRad - inset; + if (rad < 0) rad = 0; + pt[1] += rad; + if (Math.abs(rad) < 0.001) pt[1] = inset; + ctx.moveTo( pt[0], pt[1] ); + + // get the bottom left point + pt = [inset, height - inset]; + rad = blRad - inset; + if (rad < 0) rad = 0; + pt[1] -= rad; + ctx.lineTo( pt[0], pt[1] ); + + // get the bottom left curve + if (rad > 0.001) + ctx.quadraticCurveTo( inset, height-inset, inset+rad, height-inset ); + + // do the bottom of the rectangle + pt = [width - inset, height - inset]; + rad = brRad - inset; + if (rad < 0) rad = 0; + pt[0] -= rad; + ctx.lineTo( pt[0], pt[1] ); + + // get the bottom right arc + if (rad > 0.001) + ctx.quadraticCurveTo( width-inset, height-inset, width-inset, height-inset-rad ); + + // get the right of the rectangle + pt = [width - inset, inset]; + rad = trRad - inset; + if (rad < 0) rad = 0; + pt[1] += rad; + ctx.lineTo( pt[0], pt[1] ); + + // do the top right corner + if (rad > 0.001) + ctx.quadraticCurveTo( width-inset, inset, width-inset-rad, inset ); + + // do the top of the rectangle + pt = [inset, inset] + rad = tlRad - inset; + if (rad < 0) rad = 0; + pt[0] += rad; + ctx.lineTo( pt[0], pt[1] ); + + // do the top left corner + if (rad > 0.001) + ctx.quadraticCurveTo( inset, inset, inset, inset+rad ); + else + ctx.lineTo( inset, 2*inset ); + } + } + + this.render = function() + { + // get the world + var world = this.getWorld(); + if (!world) throw( "null world in rectangle render" ); + + // get the context + var ctx = world.get2DContext(); + if (!ctx) return; + + // get some dimensions + var lw = this._strokeWidth; + var w = world.getViewportWidth(), + h = world.getViewportHeight(); + + // render the fill + ctx.beginPath(); + if (this._fillColor) + { + var c = "rgba(" + 255*this._fillColor[0] + "," + 255*this._fillColor[1] + "," + 255*this._fillColor[2] + "," + this._fillColor[3] + ")"; + ctx.fillStyle = c; + + ctx.lineWidth = lw; + var inset = Math.ceil( lw ) + 0.5; + this.renderPath( inset, ctx ); + ctx.fill(); + ctx.closePath(); + } + + // render the stroke + ctx.beginPath(); + if (this._strokeColor) + { + var c = "rgba(" + 255*this._strokeColor[0] + "," + 255*this._strokeColor[1] + "," + 255*this._strokeColor[2] + "," + this._strokeColor[3] + ")"; + ctx.strokeStyle = c; + + ctx.lineWidth = lw; + var inset = Math.ceil( 0.5*lw ) + 0.5; + this.renderPath( inset, ctx ); + ctx.stroke(); + ctx.closePath(); + } + } +} + +/////////////////////////////////////////////////////////////////////// +// Class RuntimeOval +/////////////////////////////////////////////////////////////////////// +function RuntimeOval() +{ + // inherit the members of RuntimeGeomObj + this.inheritedFrom = RuntimeGeomObj; + this.inheritedFrom(); + + this.import = function( importStr ) + { + this._xOffset = Number( getPropertyFromString( "xoff: ", importStr ) ); + this._yOffset = Number( getPropertyFromString( "yoff: ", importStr ) ); + this._width = Number( getPropertyFromString( "width: ", importStr ) ); + this._height = Number( getPropertyFromString( "height: ", importStr ) ); + this._strokeWidth = Number( getPropertyFromString( "strokeWidth: ", importStr ) ); + this._innerRadius = Number( getPropertyFromString( "innerRadius: ", importStr ) ); + this._strokeStyle = getPropertyFromString( "strokeStyle: ", importStr ); + var strokeMaterialName = getPropertyFromString( "strokeMat: ", importStr ); + var fillMaterialName = getPropertyFromString( "fillMat: ", importStr ); + this._fillColor = eval( "[" + getPropertyFromString( "fillColor: ", importStr ) + "]" ); + this._strokeColor = eval( "[" + getPropertyFromString( "strokeColor: ", importStr ) + "]" ); + + this.importMaterials( importStr ); + } + + this.render = function() + { + // get the world + var world = this.getWorld(); + if (!world) throw( "null world in buildBuffers" ); + + // get the context + var ctx = world.get2DContext(); + if (!ctx) return; + + // declare some variables + var p0, p1; + var x0, y1, x1, y1; + + // create the matrix + var lineWidth = this._strokeWidth; + var innerRad = this._innerRadius; + var xScale = 0.5*this._width - lineWidth, + yScale = 0.5*this._height - lineWidth; + + // translate + var xCtr = 0.5*world.getViewportWidth() + this._xOffset, + yCtr = 0.5*world.getViewportHeight() + this._yOffset; + var mat = [ + [ xScale, 0.0, 0.0, xCtr], + [ 0.0, yScale, 0.0, yCtr], + [ 0.0, 0.0, 1.0, 0.0], + [ 0.0, 0.0, 0.0, 1.0] + ]; + + // get a bezier representation of the circle + var bezPts = this.circularArcToBezier( [0,0,0], [1,0,0], 2.0*Math.PI ); + if (bezPts) + { + var n = bezPts.length; + + // set up the fill style + ctx.beginPath(); + ctx.lineWidth = 0; + if (this._fillColor) + { + var c = "rgba(" + 255*this._fillColor[0] + "," + 255*this._fillColor[1] + "," + 255*this._fillColor[2] + "," + this._fillColor[3] + ")"; + ctx.fillStyle = c; + + // draw the fill + ctx.beginPath(); + var p = this.transformPoint( bezPts[0], mat ); + ctx.moveTo( p[0], p[1] ); + var index = 1; + while (index < n) + { + p0 = this.transformPoint( bezPts[index], mat ); + p1 = this.transformPoint( bezPts[index+1], mat ); + + x0 = p0[0]; y0 = p0[1]; + x1 = p1[0]; y1 = p1[1]; + ctx.quadraticCurveTo( x0, y0, x1, y1 ); + index += 2; + } + + if ( innerRad > 0.001) + { + xScale = 0.5*innerRad*this._width; + yScale = 0.5*innerRad*this._height; + mat[0] = xScale; + mat[5] = yScale; + + // get the bezier points + var bezPts = this.circularArcToBezier( Vector.create([0,0,0]), Vector.create([1,0,0]), -2.0*Math.PI ); + if (bezPts) + { + var n = bezPts.length; + p = this.transformPoint( bezPts[0], mat ); + ctx.moveTo( p[0], p[1] ); + index = 1; + while (index < n) + { + p0 = this.transformPoint( bezPts[index], mat ); + p1 = this.transformPoint( bezPts[index+1], mat ); + + var x0 = p0[0], y0 = p0[1], + x1 = p1[0], y1 = p1[1]; + ctx.quadraticCurveTo( x0, y0, x1, y1 ); + index += 2; + } + } + } + + // fill the path + ctx.fill(); + } + + // calculate the stroke matrix + xScale = 0.5*this._width - 0.5*lineWidth; + yScale = 0.5*this._height - 0.5*lineWidth; + mat[0] = xScale; + mat[5] = yScale; + + // set up the stroke style + ctx.beginPath(); + ctx.lineWidth = lineWidth; + if (this._strokeColor) + { + var c = "rgba(" + 255*this._strokeColor[0] + "," + 255*this._strokeColor[1] + "," + 255*this._strokeColor[2] + "," + this._strokeColor[3] + ")"; + ctx.strokeStyle = c; + + // draw the stroke + p = this.transformPoint( bezPts[0], mat ); + ctx.moveTo( p[0], p[1] ); + index = 1; + while (index < n) + { + var p0 = this.transformPoint( bezPts[index], mat ); + var p1 = this.transformPoint( bezPts[index+1], mat ); + + var x0 = p0[0], y0 = p0[1], + x1 = p1[0], y1 = p1[1]; + ctx.quadraticCurveTo( x0, y0, x1, y1 ); + index += 2; + } + + if (innerRad > 0.01) + { + // calculate the stroke matrix + xScale = 0.5*innerRad*this._width - 0.5*lineWidth; + yScale = 0.5*innerRad*this._height - 0.5*lineWidth; + mat[0] = xScale; + mat[5] = yScale; + + // draw the stroke + p = this.transformPoint( bezPts[0], mat ); + ctx.moveTo( p[0], p[1] ); + index = 1; + while (index < n) + { + var p0 = this.transformPoint( bezPts[index], mat ); + var p1 = this.transformPoint( bezPts[index+1], mat ); + + var x0 = p0[0], y0 = p0[1], + x1 = p1[0], y1 = p1[1]; + ctx.quadraticCurveTo( x0, y0, x1, y1 ); + index += 2; + } + } + + // render the stroke + ctx.stroke(); + } + } + } + + /////////////////////////////////////////////////////////////////////// + // this function returns the quadratic Bezier approximation to the specified + // circular arc. The input can be 2D or 3D, determined by the minimum dimension + // of the center and start point. + // includedAngle is in radians, can be positiveor negative + this.circularArcToBezier= function( ctr_, startPt_, includedAngle ) + { + var dimen = 3; + var ctr = ctr_.slice(); + var startPt = startPt_.slice(); + + // make sure the start point is good + var pt = this.vecSubtract(dimen, startPt, ctr); + var rad = this.vecMag(dimen, pt); + + if ((dimen != 3) || (rad <= 0) || (includedAngle === 0)) + { + if (dimen != 3) console.log( "circularArcToBezier works for 3 dimensional points only. Was " + dimen ); + return [ startPt.slice(0), startPt.slice(0), startPt.slice(0) ]; + } + + // determine the number of segments. 45 degree span maximum. + var nSegs = Math.ceil( Math.abs(includedAngle)/(0.25*Math.PI) ); + if (nSegs <= 0) return [ startPt.slice(0), startPt.slice(0), startPt.slice(0) ]; + var dAngle = includedAngle/nSegs; + + // determine the length of the center control point from the circle center + var cs = Math.cos( 0.5*Math.abs(dAngle) ), sn = Math.sin( 0.5*Math.abs(dAngle) ); + var c = rad*sn; + var h = c*sn/cs; + var d = rad*cs + h; + + var rtnPts = [ this.vecAdd(dimen, pt, ctr) ]; + var rotMat = Matrix.RotationZ( dAngle ); + for ( var i=0; i= 0) + rtnStr = rtnStr.substr(0, index); + + return rtnStr; + } + +} + +function RuntimeFlatMaterial() +{ + // inherit the members of RuntimeMaterial + this.inheritedFrom = RuntimeMaterial; + this.inheritedFrom(); + + this._name = "FlatMaterial"; + this._shaderName = "flat"; + + // assign a default color + this._color = [1,0,0,1]; + + this.import = function( importStr ) + { + var colorStr = this.getPropertyFromString( "color: ", importStr ); + if (colorStr) + this._color = eval( "[" + colorStr + "]" ); + }; + + + this.init = function() + { + if (this._shader) + { + this._shader.colorMe["color"].set( this._color ); + } + } +} + +function RuntimePulseMaterial() +{ + // inherit the members of RuntimeMaterial + this.inheritedFrom = RuntimeMaterial; + this.inheritedFrom(); + + this._name = "PulseMaterial"; + this._shaderName = "pulse"; + + this._texMap = 'assets/images/cubelight.png'; + + this.isAnimated = function() { return true; } + + + this.import = function( importStr ) + { + this._texMap = this.getPropertyFromString( "texture: ", importStr ); + } + + this.init = function( world ) + { + var material = this._materialNode; + if (material) + { + var technique = material.shaderProgram.default; + var renderer = g_Engine.getContext().renderer; + if (renderer && technique) + { + if (this._shader && this._shader.default) + { + var res = [ renderer.vpWidth, renderer.vpHeight ]; + technique.u_resolution.set( res ); + + var wrap = 'REPEAT', mips = true; + this._texMap = world.remapAssetFolder( this._texMap ); + var tex = renderer.getTextureByName(this._texMap, wrap, mips ); + if (tex) + technique.u_tex0.set( tex ); + + this._shader.default.u_time.set( [this._time] ); + } + } + } + } + + // several materials inherit from pulse. + // they may share this update method + this.update = function( time ) + { + var material = this._materialNode; + if (material) + { + var technique = material.shaderProgram.default; + var renderer = g_Engine.getContext().renderer; + if (renderer && technique) + { + if (this._shader && this._shader.default) + this._shader.default.u_time.set( [this._time] ); + this._time += this._dTime; + if (this._time > 200.0) this._time = 0.0; + } + } + } +} + +function RuntimeRadialGradientMaterial() +{ + // inherit the members of RuntimeMaterial + this.inheritedFrom = RuntimeMaterial; + this.inheritedFrom(); + + this._name = "RadialGradientMaterial"; + this._shaderName = "radialGradient"; + + // setup default values + this._color1 = [1,0,0,1]; this._colorStop1 = 0.0; + this._color2 = [0,1,0,1]; this._colorStop2 = 0.3; + this._color3 = [0,1,0,1]; this._colorStop3 = 0.6; + this._color4 = [0,1,0,1]; this._colorStop4 = 1.0; + + this.init = function() + { + var material = this._materialNode; + if (material) + { + var technique = material.shaderProgram.default; + var renderer = g_Engine.getContext().renderer; + if (renderer && technique) + { + if (this._shader && this._shader.default) + { + this._shader.default.u_color1.set( this._color1 ); + this._shader.default.u_color2.set( this._color2 ); + this._shader.default.u_color3.set( this._color3 ); + this._shader.default.u_color4.set( this._color4 ); + + this._shader.default.u_colorStop1.set( [this._colorStop1] ); + this._shader.default.u_colorStop2.set( [this._colorStop2] ); + this._shader.default.u_colorStop3.set( [this._colorStop3] ); + this._shader.default.u_colorStop4.set( [this._colorStop4] ); + + if (this._angle !== undefined) + this._shader.default.u_cos_sin_angle.set([Math.cos(this._angle), Math.sin(this._angle)]); + } + } + } + } + + this.import = function( importStr ) + { + var colorStr; + colorStr = this.getPropertyFromString( "color1: ", importStr ); + this._color1 = eval( "[" + colorStr + "]" ); + colorStr = this.getPropertyFromString( "color2: ", importStr ); + this._color2 = eval( "[" + colorStr + "]" ); + colorStr = this.getPropertyFromString( "color3: ", importStr ); + this._color3 = eval( "[" + colorStr + "]" ); + colorStr = this.getPropertyFromString( "color4: ", importStr ); + this._color4 = eval( "[" + colorStr + "]" ); + + this._colorStop1 = Number( this.getPropertyFromString( "colorStop1: ", importStr ) ); + this._colorStop2 = Number( this.getPropertyFromString( "colorStop2: ", importStr ) ); + this._colorStop3 = Number( this.getPropertyFromString( "colorStop3: ", importStr ) ); + this._colorStop4 = Number( this.getPropertyFromString( "colorStop4: ", importStr ) ); + + if (this._angle !== undefined) + this._angle = this.getPropertyFromString( "angle: ", importStr ); + } + +} + +function RuntimeLinearGradientMaterial() +{ + // inherit the members of RuntimeMaterial + this.inheritedFrom = RuntimeRadialGradientMaterial; + this.inheritedFrom(); + + this._name = "LinearGradientMaterial"; + this._shaderName = "linearGradient"; + + // the only difference between linear & radial gradient is the existance of an angle for linear. + this._angle = 0.0; +} + +function RuntimeBumpMetalMaterial() +{ + // inherit the members of RuntimeMaterial + this.inheritedFrom = RuntimeMaterial; + this.inheritedFrom(); + + this._name = "BumpMetalMaterial"; + this._shaderName = "bumpMetal"; + + this._lightDiff = [0.3, 0.3, 0.3, 1.0]; + this._diffuseTexture = "assets/images/metal.png"; + this._specularTexture = "assets/images/silver.png"; + this._normalTexture = "assets/images/normalMap.png"; + + this.import = function( importStr ) + { + this._lightDiff = eval( "[" + this.getPropertyFromString( "lightDiff: ", importStr ) + "]" ); + this._diffuseTexture = this.getPropertyFromString( "diffuseTexture: ", importStr ); + this._specularTexture = this.getPropertyFromString( "specularTexture: ", importStr ); + this._normalTexture = this.getPropertyFromString( "normalMap: ", importStr ); + } + + this.init = function() + { + var material = this._materialNode; + if (material) + { + var technique = material.shaderProgram.default; + var renderer = g_Engine.getContext().renderer; + if (renderer && technique) + { + if (this._shader && this._shader.default) + { + technique.u_light0Diff.set( this._lightDiff ); + + var tex; + var wrap = 'REPEAT', mips = true; + if (this._diffuseTexture) + { + this._diffuseTexture = world.remapAssetFolder( this._diffuseTexture ); + tex = renderer.getTextureByName(this._diffuseTexture, wrap, mips ); + if (tex) technique.u_colMap.set( tex ); + + } + if (this._normalTexture) + { + this._normalTexture = world.remapAssetFolder( this._normalTexture ); + tex = renderer.getTextureByName(this._normalTexture, wrap, mips ); + if (tex) technique.u_normalMap.set( tex ); + } + if (this._specularTexture) + { + this._specularTexture = world.remapAssetFolder( this._specularTexture ); + tex = renderer.getTextureByName(this._specularTexture, wrap, mips ); + technique.u_glowMap.set( tex ); + } + } + } + } + } +} + +function RuntimeUberMaterial() +{ +} + +function RuntimePlasmaMaterial() +{ + // inherit the members of RuntimeMaterial + this.inheritedFrom = RuntimeMaterial; + this.inheritedFrom(); + + this.init = function( ) + { + this.update(); + } + + this.update = function( time ) + { + var material = this._materialNode; + if (material) + { + var technique = material.shaderProgram.default; + var renderer = g_Engine.getContext().renderer; + if (renderer && technique) + { + if (this._shader && this._shader.default) + this._shader.default.u_time.set( [this._time] ); + this._time += this._dTime; + if (this._time > 200.0) this._time = 0.0; + } + } + } +} \ No newline at end of file diff --git a/assets/descriptor.json b/assets/descriptor.json index ef21b8b8..af0520dd 100644 --- a/assets/descriptor.json +++ b/assets/descriptor.json @@ -4,32 +4,55 @@ "root": "/assets/", "directories": [{"name": "images"}, {"name": "shaders"}], "files": [ + "canvas-runtime.js", "rdge-compiled.js", - "images/black.png", - "images/blue.png", "images/BoxB2_AO.png", - "images/BoxB2_DM.png", - "images/cubelight.png", "images/grey.png", - "images/material_paint.png", - "images/metal.png", - "images/normalMap.png", - "images/random_normal.png", "images/rocky-diffuse.jpg", + "images/BoxB2_DM.png", + "images/material_paint.png", "images/rocky-normal.jpg", + "images/black.png", + "images/metal.png", "images/rocky-spec.jpg", + "images/blue.png", + "images/normalMap.png", "images/silver.png", + "images/cubelight.png", + "images/random_normal.png", "images/white.png", "shaders/Basic.frag.glsl", + "shaders/TwistVert.vert.glsl", "shaders/Basic.vert.glsl", + "shaders/Water.frag.glsl", + "shaders/Deform.frag.glsl", + "shaders/Water2.frag.glsl", + "shaders/Flag.vert.glsl", + "shaders/ZInvert.frag.glsl", + "shaders/Fly.frag.glsl", "shaders/linearGradient.frag.glsl", + "shaders/Julia.frag.glsl", "shaders/linearGradient.vert.glsl", + "shaders/Keleidoscope.frag.glsl", + "shaders/plasma.frag.glsl", + "shaders/Mandel.frag.glsl", + "shaders/plasma.vert.glsl", + "shaders/Pulse.frag.glsl", + "shaders/radialBlur.frag.glsl", + "shaders/ReliefTunnel.frag.glsl", "shaders/radialGradient.frag.glsl", + "shaders/SquareTunnel.frag.glsl", "shaders/radialGradient.vert.glsl", + "shaders/Star.frag.glsl", "shaders/test_fshader.glsl", + "shaders/Taper.frag.glsl", "shaders/test_fshader_full.glsl", + "shaders/Taper.vert.glsl", "shaders/test_vshader.glsl", + "shaders/Tunnel.frag.glsl", "shaders/ub_fshader.glsl", - "shaders/ub_vshader.glsl" + "shaders/Twist.frag.glsl", + "shaders/ub_vshader.glsl", + "shaders/TwistVert.frag.glsl" ] } \ No newline at end of file diff --git a/assets/rdge-compiled.js b/assets/rdge-compiled.js index 4301200f..d1040d73 100755 --- a/assets/rdge-compiled.js +++ b/assets/rdge-compiled.js @@ -45,9 +45,8 @@ b.fillText(o.label,n+10,h+4);b.translate([-0.5,-0.5])};var o=this;setInterval(fu a;for(var f=0,g=-1E10,a=1E10,h=this.samples.length-1;h>=0;)f+=this.samples[h],g=Math.max(g,this.samples[h]),a=Math.min(a,this.samples[h]),h--;f=this.samples.length>0?f/this.samples.length:0;f=f>0?1E3/f:0;g=g>0?1E3/g:0;a=a>0?1E3/a:0;h=this.samples[this.samples.length-1];this.fpsRaw.value=(h>0?1E3/h:0).toFixed(2);this.fpsAvg.value=f.toFixed(2);this.fpsMin.value=g.toFixed(2);this.fpsMax.value=a.toFixed(2)}};objectManager=function(){this.guidCounter=0;this.objects=[];this.numObjects=0;this.freelist=[];this.reset=function(){this.objects=[];this.freelist=[];this.guidCounter=0};this.validHandle=function(a){return this.handleToIndex(a)!=-1};this.handleToIndex=function(a){var b=a>>16&65535;return this.objects[b]!=null&&a==this.objects[b].handle?b:-1};this.handleToObject=function(a){a=this.handleToIndex(a);return a!=-1?this.objects[a]:null};this.addObject=function(a){var b=this.objects.length;this.freelist.length> 0&&(b=this.freelist.pop());if(++this.guidCounter>=65535)this.guidCounter=1;a.handle=b<<16|++this.guidCounter;this.objects[b]=a;return a.handle};this.removeObject=function(a){a=this.handleToIndex(a);if(a!=-1){if(this.objects[a].onremove!=void 0)this.objects[a].onremove();this.objects[a]=null;this.freelist.push(a)}}};rdgeGlobalParameters={u_projMatrix:{type:"mat4",data:mat4.identity()},u_mvMatrix:{type:"mat4",data:mat4.identity()},u_invMvMatrix:{type:"mat4",data:mat4.identity()},u_normalMatrix:{type:"mat4",data:mat4.identity()},u_worldMatrix:{type:"mat4",data:mat4.identity()},u_viewMatrix:{type:"mat4",data:mat4.identity()},u_invViewMatrix:{type:"mat4",data:mat4.identity()},u_invWorldMatrix:{type:"mat4",data:mat4.identity()},u_inv_viewport_width:{type:"float",data:[1]},u_inv_viewport_height:{type:"float",data:[1]}, u_lightPos:{type:"vec3",data:[-20,50,20]},u_lightDiff:{type:"vec4",data:[0.8,0.8,0.8,1]},u_lightAmb:{type:"vec4",data:[1,1,1,1]},rdge_lights:{u_light0Pos:{type:"vec3",data:[-20,50,20]},u_light0Diff:{type:"vec4",data:[0.8,0.8,0.8,1]},u_light0Amb:{type:"vec4",data:[8.0E-4,8.0E-4,8.0E-4,1]},u_light0Spec:{type:"vec4",data:[1,1,1,1]},u_light1Pos:{type:"vec3",data:[0,0,0]},u_light1Diff:{type:"vec4",data:[0,0,0,0]},u_light1Amb:{type:"vec4",data:[0.5,0.5,0.5,1]},u_light1Spec:{type:"vec4",data:[1,1,1,1]}, -u_light2Pos:{type:"vec3",data:[0,0,0]},u_light2Diff:{type:"vec4",data:[0,0,0,1]},u_light2Amb:{type:"vec4",data:[0.5,0.5,0.5,1]},u_light2Spec:{type:"vec4",data:[1,1,1,1]},u_light3Pos:{type:"vec3",data:[0,0,0]},u_light3Diff:{type:"vec4",data:[0.8,0.8,0.8,1]},u_light3Amb:{type:"vec4",data:[0.5,0.5,0.5,1]},u_light3Spec:{type:"vec4",data:[1,1,1,1]}},colMap:{type:"tex2d",data:"assets/images/white.png"},envMap:{type:"tex2d",data:null},normalMap:{type:"tex2d",data:null},glowMap:{type:"tex2d",data:"assets/images/black.png"}, -u_shadowDepthMap:{type:"tex2d",data:null},u_depthMap:{type:"tex2d",data:null},u_matAmbient:{type:"vec4",data:[1,1,1,1]},u_matDiffuse:{type:"vec4",data:[1,1,1,1]},u_matSpecular:{type:"vec4",data:[1,1,1,1]},u_matShininess:{t