示例#1
0
        public void Prepare(bool generateDefaultLight = true)
        {
            meshes = MeshesList.ToArray();

            materials        = MaterialsList.ToArray();
            multiMaterials   = MultiMaterialsList.ToArray();
            shadowGenerators = ShadowGeneratorsList.ToArray();
            skeletons        = SkeletonsList.ToArray();

            if (CamerasList.Count == 0)
            {
                var camera = new BabylonCamera {
                    name = "Default camera", id = Guid.NewGuid().ToString()
                };

                var distanceVector = MaxVector - MinVector;
                var midPoint       = MinVector + distanceVector / 2;
                camera.target   = midPoint.ToArray();
                camera.position = (midPoint + distanceVector).ToArray();

                var distance = distanceVector.Length();
                camera.speed = distance / 50.0f;
                camera.maxZ  = distance * 4f;

                camera.minZ = distance < 100.0f ? 0.1f : 1.0f;

                CamerasList.Add(camera);
            }

            if (LightsList.Count == 0 && generateDefaultLight)
            {
                var light = new BabylonLight {
                    name = "Default light", id = Guid.NewGuid().ToString()
                };

                var midPoint = MinVector + (MaxVector - MinVector) / 2;
                light.type     = 0;
                light.position = (midPoint + (MaxVector - MinVector)).ToArray();

                light.diffuse  = new Vector3(1, 1, 1).ToArray();
                light.specular = new Vector3(1, 1, 1).ToArray();

                LightsList.Add(light);
            }

            cameras = CamerasList.ToArray();
            lights  = LightsList.ToArray();

            if (activeCameraID == null)
            {
                activeCameraID = CamerasList[0].id;
            }
        }
示例#2
0
        public void Prepare(bool generateDefaultLight = true)
        {
            meshes = MeshesList.ToArray();

            materials = MaterialsList.ToArray();
            multiMaterials = MultiMaterialsList.ToArray();
            shadowGenerators = ShadowGeneratorsList.ToArray();
            skeletons = SkeletonsList.ToArray();

            if (CamerasList.Count == 0)
            {
                var camera = new BabylonCamera {name = "Default camera", id = Guid.NewGuid().ToString()};

                var distanceVector = MaxVector - MinVector;
                var midPoint = MinVector +distanceVector / 2;
                camera.target = midPoint.ToArray();
                camera.position = (midPoint + distanceVector).ToArray();

                var distance = distanceVector.Length();
                camera.speed =  distance/ 50.0f;
                camera.maxZ = distance * 4f;

                camera.minZ = distance < 100.0f ? 0.1f : 1.0f;

                CamerasList.Add(camera);
            }

            if (LightsList.Count == 0 && generateDefaultLight)
            {
                var light = new BabylonLight {name = "Default light", id = Guid.NewGuid().ToString()};

                var midPoint = MinVector + (MaxVector - MinVector) / 2;
                light.type = 0;
                light.position = (midPoint + (MaxVector - MinVector)).ToArray();

                light.diffuse = new Vector3(1, 1, 1).ToArray();
                light.specular = new Vector3(1, 1, 1).ToArray();

                LightsList.Add(light);
            }
            
            cameras = CamerasList.ToArray();
            lights = LightsList.ToArray();

            if (activeCameraID == null)
            {
                activeCameraID = CamerasList[0].id;
            }
        }