public void GenerateBabylonFile(string file, string outputFile, bool skinned) { try { ReportProgressChanged(0); NovaEngine.Launch <DirectX9Provider>("", 128, 128); NovaScene novaScene = NovaEngine.CreateScene("TempScene"); if (file.EndsWith(".mxc")) { NovaEngine.ResourceManager.ArchivePath = Path.GetFullPath(file); // Get the mbx file name file = NovaEngine.ResourceManager.GetStartSceneFilename(); } novaScene.Load(file); novaScene.Render(false); Generate(novaScene, outputFile); } finally { NovaEngine.Stop(); } }
void DumpObjects(NovaScene scene, BabylonScene babylonScene) { int count = 0; foreach (NovaObject novaObject in scene.Objects) { if (novaObject.Is32bits) { if (novaObject.SubObjects.Count == 1) { var total = novaObject.VerticesCount; const int step = 32000; var stepsCount = (int)(Math.Floor((float)total / step) + 1); for (var index = 0; index < stepsCount; index++) { var start = index * step; var end = (index + 1) * step; DumpObject(novaObject, babylonScene, scene, start, end, string.Format("#{0}", index)); } } } else { DumpObject(novaObject, babylonScene, scene, 0, novaObject.VerticesCount); } ReportProgressChanged(50 + (count++ *25) / scene.Objects.Count); } }
void DumpCameras(NovaScene scene, BabylonScene babylonScene) { foreach (NovaCamera camera in scene.Cameras) { var babylonCamera = new BabylonCamera(); babylonScene.CamerasList.Add(babylonCamera); 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; babylonCamera.minZ = camera.NearClip; babylonCamera.maxZ = camera.FarClip; babylonCamera.inertia = camera.Inertia; babylonCamera.speed = camera.Speed; 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) { babylonScene.activeCameraID = scene.ActiveCamera.ID.ToString(); } }
void DumpLights(NovaScene scene, BabylonScene babylonScene) { foreach (NovaLight light in scene.Lights) { if (light.Enabled) { var babylonLight = new BabylonLight(); babylonScene.LightsList.Add(babylonLight); babylonLight.name = light.Name; babylonLight.id = light.ID.ToString(); switch (light.Type) { case NovaLightType.Point: babylonLight.type = 0; babylonLight.position = light.Position.ToArray(); break; case NovaLightType.Spot: case NovaLightType.Directional: babylonLight.type = 1; babylonLight.position = light.Position.ToArray(); babylonLight.direction = light.Direction.ToArray(); break; } babylonLight.diffuse = light.Diffuse.ToArray(); babylonLight.specular = light.Specular.ToArray(); babylonLight.intensity = light.Multiplicator; if (light.ShadowMembers.Count > 0) { var shadowGenerator = new BabylonShadowGenerator { useVarianceShadowMap = true, lightId = light.ID.ToString(), mapSize = light.ShadowMapSize, renderList = light.ShadowMembers.Select(m => m.ID.ToString()).ToArray() }; babylonScene.ShadowGeneratorsList.Add(shadowGenerator); } if (light.LensFlares != null) { light.LensFlares.Tag = light; lensFlareSystemToExport.Add(light.LensFlares); } } } }
void Generate(NovaScene scene, string outputFile) { ReportProgressChanged(25); var babylonScene = new BabylonScene(Path.GetDirectoryName(outputFile)); alreadyExportedTextures.Clear(); babylonScene.autoClear = scene.AutoClear; babylonScene.clearColor = scene.ClearColor.ToArray(); babylonScene.ambientColor = scene.AmbientColor.ToArray(); babylonScene.gravity = ((scene.Gravity == Vector3.Zero) ? new Vector3(0, -9.0f, 0) : scene.Gravity).ToArray(); // Fog babylonScene.fogMode = (int)scene.FogMode; babylonScene.fogColor = scene.FogColor.ToArray(); babylonScene.fogStart = scene.ActiveCamera.NearClip; babylonScene.fogEnd = scene.ActiveCamera.FarClip; babylonScene.fogDensity = scene.FogDensity; // Cameras DumpCameras(scene, babylonScene); // Lights DumpLights(scene, babylonScene); ReportProgressChanged(50); // Objects DumpObjects(scene, babylonScene); // Materials DumpMaterials(babylonScene); // Particles DumpParticles(babylonScene); // Lens flares DumpLensFlares(babylonScene); // Output babylonScene.Prepare(false); using (var outputStream = new FileStream(outputFile, FileMode.Create, FileAccess.Write)) { var ser = new DataContractJsonSerializer(typeof(BabylonScene)); ser.WriteObject(outputStream, babylonScene); } ReportProgressChanged(100); }
void Generate(NovaScene scene, string outputFile) { ReportProgressChanged(25); var babylonScene = new BabylonScene(Path.GetDirectoryName(outputFile)); alreadyExportedTextures.Clear(); babylonScene.autoClear = scene.AutoClear; babylonScene.clearColor = scene.ClearColor.ToArray(); babylonScene.ambientColor = scene.AmbientColor.ToArray(); babylonScene.gravity = ((scene.Gravity == Vector3.Zero) ? new Vector3(0, -9.0f, 0) : scene.Gravity).ToArray(); // Fog babylonScene.fogMode = (int)scene.FogMode; babylonScene.fogColor = scene.FogColor.ToArray(); babylonScene.fogStart = scene.ActiveCamera.NearClip; babylonScene.fogEnd = scene.ActiveCamera.FarClip; babylonScene.fogDensity = scene.FogDensity; // Cameras DumpCameras(scene, babylonScene); // Lights DumpLights(scene, babylonScene); ReportProgressChanged(50); // Objects DumpObjects(scene, babylonScene); // Materials DumpMaterials(babylonScene); // Particles DumpParticles(babylonScene); // Lens flares DumpLensFlares(babylonScene); // Output babylonScene.Prepare(false); using (var outputStream = new FileStream(outputFile, FileMode.Create, FileAccess.Write)) { var ser = new DataContractJsonSerializer(typeof(BabylonScene)); ser.WriteObject(outputStream, babylonScene); } ReportProgressChanged(100); }
void DumpLights(NovaScene scene, BabylonScene babylonScene) { foreach (NovaLight light in scene.Lights) { if (light.Enabled) { var babylonLight = new BabylonLight(); babylonScene.LightsList.Add(babylonLight); babylonLight.name = light.Name; babylonLight.id = light.ID.ToString(); switch (light.Type) { case NovaLightType.Point: babylonLight.type = 0; babylonLight.position = light.Position.ToArray(); break; case NovaLightType.Spot: case NovaLightType.Directional: babylonLight.type = 1; babylonLight.position = light.Position.ToArray(); babylonLight.direction = light.Direction.ToArray(); break; } babylonLight.diffuse = light.Diffuse.ToArray(); babylonLight.specular = light.Specular.ToArray(); babylonLight.intensity = light.Multiplicator; if (light.ShadowMembers.Count > 0) { var shadowGenerator = new BabylonShadowGenerator { useVarianceShadowMap = true, lightId = light.ID.ToString(), mapSize = light.ShadowMapSize, renderList = light.ShadowMembers.Select(m => m.ID.ToString()).ToArray() }; babylonScene.ShadowGeneratorsList.Add(shadowGenerator); } if (light.LensFlares != null) { light.LensFlares.Tag = light; lensFlareSystemToExport.Add(light.LensFlares); } } } }
void DumpCameras(NovaScene scene, BabylonScene babylonScene) { foreach (NovaCamera camera in scene.Cameras) { var babylonCamera = new BabylonCamera(); babylonScene.CamerasList.Add(babylonCamera); 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; babylonCamera.minZ = camera.NearClip; babylonCamera.maxZ = camera.FarClip; babylonCamera.inertia = camera.Inertia; babylonCamera.speed = camera.Speed; 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) { babylonScene.activeCameraID = scene.ActiveCamera.ID.ToString(); } }
void DumpObject(NovaObject novaObject, BabylonScene babylonScene, NovaScene scene, int startIndex, int endIndex, string nameIndex = "") { var babylonMesh = new BabylonMesh(); babylonScene.MeshesList.Add(babylonMesh); babylonMesh.name = novaObject.Name + nameIndex; babylonMesh.id = novaObject.ID.ToString(); babylonMesh.materialId = novaObject.Material == null ? "" : novaObject.Material.ID.ToString(); babylonMesh.parentId = novaObject.ParentEntity == null ? "" : novaObject.ParentEntity.ID.ToString(); babylonMesh.isEnabled = novaObject.Enabled; babylonMesh.isVisible = novaObject.Renderable; babylonMesh.visibility = novaObject.Visibility; babylonMesh.checkCollisions = novaObject.CheckCollisions; babylonMesh.receiveShadows = novaObject.ReceiveShadows; babylonMesh.infiniteDistance = novaObject.InfiniteDistance; if (novaObject.Billboard) { babylonMesh.billboardMode |= (novaObject.BillboardX ? 1 : 0); babylonMesh.billboardMode |= (novaObject.BillboardY ? 2 : 0); babylonMesh.billboardMode |= (novaObject.BillboardZ ? 4 : 0); } if (novaObject.ParticleSystem != null) { particleSystemsToExport.Add(novaObject.ParticleSystem); } // Mirror if (novaObject.IsMirror && novaObject.Material != null) { mirrorsMaterials.Add(novaObject.Material, novaObject); } // World babylonMesh.position = novaObject.Position.ToArray(); babylonMesh.rotation = novaObject.Rotation.ToArray(); babylonMesh.localMatrix = (Matrix.Scaling(novaObject.Scaling) * novaObject.LocalMatrix).ToArray(); // Animations var animations = new List<BabylonAnimation>(); DumpInterpolator("Visibility animation", "visibility", novaObject.VisibilityInterpolator, scene, animations); // Position if (!DumpInterpolator("Position animation", "position", novaObject.PositionInterpolator, scene, animations)) { DumpInterpolator("PositionX animation", "position.x", novaObject.PositionXInterpolator, scene, animations); DumpInterpolator("PositionY animation", "position.y", novaObject.PositionYInterpolator, scene, animations); DumpInterpolator("PositionZ animation", "position.z", novaObject.PositionZInterpolator, scene, animations); } // Rotation if (!DumpInterpolator("Rotation animation", "rotationQuaternion", novaObject.RotationInterpolator, scene, animations)) { DumpInterpolator("RotationX animation", "rotation.x", novaObject.RotationXInterpolator, scene, animations, -novaObject.Determinant); DumpInterpolator("RotationY animation", "rotation.y", novaObject.RotationYInterpolator, scene, animations, -novaObject.Determinant); DumpInterpolator("RotationZ animation", "rotation.z", novaObject.RotationZInterpolator, scene, animations, -novaObject.Determinant); } else { babylonMesh.localMatrix = Matrix.Identity.ToArray(); babylonMesh.scaling = novaObject.Scaling.ToArray(); } // Scaling if (!DumpInterpolator("Scaling animation", "scaling", novaObject.ScalingInterpolator, scene, animations)) { DumpInterpolator("ScalingX animation", "scaling.x", novaObject.ScalingXInterpolator, scene, animations); DumpInterpolator("ScalingY animation", "scaling.y", novaObject.ScalingYInterpolator, scene, animations); DumpInterpolator("ScalingZ animation", "scaling.z", novaObject.ScalingZInterpolator, scene, animations); } else { babylonMesh.localMatrix = novaObject.LocalMatrix.ToArray(); babylonMesh.scaling = novaObject.Scaling.ToArray(); } babylonMesh.animations = animations.ToArray(); babylonMesh.autoAnimate = novaObject.AutoAnimate; if (novaObject.AutoAnimate) { babylonMesh.autoAnimateFrom = novaObject.AnimationStartKey; if (novaObject.AnimationEndKey == -1) { babylonMesh.autoAnimateTo = scene.AnimationKeyMax / scene.AnimationKeyStep; babylonMesh.autoAnimateLoop = true; } else { babylonMesh.autoAnimateTo = novaObject.AnimationEndKey; } } // Vertices & faces var exportedVerticesCount = DumpObjectGeometry(novaObject, babylonMesh, startIndex, endIndex); // Subobjects var subMeshes = new List<BabylonSubMesh>(); if (novaObject.Is32bits) { var subMesh = new BabylonSubMesh(); subMesh.materialIndex = 0; subMesh.verticesStart = 0; subMesh.verticesCount = exportedVerticesCount; subMesh.indexStart = 0; subMesh.indexCount = babylonMesh.indices.Length; subMeshes.Add(subMesh); } else { foreach (NovaSubObject subObject in novaObject.SubObjects) { var subMesh = new BabylonSubMesh(); subMesh.materialIndex = subObject.AttributeRange.AttributeId; subMesh.verticesStart = subObject.AttributeRange.VertexStart; subMesh.verticesCount = subObject.AttributeRange.VertexCount; subMesh.indexStart = subObject.AttributeRange.FaceStart * 3; subMesh.indexCount = subObject.AttributeRange.FaceCount * 3; subMeshes.Add(subMesh); } } babylonMesh.subMeshes = subMeshes.ToArray(); if (novaObject.Material != null) { if (!materialsToExport.Contains(novaObject.Material)) { materialsToExport.Add(novaObject.Material); var multiMat = novaObject.Material as NovaMultiMaterial; if (multiMat != null) { foreach (var mat in multiMat.Materials) { if (!materialsToExport.Contains(mat)) { materialsToExport.Add(mat); } } } } } }
void DumpObjects(NovaScene scene, BabylonScene babylonScene) { int count = 0; foreach (NovaObject novaObject in scene.Objects) { if (novaObject.Is32bits) { if (novaObject.SubObjects.Count == 1) { var total = novaObject.VerticesCount; const int step = 32000; var stepsCount = (int)(Math.Floor((float)total / step) + 1); for (var index = 0; index < stepsCount; index++) { var start = index * step; var end = (index + 1) * step; DumpObject(novaObject, babylonScene, scene, start, end, string.Format("#{0}", index)); } } } else { DumpObject(novaObject, babylonScene, scene, 0, novaObject.VerticesCount); } ReportProgressChanged(50 + (count++ * 25) / scene.Objects.Count); } }
bool DumpInterpolator(string name, string property, NovaQuaternionInterpolator interpolator, NovaScene scene, List<BabylonAnimation> animations) { if (interpolator.Ready) { var fps = scene.AnimationFramerate < 1 ? 30 : scene.AnimationFramerate; var babylonAnimation = new BabylonAnimation { name = name, property = property, dataType = BabylonAnimation.DataType.Quaternion, framePerSecond = fps }; babylonAnimation.keys = interpolator.Datas.Select(value => new BabylonAnimationKey { frame = value.Key / scene.AnimationKeyStep, values = value.Value.ToArray() }).ToArray(); babylonAnimation.loopBehavior = interpolator.LoopAfter; animations.Add(babylonAnimation); return true; } return false; }
bool DumpInterpolator(string name, string property, NovaFloatInterpolator interpolator, NovaScene scene, List<BabylonAnimation> animations, float mult = 1.0f) { if (interpolator.Ready && !IsInterpolatorIsEmpty(interpolator)) { var fps = scene.AnimationFramerate < 1 ? 30 : scene.AnimationFramerate; var babylonAnimation = new BabylonAnimation { name = name, property = property, dataType = BabylonAnimation.DataType.Float, framePerSecond = fps }; babylonAnimation.keys = interpolator.Datas.Select(value => new BabylonAnimationKey { frame = value.Key / scene.AnimationKeyStep, values = new[] { value.Value * mult } }).ToArray(); babylonAnimation.loopBehavior = interpolator.LoopAfter; animations.Add(babylonAnimation); return true; } return false; }
void DumpObject(NovaObject novaObject, BabylonScene babylonScene, NovaScene scene, int startIndex, int endIndex, string nameIndex = "") { var babylonMesh = new BabylonMesh(); babylonScene.MeshesList.Add(babylonMesh); babylonMesh.name = novaObject.Name + nameIndex; babylonMesh.id = novaObject.ID.ToString(); babylonMesh.materialId = novaObject.Material == null ? "" : novaObject.Material.ID.ToString(); babylonMesh.parentId = novaObject.ParentEntity == null ? "" : novaObject.ParentEntity.ID.ToString(); babylonMesh.isEnabled = novaObject.Enabled; babylonMesh.isVisible = novaObject.Renderable; babylonMesh.visibility = novaObject.Visibility; babylonMesh.checkCollisions = novaObject.CheckCollisions; babylonMesh.receiveShadows = novaObject.ReceiveShadows; if (novaObject.Billboard) { babylonMesh.billboardMode |= (novaObject.BillboardX ? 1 : 0); babylonMesh.billboardMode |= (novaObject.BillboardY ? 2 : 0); babylonMesh.billboardMode |= (novaObject.BillboardZ ? 4 : 0); } if (novaObject.ParticleSystem != null) { particleSystemsToExport.Add(novaObject.ParticleSystem); } // Mirror if (novaObject.IsMirror && novaObject.Material != null) { mirrorsMaterials.Add(novaObject.Material, novaObject); } // World babylonMesh.position = novaObject.Position.ToArray(); babylonMesh.rotation = novaObject.Rotation.ToArray(); babylonMesh.localMatrix = (Matrix.Scaling(novaObject.Scaling) * novaObject.LocalMatrix).ToArray(); // Animations var animations = new List <BabylonAnimation>(); DumpInterpolator("Visibility animation", "visibility", novaObject.VisibilityInterpolator, scene, animations); // Position if (!DumpInterpolator("Position animation", "position", novaObject.PositionInterpolator, scene, animations)) { DumpInterpolator("PositionX animation", "position.x", novaObject.PositionXInterpolator, scene, animations); DumpInterpolator("PositionY animation", "position.y", novaObject.PositionYInterpolator, scene, animations); DumpInterpolator("PositionZ animation", "position.z", novaObject.PositionZInterpolator, scene, animations); } // Rotation if (!DumpInterpolator("Rotation animation", "rotationQuaternion", novaObject.RotationInterpolator, scene, animations)) { DumpInterpolator("RotationX animation", "rotation.x", novaObject.RotationXInterpolator, scene, animations, -novaObject.Determinant); DumpInterpolator("RotationY animation", "rotation.y", novaObject.RotationYInterpolator, scene, animations, -novaObject.Determinant); DumpInterpolator("RotationZ animation", "rotation.z", novaObject.RotationZInterpolator, scene, animations, -novaObject.Determinant); } else { babylonMesh.localMatrix = Matrix.Identity.ToArray(); babylonMesh.scaling = novaObject.Scaling.ToArray(); } // Scaling if (!DumpInterpolator("Scaling animation", "scaling", novaObject.ScalingInterpolator, scene, animations)) { DumpInterpolator("ScalingX animation", "scaling.x", novaObject.ScalingXInterpolator, scene, animations); DumpInterpolator("ScalingY animation", "scaling.y", novaObject.ScalingYInterpolator, scene, animations); DumpInterpolator("ScalingZ animation", "scaling.z", novaObject.ScalingZInterpolator, scene, animations); } else { babylonMesh.localMatrix = novaObject.LocalMatrix.ToArray(); babylonMesh.scaling = novaObject.Scaling.ToArray(); } babylonMesh.animations = animations.ToArray(); babylonMesh.autoAnimate = novaObject.AutoAnimate; if (novaObject.AutoAnimate) { babylonMesh.autoAnimateFrom = novaObject.AnimationStartKey; if (novaObject.AnimationEndKey == -1) { babylonMesh.autoAnimateTo = scene.AnimationKeyMax / scene.AnimationKeyStep; babylonMesh.autoAnimateLoop = true; } else { babylonMesh.autoAnimateTo = novaObject.AnimationEndKey; } } // Vertices & faces var exportedVerticesCount = DumpObjectGeometry(novaObject, babylonMesh, startIndex, endIndex); // Subobjects var subMeshes = new List <BabylonSubMesh>(); if (novaObject.Is32bits) { var subMesh = new BabylonSubMesh(); subMesh.materialIndex = 0; subMesh.verticesStart = 0; subMesh.verticesCount = exportedVerticesCount; subMesh.indexStart = 0; subMesh.indexCount = babylonMesh.indices.Length; subMeshes.Add(subMesh); } else { foreach (NovaSubObject subObject in novaObject.SubObjects) { var subMesh = new BabylonSubMesh(); subMesh.materialIndex = subObject.AttributeRange.AttributeId; subMesh.verticesStart = subObject.AttributeRange.VertexStart; subMesh.verticesCount = subObject.AttributeRange.VertexCount; subMesh.indexStart = subObject.AttributeRange.FaceStart * 3; subMesh.indexCount = subObject.AttributeRange.FaceCount * 3; subMeshes.Add(subMesh); } } babylonMesh.subMeshes = subMeshes.ToArray(); if (novaObject.Material != null) { if (!materialsToExport.Contains(novaObject.Material)) { materialsToExport.Add(novaObject.Material); var multiMat = novaObject.Material as NovaMultiMaterial; if (multiMat != null) { foreach (var mat in multiMat.Materials) { if (!materialsToExport.Contains(mat)) { materialsToExport.Add(mat); } } } } } }
bool DumpInterpolator(string name, string property, NovaQuaternionInterpolator interpolator, NovaScene scene, List <BabylonAnimation> animations) { if (interpolator.Ready) { var fps = scene.AnimationFramerate < 1 ? 30 : scene.AnimationFramerate; var babylonAnimation = new BabylonAnimation { name = name, property = property, dataType = BabylonAnimation.DataType.Quaternion, framePerSecond = fps }; babylonAnimation.keys = interpolator.Datas.Select(value => new BabylonAnimationKey { frame = value.Key / scene.AnimationKeyStep, values = value.Value.ToArray() }).ToArray(); babylonAnimation.loopBehavior = interpolator.LoopAfter; animations.Add(babylonAnimation); return(true); } return(false); }
bool DumpInterpolator(string name, string property, NovaFloatInterpolator interpolator, NovaScene scene, List <BabylonAnimation> animations, float mult = 1.0f) { if (interpolator.Ready && !IsInterpolatorIsEmpty(interpolator)) { var fps = scene.AnimationFramerate < 1 ? 30 : scene.AnimationFramerate; var babylonAnimation = new BabylonAnimation { name = name, property = property, dataType = BabylonAnimation.DataType.Float, framePerSecond = fps }; babylonAnimation.keys = interpolator.Datas.Select(value => new BabylonAnimationKey { frame = value.Key / scene.AnimationKeyStep, values = new[] { value.Value *mult } }).ToArray(); babylonAnimation.loopBehavior = interpolator.LoopAfter; animations.Add(babylonAnimation); return(true); } return(false); }
static void DumpCameras(NovaScene scene, BabylonScene babylonScene) { foreach (NovaCamera camera in scene.Cameras) { var babylonCamera = new BabylonCamera(); babylonScene.CamerasList.Add(babylonCamera); babylonCamera.name = camera.Name; babylonCamera.id = camera.ID.ToString(); babylonCamera.position = camera.Position.ToArray(); babylonCamera.rotation = camera.Rotation.ToArray(); babylonCamera.fov = camera.FOV; babylonCamera.minZ = camera.NearClip; babylonCamera.maxZ = camera.FarClip; babylonCamera.inertia = camera.Inertia; babylonCamera.speed = camera.Speed; babylonCamera.checkCollisions = camera.CheckCollisions; babylonCamera.applyGravity = camera.ApplyGravity; babylonCamera.ellipsoid = camera.EllipsoidVector.ToArray(); } if (scene.ActiveCamera != null) { babylonScene.activeCameraID = scene.ActiveCamera.ID.ToString(); } }