Deltakosh %!s(int64=11) %!d(string=hai) anos
pai
achega
d3678137fe
Modificáronse 100 ficheiros con 2149 adicións e 694 borrados
  1. 1 0
      Babylon/Animations/babylon.animation.js
  2. 32 31
      Babylon/Cameras/babylon.arcRotateCamera.js
  3. 47 1
      Babylon/Cameras/babylon.camera.js
  4. 5 33
      Babylon/Cameras/babylon.deviceOrientationCamera.js
  5. 57 30
      Babylon/Cameras/babylon.freeCamera.js
  6. 6 35
      Babylon/Cameras/babylon.touchCamera.js
  7. 17 9
      Babylon/Collisions/babylon.collider.js
  8. 11 8
      Babylon/Lights/Shadows/babylon.shadowGenerator.js
  9. 41 8
      Babylon/Lights/babylon.directionalLight.js
  10. 18 8
      Babylon/Lights/babylon.hemisphericLight.js
  11. 24 1
      Babylon/Lights/babylon.light.js
  12. 28 8
      Babylon/Lights/babylon.pointLight.js
  13. 39 8
      Babylon/Lights/babylon.spotLight.js
  14. 12 5
      Babylon/Materials/babylon.effect.js
  15. 39 27
      Babylon/Materials/babylon.standardMaterial.js
  16. 2 2
      Babylon/Materials/textures/babylon.baseTexture.js
  17. 15 54
      Babylon/Mesh/babylon.mesh.js
  18. 6 2
      Babylon/Mesh/babylon.subMesh.js
  19. 2 2
      Babylon/Rendering/babylon.renderingGroup.js
  20. 1 1
      Babylon/Rendering/babylon.renderingManager.js
  21. 6 1
      Babylon/Shaders/default.vertex.fx
  22. 253 66
      Babylon/Shaders/iedefault.fragment.fx
  23. 57 2
      Babylon/Shaders/iedefault.vertex.fx
  24. 0 4
      Babylon/Shaders/shadowMap.vertex.fx
  25. 85 60
      Babylon/Tools/babylon.database.js
  26. 71 27
      Babylon/Tools/babylon.sceneLoader.js
  27. 492 0
      Babylon/Tools/babylon.standardMaterial.js
  28. 1 1
      Babylon/Tools/babylon.tools.js
  29. 5 3
      Babylon/babylon.engine.js
  30. 71 0
      Babylon/babylon.node.js
  31. 49 8
      Babylon/babylon.scene.js
  32. 5 3
      Exporters/Blender/io_export_babylon.py
  33. 224 0
      Exporters/FBX - OBJ/BabylonExport.Core/BabylonExport.Core.csproj
  34. 1 1
      Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonAnimation.cs
  35. 1 1
      Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonAnimationKey.cs
  36. 1 1
      Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonBone.cs
  37. 22 1
      Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonCamera.cs
  38. 1 1
      Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonLight.cs
  39. 2 2
      Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonMaterial.cs
  40. 1 1
      Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonMesh.cs
  41. 1 1
      Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonMultiMaterial.cs
  42. 1 1
      Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonParticleSystem.cs
  43. 1 1
      Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonScene.cs
  44. 1 1
      Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonShadowGenerator.cs
  45. 1 1
      Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonSkeleton.cs
  46. 1 1
      Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonSubMesh.cs
  47. 1 1
      Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonTexture.cs
  48. 1 1
      Exporters/FBX - OBJ/BabylonExport/Entities/IDumpable.cs
  49. 1 1
      Exporters/FBX - OBJ/BabylonExport/Entities/IQueryable.cs
  50. 2 2
      Exporters/FBX - OBJ/BabylonExport/Entities/Mesh.cs
  51. 1 1
      Exporters/FBX - OBJ/BabylonExport/Entities/PositionNormalTextured.cs
  52. 1 1
      Exporters/FBX - OBJ/BabylonExport/Entities/PositionNormalTexturedWeights.cs
  53. 2 2
      Exporters/FBX - OBJ/BabylonExport/Entities/ProxyMesh.cs
  54. 2 2
      Exporters/FBX - OBJ/BabylonExport/Entities/StandardMaterial.cs
  55. 5 3
      Exporters/FBX - OBJ/BabylonExport/Exporters/Blender/io_export_babylon.py
  56. 4 4
      Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/FBXExporter.cs
  57. 1 1
      Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/ContentBuilder.cs
  58. 1 1
      Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/ErrorLogger.cs
  59. 3 3
      Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/GraphicsDeviceService.cs
  60. 1 1
      Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/ServiceContainer.cs
  61. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Exporters/FBX/XNA/XNA Game Studio/Microsoft.Xna.GameStudio.ContentPipelineExtensions.targets
  62. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Exporters/FBX/XNA/XNA Game Studio/Microsoft.Xna.GameStudio.targets
  63. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.Framework.Tools.Packaging.Tasks.dll
  64. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.GameStudio.AvailablePlatforms.targets
  65. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.GameStudio.Common.targets
  66. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.GameStudio.Content.targets
  67. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.GameStudio.ContentPipeline.targets
  68. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.GameStudio.Windows.targets
  69. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.GameStudio.Xbox 360.targets
  70. 1 1
      Exporters/FBX - OBJ/BabylonExport/Exporters/IExporter.cs
  71. 41 4
      Exporters/FBX - OBJ/BabylonExport/Exporters/MXB/NovaExporter.Materials.cs
  72. 32 2
      Exporters/FBX - OBJ/BabylonExport/Exporters/MXB/NovaExporter.cs
  73. 11 6
      Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/XNA Game Studio/SkinnedModel/Properties/AssemblyInfo.cs
  74. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/Microsoft.Xna.Framework.Content.Pipeline.AudioImporters.dll
  75. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll
  76. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll
  77. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll
  78. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/Microsoft.Xna.Framework.Content.Pipeline.VideoImporters.dll
  79. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll
  80. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/Microsoft.Xna.Framework.Content.Pipeline.dll
  81. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/Microsoft.Xna.Framework.Tools.Packaging.Tasks.dll
  82. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/SharpDX.DXGI.dll
  83. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/SharpDX.Direct3D9.dll
  84. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/SharpDX.dll
  85. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/SkinnedModel.dll
  86. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/SkinnedModelPipeline.dll
  87. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/Vertice.Core.dll
  88. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/Vertice.Nova.Core.DirectX10.dll
  89. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/Vertice.Nova.Core.DirectX9.dll
  90. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/Vertice.Nova.Interop.dll
  91. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/Vertice.Nova.dll
  92. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/Vertice.Wrappers.DirectX.dll
  93. 0 0
      Exporters/FBX - OBJ/BabylonExport.Core/Refs/xnafx40_redist.msi
  94. 2 2
      Exporters/FBX - OBJ/BabylonExport/Tools.cs
  95. 58 0
      Exporters/FBX - OBJ/BabylonExport.Interface/BabylonExport.Interface.csproj
  96. 17 0
      Exporters/FBX - OBJ/BabylonExport.Interface/IService.cs
  97. 11 6
      Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/XNA Game Studio/SkinnedModelPipeline/Properties/AssemblyInfo.cs
  98. 2 2
      Exporters/FBX - OBJ/BabylonExport/App.config
  99. 191 185
      Exporters/FBX - OBJ/BabylonExport/BabylonExport.csproj
  100. 0 0
      Exporters/FBX - OBJ/BabylonExport/Exporters/Blender/io_export_babylon.zip

+ 1 - 0
Babylon/Animations/babylon.animation.js

@@ -122,6 +122,7 @@
         var ratio = delay * (this.framePerSecond * speedRatio) / 1000.0;
 
         if (ratio > range && !loop) { // If we are out of range and not looping get back to caller
+            offsetValue = 0;
             returnValue = false;
         } else {
             // Get max value if required

+ 32 - 31
Babylon/Cameras/babylon.arcRotateCamera.js

@@ -4,13 +4,12 @@
     var eventPrefix = BABYLON.Tools.GetPointerPrefix();
 
     BABYLON.ArcRotateCamera = function (name, alpha, beta, radius, target, scene) {
-        this.name = name;
-        this.id = name;
+        BABYLON.Camera.call(this, name, BABYLON.Vector3.Zero(), scene);
+        
         this.alpha = alpha;
         this.beta = beta;
         this.radius = radius;
         this.target = target;
-        this.position = BABYLON.Vector3.Zero();
         
         this._keys = [];
         this.keysUp = [38];
@@ -18,20 +17,9 @@
         this.keysLeft = [37];
         this.keysRight = [39];
 
-        this._scene = scene;
-
-        scene.cameras.push(this);
-        
-        if (!scene.activeCamera) {
-            scene.activeCamera = this;
-        }
-
         this._viewMatrix = new BABYLON.Matrix();
 
         this.getViewMatrix();
-        
-        // Animations
-        this.animations = [];
     };
     
     BABYLON.ArcRotateCamera.prototype = Object.create(BABYLON.Camera.prototype);
@@ -45,6 +33,7 @@
     BABYLON.ArcRotateCamera.prototype.upperBetaLimit = null;
     BABYLON.ArcRotateCamera.prototype.lowerRadiusLimit = null;
     BABYLON.ArcRotateCamera.prototype.upperRadiusLimit = null;
+    BABYLON.ArcRotateCamera.prototype.angularSensibility = 1000.0;
 
     // Methods
     BABYLON.ArcRotateCamera.prototype.attachControl = function(canvas, noPreventDefault) {
@@ -98,8 +87,8 @@
                 var offsetX = evt.clientX - previousPosition.x;
                 var offsetY = evt.clientY - previousPosition.y;
 
-                that.inertialAlphaOffset -= offsetX / 1000;
-                that.inertialBetaOffset -= offsetY / 1000;
+                that.inertialAlphaOffset -= offsetX / that.angularSensibility;
+                that.inertialBetaOffset -= offsetY / that.angularSensibility;
 
                 previousPosition = {
                     x: evt.clientX,
@@ -119,8 +108,8 @@
                 var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
                 var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
 
-                that.inertialAlphaOffset -= offsetX / 1000;
-                that.inertialBetaOffset -= offsetY / 1000;
+                that.inertialAlphaOffset -= offsetX / that.angularSensibility;
+                that.inertialBetaOffset -= offsetY / that.angularSensibility;
 
                 if (!noPreventDefault) {
                     evt.preventDefault();
@@ -207,19 +196,27 @@
                     }
                 }
             };
+
+            this._reset = function() {
+                that._keys = [];
+                that.inertialAlphaOffset = 0;
+                that.inertialBetaOffset = 0;
+                previousPosition = null;
+                pointerId = null;
+            };
         }
 
-        canvas.addEventListener(eventPrefix + "down", this._onPointerDown);
-        canvas.addEventListener(eventPrefix + "up", this._onPointerUp);
-        canvas.addEventListener(eventPrefix + "out", this._onPointerUp);
-        canvas.addEventListener(eventPrefix + "move", this._onPointerMove);
-        canvas.addEventListener("mousemove", this._onMouseMove);
-        canvas.addEventListener("MSPointerDown", this._onGestureStart);
-        canvas.addEventListener("MSGestureChange", this._onGesture);
-        window.addEventListener("keydown", this._onKeyDown);
-        window.addEventListener("keyup", this._onKeyUp);
-        window.addEventListener('mousewheel', this._wheel);
-        window.addEventListener("blur", this._onLostFocus);
+        canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
+        canvas.addEventListener(eventPrefix + "up", this._onPointerUp, false);
+        canvas.addEventListener(eventPrefix + "out", this._onPointerUp, false);
+        canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
+        canvas.addEventListener("mousemove", this._onMouseMove, false);
+        canvas.addEventListener("MSPointerDown", this._onGestureStart, false);
+        canvas.addEventListener("MSGestureChange", this._onGesture, false);
+        window.addEventListener("keydown", this._onKeyDown, false);
+        window.addEventListener("keyup", this._onKeyUp, false);
+        window.addEventListener('mousewheel', this._wheel, false);
+        window.addEventListener("blur", this._onLostFocus, false);
     };
     
     BABYLON.ArcRotateCamera.prototype.detachControl = function (canvas) {
@@ -241,6 +238,10 @@
 
         this._MSGestureHandler = null;
         this._attachedCanvas = null;
+
+        if (this._reset) {
+            this._reset();
+        }
     };
 
     BABYLON.ArcRotateCamera.prototype._update = function () {
@@ -304,7 +305,7 @@
         this.beta = Math.acos(radiusv3.y / this.radius);
     };
 
-    BABYLON.ArcRotateCamera.prototype.getViewMatrix = function () {
+    BABYLON.ArcRotateCamera.prototype._getViewMatrix = function () {
         // Compute
         if (this.beta > Math.PI)
             this.beta = Math.PI;
@@ -318,7 +319,7 @@
         var sinb = Math.sin(this.beta);
 
         this.target.addToRef(new BABYLON.Vector3(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb), this.position);
-        BABYLON.Matrix.LookAtLHToRef(this.position, this.target, BABYLON.Vector3.Up(), this._viewMatrix);
+        BABYLON.Matrix.LookAtLHToRef(this.position, this.target, this.upVector, this._viewMatrix);
 
         return this._viewMatrix;
     };

+ 47 - 1
Babylon/Cameras/babylon.camera.js

@@ -5,6 +5,7 @@
         this.name = name;
         this.id = name;
         this.position = position;
+        this.upVector = BABYLON.Vector3.Up();
        
         this._scene = scene;
 
@@ -13,8 +14,16 @@
         if (!scene.activeCamera) {
             scene.activeCamera = this;
         }
+
+        this._computedViewMatrix = BABYLON.Matrix.Identity();
+        this._currentRenderId = -1;
+        
+        // Animations
+        this.animations = [];
     };
     
+    BABYLON.Camera.prototype = Object.create(BABYLON.Node.prototype);
+    
     // Statics
     BABYLON.Camera.PERSPECTIVE_CAMERA = 0;
     BABYLON.Camera.ORTHOGRAPHIC_CAMERA = 1;
@@ -40,11 +49,48 @@
 
     BABYLON.Camera.prototype._update = function () {
     };
+    
+    BABYLON.Camera.prototype.getWorldMatrix = function () {
+        var viewMatrix = this.getViewMatrix();
 
-    BABYLON.Camera.prototype.getViewMatrix = function () {
+        if (!this._worldMatrix) {
+            this._worldMatrix = BABYLON.Matrix.Identity();
+        }
+
+        viewMatrix.invertToRef(this._worldMatrix);
+
+        return this._worldMatrix;
+    };
+
+    BABYLON.Camera.prototype._getViewMatrix = function() {
         return BABYLON.Matrix.Identity();
     };
 
+    BABYLON.Camera.prototype.getViewMatrix = function () {
+        if (this._currentRenderId == this._scene.getRenderId()) {
+            return this._computedViewMatrix;
+        }
+
+        this._computedViewMatrix = this._getViewMatrix();
+        this._currentRenderId = this._scene.getRenderId();
+        
+        if (this.parent && this.parent.getWorldMatrix) {
+            if (!this._worldMatrix) {
+                this._worldMatrix = BABYLON.Matrix.Identity();
+            }
+
+            this._computedViewMatrix.invertToRef(this._worldMatrix);
+
+            this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._computedViewMatrix);
+
+            this._computedViewMatrix.invert();
+
+            return this._computedViewMatrix;
+        }
+
+        return this._computedViewMatrix;
+    };
+
     BABYLON.Camera.prototype.getProjectionMatrix = function () {
         if (!this._projectionMatrix) {
             this._projectionMatrix = new BABYLON.Matrix();

+ 5 - 33
Babylon/Cameras/babylon.deviceOrientationCamera.js

@@ -2,25 +2,7 @@
 
 (function () {
     BABYLON.DeviceOrientationCamera = function (name, position, scene) {
-        this.name = name;
-        this.id = name;
-
-        this._scene = scene;
-        this.position = position;
-        scene.cameras.push(this);
-        this.cameraDirection = new BABYLON.Vector3(0, 0, 0);
-        this.cameraRotation = new BABYLON.Vector2(0, 0);
-        this.rotation = new BABYLON.Vector3(0, 0, 0);
-        this.ellipsoid = new BABYLON.Vector3(0.5, 1, 0.5);
-        this.angularSensibility = 10000.0;
-        this.moveSensibility = 50.0;
-
-        if (!scene.activeCamera) {
-            scene.activeCamera = this;
-        }
-        // Collisions
-        this._collider = new BABYLON.Collider();
-        this._needMoveForGravity = true;
+        BABYLON.FreeCamera.call(this, name, position, scene);
 
         // Offset
         this._offsetX = null;
@@ -29,23 +11,13 @@
         this._orientationBeta = 0;
         this._initialOrientationGamma = 0;
         this._initialOrientationBeta = 0;
-
-        // Animations
-        this.animations = [];
-
-        // Internals
-        this._cameraRotationMatrix = new BABYLON.Matrix();
-        this._referencePoint = BABYLON.Vector3.Zero();
-        this._currentTarget = BABYLON.Vector3.Zero();
-        this._transformedReferencePoint = BABYLON.Vector3.Zero();
-        this._viewMatrix = BABYLON.Matrix.Zero();
-        this._upVector = BABYLON.Vector3.Up();
-        this._oldPosition = BABYLON.Vector3.Zero();
-        this._diffPosition = BABYLON.Vector3.Zero();
-        this._newPosition = BABYLON.Vector3.Zero();
     };
 
     BABYLON.DeviceOrientationCamera.prototype = Object.create(BABYLON.FreeCamera.prototype);
+    
+    // Members
+    BABYLON.DeviceOrientationCamera.prototype.angularSensibility = 10000.0;
+    BABYLON.DeviceOrientationCamera.prototype.moveSensibility = 50.0;
 
     // Controls
     BABYLON.DeviceOrientationCamera.prototype.attachControl = function (canvas, noPreventDefault) {

+ 57 - 30
Babylon/Cameras/babylon.freeCamera.js

@@ -2,12 +2,8 @@
 
 (function () {
     BABYLON.FreeCamera = function (name, position, scene) {
-        this.name = name;
-        this.id = name;
-
-        this._scene = scene;
-        this.position = position;
-        scene.cameras.push(this);
+        BABYLON.Camera.call(this, name, position, scene);
+        
         this.cameraDirection = new BABYLON.Vector3(0, 0, 0);
         this.cameraRotation = new BABYLON.Vector2(0, 0);
         this.rotation = new BABYLON.Vector3(0, 0, 0);
@@ -19,19 +15,12 @@
         this.keysLeft = [37];
         this.keysRight = [39];
 
-        if (!scene.activeCamera) {
-            scene.activeCamera = this;
-        }
         // Collisions
         this._collider = new BABYLON.Collider();
         this._needMoveForGravity = true;
 
-        // Animations
-        this.animations = [];
-
         // Internals
         this._currentTarget = BABYLON.Vector3.Zero();
-        this._upVector = BABYLON.Vector3.Up();
         this._viewMatrix = BABYLON.Matrix.Zero();
         this._camMatrix = BABYLON.Matrix.Zero();
         this._cameraTransformMatrix = BABYLON.Matrix.Zero();
@@ -41,6 +30,8 @@
         this._oldPosition = BABYLON.Vector3.Zero();
         this._diffPosition = BABYLON.Vector3.Zero();
         this._newPosition = BABYLON.Vector3.Zero();
+        this._lookAtTemp = BABYLON.Matrix.Zero();
+        this._tempMatrix = BABYLON.Matrix.Zero();
     };
 
     BABYLON.FreeCamera.prototype = Object.create(BABYLON.Camera.prototype);
@@ -49,6 +40,10 @@
     BABYLON.FreeCamera.prototype.speed = 2.0;
     BABYLON.FreeCamera.prototype.checkCollisions = false;
     BABYLON.FreeCamera.prototype.applyGravity = false;
+    BABYLON.FreeCamera.prototype.noRotationConstraint = false;
+    BABYLON.FreeCamera.prototype.angularSensibility = 2000.0;
+    BABYLON.FreeCamera.prototype.lockedTarget = null;
+
 
     // Methods
     BABYLON.FreeCamera.prototype._computeLocalCameraSpeed = function () {
@@ -57,7 +52,9 @@
 
     // Target
     BABYLON.FreeCamera.prototype.setTarget = function (target) {
-        BABYLON.Matrix.LookAtLHToRef(this.position, target, BABYLON.Vector3.Up(), this._camMatrix);
+        this.upVector.normalize();
+        
+        BABYLON.Matrix.LookAtLHToRef(this.position, target, this.upVector, this._camMatrix);
         this._camMatrix.invert();
 
         this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
@@ -70,7 +67,7 @@
             this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
         }
 
-        this.rotation.z = -Math.acos(BABYLON.Vector3.Dot(new BABYLON.Vector3(0, 1.0, 0), BABYLON.Vector3.Up()));
+        this.rotation.z = -Math.acos(BABYLON.Vector3.Dot(new BABYLON.Vector3(0, 1.0, 0), this.upVector));
 
         if (isNaN(this.rotation.x))
             this.rotation.x = 0;
@@ -136,8 +133,8 @@
                     offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
                 }
 
-                that.cameraRotation.y += offsetX / 2000.0;
-                that.cameraRotation.x += offsetY / 2000.0;
+                that.cameraRotation.y += offsetX / that.angularSensibility;
+                that.cameraRotation.x += offsetY / that.angularSensibility;
 
                 previousPosition = {
                     x: evt.clientX,
@@ -183,6 +180,13 @@
             this._onLostFocus = function () {
                 that._keys = [];
             };
+
+            this._reset = function() {
+                that._keys = [];
+                previousPosition = null;
+                that.cameraDirection = new BABYLON.Vector3(0, 0, 0);
+                that.cameraRotation = new BABYLON.Vector2(0, 0);
+            };
         }
 
         canvas.addEventListener("mousedown", this._onMouseDown, false);
@@ -208,6 +212,9 @@
         window.removeEventListener("blur", this._onLostFocus);
         
         this._attachedCanvas = null;
+        if (this._reset) {
+            this._reset();
+        }
     };
 
     BABYLON.FreeCamera.prototype._collideWithWorld = function (velocity) {
@@ -243,8 +250,8 @@
                 this._localDirection.copyFromFloats(0, 0, -speed);
             }
 
-            BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, 0, this._cameraTransformMatrix);
-            BABYLON.Vector3.TransformCoordinatesToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
+            this.getViewMatrix().invertToRef(this._cameraTransformMatrix);
+            BABYLON.Vector3.TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
             this.cameraDirection.addInPlace(this._transformedDirection);
         }
     };
@@ -275,12 +282,14 @@
             this.rotation.x += this.cameraRotation.x;
             this.rotation.y += this.cameraRotation.y;
 
-            var limit = (Math.PI / 2) * 0.95;
+            if (!this.noRotationConstraint) {
+                var limit = (Math.PI / 2) * 0.95;
 
-            if (this.rotation.x > limit)
-                this.rotation.x = limit;
-            if (this.rotation.x < -limit)
-                this.rotation.x = -limit;
+                if (this.rotation.x > limit)
+                    this.rotation.x = limit;
+                if (this.rotation.x < -limit)
+                    this.rotation.x = -limit;
+            }
         }
 
         // Inertia
@@ -292,17 +301,35 @@
         }
     };
 
-    BABYLON.FreeCamera.prototype.getViewMatrix = function () {
+    BABYLON.FreeCamera.prototype._getViewMatrix = function () {
         BABYLON.Vector3.FromFloatsToRef(0, 0, 1, this._referencePoint);
-        // Compute
-        BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
 
-        BABYLON.Vector3.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
+        if (!this.lockedTarget) {
+            // Compute
+            if (this.upVector.x != 0 || this.upVector.y != 1.0 || this.upVector.z != 0) {
+                BABYLON.Matrix.LookAtLHToRef(BABYLON.Vector3.Zero(), this._referencePoint, this.upVector, this._lookAtTemp);
+                BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
 
-        this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
+                this._lookAtTemp.multiplyToRef(this._cameraRotationMatrix, this._tempMatrix);
+                this._lookAtTemp.invert();
+                this._tempMatrix.multiplyToRef(this._lookAtTemp, this._cameraRotationMatrix);
+            } else {
+                BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
+            }
 
-        BABYLON.Matrix.LookAtLHToRef(this.position, this._currentTarget, this._upVector, this._viewMatrix);
+            BABYLON.Vector3.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
 
+            // Computing target and final matrix
+            this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
+        } else {
+            if (this.lockedTarget.position) {
+                this._currentTarget.copyFrom(this.lockedTarget.position);
+            } else {
+                this._currentTarget.copyFrom(this.lockedTarget);
+            }
+        }
+        
+        BABYLON.Matrix.LookAtLHToRef(this.position, this._currentTarget, this.upVector, this._viewMatrix);
         return this._viewMatrix;
     };
 })();

+ 6 - 35
Babylon/Cameras/babylon.touchCamera.js

@@ -2,50 +2,21 @@
 
 (function () {
     BABYLON.TouchCamera = function (name, position, scene) {
-        this.name = name;
-        this.id = name;
-
-        this._scene = scene;
-        this.position = position;
-        scene.cameras.push(this);
-        this.cameraDirection = new BABYLON.Vector3(0, 0, 0);
-        this.cameraRotation = new BABYLON.Vector2(0, 0);
-        this.rotation = new BABYLON.Vector3(0, 0, 0);
-        this.ellipsoid = new BABYLON.Vector3(0.5, 1, 0.5);
-        this.angularSensibility = 200000.0;
-        this.moveSensibility = 500.0;
-
-        if (!scene.activeCamera) {
-            scene.activeCamera = this;
-        }
-        // Collisions
-        this._collider = new BABYLON.Collider();
-        this._needMoveForGravity = true;
-        
+        BABYLON.FreeCamera.call(this, name, position, scene);
+            
         // Offset
         this._offsetX = null;
         this._offsetY = null;
         this._pointerCount = 0;
         this._pointerPressed = [];
-        
-        // Animations
-        this.animations = [];
-        
-        // Internals
-        this._cameraRotationMatrix = new BABYLON.Matrix();
-        this._referencePoint = BABYLON.Vector3.Zero();
-        this._currentTarget = BABYLON.Vector3.Zero();
-        this._camMatrix = BABYLON.Matrix.Zero();
-        this._transformedReferencePoint = BABYLON.Vector3.Zero();
-        this._viewMatrix = BABYLON.Matrix.Zero();
-        this._upVector = BABYLON.Vector3.Up();
-        this._oldPosition = BABYLON.Vector3.Zero();
-        this._diffPosition = BABYLON.Vector3.Zero();
-        this._newPosition = BABYLON.Vector3.Zero();
     };
 
     BABYLON.TouchCamera.prototype = Object.create(BABYLON.FreeCamera.prototype);
 
+    BABYLON.TouchCamera.prototype.angularSensibility = 200000.0;
+    BABYLON.TouchCamera.prototype.moveSensibility = 500.0;
+
+
     // Controls
     BABYLON.TouchCamera.prototype.attachControl = function (canvas, noPreventDefault) {
         var previousPosition;

+ 17 - 9
Babylon/Collisions/babylon.collider.js

@@ -10,7 +10,6 @@
         this.normalizedVelocity = BABYLON.Vector3.Zero();
         
         // Internals
-        this._trianglePlane = new BABYLON.Plane(0, 0, 0, 0);
         this._collisionPoint = BABYLON.Vector3.Zero();
         this._planeIntersectionPoint = BABYLON.Vector3.Zero();
         this._tempVector = BABYLON.Vector3.Zero();
@@ -129,17 +128,26 @@
         return true;
     };
 
-    BABYLON.Collider.prototype._testTriangle = function (subMesh, p1, p2, p3) {
+    BABYLON.Collider.prototype._testTriangle = function (faceIndex, subMesh, p1, p2, p3) {
         var t0;
         var embeddedInPlane = false;
 
-        this._trianglePlane.copyFromPoints(p1, p2, p3);
+        if (!subMesh._trianglePlanes) {
+            subMesh._trianglePlanes = [];
+        }
+        
+        if (!subMesh._trianglePlanes[faceIndex]) {
+            subMesh._trianglePlanes[faceIndex] = new BABYLON.Plane(0, 0, 0, 0);
+            subMesh._trianglePlanes[faceIndex].copyFromPoints(p1, p2, p3);
+        }
+
+        var trianglePlane = subMesh._trianglePlanes[faceIndex];
 
-        if ((!subMesh.getMaterial()) && !this._trianglePlane.isFrontFacingTo(this.normalizedVelocity, 0))
+        if ((!subMesh.getMaterial()) && !trianglePlane.isFrontFacingTo(this.normalizedVelocity, 0))
             return;
 
-        var signedDistToTrianglePlane = this._trianglePlane.signedDistanceTo(this.basePoint);
-        var normalDotVelocity = BABYLON.Vector3.Dot(this._trianglePlane.normal, this.velocity);
+        var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this.basePoint);
+        var normalDotVelocity = BABYLON.Vector3.Dot(trianglePlane.normal, this.velocity);
 
         if (normalDotVelocity == 0) {
             if (Math.abs(signedDistToTrianglePlane) >= 1.0)
@@ -172,11 +180,11 @@
         var t = 1.0;
 
         if (!embeddedInPlane) {
-            this.basePoint.subtractToRef(this._trianglePlane.normal, this._planeIntersectionPoint);
+            this.basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
             this.velocity.scaleToRef(t0, this._tempVector);
             this._planeIntersectionPoint.addInPlace(this._tempVector);
 
-            if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, this._trianglePlane.normal)) {
+            if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
                 found = true;
                 t = t0;
                 this._collisionPoint.copyFrom(this._planeIntersectionPoint);
@@ -308,7 +316,7 @@
             var p2 = pts[indices[i + 1] - decal];
             var p3 = pts[indices[i + 2] - decal];
 
-            this._testTriangle(subMesh, p3, p2, p1);
+            this._testTriangle(i, subMesh, p3, p2, p1);
         }
     };
     

+ 11 - 8
Babylon/Lights/Shadows/babylon.shadowGenerator.js

@@ -70,10 +70,6 @@
             defines.push("#define VSM");
         }
         
-        if (BABYLON.Tools.isIE()) {
-            defines.push("#define IE");
-        }
-
         var attribs = [BABYLON.VertexBuffer.PositionKind];
         if (mesh.skeleton && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesIndicesKind) && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesWeightsKind)) {
             attribs.push(BABYLON.VertexBuffer.MatricesIndicesKind);
@@ -105,14 +101,21 @@
     
     // Methods
     BABYLON.ShadowGenerator.prototype.getTransformMatrix = function () {
-        if (!this._cachedPosition || !this._cachedDirection || !this._light.position.equals(this._cachedPosition) || !this._light.direction.equals(this._cachedDirection)) {
+        var lightPosition = this._light.position;
+        var lightDirection = this._light.direction;
+        
+        if (this._light._computeTransformedPosition()) {
+            lightPosition = this._light._transformedPosition;
+        }
+
+        if (!this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !lightDirection.equals(this._cachedDirection)) {
 
-            this._cachedPosition = this._light.position.clone();
-            this._cachedDirection = this._light.direction.clone();
+            this._cachedPosition = lightPosition.clone();
+            this._cachedDirection = lightDirection.clone();
 
             var activeCamera = this._scene.activeCamera;
 
-            BABYLON.Matrix.LookAtLHToRef(this._light.position, this._light.position.add(this._light.direction), BABYLON.Vector3.Up(), this._viewMatrix);
+            BABYLON.Matrix.LookAtLHToRef(lightPosition, this._light.position.add(lightDirection), BABYLON.Vector3.Up(), this._viewMatrix);
             BABYLON.Matrix.PerspectiveFovLHToRef(Math.PI / 2.0, 1.0, activeCamera.minZ, activeCamera.maxZ, this._projectionMatrix);
 
             this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);

+ 41 - 8
Babylon/Lights/babylon.directionalLight.js

@@ -2,19 +2,52 @@
 
 (function () {
     BABYLON.DirectionalLight = function (name, direction, scene) {
-        this.name = name;
-        this.id = name;
+        BABYLON.Light.call(this, name, scene);
+
         this.position = direction.scale(-1);
         this.direction = direction;
         this.diffuse = new BABYLON.Color3(1.0, 1.0, 1.0);
         this.specular = new BABYLON.Color3(1.0, 1.0, 1.0);
-        this._scene = scene;
-
-        scene.lights.push(this);
-        
-        // Animations
-        this.animations = [];
     };
     
     BABYLON.DirectionalLight.prototype = Object.create(BABYLON.Light.prototype);
+    
+    // Methods
+    BABYLON.DirectionalLight.prototype._computeTransformedPosition = function () {
+        if (this.parent && this.parent.getWorldMatrix) {
+            if (!this._transformedPosition) {
+                this._transformedPosition = BABYLON.Vector3.Zero();
+            }
+
+            BABYLON.Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this._transformedPosition);
+            return true;
+        }
+
+        return false;
+    };
+
+    BABYLON.DirectionalLight.prototype.transferToEffect = function (effect, directionUniformName) {
+        if (this.parent && this.parent.getWorldMatrix) {
+            if (!this._transformedDirection) {
+                this._transformedDirection = BABYLON.Vector3.Zero();
+            }
+
+            BABYLON.Vector3.TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this._transformedDirection);
+            effect.setFloat4(directionUniformName, this._transformedDirection.x, this._transformedDirection.y, this._transformedDirection.z, 1);
+
+            return;
+        }
+
+        effect.setFloat4(directionUniformName, this.direction.x, this.direction.y, this.direction.z, 1);
+    };
+    
+    BABYLON.DirectionalLight.prototype._getWorldMatrix = function () {
+        if (!this._worldMatrix) {
+            this._worldMatrix = BABYLON.Matrix.Identity();
+        }
+
+        BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
+
+        return this._worldMatrix;
+    };
 })();

+ 18 - 8
Babylon/Lights/babylon.hemisphericLight.js

@@ -2,23 +2,33 @@
 
 (function () {
     BABYLON.HemisphericLight = function (name, direction, scene) {
-        this.name = name;
-        this.id = name;
+        BABYLON.Light.call(this, name, scene);
+        
         this.direction = direction;
         this.diffuse = new BABYLON.Color3(1.0, 1.0, 1.0);
         this.specular = new BABYLON.Color3(1.0, 1.0, 1.0);
         this.groundColor = new BABYLON.Color3(0.0, 0.0, 0.0);
-        this._scene = scene;
-
-        scene.lights.push(this);
-
-        // Animations
-        this.animations = [];
     };
     
     BABYLON.HemisphericLight.prototype = Object.create(BABYLON.Light.prototype);
     
+    // Properties
     BABYLON.HemisphericLight.prototype.getShadowGenerator = function () {
         return null;
     };
+    
+    // Methods
+    BABYLON.HemisphericLight.prototype._getWorldMatrix = function () {
+        if (!this._worldMatrix) {
+            this._worldMatrix = BABYLON.Matrix.Identity();
+        }
+
+        return this._worldMatrix;
+    };
+
+    BABYLON.HemisphericLight.prototype.transferToEffect = function (effect, directionUniformName, groundColorUniformName) {
+        var normalizeDirection = BABYLON.Vector3.Normalize(this.direction);
+        effect.setFloat4(directionUniformName, normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0);
+        effect.setColor3(groundColorUniformName, this.groundColor.scale(this.intensity));
+    };
 })();

+ 24 - 1
Babylon/Lights/babylon.light.js

@@ -8,11 +8,15 @@
         this._scene = scene;
 
         scene.lights.push(this);
+        
+        // Animations
+        this.animations = [];
     };
     
+    BABYLON.Light.prototype = Object.create(BABYLON.Node.prototype);
+    
     // Members
     BABYLON.Light.prototype.intensity = 1.0;
-    BABYLON.Light.prototype.isEnabled = true;
     
     // Properties
     BABYLON.Light.prototype.getScene = function () {
@@ -24,6 +28,25 @@
     };
 
     // Methods
+    BABYLON.Light.prototype.transferToEffect = function() {
+    };
+
+    BABYLON.Light.prototype.getWorldMatrix = function() {
+        var worldMatrix = this._getWorldMatrix();
+
+        if (this.parent && this.parent.getWorldMatrix) {
+            if (!this._parentedWorldMatrix) {
+                this._parentedWorldMatrix = BABYLON.Matrix.Identity();
+            }
+
+            worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._parentedWorldMatrix);
+
+            return this._parentedWorldMatrix;
+        }
+
+        return worldMatrix;
+    };
+
     BABYLON.Light.prototype.dispose = function () {
         if (this._shadowGenerator) {
             this._shadowGenerator.dispose();

+ 28 - 8
Babylon/Lights/babylon.pointLight.js

@@ -2,22 +2,42 @@
 
 (function () {
     BABYLON.PointLight = function (name, position, scene) {
-        this.name = name;
-        this.id = name;
+        BABYLON.Light.call(this, name, scene);
+        
         this.position = position;
         this.diffuse = new BABYLON.Color3(1.0, 1.0, 1.0);
         this.specular = new BABYLON.Color3(1.0, 1.0, 1.0);
-        this._scene = scene;
-
-        scene.lights.push(this);
-
-        // Animations
-        this.animations = [];
     };
     
     BABYLON.PointLight.prototype = Object.create(BABYLON.Light.prototype);
     
+    // Methods
+    BABYLON.Light.prototype.transferToEffect = function (effect, positionUniformName) {
+        if (this.parent && this.parent.getWorldMatrix) {
+            if (!this._transformedPosition) {
+                this._transformedPosition = BABYLON.Vector3.Zero();
+            }
+
+            BABYLON.Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this._transformedPosition);
+            effect.setFloat4(positionUniformName, this._transformedPosition.x, this._transformedPosition.y, this._transformedPosition.z, 0);
+
+            return;
+        }
+
+        effect.setFloat4(positionUniformName, this.position.x, this.position.y, this.position.z, 0);
+    };
+
     BABYLON.PointLight.prototype.getShadowGenerator = function () {
         return null;
     };
+    
+    BABYLON.PointLight.prototype._getWorldMatrix = function () {
+        if (!this._worldMatrix) {
+            this._worldMatrix = BABYLON.Matrix.Identity();
+        }
+
+        BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
+
+        return this._worldMatrix;
+    };
 })();

+ 39 - 8
Babylon/Lights/babylon.spotLight.js

@@ -2,21 +2,52 @@
 
 (function () {
     BABYLON.SpotLight = function (name, position, direction, angle, exponent, scene) {
-        this.name = name;
-        this.id = name;
+        BABYLON.Light.call(this, name, scene);
+        
         this.position = position;
         this.direction = direction;
         this.angle = angle;
         this.exponent = exponent;
         this.diffuse = new BABYLON.Color3(1.0, 1.0, 1.0);
         this.specular = new BABYLON.Color3(1.0, 1.0, 1.0);
-        this._scene = scene;
-
-        scene.lights.push(this);
-
-        // Animations
-        this.animations = [];
     };
     
     BABYLON.SpotLight.prototype = Object.create(BABYLON.Light.prototype);
+    
+    // Methods
+    BABYLON.SpotLight.prototype.transferToEffect = function (effect, positionUniformName, directionUniformName) {
+        var normalizeDirection;
+        
+        if (this.parent && this.parent.getWorldMatrix) {
+            if (!this._transformedDirection) {
+                this._transformedDirection = BABYLON.Vector3.Zero();
+            }
+            if (!this._transformedPosition) {
+                this._transformedPosition = BABYLON.Vector3.Zero();
+            }
+            
+            var parentWorldMatrix = this.parent.getWorldMatrix();
+
+            BABYLON.Vector3.TransformCoordinatesToRef(this.position, parentWorldMatrix, this._transformedPosition);
+            BABYLON.Vector3.TransformNormalToRef(this.direction, parentWorldMatrix, this._transformedDirection);
+
+            effect.setFloat4(positionUniformName, this._transformedPosition.x, this._transformedPosition.y, this._transformedPosition.z, this.exponent);
+            normalizeDirection = BABYLON.Vector3.Normalize(this._transformedDirection);
+        } else {
+            effect.setFloat4(positionUniformName, this.position.x, this.position.y, this.position.z, this.exponent);
+            normalizeDirection = BABYLON.Vector3.Normalize(this.direction);
+        }
+
+        effect.setFloat4(directionUniformName, normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, Math.cos(this.angle * 0.5));
+    };
+
+    BABYLON.SpotLight.prototype._getWorldMatrix = function () {
+        if (!this._worldMatrix) {
+            this._worldMatrix = BABYLON.Matrix.Identity();
+        }
+
+        BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
+
+        return this._worldMatrix;
+    };
 })();

+ 12 - 5
Babylon/Materials/babylon.effect.js

@@ -2,7 +2,7 @@
 
 (function () {
 
-    BABYLON.Effect = function (baseName, attributesNames, uniformsNames, samplers, engine, defines) {
+    BABYLON.Effect = function (baseName, attributesNames, uniformsNames, samplers, engine, defines, optionalDefines) {
         this._engine = engine;
         this.name = baseName;
         this.defines = defines;
@@ -16,7 +16,7 @@
 
         // Is in local store ?
         if (BABYLON.Effect.ShadersStore[baseName + "VertexShader"]) {
-            this._prepareEffect(BABYLON.Effect.ShadersStore[baseName + "VertexShader"], BABYLON.Effect.ShadersStore[baseName + "PixelShader"], attributesNames, defines);
+            this._prepareEffect(BABYLON.Effect.ShadersStore[baseName + "VertexShader"], BABYLON.Effect.ShadersStore[baseName + "PixelShader"], attributesNames, defines, optionalDefines);
         } else {
             var shaderUrl;
 
@@ -32,7 +32,7 @@
                     // Fragment shader
                     BABYLON.Tools.LoadFile(shaderUrl + ".fragment.fx",
                         function (fragmentSourceCode) {
-                            that._prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines);
+                            that._prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, optionalDefines);
                         });
                 }
             );
@@ -80,7 +80,7 @@
     };
 
     // Methods
-    BABYLON.Effect.prototype._prepareEffect = function (vertexSourceCode, fragmentSourceCode, attributesNames, defines) {
+    BABYLON.Effect.prototype._prepareEffect = function (vertexSourceCode, fragmentSourceCode, attributesNames, defines, optionalDefines, useFallback) {
         try {
             var engine = this._engine;
             this._program = engine.createShaderProgram(vertexSourceCode, fragmentSourceCode, defines);
@@ -101,7 +101,14 @@
 
             this._isReady = true;
         } catch (e) {
-            this._compilationError = e.message;
+            if (!useFallback && optionalDefines) {
+                for (var index = 0; index < optionalDefines.length; index++) {
+                    defines = defines.replace(optionalDefines[index], "");
+                }
+                this._prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, optionalDefines, true);
+            } else {
+                this._compilationError = e.message;
+            }
         }
     };
 

+ 39 - 27
Babylon/Materials/babylon.standardMaterial.js

@@ -2,11 +2,7 @@
 
 (function () {
     BABYLON.StandardMaterial = function (name, scene) {
-        this.name = name;
-        this.id = name;
-
-        this._scene = scene;
-        scene.materials.push(this);
+        BABYLON.Material.call(this, name, scene);
 
         this.diffuseTexture = null;
         this.ambientTexture = null;
@@ -47,7 +43,7 @@
     };
 
     // Methods   
-    BABYLON.StandardMaterial.prototype.isReady = function (mesh, required) {
+    BABYLON.StandardMaterial.prototype.isReady = function (mesh) {
         if (!this.checkReadyOnEveryCall) {
             if (this._renderId === this._scene.getRenderId()) {
                 return true;
@@ -56,10 +52,11 @@
 
         var engine = this._scene.getEngine();
         var defines = [];
+        var optionalDefines = [];
 
         // Textures
         if (this.diffuseTexture) {
-            if (!this.diffuseTexture.isReady(required)) {
+            if (!this.diffuseTexture.isReady()) {
                 return false;
             } else {
                 defines.push("#define DIFFUSE");
@@ -67,7 +64,7 @@
         }
 
         if (this.ambientTexture) {
-            if (!this.ambientTexture.isReady(required)) {
+            if (!this.ambientTexture.isReady()) {
                 return false;
             } else {
                 defines.push("#define AMBIENT");
@@ -75,7 +72,7 @@
         }
 
         if (this.opacityTexture) {
-            if (!this.opacityTexture.isReady(required)) {
+            if (!this.opacityTexture.isReady()) {
                 return false;
             } else {
                 defines.push("#define OPACITY");
@@ -83,7 +80,7 @@
         }
 
         if (this.reflectionTexture) {
-            if (!this.reflectionTexture.isReady(required)) {
+            if (!this.reflectionTexture.isReady()) {
                 return false;
             } else {
                 defines.push("#define REFLECTION");
@@ -91,7 +88,7 @@
         }
 
         if (this.emissiveTexture) {
-            if (!this.emissiveTexture.isReady(required)) {
+            if (!this.emissiveTexture.isReady()) {
                 return false;
             } else {
                 defines.push("#define EMISSIVE");
@@ -99,7 +96,7 @@
         }
 
         if (this.specularTexture) {
-            if (!this.specularTexture.isReady(required)) {
+            if (!this.specularTexture.isReady()) {
                 return false;
             } else {
                 defines.push("#define SPECULAR");
@@ -107,7 +104,7 @@
         }
 
         if (this._scene.getEngine().getCaps().standardDerivatives && this.bumpTexture) {
-            if (!this.bumpTexture.isReady(required)) {
+            if (!this.bumpTexture.isReady()) {
                 return false;
             } else {
                 defines.push("#define BUMP");
@@ -133,18 +130,28 @@
         for (var index = 0; index < this._scene.lights.length; index++) {
             var light = this._scene.lights[index];
 
-            if (!light.isEnabled) {
+            if (!light.isEnabled()) {
                 continue;
             }
 
             defines.push("#define LIGHT" + lightIndex);
+            
+            if (lightIndex > 0) {
+                optionalDefines.push(defines[defines.length - 1]);
+            }
 
+            var type;
             if (light instanceof BABYLON.SpotLight) {
-                defines.push("#define SPOTLIGHT" + lightIndex);
+                type = "#define SPOTLIGHT" + lightIndex;
             } else if (light instanceof BABYLON.HemisphericLight) {
-                defines.push("#define HEMILIGHT" + lightIndex);
+                type = "#define HEMILIGHT" + lightIndex;
             } else {
-                defines.push("#define POINTDIRLIGHT" + lightIndex);
+                type = "#define POINTDIRLIGHT" + lightIndex;
+            }
+            
+            defines.push(type);
+            if (lightIndex > 0) {
+                optionalDefines.push(defines[defines.length - 1]);
             }
 
             // Shadows
@@ -152,6 +159,10 @@
             if (mesh && mesh.receiveShadows && shadowGenerator) {
                 defines.push("#define SHADOW" + lightIndex);
 
+                if (lightIndex > 0) {
+                    optionalDefines.push(defines[defines.length - 1]);
+                }
+
                 if (!shadowsActivated) {
                     defines.push("#define SHADOWS");
                     shadowsActivated = true;
@@ -159,6 +170,9 @@
 
                 if (shadowGenerator.useVarianceShadowMap) {
                     defines.push("#define SHADOWVSM" + lightIndex);
+                    if (lightIndex > 0) {
+                        optionalDefines.push(defines[defines.length - 1]);
+                    }
                 }
             }
 
@@ -186,6 +200,8 @@
                 attribs.push(BABYLON.VertexBuffer.MatricesWeightsKind);
                 defines.push("#define BONES");
                 defines.push("#define BonesPerMesh " + mesh.skeleton.bones.length);
+                defines.push("#define BONES4");
+                optionalDefines.push(defines[defines.length - 1]);
             }
         }
 
@@ -214,7 +230,7 @@
                 ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler",
                  "shadowSampler0", "shadowSampler1", "shadowSampler2", "shadowSampler3"
                 ],
-                join);
+                join, optionalDefines);
         }
         if (!this._effect.isReady()) {
             return false;
@@ -325,26 +341,22 @@
         for (var index = 0; index < this._scene.lights.length; index++) {
             var light = this._scene.lights[index];
 
-            if (!light.isEnabled) {
+            if (!light.isEnabled()) {
                 continue;
             }
 
             if (light instanceof BABYLON.PointLight) {
                 // Point Light
-                this._effect.setFloat4("vLightData" + lightIndex, light.position.x, light.position.y, light.position.z, 0);
+                light.transferToEffect(this._effect, "vLightData" + lightIndex);
             } else if (light instanceof BABYLON.DirectionalLight) {
                 // Directional Light
-                this._effect.setFloat4("vLightData" + lightIndex, light.direction.x, light.direction.y, light.direction.z, 1);
+                light.transferToEffect(this._effect, "vLightData" + lightIndex);
             } else if (light instanceof BABYLON.SpotLight) {
                 // Spot Light
-                this._effect.setFloat4("vLightData" + lightIndex, light.position.x, light.position.y, light.position.z, light.exponent);
-                var normalizeDirection = BABYLON.Vector3.Normalize(light.direction);
-                this._effect.setFloat4("vLightDirection" + lightIndex, normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, Math.cos(light.angle * 0.5));
+                light.transferToEffect(this._effect, "vLightData" + lightIndex, "vLightDirection" + lightIndex);
             } else if (light instanceof BABYLON.HemisphericLight) {
                 // Hemispheric Light
-                var normalizeDirection = BABYLON.Vector3.Normalize(light.direction);
-                this._effect.setFloat4("vLightData" + lightIndex, normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0);
-                this._effect.setColor3("vLightGround" + lightIndex, light.groundColor.scale(light.intensity));
+                light.transferToEffect(this._effect, "vLightData" + lightIndex, "vLightGround" + lightIndex);
             }
 
             light.diffuse.scaleToRef(light.intensity, this._scaledDiffuse);

+ 2 - 2
Babylon/Materials/textures/babylon.baseTexture.js

@@ -20,8 +20,8 @@
         return this._texture;
     };
 
-    BABYLON.BaseTexture.prototype.isReady = function (required) {
-        if (!required && this.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_NOTLOADED) {
+    BABYLON.BaseTexture.prototype.isReady = function () {
+        if (this.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_NOTLOADED) {
             return true;
         }
 

+ 15 - 54
Babylon/Mesh/babylon.mesh.js

@@ -52,6 +52,8 @@
         this._collisionsTransformMatrix = BABYLON.Matrix.Zero();
         this._collisionsScalingMatrix = BABYLON.Matrix.Zero();
     };
+    
+    BABYLON.Mesh.prototype = Object.create(BABYLON.Node.prototype);
 
     // Constants
     BABYLON.Mesh.BILLBOARDMODE_NONE = 0;
@@ -63,9 +65,6 @@
     // Members    
     BABYLON.Mesh.prototype.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NONE;
     BABYLON.Mesh.prototype.material = null;
-    BABYLON.Mesh.prototype.parent = null;
-    BABYLON.Mesh.prototype._isReady = true;
-    BABYLON.Mesh.prototype._isEnabled = true;
     BABYLON.Mesh.prototype.isVisible = true;
     BABYLON.Mesh.prototype.isPickable = true;
     BABYLON.Mesh.prototype.visibility = 1.0;
@@ -122,10 +121,6 @@
         return this._vertexStrideSize;
     };
 
-    BABYLON.Mesh.prototype._needToSynchonizeChildren = function () {
-        return this._childrenFlag;
-    };
-
     BABYLON.Mesh.prototype.setPivotMatrix = function (matrix) {
         this._pivotMatrix = matrix;
         this._cache.pivotMatrixUpdated = true;
@@ -167,22 +162,6 @@
         return this._isReady;
     };
 
-    BABYLON.Mesh.prototype.isEnabled = function () {
-        if (!this.isReady() || !this._isEnabled) {
-            return false;
-        }
-
-        if (this.parent) {
-            return this.parent.isEnabled();
-        }
-
-        return true;
-    };
-
-    BABYLON.Mesh.prototype.setEnabled = function (value) {
-        this._isEnabled = value;
-    };
-
     BABYLON.Mesh.prototype.isAnimated = function () {
         return this._animationStarted;
     };
@@ -220,7 +199,7 @@
             this._scaleFactor = Math.max(this.scaling.x, this.scaling.y);
             this._scaleFactor = Math.max(this._scaleFactor, this.scaling.z);
 
-            if (this.parent)
+            if (this.parent && this.parent._scaleFactor)
                 this._scaleFactor = this._scaleFactor * this.parent._scaleFactor;
 
             this._boundingInfo._update(this._worldMatrix, this._scaleFactor);
@@ -234,7 +213,7 @@
     };
 
     BABYLON.Mesh.prototype.computeWorldMatrix = function (force) {
-        if (!force && this.isSynchronized()) {
+        if (this._currentRenderId == this._scene.getRenderId() || !force && this.isSynchronized()) {
             this._childrenFlag = false;
             return this._worldMatrix;
         }
@@ -243,6 +222,7 @@
         this._cache.position.copyFrom(this.position);
         this._cache.scaling.copyFrom(this.scaling);
         this._cache.pivotMatrixUpdated = false;
+        this._currentRenderId = this._scene.getRenderId();
 
         // Scaling
         BABYLON.Matrix.ScalingToRef(this.scaling.x, this.scaling.y, this.scaling.z, this._localScaling);
@@ -268,7 +248,7 @@
             var localPosition = this.position.clone();
             var zero = this._scene.activeCamera.position.clone();
 
-            if (this.parent) {
+            if (this.parent && this.parent.position) {
                 localPosition.addInPlace(this.parent.position);
                 BABYLON.Matrix.TranslationToRef(localPosition.x, localPosition.y, localPosition.z, this._localTranslation);
             }
@@ -294,7 +274,7 @@
         }
 
         // Parent
-        if (this.parent && this.billboardMode === BABYLON.Mesh.BILLBOARDMODE_NONE) {
+        if (this.parent && this.parent.getWorldMatrix && this.billboardMode === BABYLON.Mesh.BILLBOARDMODE_NONE) {
             this._localPivotScalingRotation.multiplyToRef(this._localTranslation, this._localWorld);
             var parentWorld = this.parent.getWorldMatrix();
 
@@ -435,29 +415,6 @@
         effectiveMaterial.unbind();
     };
 
-    BABYLON.Mesh.prototype.isDescendantOf = function (ancestor) {
-        if (this.parent) {
-            if (this.parent === ancestor) {
-                return true;
-            }
-
-            return this.parent.isDescendantOf(ancestor);
-        }
-        return false;
-    };
-
-    BABYLON.Mesh.prototype.getDescendants = function () {
-        var results = [];
-        for (var index = 0; index < this._scene.meshes.length; index++) {
-            var mesh = this._scene.meshes[index];
-            if (mesh.isDescendantOf(this)) {
-                results.push(mesh);
-            }
-        }
-
-        return results;
-    };
-
     BABYLON.Mesh.prototype.getEmittedParticleSystems = function () {
         var results = [];
         for (var index = 0; index < this._scene.particleSystems.length; index++) {
@@ -671,8 +628,8 @@
     };
 
     // Picking
-    BABYLON.Mesh.prototype.intersects = function (ray) {
-        if (!this._boundingInfo || !ray.intersectsSphere(this._boundingInfo.boundingSphere)) {
+    BABYLON.Mesh.prototype.intersects = function (ray, fastCheck) {
+        if (!this._boundingInfo || !ray.intersectsSphere(this._boundingInfo.boundingSphere) || !ray.intersectsBox(this._boundingInfo.boundingBox)) {
             return { hit: false, distance: 0 };
         }
 
@@ -687,11 +644,15 @@
             if (this.subMeshes.length > 1 && !subMesh.canIntersects(ray))
                 continue;
 
-            var result = subMesh.intersects(ray, this._positions, this._indices);
+            var result = subMesh.intersects(ray, this._positions, this._indices, fastCheck);
 
             if (result.hit) {
-                if (result.distance < distance && result.distance >= 0) {
+                if ((fastCheck || result.distance < distance) && result.distance >= 0) {
                     distance = result.distance;
+
+                    if (fastCheck) {
+                        break;
+                    }
                 }
             }
         }

+ 6 - 2
Babylon/Mesh/babylon.subMesh.js

@@ -84,7 +84,7 @@
         return ray.intersectsBox(this._boundingInfo.boundingBox);
     };
 
-    BABYLON.SubMesh.prototype.intersects = function (ray, positions, indices) {
+    BABYLON.SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck) {
         var distance = Number.MAX_VALUE;
         
         // Triangles test
@@ -96,8 +96,12 @@
             var result = ray.intersectsTriangle(p0, p1, p2);
 
             if (result.hit) {
-                if (result.distance < distance && result.distance >= 0) {
+                if ((fastCheck || result.distance < distance) && result.distance >= 0) {
                     distance = result.distance;
+
+                    if (fastCheck) {
+                        break;
+                    }
                 }
             }
         }

+ 2 - 2
Babylon/Rendering/babylon.renderingGroup.js

@@ -4,7 +4,7 @@
     BABYLON.RenderingGroup = function (index, scene) {
         this.index = index;
         this._scene = scene;
-        
+
         this._opaqueSubMeshes = new BABYLON.Tools.SmartArray(256);
         this._transparentSubMeshes = new BABYLON.Tools.SmartArray(256);
         this._alphaTestSubMeshes = new BABYLON.Tools.SmartArray(256);
@@ -16,7 +16,7 @@
             customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, beforeTransparents);
             return true;
         }
-        
+
         if (this._opaqueSubMeshes.length === 0 && this._alphaTestSubMeshes.length === 0 && this._transparentSubMeshes === 0) {
             return false;
         }

+ 1 - 1
Babylon/Rendering/babylon.renderingManager.js

@@ -45,7 +45,7 @@
                 spriteManager.render();
             }
         }
-        this._scene._spritesDuration = new Date() - beforeSpritessDate;
+        this._scene._spritesDuration += new Date() - beforeSpritessDate;
     };
 
     BABYLON.RenderingManager.prototype._clearDepthBuffer = function () {

+ 6 - 1
Babylon/Shaders/default.vertex.fx

@@ -159,9 +159,14 @@ void main(void) {
 	mat4 m0 = mBones[int(matricesIndices.x)] * matricesWeights.x;
 	mat4 m1 = mBones[int(matricesIndices.y)] * matricesWeights.y;
 	mat4 m2 = mBones[int(matricesIndices.z)] * matricesWeights.z;
-	mat4 m3 = mBones[int(matricesIndices.w)] * matricesWeights.w;
 
+#ifdef BONES4
+	mat4 m3 = mBones[int(matricesIndices.w)] * matricesWeights.w;
 	finalWorld = world * (m0 + m1 + m2 + m3);
+#else
+	finalWorld = world * (m0 + m1 + m2);
+#endif 
+
 	gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
 #else
 	finalWorld = world;

+ 253 - 66
Babylon/Shaders/iedefault.fragment.fx

@@ -11,6 +11,14 @@ uniform vec4 vDiffuseColor;
 uniform vec4 vSpecularColor;
 uniform vec3 vEmissiveColor;
 
+// Input
+varying vec3 vPositionW;
+varying vec3 vNormalW;
+
+#ifdef VERTEXCOLOR
+varying vec3 vColor;
+#endif
+
 // Lights
 #ifdef LIGHT0
 uniform vec4 vLightData0;
@@ -20,19 +28,61 @@ uniform vec3 vLightSpecular0;
 varying vec4 vPositionFromLight0;
 uniform sampler2D shadowSampler0;
 #endif
+#ifdef SPOTLIGHT0
+uniform vec4 vLightDirection0;
+#endif
+#ifdef HEMILIGHT0
+uniform vec3 vLightGround0;
+#endif
 #endif
 
-//#ifdef LIGHT1
-//uniform vec4 vLightData1;
-//uniform vec3 vLightDiffuse1;
-//uniform vec3 vLightSpecular1;
-//#endif
+#ifdef LIGHT1
+uniform vec4 vLightData1;
+uniform vec3 vLightDiffuse1;
+uniform vec3 vLightSpecular1;
+#ifdef SHADOW1
+varying vec4 vPositionFromLight1;
+uniform sampler2D shadowSampler1;
+#endif
+#ifdef SPOTLIGHT1
+uniform vec4 vLightDirection1;
+#endif
+#ifdef HEMILIGHT1
+uniform vec3 vLightGround1;
+#endif
+#endif
+
+#ifdef LIGHT2
+uniform vec4 vLightData2;
+uniform vec3 vLightDiffuse2;
+uniform vec3 vLightSpecular2;
+#ifdef SHADOW2
+varying vec4 vPositionFromLight2;
+uniform sampler2D shadowSampler2;
+#endif
+#ifdef SPOTLIGHT2
+uniform vec4 vLightDirection2;
+#endif
+#ifdef HEMILIGHT2
+uniform vec3 vLightGround2;
+#endif
+#endif
 
-//#ifdef LIGHT2
-//uniform vec4 vLightData2;
-//uniform vec3 vLightDiffuse2;
-//uniform vec3 vLightSpecular2;
-//#endif
+#ifdef LIGHT3
+uniform vec4 vLightData3;
+uniform vec3 vLightDiffuse3;
+uniform vec3 vLightSpecular3;
+#ifdef SHADOW3
+varying vec4 vPositionFromLight3;
+uniform sampler2D shadowSampler3;
+#endif
+#ifdef SPOTLIGHT3
+uniform vec4 vLightDirection3;
+#endif
+#ifdef HEMILIGHT3
+uniform vec3 vLightGround3;
+#endif
+#endif
 
 // Samplers
 #ifdef DIFFUSE
@@ -72,14 +122,6 @@ uniform vec2 vSpecularInfos;
 uniform sampler2D specularSampler;
 #endif
 
-// Input
-varying vec3 vPositionW;
-varying vec3 vNormalW;
-
-#ifdef CLIPPLANE
-varying float fClipDistance;
-#endif
-
 // Shadows
 #ifdef SHADOWS
 
@@ -94,6 +136,25 @@ float unpackHalf(vec2 color)
 	return color.x + (color.y / 255.0);
 }
 
+float computeShadow(vec4 vPositionFromLight, sampler2D shadowSampler)
+{
+	vec3 depth = vPositionFromLight.xyz / vPositionFromLight.w;
+	vec2 uv = 0.5 * depth.xy + vec2(0.5, 0.5);
+
+	if (uv.x < 0. || uv.x > 1.0 || uv.y < 0. || uv.y > 1.0)
+	{
+		return 1.0;
+	}
+
+	float shadow = unpack(texture2D(shadowSampler, uv));
+
+	if (depth.z > shadow)
+	{
+		return 0.;
+	}
+	return 1.;
+}
+
 // Thanks to http://devmaster.net/
 float ChebychevInequality(vec2 moments, float t)
 {
@@ -109,6 +170,25 @@ float ChebychevInequality(vec2 moments, float t)
 	return variance / (variance + d * d);
 }
 
+float computeShadowWithVSM(vec4 vPositionFromLight, sampler2D shadowSampler)
+{
+	vec3 depth = vPositionFromLight.xyz / vPositionFromLight.w;
+	vec2 uv = 0.5 * depth.xy + vec2(0.5, 0.5);
+
+	if (uv.x < 0. || uv.x > 1.0 || uv.y < 0. || uv.y > 1.0)
+	{
+		return 1.0;
+	}
+
+	vec4 texel = texture2D(shadowSampler, uv);
+
+	vec2 moments = vec2(unpackHalf(texel.xy), unpackHalf(texel.zw));
+	return clamp(1.3 - ChebychevInequality(moments, depth.z), 0., 1.0);
+}
+#endif
+
+#ifdef CLIPPLANE
+varying float fClipDistance;
 #endif
 
 // Fog
@@ -146,10 +226,12 @@ float CalcFogFactor()
 
 	return clamp(fogCoeff, 0.0, 1.0);
 }
-
 #endif
 
-vec3 computeDiffuseLighting(vec3 vNormal, vec4 lightData, vec3 diffuseColor) {
+// Light Computing
+mat3 computeLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec3 diffuseColor, vec3 specularColor) {
+	mat3 result;
+
 	vec3 lightVectorW;
 	if (lightData.w == 0.)
 	{
@@ -163,26 +245,70 @@ vec3 computeDiffuseLighting(vec3 vNormal, vec4 lightData, vec3 diffuseColor) {
 	// diffuse
 	float ndl = max(0., dot(vNormal, lightVectorW));
 
-	return ndl * diffuseColor;
+	// Specular
+	vec3 angleW = normalize(viewDirectionW + lightVectorW);
+	float specComp = max(0., dot(vNormal, angleW));
+	specComp = max(0., pow(specComp, max(1.0, vSpecularColor.a)));
+
+	result[0] = ndl * diffuseColor;
+	result[1] = specComp * specularColor;
+	result[2] = vec3(0.);
+
+	return result;
 }
 
-vec3 computeSpecularLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec3 specularColor) {
-	vec3 lightVectorW;
-	if (lightData.w == 0.)
-	{
-		lightVectorW = normalize(lightData.xyz - vPositionW);
-	}
-	else
+mat3 computeSpotLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec4 lightDirection, vec3 diffuseColor, vec3 specularColor) {
+	mat3 result;
+
+	vec3 lightVectorW = normalize(lightData.xyz - vPositionW);
+
+	// diffuse
+	float cosAngle = max(0., dot(-lightDirection.xyz, lightVectorW));
+	float spotAtten = 0.0;
+
+	if (cosAngle >= lightDirection.w)
 	{
-		lightVectorW = normalize(-lightData.xyz);
+		cosAngle = max(0., pow(cosAngle, lightData.w));
+		spotAtten = max(0., (cosAngle - lightDirection.w) / (1. - cosAngle));
+
+		// Diffuse
+		float ndl = max(0., dot(vNormal, -lightDirection.xyz));
+
+		// Specular
+		vec3 angleW = normalize(viewDirectionW - lightDirection.xyz);
+		float specComp = max(0., dot(vNormal, angleW));
+		specComp = pow(specComp, vSpecularColor.a);
+
+		result[0] = ndl * spotAtten * diffuseColor;
+		result[1] = specComp * specularColor * spotAtten;
+		result[2] = vec3(0.);
+
+		return result;
 	}
 
+	result[0] = vec3(0.);
+	result[1] = vec3(0.);
+	result[2] = vec3(0.);
+
+	return result;
+}
+
+mat3 computeHemisphericLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec3 diffuseColor, vec3 specularColor, vec3 groundColor) {
+	mat3 result;
+
+	// Diffuse
+	float ndl = dot(vNormal, lightData.xyz) * 0.5 + 0.5;
+
 	// Specular
-	vec3 angleW = normalize(viewDirectionW + lightVectorW);
+	vec3 angleW = normalize(viewDirectionW + lightData.xyz);
 	float specComp = max(0., dot(vNormal, angleW));
 	specComp = pow(specComp, vSpecularColor.a);
 
-	return specComp * specularColor;
+	result[0] = mix(groundColor, diffuseColor, ndl);
+	result[1] = specComp * specularColor;
+	result[2] = vec3(0.);
+
+	return result;
 }
 
 void main(void) {
@@ -198,6 +324,10 @@ void main(void) {
 	vec4 baseColor = vec4(1., 1., 1., 1.);
 	vec3 diffuseColor = vDiffuseColor.rgb;
 
+#ifdef VERTEXCOLOR
+	diffuseColor *= vColor;
+#endif
+
 #ifdef DIFFUSE
 	baseColor = texture2D(diffuseSampler, vDiffuseUV);
 
@@ -222,42 +352,99 @@ void main(void) {
 	// Lighting
 	vec3 diffuseBase = vec3(0., 0., 0.);
 	vec3 specularBase = vec3(0., 0., 0.);
-	float shadow = 1.0;
+	float shadow = 1.;
 
 #ifdef LIGHT0
-	#ifdef SHADOW0
-		vec3 depth = vPositionFromLight0.xyz / vPositionFromLight0.w;
-		vec2 uv = 0.5 * depth.xy + vec2(0.5, 0.5);
-	
-		if (uv.x >= 0. && uv.x <= 1.0 && uv.y >= 0. && uv.y <= 1.0)
-		{
-		#ifdef SHADOWVSM0
-			vec4 texel = texture2D(shadowSampler0, uv);
-
-			vec2 moments = vec2(unpackHalf(texel.xy), unpackHalf(texel.zw));
-			shadow = clamp(1.3 - ChebychevInequality(moments, depth.z), 0., 1.0);
-		#else
-			float shadowDepth = unpack(texture2D(shadowSampler0, uv));
-
-			if (depth.z > shadowDepth)
-			{
-				shadow = 0.;
-			}
-		#endif
-		}
-	#endif
-	diffuseBase += computeDiffuseLighting(normalW, vLightData0, vLightDiffuse0) * shadow;
-	specularBase += computeSpecularLighting(viewDirectionW, normalW, vLightData0, vLightSpecular0) * shadow;
+#ifdef SPOTLIGHT0
+	mat3 info = computeSpotLighting(viewDirectionW, normalW, vLightData0, vLightDirection0, vLightDiffuse0, vLightSpecular0);
+#endif
+#ifdef HEMILIGHT0
+	mat3 info = computeHemisphericLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0, vLightSpecular0, vLightGround0);
+#endif
+#ifdef POINTDIRLIGHT0
+	mat3 info = computeLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0, vLightSpecular0);
+#endif
+#ifdef SHADOW0
+#ifdef SHADOWVSM0
+	shadow = computeShadowWithVSM(vPositionFromLight0, shadowSampler0);
+#else
+	shadow = computeShadow(vPositionFromLight0, shadowSampler0);
+#endif
+#else
+	shadow = 1.;
+#endif
+	diffuseBase += info[0] * shadow;
+	specularBase += info[1] * shadow;
 #endif
-//#ifdef LIGHT1
-//	diffuseBase += computeDiffuseLighting(normalW, vLightData1, vLightDiffuse1);
-//	specularBase += computeSpecularLighting(viewDirectionW, normalW, vLightData1, vLightSpecular1);
-//#endif
-//#ifdef LIGHT2
-//	diffuseBase += computeDiffuseLighting(normalW, vLightData2, vLightDiffuse2);
-//	specularBase += computeSpecularLighting(viewDirectionW, normalW, vLightData2, vLightSpecular2);
-//#endif
 
+#ifdef LIGHT1
+#ifdef SPOTLIGHT1
+	info = computeSpotLighting(viewDirectionW, normalW, vLightData1, vLightDirection1, vLightDiffuse1, vLightSpecular1);
+#endif
+#ifdef HEMILIGHT1
+	info = computeHemisphericLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1, vLightSpecular1, vLightGround1);
+#endif
+#ifdef POINTDIRLIGHT1
+	info = computeLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1, vLightSpecular1);
+#endif
+#ifdef SHADOW1
+#ifdef SHADOWVSM1
+	shadow = computeShadowWithVSM(vPositionFromLight1, shadowSampler1);
+#else
+	shadow = computeShadow(vPositionFromLight1, shadowSampler1);
+#endif
+#else
+	shadow = 1.;
+#endif
+	diffuseBase += info[0] * shadow;
+	specularBase += info[1] * shadow;
+#endif
+
+#ifdef LIGHT2
+#ifdef SPOTLIGHT2
+	info = computeSpotLighting(viewDirectionW, normalW, vLightData2, vLightDirection2, vLightDiffuse2, vLightSpecular2);
+#endif
+#ifdef HEMILIGHT2
+	info = computeHemisphericLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2, vLightSpecular2, vLightGround2);
+#endif
+#ifdef POINTDIRLIGHT2
+	info = computeLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2, vLightSpecular2);
+#endif
+#ifdef SHADOW2
+#ifdef SHADOWVSM2
+	shadow = computeShadowWithVSM(vPositionFromLight2, shadowSampler2);
+#else
+	shadow = computeShadow(vPositionFromLight2, shadowSampler2);
+#endif	
+#else
+	shadow = 1.;
+#endif
+	diffuseBase += info[0] * shadow;
+	specularBase += info[1] * shadow;
+#endif
+
+#ifdef LIGHT3
+#ifdef SPOTLIGHT3
+	info = computeSpotLighting(viewDirectionW, normalW, vLightData3, vLightDirection3, vLightDiffuse3, vLightSpecular3);
+#endif
+#ifdef HEMILIGHT3
+	info = computeHemisphericLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3, vLightSpecular3, vLightGround3);
+#endif
+#ifdef POINTDIRLIGHT3
+	info = computeLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3, vLightSpecular3);
+#endif
+#ifdef SHADOW3
+#ifdef SHADOWVSM3
+	shadow = computeShadowWithVSM(vPositionFromLight3, shadowSampler3);
+#else
+	shadow = computeShadow(vPositionFromLight3, shadowSampler3);
+#endif	
+#else
+	shadow = 1.;
+#endif
+	diffuseBase += info[0] * shadow;
+	specularBase += info[1] * shadow;
+#endif
 
 	// Reflection
 	vec3 reflectionColor = vec3(0., 0., 0.);
@@ -279,7 +466,7 @@ void main(void) {
 		coords.y = 1.0 - coords.y;
 
 		reflectionColor = texture2D(reflection2DSampler, coords).rgb * vReflectionInfos.y;
-	}	
+	}
 #endif
 
 	// Alpha
@@ -287,7 +474,7 @@ void main(void) {
 
 #ifdef OPACITY
 	vec3 opacityMap = texture2D(opacitySampler, vOpacityUV).rgb * vec3(0.3, 0.59, 0.11);
-	alpha *= (opacityMap.x + opacityMap.y + opacityMap.z )* vOpacityInfos.y;
+	alpha *= (opacityMap.x + opacityMap.y + opacityMap.z)* vOpacityInfos.y;
 #endif
 
 	// Emissive
@@ -299,7 +486,7 @@ void main(void) {
 	// Specular map
 	vec3 specularColor = vSpecularColor.rgb;
 #ifdef SPECULAR
-	specularColor = texture2D(specularSampler, vSpecularUV).rgb * vSpecularInfos.y;	
+	specularColor = texture2D(specularSampler, vSpecularUV).rgb * vSpecularInfos.y;
 #endif
 
 	// Composition

+ 57 - 2
Babylon/Shaders/iedefault.vertex.fx

@@ -18,6 +18,9 @@ attribute vec2 uv;
 #ifdef UV2
 attribute vec2 uv2;
 #endif
+#ifdef VERTEXCOLOR
+attribute vec3 color;
+#endif
 #ifdef BONES
 attribute vec4 matricesIndices;
 attribute vec4 matricesWeights;
@@ -48,7 +51,6 @@ uniform vec2 vOpacityInfos;
 #ifdef REFLECTION
 uniform vec3 vEyePosition;
 varying vec3 vReflectionUVW;
-
 uniform vec3 vReflectionInfos;
 uniform mat4 reflectionMatrix;
 #endif
@@ -65,9 +67,15 @@ uniform vec2 vSpecularInfos;
 uniform mat4 specularMatrix;
 #endif
 
+#ifdef BUMP
+varying vec2 vBumpUV;
+uniform vec2 vBumpInfos;
+uniform mat4 bumpMatrix;
+#endif
+
 #ifdef BONES
 uniform mat4 mBones[BonesPerMesh];
-uniform mat4 viewProjection; 
+uniform mat4 viewProjection;
 #else
 uniform mat4 worldViewProjection;
 #endif
@@ -76,6 +84,10 @@ uniform mat4 worldViewProjection;
 varying vec3 vPositionW;
 varying vec3 vNormalW;
 
+#ifdef VERTEXCOLOR
+varying vec3 vColor;
+#endif
+
 #ifdef CLIPPLANE
 uniform vec4 vClipPlane;
 varying float fClipDistance;
@@ -90,6 +102,18 @@ varying float fFogDistance;
 uniform mat4 lightMatrix0;
 varying vec4 vPositionFromLight0;
 #endif
+#ifdef LIGHT1
+uniform mat4 lightMatrix1;
+varying vec4 vPositionFromLight1;
+#endif
+#ifdef LIGHT2
+uniform mat4 lightMatrix2;
+varying vec4 vPositionFromLight2;
+#endif
+#ifdef LIGHT3
+uniform mat4 lightMatrix3;
+varying vec4 vPositionFromLight3;
+#endif
 #endif
 
 #ifdef REFLECTION
@@ -136,9 +160,15 @@ void main(void) {
 	mat4 m1 = mBones[int(matricesIndices.y)] * matricesWeights.y;
 	mat4 m2 = mBones[int(matricesIndices.z)] * matricesWeights.z;
 
+#ifdef BONES4
+	mat4 m3 = mBones[int(matricesIndices.w)] * matricesWeights.w;
+	finalWorld = world * (m0 + m1 + m2 + m3);
+#else
 	finalWorld = world * (m0 + m1 + m2);
+#endif 
 	gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
 #else
+
 	finalWorld = world;
 	gl_Position = worldViewProjection * vec4(position, 1.0);
 #endif
@@ -214,6 +244,17 @@ void main(void) {
 	}
 #endif
 
+#ifdef BUMP
+	if (vBumpInfos.x == 0.)
+	{
+		vBumpUV = vec2(bumpMatrix * vec4(uv, 1.0, 0.0));
+	}
+	else
+	{
+		vBumpUV = vec2(bumpMatrix * vec4(uv2, 1.0, 0.0));
+	}
+#endif
+
 	// Clip plane
 #ifdef CLIPPLANE
 	fClipDistance = dot(worldPos, vClipPlane);
@@ -229,5 +270,19 @@ void main(void) {
 #ifdef LIGHT0
 	vPositionFromLight0 = lightMatrix0 * vec4(position, 1.0);
 #endif
+#ifdef LIGHT1
+	vPositionFromLight1 = lightMatrix1 * vec4(position, 1.0);
+#endif
+#ifdef LIGHT2
+	vPositionFromLight2 = lightMatrix2 * vec4(position, 1.0);
+#endif
+#ifdef LIGHT3
+	vPositionFromLight3 = lightMatrix3 * vec4(position, 1.0);
+#endif
+#endif
+
+	// Vertex color
+#ifdef VERTEXCOLOR
+	vColor = color;
 #endif
 }

+ 0 - 4
Babylon/Shaders/shadowMap.vertex.fx

@@ -24,12 +24,8 @@ void main(void)
 	mat4 m0 = mBones[int(matricesIndices.x)] * matricesWeights.x;
 	mat4 m1 = mBones[int(matricesIndices.y)] * matricesWeights.y;
 	mat4 m2 = mBones[int(matricesIndices.z)] * matricesWeights.z;
-#ifdef IE
-	mat4 finalWorld = world * (m0 + m1 + m2);
-#else
 	mat4 m3 = mBones[int(matricesIndices.w)] * matricesWeights.w;
 	mat4 finalWorld = world * (m0 + m1 + m2 + m3);
-#endif
 	gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
 #else
 	gl_Position = worldViewProjection * vec4(position, 1.0);

+ 85 - 60
Babylon/Tools/babylon.database.js

@@ -46,6 +46,12 @@
 
         xhr.open("GET", manifestURL, false);
 
+        function noManifestFile() {
+            console.log("Valid manifest file not found. Scene & textures will be loaded directly from the web server.");
+            that.enableSceneOffline = false;
+            that.enableTexturesOffline = false;
+        };
+
         xhr.addEventListener("load", function () {
             if (xhr.status === 200) {
                 try {
@@ -57,19 +63,16 @@
                     }
                 }
                 catch (ex) {
-                    that.enableSceneOffline = false;
-                    that.enableTexturesOffline = false;
+                    noManifestFile();
                 }
             }
             else {
-                that.enableSceneOffline = false;
-                that.enableTexturesOffline = false;
+                noManifestFile();
             }
         }, false);
 
         xhr.addEventListener("error", function (event) {
-            that.enableSceneOffline = false;
-            that.enableTexturesOffline = false;
+            noManifestFile();
         }, false);
 
         xhr.send();
@@ -90,16 +93,20 @@
 
                 var request = window.indexedDB.open("babylonjs", 1.0);
 
-                // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
-                request.onerror = function (event) {
+                function handleError() {
                     that.isSupported = false;
                     if (errorCallback) errorCallback();
+                }
+
+                // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
+                request.onerror = function (event) {
+                    handleError();
                 };
 
                 // executes when a version change transaction cannot complete due to other active transactions
                 request.onblocked = function (event) {
                     console.log("IDB request blocked. Please reload the page.");
-                    if (errorCallback) errorCallback();
+                    handleError();
                 };
 
                 // DB has been opened successfully
@@ -111,9 +118,15 @@
                 // Initialization of the DB. Creating Scenes & Textures stores
                 request.onupgradeneeded = function (event) {
                     that.db = event.target.result;
-                    var scenesStore = that.db.createObjectStore("scenes", { keyPath: "sceneUrl" });
-                    var versionsStore = that.db.createObjectStore("versions", { keyPath: "sceneUrl" });
-                    var texturesStore = that.db.createObjectStore("textures", { keyPath: "textureUrl" });
+                    try {
+                        var scenesStore = that.db.createObjectStore("scenes", { keyPath: "sceneUrl" });
+                        var versionsStore = that.db.createObjectStore("versions", { keyPath: "sceneUrl" });
+                        var texturesStore = that.db.createObjectStore("textures", { keyPath: "textureUrl" });
+                    }
+                    catch (ex) {
+                        console.log("Error while creating object stores. Exception: " + ex.message);
+                        handleError();
+                    }
                 };
             }
             // DB has already been created and opened
@@ -294,39 +307,45 @@
         if (this.isSupported) {
             var version;
             var that = this;
-            var transaction = this.db.transaction(["versions"]);
-
-            transaction.oncomplete = function (event) {
-                if (version) {
-                    // If the version in the JSON file is > than the version in DB
-                    if (that.manifestVersionFound > version.data) {
-                        that.mustUpdateRessources = true;
-                        updateInDBCallback();
+            try {
+                var transaction = this.db.transaction(["versions"]);
+
+                transaction.oncomplete = function (event) {
+                    if (version) {
+                        // If the version in the JSON file is > than the version in DB
+                        if (that.manifestVersionFound > version.data) {
+                            that.mustUpdateRessources = true;
+                            updateInDBCallback();
+                        }
+                        else {
+                            callback(version.data);
+                        }
                     }
+                        // version was not found in DB
                     else {
-                        callback(version.data);
+                        that.mustUpdateRessources = true;
+                        updateInDBCallback();
                     }
-                }
-                // version was not found in DB
-                else {
-                    that.mustUpdateRessources = true;
-                    updateInDBCallback();
-                }
-            };
+                };
 
-            transaction.onabort = function (event) {
-                callback(-1);
-            };
+                transaction.onabort = function (event) {
+                    callback(-1);
+                };
 
-            var getRequest = transaction.objectStore("versions").get(url);
+                var getRequest = transaction.objectStore("versions").get(url);
 
-            getRequest.onsuccess = function (event) {
-                version = event.target.result;
-            };
-            getRequest.onerror = function (event) {
-                console.log("Error loading version for scene " + url + " from DB.");
+                getRequest.onsuccess = function (event) {
+                    version = event.target.result;
+                };
+                getRequest.onerror = function (event) {
+                    console.log("Error loading version for scene " + url + " from DB.");
+                    callback(-1);
+                };
+            }
+            catch (ex) {
+                console.log("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
                 callback(-1);
-            };
+            }
         }
         else {
             console.log("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
@@ -337,29 +356,29 @@
     BABYLON.Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
         if (this.isSupported && !this.hasReachedQuota) {
             var that = this;
-            // Open a transaction to the database
-            var transaction = this.db.transaction(["versions"], "readwrite");
+            try {
+                // Open a transaction to the database
+                var transaction = this.db.transaction(["versions"], "readwrite");
 
-            // the transaction could abort because of a QuotaExceededError error
-            transaction.onabort = function (event) {
-                try {
-                    if (event.srcElement.error.name === "QuotaExceededError") {
-                        that.hasReachedQuota = true;
+                // the transaction could abort because of a QuotaExceededError error
+                transaction.onabort = function (event) {
+                    try {
+                        if (event.srcElement.error.name === "QuotaExceededError") {
+                            that.hasReachedQuota = true;
+                        }
                     }
-                }
-                catch (ex) { }
-                callback(-1);
-            };
+                    catch (ex) { }
+                    callback(-1);
+                };
 
-            transaction.oncomplete = function (event) {
-                callback(that.manifestVersionFound);
-            };
+                transaction.oncomplete = function (event) {
+                    callback(that.manifestVersionFound);
+                };
 
-            var newVersion = {};
-            newVersion.sceneUrl = url;
-            newVersion.data = this.manifestVersionFound;
+                var newVersion = {};
+                newVersion.sceneUrl = url;
+                newVersion.data = this.manifestVersionFound;
 
-            try {
                 // Put the scene into the database
                 var addRequest = transaction.objectStore("versions").put(newVersion);
                 addRequest.onsuccess = function (event) {
@@ -370,6 +389,7 @@
                 };
             }
             catch (ex) {
+                console.log("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
                 callback(-1);
             }
         }
@@ -378,7 +398,7 @@
         }
     };
 
-    BABYLON.Database.prototype.loadSceneFromDB = function (url, sceneLoaded, progressCallBack) {
+    BABYLON.Database.prototype.loadSceneFromDB = function (url, sceneLoaded, progressCallBack, errorCallback) {
         var that = this;
         var completeUrl = BABYLON.Database.ReturnFullUrlLocation(url);
         
@@ -388,11 +408,16 @@
         };
 
         this._checkVersionFromDB(completeUrl, function (version) {
-            if (!that.mustUpdateRessources) {
-                that._loadSceneFromDBAsync(completeUrl, sceneLoaded, saveAndLoadScene);
+            if (version !== -1) {
+                if (!that.mustUpdateRessources) {
+                    that._loadSceneFromDBAsync(completeUrl, sceneLoaded, saveAndLoadScene);
+                }
+                else {
+                    that._saveSceneIntoDBAsync(completeUrl, sceneLoaded, progressCallBack);
+                }
             }
             else {
-                that._saveSceneIntoDBAsync(completeUrl, sceneLoaded, progressCallBack);
+                errorCallback();
             }
         });
     };

+ 71 - 27
Babylon/Tools/babylon.sceneLoader.js

@@ -272,6 +272,56 @@
         light.specular = BABYLON.Color3.FromArray(parsedLight.specular);
     };
 
+    var parseCamera = function (parsedCamera, scene) {
+        var camera = new BABYLON.FreeCamera(parsedCamera.name, BABYLON.Vector3.FromArray(parsedCamera.position), scene);
+        camera.id = parsedCamera.id;
+
+        // Parent
+        if (parsedCamera.parentId) {
+            camera._waitingParentId = parsedCamera.parentId;
+        }
+
+        // Target
+        if (parsedCamera.target) {
+            camera.setTarget(BABYLON.Vector3.FromArray(parsedCamera.target));
+        } else {
+            camera.rotation = BABYLON.Vector3.FromArray(parsedCamera.rotation);
+        }
+        
+        // Locked target
+        if (parsedCamera.lockedTargetId) {
+            camera._waitingLockedTargetId = parsedCamera.lockedTargetId;
+        }
+
+        camera.fov = parsedCamera.fov;
+        camera.minZ = parsedCamera.minZ;
+        camera.maxZ = parsedCamera.maxZ;
+
+        camera.speed = parsedCamera.speed;
+        camera.inertia = parsedCamera.inertia;
+
+        camera.checkCollisions = parsedCamera.checkCollisions;
+        camera.applyGravity = parsedCamera.applyGravity;
+        if (parsedCamera.ellipsoid) {
+            camera.ellipsoid = BABYLON.Vector3.FromArray(parsedCamera.ellipsoid);
+        }
+
+        // Animations
+        if (parsedCamera.animations) {
+            for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
+                var parsedAnimation = parsedCamera.animations[animationIndex];
+
+                camera.animations.push(parseAnimation(parsedAnimation));
+            }
+        }
+
+        if (parsedCamera.autoAnimate) {
+            scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, 1.0);
+        }
+
+        return camera;
+    };
+
     var parseMesh = function (parsedMesh, scene, rootUrl) {
         var mesh = new BABYLON.Mesh(parsedMesh.name, scene);
         mesh.id = parsedMesh.id;
@@ -283,7 +333,7 @@
             mesh.rotationQuaternion = BABYLON.Quaternion.FromArray(parsedMesh.rotationQuaternion);
         }
         mesh.scaling = BABYLON.Vector3.FromArray(parsedMesh.scaling);
-        
+
         if (parsedMesh.localMatrix) {
             mesh.setPivotMatrix(BABYLON.Matrix.FromArray(parsedMesh.localMatrix));
         }
@@ -322,7 +372,7 @@
             if (parsedMesh.hasMatricesIndices) {
                 mesh._delayInfo.push(BABYLON.VertexBuffer.MatricesIndicesKind);
             }
-            
+
             if (parsedMesh.hasMatricesWeights) {
                 mesh._delayInfo.push(BABYLON.VertexBuffer.MatricesWeightsKind);
             }
@@ -333,7 +383,7 @@
 
         // Parent
         if (parsedMesh.parentId) {
-            mesh.parent = scene.getLastMeshByID(parsedMesh.parentId);
+            mesh.parent = scene.getLastEntryByID(parsedMesh.parentId);
         }
 
         // Material
@@ -418,7 +468,7 @@
 
                 mesh.setIndices(parsedGeometry.indices);
             }
-            
+
             // SubMeshes
             if (parsedGeometry.subMeshes) {
                 mesh.subMeshes = [];
@@ -428,7 +478,7 @@
                     var subMesh = new BABYLON.SubMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
                 }
             }
-            
+
             // Update
             mesh.computeWorldMatrix(true);
 
@@ -524,7 +574,7 @@
         Load: function (rootUrl, sceneFilename, engine, then, progressCallBack) {
             // Checking if a manifest file has been set for this scene and if offline mode has been requested
             var database = new BABYLON.Database(rootUrl + sceneFilename);
-            
+
             BABYLON.Tools.LoadFile(rootUrl + sceneFilename, function (data) {
                 var parsedData = JSON.parse(data);
                 var scene = new BABYLON.Scene(engine);
@@ -555,27 +605,7 @@
                 // Cameras
                 for (var index = 0; index < parsedData.cameras.length; index++) {
                     var parsedCamera = parsedData.cameras[index];
-                    var camera = new BABYLON.FreeCamera(parsedCamera.name, BABYLON.Vector3.FromArray(parsedCamera.position), scene);
-                    camera.id = parsedCamera.id;
-
-                    if (parsedCamera.target) {
-                        camera.setTarget(BABYLON.Vector3.FromArray(parsedCamera.target));
-                    } else {
-                        camera.rotation = BABYLON.Vector3.FromArray(parsedCamera.rotation);
-                    }
-
-                    camera.fov = parsedCamera.fov;
-                    camera.minZ = parsedCamera.minZ;
-                    camera.maxZ = parsedCamera.maxZ;
-
-                    camera.speed = parsedCamera.speed;
-                    camera.inertia = parsedCamera.inertia;
-
-                    camera.checkCollisions = parsedCamera.checkCollisions;
-                    camera.applyGravity = parsedCamera.applyGravity;
-                    if (parsedCamera.ellipsoid) {
-                        camera.ellipsoid = BABYLON.Vector3.FromArray(parsedCamera.ellipsoid);
-                    }
+                    parseCamera(parsedCamera, scene);
                 }
 
                 if (parsedData.activeCameraID) {
@@ -611,6 +641,20 @@
                     parseMesh(parsedMesh, scene, rootUrl);
                 }
 
+                // Connecting cameras parents and locked target
+                for (var index = 0; index < scene.cameras.length; index++) {
+                    var camera = scene.cameras[index];
+                    if (camera._waitingParentId) {
+                        camera.parent = scene.getLastEntryByID(camera._waitingParentId);
+                        delete camera._waitingParentId;
+                    }
+                    
+                    if (camera._waitingLockedTargetId) {
+                        camera.lockedTarget = scene.getLastEntryByID(camera._waitingLockedTargetId);
+                        delete camera._waitingLockedTargetId;
+                    }
+                }
+
                 // Particles Systems
                 if (parsedData.particleSystems) {
                     for (var index = 0; index < parsedData.particleSystems.length; index++) {

+ 492 - 0
Babylon/Tools/babylon.standardMaterial.js

@@ -0,0 +1,492 @@
+var BABYLON = BABYLON || {};
+
+(function () {
+    BABYLON.StandardMaterial = function (name, scene) {
+        this.name = name;
+        this.id = name;
+
+        this._scene = scene;
+        scene.materials.push(this);
+
+        this.diffuseTexture = null;
+        this.ambientTexture = null;
+        this.opacityTexture = null;
+        this.reflectionTexture = null;
+        this.emissiveTexture = null;
+        this.specularTexture = null;
+        this.bumpTexture = null;
+
+        this.ambientColor = new BABYLON.Color3(0, 0, 0);
+        this.diffuseColor = new BABYLON.Color3(1, 1, 1);
+        this.specularColor = new BABYLON.Color3(1, 1, 1);
+        this.specularPower = 64;
+        this.emissiveColor = new BABYLON.Color3(0, 0, 0);
+
+        this._cachedDefines = null;
+
+        this._renderTargets = new BABYLON.Tools.SmartArray(16);
+
+        // Internals
+        this._worldViewProjectionMatrix = BABYLON.Matrix.Zero();
+        this._lightMatrix = BABYLON.Matrix.Zero();
+        this._globalAmbientColor = new BABYLON.Color3(0, 0, 0);
+        this._baseColor = new BABYLON.Color3();
+        this._scaledDiffuse = new BABYLON.Color3();
+        this._scaledSpecular = new BABYLON.Color3();
+    };
+
+    BABYLON.StandardMaterial.prototype = Object.create(BABYLON.Material.prototype);
+
+    // Properties   
+    BABYLON.StandardMaterial.prototype.needAlphaBlending = function () {
+        return (this.alpha < 1.0) || (this.opacityTexture != null);
+    };
+
+    BABYLON.StandardMaterial.prototype.needAlphaTesting = function () {
+        return this.diffuseTexture != null && this.diffuseTexture.hasAlpha;
+    };
+
+    // Methods   
+    BABYLON.StandardMaterial.prototype.isReady = function (mesh) {
+        if (!this.checkReadyOnEveryCall) {
+            if (this._renderId === this._scene.getRenderId()) {
+                return true;
+            }
+        }
+
+        var engine = this._scene.getEngine();
+        var defines = [];
+
+        // Textures
+        if (this.diffuseTexture) {
+            if (!this.diffuseTexture.isReady()) {
+                return false;
+            } else {
+                defines.push("#define DIFFUSE");
+            }
+        }
+
+        if (this.ambientTexture) {
+            if (!this.ambientTexture.isReady()) {
+                return false;
+            } else {
+                defines.push("#define AMBIENT");
+            }
+        }
+
+        if (this.opacityTexture) {
+            if (!this.opacityTexture.isReady()) {
+                return false;
+            } else {
+                defines.push("#define OPACITY");
+            }
+        }
+
+        if (this.reflectionTexture) {
+            if (!this.reflectionTexture.isReady()) {
+                return false;
+            } else {
+                defines.push("#define REFLECTION");
+            }
+        }
+
+        if (this.emissiveTexture) {
+            if (!this.emissiveTexture.isReady()) {
+                return false;
+            } else {
+                defines.push("#define EMISSIVE");
+            }
+        }
+
+        if (this.specularTexture) {
+            if (!this.specularTexture.isReady()) {
+                return false;
+            } else {
+                defines.push("#define SPECULAR");
+            }
+        }
+
+        if (this._scene.getEngine().getCaps().standardDerivatives && this.bumpTexture) {
+            if (!this.bumpTexture.isReady()) {
+                return false;
+            } else {
+                defines.push("#define BUMP");
+            }
+        }
+
+        // Effect
+        if (BABYLON.clipPlane) {
+            defines.push("#define CLIPPLANE");
+        }
+
+        if (engine.getAlphaTesting()) {
+            defines.push("#define ALPHATEST");
+        }
+
+        // Fog
+        if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
+            defines.push("#define FOG");
+        }
+
+        var shadowsActivated = false;
+        var lightIndex = 0;
+        for (var index = 0; index < this._scene.lights.length; index++) {
+            var light = this._scene.lights[index];
+
+            if (!light.isEnabled) {
+                continue;
+            }
+
+            defines.push("#define LIGHT" + lightIndex);
+
+            if (light instanceof BABYLON.SpotLight) {
+                defines.push("#define SPOTLIGHT" + lightIndex);
+            } else if (light instanceof BABYLON.HemisphericLight) {
+                defines.push("#define HEMILIGHT" + lightIndex);
+            } else {
+                defines.push("#define POINTDIRLIGHT" + lightIndex);
+            }
+
+            // Shadows
+            var shadowGenerator = light.getShadowGenerator();
+            if (mesh && mesh.receiveShadows && shadowGenerator) {
+                defines.push("#define SHADOW" + lightIndex);
+
+                if (!shadowsActivated) {
+                    defines.push("#define SHADOWS");
+                    shadowsActivated = true;
+                }
+
+                if (shadowGenerator.useVarianceShadowMap) {
+                    defines.push("#define SHADOWVSM" + lightIndex);
+                }
+            }
+
+            lightIndex++;
+            if (lightIndex == 4)
+                break;
+        }
+
+        var attribs = [BABYLON.VertexBuffer.PositionKind, BABYLON.VertexBuffer.NormalKind];
+        if (mesh) {
+            if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)) {
+                attribs.push(BABYLON.VertexBuffer.UVKind);
+                defines.push("#define UV1");
+            }
+            if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UV2Kind)) {
+                attribs.push(BABYLON.VertexBuffer.UV2Kind);
+                defines.push("#define UV2");
+            }
+            if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.ColorKind)) {
+                attribs.push(BABYLON.VertexBuffer.ColorKind);
+                defines.push("#define VERTEXCOLOR");
+            }
+            if (mesh.skeleton && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesIndicesKind) && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesWeightsKind)) {
+                attribs.push(BABYLON.VertexBuffer.MatricesIndicesKind);
+                attribs.push(BABYLON.VertexBuffer.MatricesWeightsKind);
+                defines.push("#define BONES");
+                defines.push("#define BonesPerMesh " + mesh.skeleton.bones.length);
+            }
+        }
+
+        // Get correct effect      
+        var join = defines.join("\n");
+        if (this._cachedDefines != join) {
+            this._cachedDefines = join;
+
+            // IE patch
+            var shaderName = "default";
+            if (BABYLON.Tools.isIE()) {
+                shaderName = "iedefault";
+            }
+
+            this._effect = this._scene.getEngine().createEffect(shaderName,
+                attribs,
+                ["world", "view", "worldViewProjection", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
+                "vLightData0", "vLightDiffuse0", "vLightSpecular0", "vLightDirection0", "vLightGround0", "lightMatrix0",
+                "vLightData1", "vLightDiffuse1", "vLightSpecular1", "vLightDirection1", "vLightGround1", "lightMatrix1",
+                "vLightData2", "vLightDiffuse2", "vLightSpecular2", "vLightDirection2", "vLightGround2", "lightMatrix2",
+                "vLightData3", "vLightDiffuse3", "vLightSpecular3", "vLightDirection3", "vLightGround3", "lightMatrix3",
+                "vFogInfos", "vFogColor",
+                 "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos",
+                 "mBones",
+                 "vClipPlane", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix"],
+                ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler",
+                 "shadowSampler0", "shadowSampler1", "shadowSampler2", "shadowSampler3"
+                ],
+                join);
+        }
+        if (!this._effect.isReady()) {
+            return false;
+        }
+
+        this._renderId = this._scene.getRenderId();
+        return true;
+    };
+
+    BABYLON.StandardMaterial.prototype.getRenderTargetTextures = function () {
+        this._renderTargets.reset();
+
+        if (this.reflectionTexture && this.reflectionTexture.isRenderTarget) {
+            this._renderTargets.push(this.reflectionTexture);
+        }
+
+        return this._renderTargets;
+    };
+
+    BABYLON.StandardMaterial.prototype.unbind = function () {
+        if (this.reflectionTexture && this.reflectionTexture.isRenderTarget) {
+            this._effect.setTexture("reflection2DSampler", null);
+        }
+    };
+
+    BABYLON.StandardMaterial.prototype.bind = function (world, mesh) {
+        this._baseColor.copyFrom(this.diffuseColor);
+
+        // Matrices        
+        this._effect.setMatrix("world", world);
+
+        // Bones
+        if (mesh.skeleton && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesIndicesKind) && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesWeightsKind)) {
+            this._effect.setMatrix("viewProjection", this._scene.getTransformMatrix());
+
+            this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices());
+        } else {
+            world.multiplyToRef(this._scene.getTransformMatrix(), this._worldViewProjectionMatrix);
+            this._effect.setMatrix("worldViewProjection", this._worldViewProjectionMatrix);
+        }
+
+        // Textures        
+        if (this.diffuseTexture) {
+            this._effect.setTexture("diffuseSampler", this.diffuseTexture);
+
+            this._effect.setFloat2("vDiffuseInfos", this.diffuseTexture.coordinatesIndex, this.diffuseTexture.level);
+            this._effect.setMatrix("diffuseMatrix", this.diffuseTexture._computeTextureMatrix());
+
+            this._baseColor.copyFromFloats(1, 1, 1);
+        }
+
+        if (this.ambientTexture) {
+            this._effect.setTexture("ambientSampler", this.ambientTexture);
+
+            this._effect.setFloat2("vAmbientInfos", this.ambientTexture.coordinatesIndex, this.ambientTexture.level);
+            this._effect.setMatrix("ambientMatrix", this.ambientTexture._computeTextureMatrix());
+        }
+
+        if (this.opacityTexture) {
+            this._effect.setTexture("opacitySampler", this.opacityTexture);
+
+            this._effect.setFloat2("vOpacityInfos", this.opacityTexture.coordinatesIndex, this.opacityTexture.level);
+            this._effect.setMatrix("opacityMatrix", this.opacityTexture._computeTextureMatrix());
+        }
+
+        if (this.reflectionTexture) {
+            if (this.reflectionTexture.isCube) {
+                this._effect.setTexture("reflectionCubeSampler", this.reflectionTexture);
+            } else {
+                this._effect.setTexture("reflection2DSampler", this.reflectionTexture);
+            }
+
+            this._effect.setMatrix("reflectionMatrix", this.reflectionTexture._computeReflectionTextureMatrix());
+            this._effect.setFloat3("vReflectionInfos", this.reflectionTexture.coordinatesMode, this.reflectionTexture.level, this.reflectionTexture.isCube ? 1 : 0);
+        }
+
+        if (this.emissiveTexture) {
+            this._effect.setTexture("emissiveSampler", this.emissiveTexture);
+
+            this._effect.setFloat2("vEmissiveInfos", this.emissiveTexture.coordinatesIndex, this.emissiveTexture.level);
+            this._effect.setMatrix("emissiveMatrix", this.emissiveTexture._computeTextureMatrix());
+        }
+
+        if (this.specularTexture) {
+            this._effect.setTexture("specularSampler", this.specularTexture);
+
+            this._effect.setFloat2("vSpecularInfos", this.specularTexture.coordinatesIndex, this.specularTexture.level);
+            this._effect.setMatrix("specularMatrix", this.specularTexture._computeTextureMatrix());
+        }
+
+        if (this.bumpTexture && this._scene.getEngine().getCaps().standardDerivatives) {
+            this._effect.setTexture("bumpSampler", this.bumpTexture);
+
+            this._effect.setFloat2("vBumpInfos", this.bumpTexture.coordinatesIndex, this.bumpTexture.level);
+            this._effect.setMatrix("bumpMatrix", this.bumpTexture._computeTextureMatrix());
+        }
+
+        // Colors
+        this._scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
+
+        this._effect.setVector3("vEyePosition", this._scene.activeCamera.position);
+        this._effect.setColor3("vAmbientColor", this._globalAmbientColor);
+        this._effect.setColor4("vDiffuseColor", this._baseColor, this.alpha * mesh.visibility);
+        this._effect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
+        this._effect.setColor3("vEmissiveColor", this.emissiveColor);
+
+        var lightIndex = 0;
+        for (var index = 0; index < this._scene.lights.length; index++) {
+            var light = this._scene.lights[index];
+
+            if (!light.isEnabled) {
+                continue;
+            }
+
+            if (light instanceof BABYLON.PointLight) {
+                // Point Light
+                this._effect.setFloat4("vLightData" + lightIndex, light.position.x, light.position.y, light.position.z, 0);
+            } else if (light instanceof BABYLON.DirectionalLight) {
+                // Directional Light
+                this._effect.setFloat4("vLightData" + lightIndex, light.direction.x, light.direction.y, light.direction.z, 1);
+            } else if (light instanceof BABYLON.SpotLight) {
+                // Spot Light
+                this._effect.setFloat4("vLightData" + lightIndex, light.position.x, light.position.y, light.position.z, light.exponent);
+                var normalizeDirection = BABYLON.Vector3.Normalize(light.direction);
+                this._effect.setFloat4("vLightDirection" + lightIndex, normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, Math.cos(light.angle * 0.5));
+            } else if (light instanceof BABYLON.HemisphericLight) {
+                // Hemispheric Light
+                var normalizeDirection = BABYLON.Vector3.Normalize(light.direction);
+                this._effect.setFloat4("vLightData" + lightIndex, normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0);
+                this._effect.setColor3("vLightGround" + lightIndex, light.groundColor.scale(light.intensity));
+            }
+
+            light.diffuse.scaleToRef(light.intensity, this._scaledDiffuse);
+            light.specular.scaleToRef(light.intensity, this._scaledSpecular);
+            this._effect.setColor3("vLightDiffuse" + lightIndex, this._scaledDiffuse);
+            this._effect.setColor3("vLightSpecular" + lightIndex, this._scaledSpecular);
+
+            // Shadows
+            var shadowGenerator = light.getShadowGenerator();
+            if (mesh.receiveShadows && shadowGenerator) {
+                world.multiplyToRef(shadowGenerator.getTransformMatrix(), this._lightMatrix);
+                this._effect.setMatrix("lightMatrix" + lightIndex, this._lightMatrix);
+                this._effect.setTexture("shadowSampler" + lightIndex, shadowGenerator.getShadowMap());
+            }
+
+            lightIndex++;
+
+            if (lightIndex == 4)
+                break;
+        }
+
+        if (BABYLON.clipPlane) {
+            this._effect.setFloat4("vClipPlane", BABYLON.clipPlane.normal.x, BABYLON.clipPlane.normal.y, BABYLON.clipPlane.normal.z, BABYLON.clipPlane.d);
+        }
+
+        // View
+        if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE || this.reflectionTexture) {
+            this._effect.setMatrix("view", this._scene.getViewMatrix());
+        }
+
+        // Fog
+        if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
+            this._effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
+            this._effect.setColor3("vFogColor", this._scene.fogColor);
+        }
+    };
+
+    BABYLON.StandardMaterial.prototype.getAnimatables = function () {
+        var results = [];
+
+        if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
+            results.push(this.diffuseTexture);
+        }
+
+        if (this.ambientTexture && this.ambientTexture.animations && this.ambientTexture.animations.length > 0) {
+            results.push(this.ambientTexture);
+        }
+
+        if (this.opacityTexture && this.opacityTexture.animations && this.opacityTexture.animations.length > 0) {
+            results.push(this.opacityTexture);
+        }
+
+        if (this.reflectionTexture && this.reflectionTexture.animations && this.reflectionTexture.animations.length > 0) {
+            results.push(this.reflectionTexture);
+        }
+
+        if (this.emissiveTexture && this.emissiveTexture.animations && this.emissiveTexture.animations.length > 0) {
+            results.push(this.emissiveTexture);
+        }
+
+        if (this.specularTexture && this.specularTexture.animations && this.specularTexture.animations.length > 0) {
+            results.push(this.specularTexture);
+        }
+
+        if (this.bumpTexture && this.bumpTexture.animations && this.bumpTexture.animations.length > 0) {
+            results.push(this.bumpTexture);
+        }
+
+        return results;
+    };
+
+    BABYLON.StandardMaterial.prototype.dispose = function () {
+        if (this.diffuseTexture) {
+            this.diffuseTexture.dispose();
+        }
+
+        if (this.ambientTexture) {
+            this.ambientTexture.dispose();
+        }
+
+        if (this.opacityTexture) {
+            this.opacityTexture.dispose();
+        }
+
+        if (this.reflectionTexture) {
+            this.reflectionTexture.dispose();
+        }
+
+        if (this.emissiveTexture) {
+            this.emissiveTexture.dispose();
+        }
+
+        if (this.specularTexture) {
+            this.specularTexture.dispose();
+        }
+
+        if (this.bumpTexture) {
+            this.bumpTexture.dispose();
+        }
+
+        this.baseDispose();
+    };
+
+    BABYLON.StandardMaterial.prototype.clone = function (name) {
+        var newStandardMaterial = new BABYLON.StandardMaterial(name, this._scene);
+
+        // Base material
+        newStandardMaterial.checkReadyOnEveryCall = this.checkReadyOnEveryCall;
+        newStandardMaterial.alpha = this.alpha;
+        newStandardMaterial.wireframe = this.wireframe;
+        newStandardMaterial.backFaceCulling = this.backFaceCulling;
+
+        // Standard material
+        if (this.diffuseTexture && this.diffuseTexture.clone) {
+            newStandardMaterial.diffuseTexture = this.diffuseTexture.clone();
+        }
+        if (this.ambientTexture && this.ambientTexture.clone) {
+            newStandardMaterial.ambientTexture = this.ambientTexture.clone();
+        }
+        if (this.opacityTexture && this.opacityTexture.clone) {
+            newStandardMaterial.opacityTexture = this.opacityTexture.clone();
+        }
+        if (this.reflectionTexture && this.reflectionTexture.clone) {
+            newStandardMaterial.reflectionTexture = this.reflectionTexture.clone();
+        }
+        if (this.emissiveTexture && this.emissiveTexture.clone) {
+            newStandardMaterial.emissiveTexture = this.emissiveTexture.clone();
+        }
+        if (this.specularTexture && this.specularTexture.clone) {
+            newStandardMaterial.specularTexture = this.specularTexture.clone();
+        }
+        if (this.bumpTexture && this.bumpTexture.clone) {
+            newStandardMaterial.bumpTexture = this.bumpTexture.clone();
+        }
+
+        newStandardMaterial.ambientColor = this.ambientColor.clone();
+        newStandardMaterial.diffuseColor = this.diffuseColor.clone();
+        newStandardMaterial.specularColor = this.specularColor.clone();
+        newStandardMaterial.specularPower = this.specularPower;
+        newStandardMaterial.emissiveColor = this.emissiveColor.clone();
+
+        return newStandardMaterial;
+    };
+
+})();

+ 1 - 1
Babylon/Tools/babylon.tools.js

@@ -194,7 +194,7 @@
         };
 
         var loadFromIndexedDB = function () {
-            database.loadSceneFromDB(url, callback, progressCallBack);
+            database.loadSceneFromDB(url, callback, progressCallBack, noIndexedDB);
         };
 
         // Caching only scenes files

+ 5 - 3
Babylon/babylon.engine.js

@@ -185,7 +185,7 @@
     };
 
     BABYLON.Engine.prototype.clear = function (color, backBuffer, depthStencil) {
-        this._gl.clearColor(color.r, color.g, color.b, 1.0);
+        this._gl.clearColor(color.r, color.g, color.b, color.a || 1.0);
         this._gl.clearDepth(1.0);
         var mode = 0;
 
@@ -344,13 +344,13 @@
     };
 
     // Shaders
-    BABYLON.Engine.prototype.createEffect = function (baseName, attributesNames, uniformsNames, samplers, defines) {
+    BABYLON.Engine.prototype.createEffect = function (baseName, attributesNames, uniformsNames, samplers, defines, optionalDefines) {
         var name = baseName + "@" + defines;
         if (this._compiledEffects[name]) {
             return this._compiledEffects[name];
         }
 
-        var effect = new BABYLON.Effect(baseName, attributesNames, uniformsNames, samplers, this, defines);
+        var effect = new BABYLON.Effect(baseName, attributesNames, uniformsNames, samplers, this, defines, optionalDefines);
         this._compiledEffects[name] = effect;
 
         return effect;
@@ -363,6 +363,8 @@
         gl.compileShader(shader);
 
         if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
+            console.error("Error while compiling shader: " + gl.getShaderInfoLog(shader));
+            console.error("Defines: " + defines);
             throw new Error(gl.getShaderInfoLog(shader));
         }
         return shader;

+ 71 - 0
Babylon/babylon.node.js

@@ -0,0 +1,71 @@
+var BABYLON = BABYLON || {};
+
+(function () {
+    BABYLON.Node = function () {
+    };
+    
+    // Properties
+    BABYLON.Node.prototype.parent = null;
+    BABYLON.Node.prototype._childrenFlag = false;
+    BABYLON.Node.prototype._isReady = true;
+    BABYLON.Node.prototype._isEnabled = true;
+
+    
+    BABYLON.Node.prototype.isSynchronized = function () {
+        return true;
+    };
+    
+    BABYLON.Node.prototype._needToSynchonizeChildren = function () {
+        return this._childrenFlag;
+    };
+    
+    BABYLON.Node.prototype.isReady = function () {
+        return this._isReady;
+    };
+    
+    BABYLON.Node.prototype.isEnabled = function () {
+        if (!this.isReady() || !this._isEnabled) {
+            return false;
+        }
+
+        if (this.parent) {
+            return this.parent.isEnabled();
+        }
+
+        return true;
+    };
+
+    BABYLON.Node.prototype.setEnabled = function (value) {
+        this._isEnabled = value;
+    };
+    
+    BABYLON.Node.prototype.isDescendantOf = function (ancestor) {
+        if (this.parent) {
+            if (this.parent === ancestor) {
+                return true;
+            }
+
+            return this.parent.isDescendantOf(ancestor);
+        }
+        return false;
+    };
+
+    BABYLON.Node.prototype._getDescendants = function(list, results) {
+        for (var index = 0; index < list.length; index++) {
+            var item = list[index];
+            if (item.isDescendantOf(this)) {
+                results.push(item);
+            }
+        }
+    };
+
+    BABYLON.Node.prototype.getDescendants = function () {
+        var results = [];
+        this._getDescendants(this._scene.meshes, results);
+        this._getDescendants(this._scene.lights, results);
+        this._getDescendants(this._scene.cameras, results);
+
+        return results;
+    };
+
+})();

+ 49 - 8
Babylon/babylon.scene.js

@@ -162,7 +162,7 @@
             }
 
             if (mat) {
-                if (!mat.isReady(mesh, mesh.delayLoadState !== BABYLON.Engine.DELAYLOADSTATE_NOTLOADED)) {
+                if (!mat.isReady(mesh)) {
                     return false;
                 }
             }
@@ -317,6 +317,26 @@
 
         return null;
     };
+    
+    BABYLON.Scene.prototype.getMaterialByName = function (name) {
+        for (var index = 0; index < this.materials.length; index++) {
+            if (this.materials[index].name === name) {
+                return this.materials[index];
+            }
+        }
+
+        return null;
+    };
+    
+    BABYLON.Scene.prototype.getCameraByName = function (name) {
+        for (var index = 0; index < this.cameras.length; index++) {
+            if (this.cameras[index].name === name) {
+                return this.cameras[index];
+            }
+        }
+
+        return null;
+    };
 
     BABYLON.Scene.prototype.getLightByID = function (id) {
         for (var index = 0; index < this.lights.length; index++) {
@@ -347,6 +367,22 @@
 
         return null;
     };
+    
+    BABYLON.Scene.prototype.getLastEntryByID = function (id) {
+        for (var index = this.meshes.length - 1; index >= 0 ; index--) {
+            if (this.meshes[index].id === id) {
+                return this.meshes[index];
+            }
+        }
+        
+        for (var index = this.cameras.length - 1; index >= 0 ; index--) {
+            if (this.cameras[index].id === id) {
+                return this.cameras[index];
+            }
+        }
+
+        return null;
+    };
 
     BABYLON.Scene.prototype.getMeshByName = function (name) {
         for (var index = 0; index < this.meshes.length; index++) {
@@ -523,6 +559,7 @@
     BABYLON.Scene.prototype.render = function () {
         var startDate = new Date();
         this._particlesDuration = 0;
+        this._spritesDuration = 0;
         this._activeParticles = 0;
         var engine = this._engine;
 
@@ -535,12 +572,9 @@
             this._onBeforeRenderCallbacks[callbackIndex]();
         }
 
-        // Camera
         if (!this.activeCamera)
             throw new Error("Active camera not set");
 
-        this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
-
         // Animations
         this._animationRatio = BABYLON.Tools.GetDeltaTime() * (60.0 / 1000.0);
         this._animate();
@@ -551,6 +585,9 @@
         this._evaluateActiveMeshes();
         this._evaluateActiveMeshesDuration = new Date() - beforeEvaluateActiveMeshesDate;
 
+        // Camera
+        this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
+
         // Skeletons
         for (var skeletonIndex = 0; skeletonIndex < this._activeSkeletons.length; skeletonIndex++) {
             var skeleton = this._activeSkeletons.data[skeletonIndex];
@@ -563,7 +600,7 @@
             var light = this.lights[lightIndex];
             var shadowGenerator = light.getShadowGenerator();
 
-            if (light.isEnabled && shadowGenerator) {
+            if (light.isEnabled() && shadowGenerator) {
                 this._renderTargets.push(shadowGenerator.getShadowMap());
             }
         }
@@ -799,7 +836,7 @@
         return BABYLON.Ray.CreateNew(x, y, engine.getRenderWidth() * engine.getHardwareScalingLevel(), engine.getRenderHeight() * engine.getHardwareScalingLevel(), world ? world : BABYLON.Matrix.Identity(), this._viewMatrix, this._projectionMatrix);
     };
 
-    BABYLON.Scene.prototype.pick = function (x, y, predicate) {
+    BABYLON.Scene.prototype.pick = function (x, y, predicate, fastCheck) {
         var distance = Number.MAX_VALUE;
         var pickedPoint = null;
         var pickedMesh = null;
@@ -819,16 +856,20 @@
             var world = mesh.getWorldMatrix();
             var ray = this.createPickingRay(x, y, world);
 
-            var result = mesh.intersects(ray);
+            var result = mesh.intersects(ray, fastCheck);
             if (!result.hit)
                 continue;
 
-            if (result.distance >= distance)
+            if (!fastCheck && result.distance >= distance)
                 continue;
 
             distance = result.distance;
             pickedMesh = mesh;
             pickedPoint = result.pickedPoint;
+            
+            if (fastCheck) {
+                break;
+            }
         }
 
         return { hit: distance != Number.MAX_VALUE, distance: distance, pickedMesh: pickedMesh, pickedPoint: pickedPoint };

+ 5 - 3
Exporters/Blender/io_export_babylon.py

@@ -333,16 +333,15 @@ class Export_babylon(bpy.types.Operator, ExportHelper):
         rot = mathutils.Quaternion((0, 0, 0, 1))
         scale = mathutils.Vector((1, 1, 1))
         
+        world = object.matrix_world
         if object.parent and object.parent.type == "ARMATURE" and len(object.vertex_groups) > 0:
-            mesh.transform(object.matrix_world)
             hasSkeleton = True
         else:
             hasSkeleton = False
-            world = object.matrix_world
             if (object.parent):
                 world = object.parent.matrix_world.inverted() * object.matrix_world
 
-            loc, rot, scale = world.decompose()
+        loc, rot, scale = world.decompose()
                                                 
         # Triangulate mesh if required
         Export_babylon.mesh_triangulate(mesh)
@@ -438,6 +437,8 @@ class Export_babylon(bpy.types.Operator, ExportHelper):
                                     i = i + 1
                                     if (i == 4):
                                         break;
+                            if (i == 4):
+                                break;
 
 
                     # Texture coordinates
@@ -564,6 +565,7 @@ class Export_babylon(bpy.types.Operator, ExportHelper):
         elif len(object.material_slots) > 1:
             multimat = MultiMaterial()
             multimat.name = "Multimaterial#" + str(len(multiMaterials))
+            multimat.materials = []
             Export_babylon.write_string(file_handler, "materialId", multimat.name)
             for mat in object.material_slots:
                 multimat.materials.append(mat.name)

+ 224 - 0
Exporters/FBX - OBJ/BabylonExport.Core/BabylonExport.Core.csproj

@@ -0,0 +1,224 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{CE70B051-FB63-420D-80C0-51CC03A214BA}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>BabylonExport.Core</RootNamespace>
+    <AssemblyName>BabylonExport.Core</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SccProjectName>SAK</SccProjectName>
+    <SccLocalPath>SAK</SccLocalPath>
+    <SccAuxPath>SAK</SccAuxPath>
+    <SccProvider>SAK</SccProvider>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <PlatformTarget>x86</PlatformTarget>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Microsoft.Build" />
+    <Reference Include="Microsoft.Build.Engine" />
+    <Reference Include="Microsoft.Build.Framework" />
+    <Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
+    <Reference Include="Microsoft.Xna.Framework.Content.Pipeline, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\BabylonExport\Refs\Microsoft.Xna.Framework.Content.Pipeline.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.AudioImporters, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\BabylonExport\Refs\Microsoft.Xna.Framework.Content.Pipeline.AudioImporters.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.EffectImporter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\BabylonExport\Refs\Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.FBXImporter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\BabylonExport\Refs\Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.TextureImporter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\BabylonExport\Refs\Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.VideoImporters, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\BabylonExport\Refs\Microsoft.Xna.Framework.Content.Pipeline.VideoImporters.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.XImporter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\BabylonExport\Refs\Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
+    <Reference Include="Microsoft.Xna.Framework.Tools.Packaging.Tasks, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\BabylonExport\Refs\Microsoft.Xna.Framework.Tools.Packaging.Tasks.dll</HintPath>
+    </Reference>
+    <Reference Include="SharpDX">
+      <HintPath>..\BabylonExport\Refs\SharpDX.dll</HintPath>
+    </Reference>
+    <Reference Include="SharpDX.Direct3D9">
+      <HintPath>..\BabylonExport\Refs\SharpDX.Direct3D9.dll</HintPath>
+    </Reference>
+    <Reference Include="SharpDX.DXGI">
+      <HintPath>..\BabylonExport\Refs\SharpDX.DXGI.dll</HintPath>
+    </Reference>
+    <Reference Include="SkinnedModel">
+      <HintPath>..\BabylonExport\Refs\SkinnedModel.dll</HintPath>
+    </Reference>
+    <Reference Include="SkinnedModelPipeline">
+      <HintPath>..\BabylonExport\Refs\SkinnedModelPipeline.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Data.Linq" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Runtime.Serialization" />
+    <Reference Include="System.ServiceModel" />
+    <Reference Include="System.Windows.Forms" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+    <Reference Include="Vertice.Core">
+      <HintPath>..\BabylonExport\Refs\Vertice.Core.dll</HintPath>
+    </Reference>
+    <Reference Include="Vertice.Nova">
+      <HintPath>..\BabylonExport\Refs\Vertice.Nova.dll</HintPath>
+    </Reference>
+    <Reference Include="Vertice.Nova.Core.DirectX10">
+      <HintPath>..\BabylonExport\Refs\Vertice.Nova.Core.DirectX10.dll</HintPath>
+    </Reference>
+    <Reference Include="Vertice.Nova.Core.DirectX9">
+      <HintPath>..\BabylonExport\Refs\Vertice.Nova.Core.DirectX9.dll</HintPath>
+    </Reference>
+    <Reference Include="Vertice.Nova.Interop">
+      <HintPath>..\BabylonExport\Refs\Vertice.Nova.Interop.dll</HintPath>
+    </Reference>
+    <Reference Include="Vertice.Wrappers.DirectX">
+      <HintPath>..\BabylonExport\Refs\Vertice.Wrappers.DirectX.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Entities\Export\BabylonAnimation.cs" />
+    <Compile Include="Entities\Export\BabylonAnimationKey.cs" />
+    <Compile Include="Entities\Export\BabylonBone.cs" />
+    <Compile Include="Entities\Export\BabylonCamera.cs" />
+    <Compile Include="Entities\Export\BabylonLight.cs" />
+    <Compile Include="Entities\Export\BabylonMaterial.cs" />
+    <Compile Include="Entities\Export\BabylonMesh.cs" />
+    <Compile Include="Entities\Export\BabylonMultiMaterial.cs" />
+    <Compile Include="Entities\Export\BabylonParticleSystem.cs" />
+    <Compile Include="Entities\Export\BabylonScene.cs" />
+    <Compile Include="Entities\Export\BabylonShadowGenerator.cs" />
+    <Compile Include="Entities\Export\BabylonSkeleton.cs" />
+    <Compile Include="Entities\Export\BabylonSubMesh.cs" />
+    <Compile Include="Entities\Export\BabylonTexture.cs" />
+    <Compile Include="Entities\IDumpable.cs" />
+    <Compile Include="Entities\IQueryable.cs" />
+    <Compile Include="Entities\Mesh.cs" />
+    <Compile Include="Entities\PositionNormalTextured.cs" />
+    <Compile Include="Entities\PositionNormalTexturedWeights.cs" />
+    <Compile Include="Entities\ProxyMesh.cs" />
+    <Compile Include="Entities\StandardMaterial.cs" />
+    <Compile Include="Exporters\FBX\FBXExporter.cs" />
+    <Compile Include="Exporters\FBX\XNA\ContentBuilder.cs" />
+    <Compile Include="Exporters\FBX\XNA\ErrorLogger.cs" />
+    <Compile Include="Exporters\FBX\XNA\GraphicsDeviceService.cs" />
+    <Compile Include="Exporters\FBX\XNA\ServiceContainer.cs" />
+    <Compile Include="Exporters\IExporter.cs" />
+    <Compile Include="Exporters\MXB\NovaExporter.cs" />
+    <Compile Include="Exporters\MXB\NovaExporter.Materials.cs" />
+    <Compile Include="Exporters\OBJ\Document.cs" />
+    <Compile Include="Exporters\OBJ\Line.cs" />
+    <Compile Include="Exporters\OBJ\MtlHeader.cs" />
+    <Compile Include="Exporters\OBJ\MtlLine.cs" />
+    <Compile Include="Exporters\OBJ\ObjExporter.cs" />
+    <Compile Include="Exporters\OBJ\ObjExporter.Material.cs" />
+    <Compile Include="Exporters\OBJ\ObjHeader.cs" />
+    <Compile Include="Exporters\OBJ\ObjLine.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Tools.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Exporters\Blender\io_export_babylon.py" />
+    <None Include="Exporters\FBX\XNA\XNA Game Studio\Microsoft.Xna.GameStudio.ContentPipelineExtensions.targets">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="Exporters\FBX\XNA\XNA Game Studio\Microsoft.Xna.GameStudio.targets">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="Exporters\FBX\XNA\XNA Game Studio\v4.0\Microsoft.Xna.GameStudio.AvailablePlatforms.targets">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="Exporters\FBX\XNA\XNA Game Studio\v4.0\Microsoft.Xna.GameStudio.Common.targets">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="Exporters\FBX\XNA\XNA Game Studio\v4.0\Microsoft.Xna.GameStudio.Content.targets">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="Exporters\FBX\XNA\XNA Game Studio\v4.0\Microsoft.Xna.GameStudio.ContentPipeline.targets">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="Exporters\FBX\XNA\XNA Game Studio\v4.0\Microsoft.Xna.GameStudio.Windows.targets">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="Exporters\FBX\XNA\XNA Game Studio\v4.0\Microsoft.Xna.GameStudio.Xbox 360.targets">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="Refs\xnafx40_redist.msi" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Exporters\FBX\XNA\XNA Game Studio\v4.0\Microsoft.Xna.Framework.Tools.Packaging.Tasks.dll">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="Refs\Microsoft.Xna.Framework.Content.Pipeline.AudioImporters.dll" />
+    <Content Include="Refs\Microsoft.Xna.Framework.Content.Pipeline.dll" />
+    <Content Include="Refs\Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll" />
+    <Content Include="Refs\Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll" />
+    <Content Include="Refs\Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll" />
+    <Content Include="Refs\Microsoft.Xna.Framework.Content.Pipeline.VideoImporters.dll" />
+    <Content Include="Refs\Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll" />
+    <Content Include="Refs\Microsoft.Xna.Framework.Tools.Packaging.Tasks.dll" />
+    <Content Include="Refs\SharpDX.Direct3D9.dll" />
+    <Content Include="Refs\SharpDX.dll" />
+    <Content Include="Refs\SharpDX.DXGI.dll" />
+    <Content Include="Refs\SkinnedModel.dll" />
+    <Content Include="Refs\SkinnedModelPipeline.dll" />
+    <Content Include="Refs\Vertice.Core.dll" />
+    <Content Include="Refs\Vertice.Nova.Core.DirectX10.dll" />
+    <Content Include="Refs\Vertice.Nova.Core.DirectX9.dll" />
+    <Content Include="Refs\Vertice.Nova.dll" />
+    <Content Include="Refs\Vertice.Nova.Interop.dll" />
+    <Content Include="Refs\Vertice.Wrappers.DirectX.dll" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonAnimation.cs

@@ -1,7 +1,7 @@
 using System.Runtime.Serialization;
 using Vertice.Nova.Animations;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     [DataContract]
     public class BabylonAnimation

+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonAnimationKey.cs

@@ -1,6 +1,6 @@
 using System.Runtime.Serialization;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     [DataContract]
     public class BabylonAnimationKey

+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonBone.cs

@@ -1,7 +1,7 @@
 using System.Runtime.Serialization;
 using Vertice.Nova.Animations;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     [DataContract]
     public class BabylonBone

+ 22 - 1
Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonCamera.cs

@@ -1,6 +1,6 @@
 using System.Runtime.Serialization;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     [DataContract]
     public class BabylonCamera
@@ -12,6 +12,12 @@ namespace BabylonExport
         public string id { get; set; }
 
         [DataMember]
+        public string parentId { get; set; }
+
+        [DataMember]
+        public string lockedTargetId { get; set; }
+
+        [DataMember]
         public float[] position { get; set; }
 
         [DataMember]
@@ -44,6 +50,21 @@ namespace BabylonExport
         [DataMember]
         public float[] ellipsoid { get; set; }
 
+        [DataMember]
+        public bool autoAnimate { get; set; }
+
+        [DataMember]
+        public int autoAnimateFrom { get; set; }
+
+        [DataMember]
+        public int autoAnimateTo { get; set; }
+
+        [DataMember]
+        public bool autoAnimateLoop { get; set; }
+
+        [DataMember]
+        public BabylonAnimation[] animations { get; set; }
+
 
         public BabylonCamera()
         {

+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonLight.cs

@@ -1,6 +1,6 @@
 using System.Runtime.Serialization;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     [DataContract]
     public class BabylonLight

+ 2 - 2
Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonMaterial.cs

@@ -1,7 +1,7 @@
 using System.Runtime.Serialization;
-using BabylonExport.Exporters;
+using BabylonExport.Core.Exporters;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     [DataContract]
     public class BabylonMaterial

+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonMesh.cs

@@ -1,6 +1,6 @@
 using System.Runtime.Serialization;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     [DataContract]
     public class BabylonMesh

+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonMultiMaterial.cs

@@ -1,6 +1,6 @@
 using System.Runtime.Serialization;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     [DataContract]
     public class BabylonMultiMaterial

+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonParticleSystem.cs

@@ -1,6 +1,6 @@
 using System.Runtime.Serialization;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     [DataContract]
     public class BabylonParticleSystem

+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonScene.cs

@@ -4,7 +4,7 @@ using System.IO;
 using System.Runtime.Serialization;
 using SharpDX;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     [DataContract]
     public class BabylonScene

+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonShadowGenerator.cs

@@ -1,7 +1,7 @@
 using System.Runtime.Serialization;
 using Vertice.Nova.Animations;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     [DataContract]
     public class BabylonShadowGenerator

+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonSkeleton.cs

@@ -1,7 +1,7 @@
 using System.Runtime.Serialization;
 using Vertice.Nova.Animations;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     [DataContract]
     public class BabylonSkeleton

+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonSubMesh.cs

@@ -1,6 +1,6 @@
 using System.Runtime.Serialization;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     [DataContract]
     public class BabylonSubMesh

+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Entities/Export/BabylonTexture.cs

@@ -1,6 +1,6 @@
 using System.Runtime.Serialization;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     [DataContract]
     public class BabylonTexture

+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Entities/IDumpable.cs

@@ -1,6 +1,6 @@
 using System.Collections.Generic;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     public interface IDumpable
     {

+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Entities/IQueryable.cs

@@ -1,6 +1,6 @@
 using SharpDX;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     public interface IQueryable
     {

+ 2 - 2
Exporters/FBX - OBJ/BabylonExport/Entities/Mesh.cs

@@ -1,9 +1,9 @@
 using System;
 using System.Collections.Generic;
-using BabylonExport.Exporters;
+using BabylonExport.Core.Exporters;
 using SharpDX;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     public class Mesh<T> where T : struct, IDumpable, IQueryable
     {

+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Entities/PositionNormalTextured.cs

@@ -2,7 +2,7 @@
 using System.Globalization;
 using SharpDX;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     public struct PositionNormalTextured : IDumpable, IQueryable
     {

+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Entities/PositionNormalTexturedWeights.cs

@@ -2,7 +2,7 @@
 using System.Globalization;
 using SharpDX;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     public struct PositionNormalTexturedWeights : IDumpable, IQueryable
     {

+ 2 - 2
Exporters/FBX - OBJ/BabylonExport/Entities/ProxyMesh.cs

@@ -1,8 +1,8 @@
 using System;
-using BabylonExport.Exporters;
+using BabylonExport.Core.Exporters;
 using SharpDX;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     public class ProxyMesh
     {

+ 2 - 2
Exporters/FBX - OBJ/BabylonExport/Entities/StandardMaterial.cs

@@ -1,9 +1,9 @@
 using System;
 using System.IO;
-using BabylonExport.Exporters;
+using BabylonExport.Core.Exporters;
 using SharpDX;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     public class StandardMaterial
     {

+ 5 - 3
Exporters/FBX - OBJ/BabylonExport/Exporters/Blender/io_export_babylon.py

@@ -333,16 +333,15 @@ class Export_babylon(bpy.types.Operator, ExportHelper):
         rot = mathutils.Quaternion((0, 0, 0, 1))
         scale = mathutils.Vector((1, 1, 1))
         
+        world = object.matrix_world
         if object.parent and object.parent.type == "ARMATURE" and len(object.vertex_groups) > 0:
-            mesh.transform(object.matrix_world)
             hasSkeleton = True
         else:
             hasSkeleton = False
-            world = object.matrix_world
             if (object.parent):
                 world = object.parent.matrix_world.inverted() * object.matrix_world
 
-            loc, rot, scale = world.decompose()
+        loc, rot, scale = world.decompose()
                                                 
         # Triangulate mesh if required
         Export_babylon.mesh_triangulate(mesh)
@@ -438,6 +437,8 @@ class Export_babylon(bpy.types.Operator, ExportHelper):
                                     i = i + 1
                                     if (i == 4):
                                         break;
+                            if (i == 4):
+                                break;
 
 
                     # Texture coordinates
@@ -564,6 +565,7 @@ class Export_babylon(bpy.types.Operator, ExportHelper):
         elif len(object.material_slots) > 1:
             multimat = MultiMaterial()
             multimat.name = "Multimaterial#" + str(len(multiMaterials))
+            multimat.materials = []
             Export_babylon.write_string(file_handler, "materialId", multimat.name)
             for mat in object.material_slots:
                 multimat.materials.append(mat.name)

+ 4 - 4
Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/FBXExporter.cs

@@ -4,13 +4,13 @@ using System.IO;
 using System.Linq;
 using System.Runtime.Serialization.Json;
 using System.Windows.Forms;
-using BabylonExport.Exporters.FBX;
+using BabylonExport.Core.Exporters.FBX;
 using Microsoft.Xna.Framework.Content;
 using Microsoft.Xna.Framework.Graphics;
 using SkinnedModel;
 using Vertice.Nova.Animations;
 
-namespace BabylonExport.Exporters
+namespace BabylonExport.Core.Exporters
 {
     public class FBXExporter : IExporter
     {
@@ -40,8 +40,8 @@ namespace BabylonExport.Exporters
             var services = new ServiceContainer();
 
             // Create a graphics device
-            var form = new Form();
-            services.AddService<IGraphicsDeviceService>(GraphicsDeviceService.AddRef(form.Handle, 1, 1));
+
+            services.AddService<IGraphicsDeviceService>(GraphicsDeviceService.singletonInstance);
 
             var contentBuilder = new ContentBuilder();
             var contentManager = new ContentManager(services, contentBuilder.OutputDirectory);

+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/ContentBuilder.cs

@@ -8,7 +8,7 @@ using Microsoft.Build.Execution;
 using Microsoft.Build.Framework;
 using System.Windows.Forms;
 
-namespace BabylonExport.Exporters.FBX
+namespace BabylonExport.Core.Exporters.FBX
 {
     class ContentBuilder : IDisposable
     {

+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/ErrorLogger.cs

@@ -1,7 +1,7 @@
 using System.Collections.Generic;
 using Microsoft.Build.Framework;
 
-namespace BabylonExport.Exporters.FBX
+namespace BabylonExport.Core.Exporters.FBX
 {
     class ErrorLogger : ILogger
     {

+ 3 - 3
Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/GraphicsDeviceService.cs

@@ -4,11 +4,11 @@ using Microsoft.Xna.Framework.Graphics;
 
 #pragma warning disable 67
 
-namespace BabylonExport.Exporters.FBX
+namespace BabylonExport.Core.Exporters.FBX
 {
-    class GraphicsDeviceService : IGraphicsDeviceService
+    public class GraphicsDeviceService : IGraphicsDeviceService
     {
-        static GraphicsDeviceService singletonInstance;
+        public static GraphicsDeviceService singletonInstance;
         static int referenceCount;
 
         GraphicsDeviceService(IntPtr windowHandle, int width, int height)

+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/ServiceContainer.cs

@@ -1,7 +1,7 @@
 using System;
 using System.Collections.Generic;
 
-namespace BabylonExport.Exporters.FBX
+namespace BabylonExport.Core.Exporters.FBX
 {
     public class ServiceContainer : IServiceProvider
     {

Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/XNA Game Studio/Microsoft.Xna.GameStudio.ContentPipelineExtensions.targets → Exporters/FBX - OBJ/BabylonExport.Core/Exporters/FBX/XNA/XNA Game Studio/Microsoft.Xna.GameStudio.ContentPipelineExtensions.targets


Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/XNA Game Studio/Microsoft.Xna.GameStudio.targets → Exporters/FBX - OBJ/BabylonExport.Core/Exporters/FBX/XNA/XNA Game Studio/Microsoft.Xna.GameStudio.targets


Exporters/FBX - OBJ/BabylonExport/Refs/Microsoft.Xna.Framework.Tools.Packaging.Tasks.dll → Exporters/FBX - OBJ/BabylonExport.Core/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.Framework.Tools.Packaging.Tasks.dll


Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.GameStudio.AvailablePlatforms.targets → Exporters/FBX - OBJ/BabylonExport.Core/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.GameStudio.AvailablePlatforms.targets


Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.GameStudio.Common.targets → Exporters/FBX - OBJ/BabylonExport.Core/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.GameStudio.Common.targets


Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.GameStudio.Content.targets → Exporters/FBX - OBJ/BabylonExport.Core/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.GameStudio.Content.targets


Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.GameStudio.ContentPipeline.targets → Exporters/FBX - OBJ/BabylonExport.Core/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.GameStudio.ContentPipeline.targets


Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.GameStudio.Windows.targets → Exporters/FBX - OBJ/BabylonExport.Core/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.GameStudio.Windows.targets


Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.GameStudio.Xbox 360.targets → Exporters/FBX - OBJ/BabylonExport.Core/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.GameStudio.Xbox 360.targets


+ 1 - 1
Exporters/FBX - OBJ/BabylonExport/Exporters/IExporter.cs

@@ -1,6 +1,6 @@
 using System;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     public interface IExporter
     {

+ 41 - 4
Exporters/FBX - OBJ/BabylonExport/Exporters/MXB/NovaExporter.Materials.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Drawing;
+using System.Drawing.Imaging;
 using System.IO;
 using System.Linq;
 using BabylonExport;
@@ -11,7 +12,7 @@ using Vertice.Nova.Core;
 using Vertice.Nova.Materials;
 using System.Windows.Forms;
 
-namespace BabylonExport.Exporters
+namespace BabylonExport.Core.Exporters
 {
     partial class NovaExporter
     {
@@ -92,6 +93,15 @@ namespace BabylonExport.Exporters
             babylonMaterial.specularPower = stdMaterial.SpecularSharpness;
             babylonMaterial.backFaceCulling = (stdMaterial.CullMode == NovaCull.CounterClockwise);
 
+            if (stdMaterial.DiffuseTexture != null && stdMaterial.DiffuseTexture.HasTextureData && stdMaterial.OpacityTexture != null && stdMaterial.OpacityTexture.HasTextureData)
+            {
+                if (stdMaterial.DiffuseTexture.LoadedTexture == stdMaterial.OpacityTexture.LoadedTexture)
+                {
+                    stdMaterial.DiffuseTexture = stdMaterial.OpacityTexture;
+                    stdMaterial.OpacityTexture = null;
+                }
+            }
+
             if (stdMaterial.DiffuseTexture != null && stdMaterial.DiffuseTexture.HasTextureData && !stdMaterial.DiffuseTexture.IsVideo && !stdMaterial.DiffuseTexture.IsCubeRender)
             {
                 babylonMaterial.diffuseTexture = new BabylonTexture();
@@ -159,6 +169,15 @@ namespace BabylonExport.Exporters
             babylonMaterial.specularPower = ppShader.SpecularSharpness;
             babylonMaterial.backFaceCulling = (ppShader.CullMode == NovaCull.CounterClockwise);
 
+            if (ppShader.DiffuseTexture != null && ppShader.DiffuseTexture.HasTextureData && ppShader.OpacityTexture != null && ppShader.OpacityTexture.HasTextureData)
+            {
+                if (ppShader.DiffuseTexture.LoadedTexture == ppShader.OpacityTexture.LoadedTexture)
+                {
+                    ppShader.DiffuseTexture = ppShader.OpacityTexture;
+                    ppShader.OpacityTexture = null;
+                }
+            }
+
             if (ppShader.DiffuseTexture != null && ppShader.DiffuseTexture.HasTextureData && !ppShader.DiffuseTexture.IsVideo && !ppShader.DiffuseTexture.IsCubeRender)
             {
                 babylonMaterial.diffuseTexture = new BabylonTexture();
@@ -401,14 +420,32 @@ namespace BabylonExport.Exporters
         {
             string name = texture.Name;
             // Data
-            if (!alreadyExportedTextures.Contains(texture.Name))
+            if (!alreadyExportedTextures.Contains(texture.Name + texture.HasAlpha))
             {
-                alreadyExportedTextures.Add(texture.Name);
+                alreadyExportedTextures.Add(texture.Name + texture.HasAlpha);
 
                 if (Path.GetExtension(texture.Name).ToLower() == ".dds" || Path.GetExtension(texture.Name).ToLower() == ".bmp")
                 {
                     name = Path.GetFileNameWithoutExtension(texture.Name) + ".png";
+                    var alreadyExists = File.Exists(Path.Combine(babylonScene.OutputPath, name));
+
                     texture.LoadedTexture.SaveToPNG(Path.Combine(babylonScene.OutputPath, name));
+
+                    if (!texture.HasAlpha)
+                    {
+                        var oldPath = Path.Combine(babylonScene.OutputPath, name);
+                        var bmp = Image.FromFile(oldPath);
+
+                        name = Path.GetFileNameWithoutExtension(texture.Name) + ".jpg";
+
+                        bmp.Save(Path.Combine(babylonScene.OutputPath, name), ImageFormat.Jpeg);
+                        bmp.Dispose();
+
+                        if (!alreadyExists)
+                        {
+                            File.Delete(oldPath);
+                        }
+                    }
                 }
                 else
                 {
@@ -421,7 +458,7 @@ namespace BabylonExport.Exporters
                 if (Path.GetExtension(texture.Name).ToLower() == ".dds" ||
                     Path.GetExtension(texture.Name).ToLower() == ".bmp")
                 {
-                    name = Path.GetFileNameWithoutExtension(texture.Name) + ".png";
+                    name = Path.GetFileNameWithoutExtension(texture.Name) + (texture.HasAlpha ? ".png" : ".jpg");
                 }
             }
 

+ 32 - 2
Exporters/FBX - OBJ/BabylonExport/Exporters/MXB/NovaExporter.cs

@@ -11,7 +11,7 @@ using Vertice.Nova.Materials;
 using Vertice.Nova.Animations;
 using Vertice.Nova.Core.DirectX10;
 
-namespace BabylonExport.Exporters
+namespace BabylonExport.Core.Exporters
 {
     public partial class NovaExporter : IExporter
     {
@@ -556,7 +556,7 @@ namespace BabylonExport.Exporters
             return exportedVerticesCount;
         }
 
-        static void DumpCameras(NovaScene scene, BabylonScene babylonScene)
+        void DumpCameras(NovaScene scene, BabylonScene babylonScene)
         {
             foreach (NovaCamera camera in scene.Cameras)
             {
@@ -565,6 +565,8 @@ namespace BabylonExport.Exporters
 
                 babylonCamera.name = camera.Name;
                 babylonCamera.id = camera.ID.ToString();
+                babylonCamera.parentId = camera.ParentEntity == null ? "" : camera.ParentEntity.ID.ToString();
+                babylonCamera.lockedTargetId = camera.Target == null ? "" : camera.Target.ID.ToString();
                 babylonCamera.position = camera.Position.ToArray();
                 babylonCamera.rotation = camera.Rotation.ToArray();
                 babylonCamera.fov = camera.FOV;
@@ -575,6 +577,34 @@ namespace BabylonExport.Exporters
                 babylonCamera.checkCollisions = camera.CheckCollisions;
                 babylonCamera.applyGravity = camera.ApplyGravity;
                 babylonCamera.ellipsoid = camera.EllipsoidVector.ToArray();
+
+                // Animations
+                var animations = new List<BabylonAnimation>();
+
+                // Position
+                if (!DumpInterpolator("Position animation", "position", camera.PositionInterpolator, scene, animations))
+                {
+                    DumpInterpolator("PositionX animation", "position.x", camera.PositionXInterpolator, scene, animations);
+                    DumpInterpolator("PositionY animation", "position.y", camera.PositionYInterpolator, scene, animations);
+                    DumpInterpolator("PositionZ animation", "position.z", camera.PositionZInterpolator, scene, animations);
+                }
+
+                babylonCamera.animations = animations.ToArray();
+                babylonCamera.autoAnimate = camera.AutoAnimate;
+
+                if (camera.AutoAnimate)
+                {
+                    babylonCamera.autoAnimateFrom = camera.AnimationStartKey;
+                    if (camera.AnimationEndKey == -1)
+                    {
+                        babylonCamera.autoAnimateTo = scene.AnimationKeyMax / scene.AnimationKeyStep;
+                        babylonCamera.autoAnimateLoop = true;
+                    }
+                    else
+                    {
+                        babylonCamera.autoAnimateTo = camera.AnimationEndKey;
+                    }
+                }
             }
 
             if (scene.ActiveCamera != null)

+ 11 - 6
Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/XNA Game Studio/SkinnedModel/Properties/AssemblyInfo.cs

@@ -5,11 +5,12 @@ using System.Runtime.InteropServices;
 // General Information about an assembly is controlled through the following 
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
-[assembly: AssemblyTitle("SkinnedModel")]
-[assembly: AssemblyProduct("SkinnedModel")]
-[assembly: AssemblyDescription("Helper library for loading and rendering skinned character animations.")]
-[assembly: AssemblyCompany("Microsoft")]
-[assembly: AssemblyCopyright("Copyright © Microsoft 2009")]
+[assembly: AssemblyTitle("BabylonExport.Core")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("BabylonExport.Core")]
+[assembly: AssemblyCopyright("Copyright ©  2013")]
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
 
@@ -19,7 +20,7 @@ using System.Runtime.InteropServices;
 [assembly: ComVisible(false)]
 
 // The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("5e380a3c-8bce-4895-9576-cb762960c86b")]
+[assembly: Guid("c960f8e7-d038-4054-b593-3449d420c1e8")]
 
 // Version information for an assembly consists of the following four values:
 //
@@ -28,4 +29,8 @@ using System.Runtime.InteropServices;
 //      Build Number
 //      Revision
 //
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

Exporters/FBX - OBJ/BabylonExport/Refs/Microsoft.Xna.Framework.Content.Pipeline.AudioImporters.dll → Exporters/FBX - OBJ/BabylonExport.Core/Refs/Microsoft.Xna.Framework.Content.Pipeline.AudioImporters.dll


Exporters/FBX - OBJ/BabylonExport/Refs/Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll → Exporters/FBX - OBJ/BabylonExport.Core/Refs/Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll


Exporters/FBX - OBJ/BabylonExport/Refs/Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll → Exporters/FBX - OBJ/BabylonExport.Core/Refs/Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll


Exporters/FBX - OBJ/BabylonExport/Refs/Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll → Exporters/FBX - OBJ/BabylonExport.Core/Refs/Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll


Exporters/FBX - OBJ/BabylonExport/Refs/Microsoft.Xna.Framework.Content.Pipeline.VideoImporters.dll → Exporters/FBX - OBJ/BabylonExport.Core/Refs/Microsoft.Xna.Framework.Content.Pipeline.VideoImporters.dll


Exporters/FBX - OBJ/BabylonExport/Refs/Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll → Exporters/FBX - OBJ/BabylonExport.Core/Refs/Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll


Exporters/FBX - OBJ/BabylonExport/Refs/Microsoft.Xna.Framework.Content.Pipeline.dll → Exporters/FBX - OBJ/BabylonExport.Core/Refs/Microsoft.Xna.Framework.Content.Pipeline.dll


Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/XNA Game Studio/v4.0/Microsoft.Xna.Framework.Tools.Packaging.Tasks.dll → Exporters/FBX - OBJ/BabylonExport.Core/Refs/Microsoft.Xna.Framework.Tools.Packaging.Tasks.dll


Exporters/FBX - OBJ/BabylonExport/Refs/SharpDX.DXGI.dll → Exporters/FBX - OBJ/BabylonExport.Core/Refs/SharpDX.DXGI.dll


Exporters/FBX - OBJ/BabylonExport/Refs/SharpDX.Direct3D9.dll → Exporters/FBX - OBJ/BabylonExport.Core/Refs/SharpDX.Direct3D9.dll


Exporters/FBX - OBJ/BabylonExport/Refs/SharpDX.dll → Exporters/FBX - OBJ/BabylonExport.Core/Refs/SharpDX.dll


Exporters/FBX - OBJ/BabylonExport/Refs/SkinnedModel.dll → Exporters/FBX - OBJ/BabylonExport.Core/Refs/SkinnedModel.dll


Exporters/FBX - OBJ/BabylonExport/Refs/SkinnedModelPipeline.dll → Exporters/FBX - OBJ/BabylonExport.Core/Refs/SkinnedModelPipeline.dll


Exporters/FBX - OBJ/BabylonExport/Refs/Vertice.Core.dll → Exporters/FBX - OBJ/BabylonExport.Core/Refs/Vertice.Core.dll


Exporters/FBX - OBJ/BabylonExport/Refs/Vertice.Nova.Core.DirectX10.dll → Exporters/FBX - OBJ/BabylonExport.Core/Refs/Vertice.Nova.Core.DirectX10.dll


Exporters/FBX - OBJ/BabylonExport/Refs/Vertice.Nova.Core.DirectX9.dll → Exporters/FBX - OBJ/BabylonExport.Core/Refs/Vertice.Nova.Core.DirectX9.dll


Exporters/FBX - OBJ/BabylonExport/Refs/Vertice.Nova.Interop.dll → Exporters/FBX - OBJ/BabylonExport.Core/Refs/Vertice.Nova.Interop.dll


Exporters/FBX - OBJ/BabylonExport/Refs/Vertice.Nova.dll → Exporters/FBX - OBJ/BabylonExport.Core/Refs/Vertice.Nova.dll


Exporters/FBX - OBJ/BabylonExport/Refs/Vertice.Wrappers.DirectX.dll → Exporters/FBX - OBJ/BabylonExport.Core/Refs/Vertice.Wrappers.DirectX.dll


Exporters/FBX - OBJ/BabylonExport/Refs/xnafx40_redist.msi → Exporters/FBX - OBJ/BabylonExport.Core/Refs/xnafx40_redist.msi


+ 2 - 2
Exporters/FBX - OBJ/BabylonExport/Tools.cs

@@ -1,7 +1,7 @@
 using SharpDX;
 using Vertice.Core;
 
-namespace BabylonExport
+namespace BabylonExport.Core
 {
     public static class Tools
     {      
@@ -12,7 +12,7 @@ namespace BabylonExport
 
         public static float[] ToArray(this RGBAColor color)
         {
-            return new []{color.Red, color.Green, color.Blue};
+            return new []{color.Red, color.Green, color.Blue, color.Alpha};
         }
 
         public static float[] ToArray(this Vertice.Core.Vector3 vector3)

+ 58 - 0
Exporters/FBX - OBJ/BabylonExport.Interface/BabylonExport.Interface.csproj

@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{DEC52846-FFCB-4A66-9F13-64F65B61EDBA}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>BabylonExport.Interface</RootNamespace>
+    <AssemblyName>BabylonExport.Interface</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SccProjectName>SAK</SccProjectName>
+    <SccLocalPath>SAK</SccLocalPath>
+    <SccAuxPath>SAK</SccAuxPath>
+    <SccProvider>SAK</SccProvider>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.ServiceModel" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="IService.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 17 - 0
Exporters/FBX - OBJ/BabylonExport.Interface/IService.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.ServiceModel;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BabylonExport.Interface
+{
+
+    [ServiceContract]
+    public interface IService
+    {
+        [OperationContract]
+        bool Convert(string file, string outputName);
+    }
+}

+ 11 - 6
Exporters/FBX - OBJ/BabylonExport/Exporters/FBX/XNA/XNA Game Studio/SkinnedModelPipeline/Properties/AssemblyInfo.cs

@@ -5,11 +5,12 @@ using System.Runtime.InteropServices;
 // General Information about an assembly is controlled through the following 
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
-[assembly: AssemblyTitle("SkinnedModelPipeline")]
-[assembly: AssemblyProduct("SkinnedModelPipeline")]
-[assembly: AssemblyDescription("Content Pipeline extension used by the Skinned Model sample.")]
-[assembly: AssemblyCompany("Microsoft")]
-[assembly: AssemblyCopyright("Copyright © Microsoft 2009")]
+[assembly: AssemblyTitle("BabylonExport.Interface")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("BabylonExport.Interface")]
+[assembly: AssemblyCopyright("Copyright ©  2013")]
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
 
@@ -19,7 +20,7 @@ using System.Runtime.InteropServices;
 [assembly: ComVisible(false)]
 
 // The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("004749eb-b0cf-4c1f-bdf3-390054aa0da5")]
+[assembly: Guid("99970c29-2668-4b9f-858a-f32c260bcc12")]
 
 // Version information for an assembly consists of the following four values:
 //
@@ -28,4 +29,8 @@ using System.Runtime.InteropServices;
 //      Build Number
 //      Revision
 //
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 2 - 2
Exporters/FBX - OBJ/BabylonExport/App.config

@@ -1,6 +1,6 @@
-<?xml version="1.0"?>
+<?xml version="1.0"?>
 <configuration>
   <startup useLegacyV2RuntimeActivationPolicy="true"> 
-        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
     </startup>
 </configuration>

+ 191 - 185
Exporters/FBX - OBJ/BabylonExport/BabylonExport.csproj

@@ -9,13 +9,16 @@
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>BabylonExport</RootNamespace>
     <AssemblyName>BabylonExport</AssemblyName>
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <SccProjectName>SAK</SccProjectName>
     <SccLocalPath>SAK</SccLocalPath>
     <SccAuxPath>SAK</SccAuxPath>
     <SccProvider>SAK</SccProvider>
     <TargetFrameworkProfile />
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
     <PublishUrl>publish\</PublishUrl>
     <Install>true</Install>
     <InstallFrom>Disk</InstallFrom>
@@ -28,11 +31,8 @@
     <MapFileExtensions>true</MapFileExtensions>
     <ApplicationRevision>0</ApplicationRevision>
     <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
-    <IsWebBootstrapper>false</IsWebBootstrapper>
     <UseApplicationTrust>false</UseApplicationTrust>
     <BootstrapperEnabled>true</BootstrapperEnabled>
-    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
-    <RestorePackages>true</RestorePackages>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <PlatformTarget>x86</PlatformTarget>
@@ -43,6 +43,7 @@
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
@@ -52,159 +53,73 @@
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>false</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x64\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <Prefer32Bit>false</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <OutputPath>bin\x64\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <Prefer32Bit>false</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x86\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x86</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <Prefer32Bit>false</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+    <OutputPath>bin\x86\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x86</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <Prefer32Bit>false</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup>
+    <StartupObject />
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="Microsoft.Build" />
-    <Reference Include="Microsoft.Build.Engine" />
-    <Reference Include="Microsoft.Build.Framework" />
-    <Reference Include="Microsoft.Xna.Framework">
-      <HintPath>..\Ref\XNA\Microsoft.Xna.Framework.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Xna.Framework.Content.Pipeline">
-      <HintPath>..\Ref\XNA\Microsoft.Xna.Framework.Content.Pipeline.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.AudioImporters">
-      <HintPath>..\Ref\XNA\Microsoft.Xna.Framework.Content.Pipeline.AudioImporters.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.EffectImporter">
-      <HintPath>..\Ref\XNA\Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.FBXImporter">
-      <HintPath>..\Ref\XNA\Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.TextureImporter">
-      <HintPath>..\Ref\XNA\Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.VideoImporters">
-      <HintPath>..\Ref\XNA\Microsoft.Xna.Framework.Content.Pipeline.VideoImporters.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.XImporter">
-      <HintPath>..\Ref\XNA\Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Xna.Framework.Game">
-      <HintPath>..\Ref\XNA\Microsoft.Xna.Framework.Game.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Xna.Framework.Graphics">
-      <HintPath>..\Ref\XNA\Microsoft.Xna.Framework.Graphics.dll</HintPath>
-    </Reference>
-    <Reference Include="SharpDX, Version=2.4.2.0, Culture=neutral, PublicKeyToken=627a3d6d1956f55a, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>Refs\SharpDX.dll</HintPath>
-    </Reference>
-    <Reference Include="SharpDX.Direct3D9, Version=2.4.2.0, Culture=neutral, PublicKeyToken=627a3d6d1956f55a, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>Refs\SharpDX.Direct3D9.dll</HintPath>
-    </Reference>
-    <Reference Include="SharpDX.DXGI, Version=2.4.2.0, Culture=neutral, PublicKeyToken=627a3d6d1956f55a, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>Refs\SharpDX.DXGI.dll</HintPath>
-    </Reference>
-    <Reference Include="SkinnedModel, Version=1.0.0.0, Culture=neutral, processorArchitecture=x86">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>Refs\SkinnedModel.dll</HintPath>
-    </Reference>
-    <Reference Include="SkinnedModelPipeline, Version=1.0.0.0, Culture=neutral, processorArchitecture=x86">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>Refs\SkinnedModelPipeline.dll</HintPath>
-    </Reference>
+    <Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.Drawing" />
     <Reference Include="System.Runtime.Serialization" />
+    <Reference Include="System.ServiceModel" />
     <Reference Include="System.Windows.Forms" />
     <Reference Include="System.Xml.Linq" />
     <Reference Include="System.Data.DataSetExtensions" />
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="System.Data" />
     <Reference Include="System.Xml" />
-    <Reference Include="Vertice.Core, Version=6.0.0.17, Culture=neutral, PublicKeyToken=4b8661552b78caf7, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>Refs\Vertice.Core.dll</HintPath>
-    </Reference>
-    <Reference Include="Vertice.Nova, Version=6.0.0.17, Culture=neutral, PublicKeyToken=4b8661552b78caf7, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>Refs\Vertice.Nova.dll</HintPath>
-    </Reference>
-    <Reference Include="Vertice.Nova.Core.DirectX10, Version=6.0.0.17, Culture=neutral, PublicKeyToken=4b8661552b78caf7, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>Refs\Vertice.Nova.Core.DirectX10.dll</HintPath>
-    </Reference>
-    <Reference Include="Vertice.Nova.Core.DirectX9, Version=6.0.0.17, Culture=neutral, PublicKeyToken=4b8661552b78caf7, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>Refs\Vertice.Nova.Core.DirectX9.dll</HintPath>
-    </Reference>
-    <Reference Include="Vertice.Nova.Interop, Version=6.0.0.17, Culture=neutral, PublicKeyToken=4b8661552b78caf7, processorArchitecture=x86">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>Refs\Vertice.Nova.Interop.dll</HintPath>
-    </Reference>
-    <Reference Include="Vertice.Wrappers.DirectX, Version=6.0.0.17, Culture=neutral, PublicKeyToken=4b8661552b78caf7, processorArchitecture=x86">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>Refs\Vertice.Wrappers.DirectX.dll</HintPath>
-    </Reference>
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Entities\Export\BabylonAnimationKey.cs" />
-    <Compile Include="Entities\Export\BabylonParticleSystem.cs" />
-    <Compile Include="Entities\Export\BabylonAnimation.cs" />
-    <Compile Include="Entities\Export\BabylonShadowGenerator.cs" />
-    <Compile Include="Entities\Export\BabylonSkeleton.cs" />
-    <Compile Include="Entities\Export\BabylonBone.cs" />
-    <Compile Include="Entities\IQueryable.cs" />
-    <Compile Include="Entities\IDumpable.cs" />
-    <Compile Include="Entities\PositionNormalTexturedWeights.cs" />
-    <Compile Include="Entities\PositionNormalTextured.cs" />
-    <Compile Include="Entities\StandardMaterial.cs" />
-    <Compile Include="Entities\Export\BabylonCamera.cs" />
-    <Compile Include="Entities\Export\BabylonScene.cs" />
-    <Compile Include="Entities\Export\BabylonLight.cs" />
-    <Compile Include="Entities\Export\BabylonMesh.cs" />
-    <Compile Include="Entities\Export\BabylonMaterial.cs" />
-    <Compile Include="Entities\Export\BabylonMultiMaterial.cs" />
-    <Compile Include="Entities\Export\BabylonTexture.cs" />
-    <Compile Include="Entities\Export\BabylonSubMesh.cs" />
-    <Compile Include="Exporters\FBX\XNA\ContentBuilder.cs" />
-    <Compile Include="Exporters\FBX\XNA\ErrorLogger.cs" />
-    <Compile Include="Exporters\FBX\FBXExporter.cs" />
-    <Compile Include="Exporters\FBX\XNA\GraphicsDeviceService.cs" />
-    <Compile Include="Exporters\FBX\XNA\ServiceContainer.cs" />
-    <Compile Include="Exporters\IExporter.cs" />
-    <Compile Include="Entities\Mesh.cs" />
-    <Compile Include="Entities\ProxyMesh.cs" />
-    <Compile Include="Exporters\MXB\NovaExporter.cs" />
-    <Compile Include="Exporters\MXB\NovaExporter.Materials.cs" />
-    <Compile Include="Exporters\OBJ\Document.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="Exporters\OBJ\Line.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="Exporters\OBJ\MtlHeader.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="Exporters\OBJ\MtlLine.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="Exporters\OBJ\ObjHeader.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="Exporters\OBJ\ObjExporter.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="Exporters\OBJ\ObjExporter.Material.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="Exporters\OBJ\ObjLine.cs">
-      <SubType>Code</SubType>
-    </Compile>
     <Compile Include="Program.cs" />
-    <Compile Include="Tools.cs" />
+    <Compile Include="Service.cs" />
   </ItemGroup>
   <ItemGroup>
     <Content Include="generateAll.bat">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
-    <None Include="Exporters\Blender\io_export_babylon.py" />
-    <None Include="Refs\xnafx40_redist.msi" />
     <None Include="Test scenes\Chimie\BalanceDM.dds" />
     <None Include="Test scenes\Chimie\BalanceLightingMap.dds" />
     <None Include="Test scenes\Chimie\BoisLightingMap.dds" />
@@ -532,33 +447,10 @@
     <None Include="Test scenes\TheCar\volant.dds" />
     <None Include="Test scenes\TheCar\wood.dds" />
     <None Include="Test scenes\TheCar\WOODlm.dds" />
+    <None Include="Test scenes\Train\train.mxb" />
     <None Include="Test scenes\Viper\Viper.mtl" />
     <None Include="Test scenes\Viper\Viper.obj" />
     <None Include="App.config" />
-    <None Include="Exporters\FBX\XNA\XNA Game Studio\Microsoft.Xna.GameStudio.ContentPipelineExtensions.targets">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>
-    <None Include="Exporters\FBX\XNA\XNA Game Studio\Microsoft.Xna.GameStudio.targets">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>
-    <None Include="Exporters\FBX\XNA\XNA Game Studio\v4.0\Microsoft.Xna.GameStudio.AvailablePlatforms.targets">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>
-    <None Include="Exporters\FBX\XNA\XNA Game Studio\v4.0\Microsoft.Xna.GameStudio.Common.targets">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>
-    <None Include="Exporters\FBX\XNA\XNA Game Studio\v4.0\Microsoft.Xna.GameStudio.Content.targets">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>
-    <None Include="Exporters\FBX\XNA\XNA Game Studio\v4.0\Microsoft.Xna.GameStudio.ContentPipeline.targets">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>
-    <None Include="Exporters\FBX\XNA\XNA Game Studio\v4.0\Microsoft.Xna.GameStudio.Windows.targets">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>
-    <None Include="Exporters\FBX\XNA\XNA Game Studio\v4.0\Microsoft.Xna.GameStudio.Xbox 360.targets">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>
     <None Include="packages.config" />
     <None Include="Test scenes\Wcafe\Affiches.dds" />
     <None Include="Test scenes\Wcafe\Affiches2.dds" />
@@ -650,27 +542,9 @@
     <None Include="Test scenes\Wcafe\ZincLightingMap.dds" />
   </ItemGroup>
   <ItemGroup>
-    <None Include="Exporters\FBX\XNA\XNA Game Studio\v4.0\Microsoft.Xna.Framework.Tools.Packaging.Tasks.dll">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>
-  </ItemGroup>
-  <ItemGroup>
     <Content Include="DirectShow.Net.dll">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
-    <Content Include="Refs\Microsoft.Xna.Framework.Content.Pipeline.AudioImporters.dll" />
-    <Content Include="Refs\Microsoft.Xna.Framework.Content.Pipeline.dll" />
-    <Content Include="Refs\Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll" />
-    <Content Include="Refs\Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll" />
-    <Content Include="Refs\Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll" />
-    <Content Include="Refs\Microsoft.Xna.Framework.Content.Pipeline.VideoImporters.dll" />
-    <Content Include="Refs\Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll" />
-    <Content Include="Refs\Microsoft.Xna.Framework.Tools.Packaging.Tasks.dll" />
-    <Content Include="Refs\SharpDX.Direct3D9.dll" />
-    <Content Include="Refs\SharpDX.DXGI.dll" />
-    <Content Include="Refs\SkinnedModel.dll" />
-    <Content Include="Refs\SkinnedModelPipeline.dll" />
-    <Content Include="Refs\Vertice.Nova.Core.DirectX10.dll" />
     <Content Include="Test scenes\Chimie\Coeur.jpg" />
     <Content Include="Test scenes\Chimie\heartSpecjpg.jpg" />
     <Content Include="Test scenes\Chimie\Labels.png" />
@@ -697,6 +571,134 @@
     <Content Include="Test scenes\SpaceDeK\VaisseauDiffuseMap.jpg" />
     <Content Include="Test scenes\SpaceDeK\VaisseauSpecularMap.jpg" />
     <Content Include="Test scenes\Spaceship\wedge_p2_diff_v1.tga" />
+    <Content Include="Test scenes\Train\barrieres_bois.dds" />
+    <Content Include="Test scenes\Train\barrieres_bois_n.dds" />
+    <Content Include="Test scenes\Train\bat_console_murs_ext_lm.dds" />
+    <Content Include="Test scenes\Train\bat_console_murs_lm.dds" />
+    <Content Include="Test scenes\Train\bat_lm.dds" />
+    <Content Include="Test scenes\Train\bg.dds" />
+    <Content Include="Test scenes\Train\bg_credits.dds" />
+    <Content Include="Test scenes\Train\bg_help.dds" />
+    <Content Include="Test scenes\Train\bosquet_grass.dds" />
+    <Content Include="Test scenes\Train\bottes_paille.dds" />
+    <Content Include="Test scenes\Train\bottes_paille_face.dds" />
+    <Content Include="Test scenes\Train\champ_ble.dds" />
+    <Content Include="Test scenes\Train\chariot_planche.dds" />
+    <Content Include="Test scenes\Train\chariot_planche_n.dds" />
+    <Content Include="Test scenes\Train\chariot_roue.dds" />
+    <Content Include="Test scenes\Train\chariot_roue_n.dds" />
+    <Content Include="Test scenes\Train\console.dds" />
+    <Content Include="Test scenes\Train\console_n.dds" />
+    <Content Include="Test scenes\Train\cubemap.dds" />
+    <Content Include="Test scenes\Train\cubemap5.dds" />
+    <Content Include="Test scenes\Train\cubemap_vitres.dds" />
+    <Content Include="Test scenes\Train\cuir.dds" />
+    <Content Include="Test scenes\Train\cuir_n.dds" />
+    <Content Include="Test scenes\Train\cur_default.cur" />
+    <Content Include="Test scenes\Train\cur_link.cur" />
+    <Content Include="Test scenes\Train\disneyland_paris.dds" />
+    <Content Include="Test scenes\Train\flechage.dds" />
+    <Content Include="Test scenes\Train\flechage2.dds" />
+    <Content Include="Test scenes\Train\grass.dds" />
+    <Content Include="Test scenes\Train\grillage.dds" />
+    <Content Include="Test scenes\Train\lens2.dds" />
+    <Content Include="Test scenes\Train\lens3.dds" />
+    <Content Include="Test scenes\Train\lens4.dds" />
+    <Content Include="Test scenes\Train\lens5.dds" />
+    <Content Include="Test scenes\Train\lens6.dds" />
+    <Content Include="Test scenes\Train\lens_sun.dds" />
+    <Content Include="Test scenes\Train\light_blanche.dds" />
+    <Content Include="Test scenes\Train\light_jaune.dds" />
+    <Content Include="Test scenes\Train\light_rouge.dds" />
+    <Content Include="Test scenes\Train\light_verte.dds" />
+    <Content Include="Test scenes\Train\metal_rouille.dds" />
+    <Content Include="Test scenes\Train\metal_rouille_n.dds" />
+    <Content Include="Test scenes\Train\metal_tache.dds" />
+    <Content Include="Test scenes\Train\metal_tache_n.dds" />
+    <Content Include="Test scenes\Train\murs_wood.dds" />
+    <Content Include="Test scenes\Train\murs_wood_n.dds" />
+    <Content Include="Test scenes\Train\no_signal.dds" />
+    <Content Include="Test scenes\Train\OSVCenter.dds" />
+    <Content Include="Test scenes\Train\OSVCenterb.dds" />
+    <Content Include="Test scenes\Train\OSVFps.dds" />
+    <Content Include="Test scenes\Train\OSVFpsb.dds" />
+    <Content Include="Test scenes\Train\OSVFullScreen.dds" />
+    <Content Include="Test scenes\Train\OSVFullScreenb.dds" />
+    <Content Include="Test scenes\Train\OSVPan.dds" />
+    <Content Include="Test scenes\Train\OSVPanb.dds" />
+    <Content Include="Test scenes\Train\OSVRotation.dds" />
+    <Content Include="Test scenes\Train\OSVRotationb.dds" />
+    <Content Include="Test scenes\Train\OSVSound.dds" />
+    <Content Include="Test scenes\Train\OSVSoundb.dds" />
+    <Content Include="Test scenes\Train\OSVTemp.dds" />
+    <Content Include="Test scenes\Train\OSVTempb.dds" />
+    <Content Include="Test scenes\Train\OSVZoom.dds" />
+    <Content Include="Test scenes\Train\OSVZoomb.dds" />
+    <Content Include="Test scenes\Train\paille_alpha.dds" />
+    <Content Include="Test scenes\Train\pile_bois.dds" />
+    <Content Include="Test scenes\Train\pile_bois_n.dds" />
+    <Content Include="Test scenes\Train\planches.dds" />
+    <Content Include="Test scenes\Train\planches_n.dds" />
+    <Content Include="Test scenes\Train\poteaux.dds" />
+    <Content Include="Test scenes\Train\poteaux_n.dds" />
+    <Content Include="Test scenes\Train\poubelle.dds" />
+    <Content Include="Test scenes\Train\poubelle_n.dds" />
+    <Content Include="Test scenes\Train\rochers_big.dds" />
+    <Content Include="Test scenes\Train\rochers_big_n.dds" />
+    <Content Include="Test scenes\Train\rock_tunnel.dds" />
+    <Content Include="Test scenes\Train\rock_tunnel_n.dds" />
+    <Content Include="Test scenes\Train\sacs_sable.dds" />
+    <Content Include="Test scenes\Train\sacs_sable_n.dds" />
+    <Content Include="Test scenes\Train\sapin_leaves.dds" />
+    <Content Include="Test scenes\Train\sapin_trunk_up.dds" />
+    <Content Include="Test scenes\Train\sapin_trunk_up_n.dds" />
+    <Content Include="Test scenes\Train\skydome.dds" />
+    <Content Include="Test scenes\Train\smoke.dds" />
+    <Content Include="Test scenes\Train\snd_bg.mp3" />
+    <Content Include="Test scenes\Train\snd_bt_clic.mp3" />
+    <Content Include="Test scenes\Train\snd_bt_clic_ui.wma" />
+    <Content Include="Test scenes\Train\snd_bt_roll.mp3" />
+    <Content Include="Test scenes\Train\snd_coaster_cry.mp3" />
+    <Content Include="Test scenes\Train\snd_roller_coaster.mp3" />
+    <Content Include="Test scenes\Train\snd_roller_coaster_loop.mp3" />
+    <Content Include="Test scenes\Train\snd_siren.mp3" />
+    <Content Include="Test scenes\Train\sol_metal.dds" />
+    <Content Include="Test scenes\Train\sol_metal_n.dds" />
+    <Content Include="Test scenes\Train\terrain1.dds" />
+    <Content Include="Test scenes\Train\terrain1_lm.dds" />
+    <Content Include="Test scenes\Train\terrain1_n.dds" />
+    <Content Include="Test scenes\Train\terrain2.dds" />
+    <Content Include="Test scenes\Train\terrain2_lm.dds" />
+    <Content Include="Test scenes\Train\terrain2_n.dds" />
+    <Content Include="Test scenes\Train\terrain3.dds" />
+    <Content Include="Test scenes\Train\terrain3_lm.dds" />
+    <Content Include="Test scenes\Train\terrain3_n.dds" />
+    <Content Include="Test scenes\Train\terrain4.dds" />
+    <Content Include="Test scenes\Train\terrain4_lm.dds" />
+    <Content Include="Test scenes\Train\terrain4_n.dds" />
+    <Content Include="Test scenes\Train\terrain_clotures_lm.dds" />
+    <Content Include="Test scenes\Train\terrain_escalier_lm.dds" />
+    <Content Include="Test scenes\Train\terrain_tunnel_lm.dds" />
+    <Content Include="Test scenes\Train\toit_bois.dds" />
+    <Content Include="Test scenes\Train\toit_bois_n.dds" />
+    <Content Include="Test scenes\Train\tole.dds" />
+    <Content Include="Test scenes\Train\tole_n.dds" />
+    <Content Include="Test scenes\Train\tonneau.dds" />
+    <Content Include="Test scenes\Train\tonneau_n.dds" />
+    <Content Include="Test scenes\Train\tracteur.dds" />
+    <Content Include="Test scenes\Train\tracteur_n.dds" />
+    <Content Include="Test scenes\Train\train_4.dds" />
+    <Content Include="Test scenes\Train\train_4_n.dds" />
+    <Content Include="Test scenes\Train\train_cote.dds" />
+    <Content Include="Test scenes\Train\train_cote_n.dds" />
+    <Content Include="Test scenes\Train\train_loco_lm.dds" />
+    <Content Include="Test scenes\Train\train_wagon_lm.dds" />
+    <Content Include="Test scenes\Train\tronc.dds" />
+    <Content Include="Test scenes\Train\tronc_face.dds" />
+    <Content Include="Test scenes\Train\tronc_face_n.dds" />
+    <Content Include="Test scenes\Train\tronc_n.dds" />
+    <Content Include="Test scenes\Train\verre_lampes.dds" />
+    <Content Include="Test scenes\Train\water_n.jpg" />
     <Content Include="Test scenes\Viper\aripa-buna.jpg" />
     <Content Include="Test scenes\Viper\carlinga-specular.jpg" />
     <Content Include="Test scenes\Viper\carlinga.jpg" />
@@ -717,12 +719,6 @@
     <Content Include="Test scenes\Viper\wing-up-bump.jpg" />
     <Content Include="Test scenes\Viper\wing-up-specular.jpg" />
     <Content Include="Test scenes\Viper\wing-up.jpg" />
-    <Content Include="Refs\SharpDX.dll" />
-    <Content Include="Refs\Vertice.Core.dll" />
-    <Content Include="Refs\Vertice.Nova.Core.DirectX9.dll" />
-    <Content Include="Refs\Vertice.Nova.dll" />
-    <Content Include="Refs\Vertice.Nova.Interop.dll" />
-    <Content Include="Refs\Vertice.Wrappers.DirectX.dll" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Properties\" />
@@ -749,6 +745,16 @@
       <Install>true</Install>
     </BootstrapperPackage>
   </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\BabylonExport.Core\BabylonExport.Core.csproj">
+      <Project>{ce70b051-fb63-420d-80c0-51cc03a214ba}</Project>
+      <Name>BabylonExport.Core</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\BabylonExport.Interface\BabylonExport.Interface.csproj">
+      <Project>{dec52846-ffcb-4a66-9f13-64f65b61edba}</Project>
+      <Name>BabylonExport.Interface</Name>
+    </ProjectReference>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

+ 0 - 0
Exporters/FBX - OBJ/BabylonExport/Exporters/Blender/io_export_babylon.zip


Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio