コード例 #1
0
        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);
                    }
                }
            }
        }