Beispiel #1
0
        public void Free()
        {
            Shaders.Unload(Shader);

            for (int i = 0; i < Textures.Length; i++)
            {
                LED_Engine.Textures.Unload(Textures[i]);
            }

            UseCounter = 0;
        }
Beispiel #2
0
        public static Material Load(string Name)
        {
            try
            {
                Material M = GetMaterial(Name);

                if (M == null)
                {
                    foreach (var v in MaterialsList)
                    {
                        if (v.Name.GetHashCode() == Name.GetHashCode())
                        {
                            M = v;
                        }
                    }
                    if (M == null)
                    {
                        return(null);
                    }
                }

                if (M.UseCounter == 0)
                {
                    Shaders.Load(M.Shader.Name);

                    for (int i = 0; i < M.Textures.Length; i++)
                    {
                        if (M.Textures[i] != null)
                        {
                            Textures.Load(M.Textures[i].Name);
                        }
                    }

                    MATERIALS.Add(M);
                }

                M.UseCounter++;
                return(M);
            }
            catch
            {
                Log.WriteLineRed("Materials.Load() Exception, Name: \"{0}\"", Name);
                return(null);
            }
        }
Beispiel #3
0
        public static void LoadEngineContent()
        {
            foreach (var i in Textures.TexturesList)
            {
                if (i.EngineContent)
                {
                    Textures.Load(i.Name);
                }
            }

            foreach (var i in Shaders.ShadersList)
            {
                if (i.EngineContent)
                {
                    Shaders.Load(i.Name);
                }
            }

            foreach (var i in Materials.MaterialsList)
            {
                if (i.EngineContent)
                {
                    Materials.Load(i.Name);
                }
            }

            if (Settings.Debug.Enabled)
            {
                //DebugAmbientLight = Mesh.LoadFromFile("DebugAmbientLight", Engine.CombinePaths(Settings.Paths.EngineMeshes, "DebugAmbientLight.obj"));
                //DebugDirectionalLight = Mesh.LoadFromFile("DebugDirectionalLight", Engine.CombinePaths(Settings.Paths.EngineMeshes, "DebugDirectionalLight.obj"));
                //DebugPointLight = Mesh.LoadFromFile("DebugPointLight", Engine.CombinePaths(Settings.Paths.EngineMeshes, "DebugPointLight.obj"));
                //DebugSpotLight = Mesh.LoadFromFile("DebugSpotLight", Engine.CombinePaths(Settings.Paths.EngineMeshes, "DebugSpotLight.obj"));

                //DebugAmbientLight.Parts[0].Material = Materials.Load("DebugAmbientLight");
                //DebugDirectionalLight.Parts[0].Material = Materials.Load("DebugDirectionalLight");
                //DebugPointLight.Parts[0].Material = Materials.Load("DebugPointLight");
                //DebugSpotLight.Parts[0].Material = Materials.Load("DebugSpotLight");
            }
        }
Beispiel #4
0
        public Material(Material Original)
        {
            Shader = Shaders.Load(Original.Shader.Name);

            CullFace      = Original.CullFace;
            Transparent   = Original.Transparent;
            Ka            = Original.Ka;
            Kd            = Original.Kd;
            Ks            = Original.Ks;
            Ke            = Original.Ke;
            Shininess     = Original.Shininess;
            Reflection    = Original.Reflection;
            ParallaxScale = Original.ParallaxScale;

            Textures = new Texture[Original.Textures.Length];
            for (int i = 0; i < Textures.Length; i++)
            {
                if (Original.Textures[i] != null)
                {
                    Textures[i] = LED_Engine.Textures.Load(Original.Textures[i].Name);
                }
            }
        }
Beispiel #5
0
        public static void LoadContentLists()
        {
            try
            {
                ClearLists();

                #region Paths
                string[] Paths = new string[] { Settings.Paths.EngineContentPath, Settings.Paths.GameDataPath };

                string[] MaterialsConfigs       = new string[] { Settings.Paths.ContentFiles.EngineMaterials, Settings.Paths.ContentFiles.Materials };
                string[] MeshesConfigs          = new string[] { Settings.Paths.ContentFiles.EngineMeshes, Settings.Paths.ContentFiles.Meshes };
                string[] ShadersConfigs         = new string[] { Settings.Paths.ContentFiles.EngineShaders, Settings.Paths.ContentFiles.Shaders };
                string[] TexturesConfigs        = new string[] { Settings.Paths.ContentFiles.EngineTextures, Settings.Paths.ContentFiles.Textures };
                string[] CubemapTexturesConfigs = new string[] { Settings.Paths.ContentFiles.EngineCubemapTextures, Settings.Paths.ContentFiles.CubemapTextures };

                string[] MapsPaths            = new string[] { Settings.Paths.EngineMaps, Settings.Paths.Maps };
                string[] MeshesPaths          = new string[] { Settings.Paths.EngineMeshes, Settings.Paths.Meshes };
                string[] ShadersPaths         = new string[] { Settings.Paths.EngineShaders, Settings.Paths.Shaders };
                string[] TexturesPaths        = new string[] { Settings.Paths.EngineTextures, Settings.Paths.Textures };
                string[] CubemapTexturesPaths = new string[] { Settings.Paths.EngineCubemapTextures, Settings.Paths.CubemapTextures };
                #endregion

                #region Load Lists
                ClearLists();

                for (int i = 0; i < Paths.Length; i++)
                {
                    bool EngineContent = false;
                    if (i == 0)
                    {
                        EngineContent = true;
                    }

                    Textures.LoadTexturesList(TexturesConfigs[i], TexturesPaths[i], EngineContent);
                }

                for (int i = 0; i < Paths.Length; i++)
                {
                    bool EngineContent = false;
                    if (i == 0)
                    {
                        EngineContent = true;
                    }

                    Textures.LoadCubemapTexturesList(CubemapTexturesConfigs[i], CubemapTexturesPaths[i], EngineContent);
                }

                for (int i = 0; i < Paths.Length; i++)
                {
                    bool EngineContent = false;
                    if (i == 0)
                    {
                        EngineContent = true;
                    }

                    Shaders.LoadShadersList(ShadersConfigs[i], ShadersPaths[i], EngineContent);
                }

                for (int i = 0; i < Paths.Length; i++)
                {
                    bool EngineContent = false;
                    if (i == 0)
                    {
                        EngineContent = true;
                    }

                    Materials.LoadMaterialsList(MaterialsConfigs[i], EngineContent);
                }

                for (int i = 0; i < Paths.Length; i++)
                {
                    bool EngineContent = false;
                    if (i == 0)
                    {
                        EngineContent = true;
                    }

                    Meshes.LoadMeshesList(MeshesConfigs[i], MeshesPaths[i], EngineContent);
                }

                for (int i = 0; i < Paths.Length; i++)
                {
                    bool EngineContent = false;
                    if (i == 0)
                    {
                        EngineContent = true;
                    }

                    Maps.LoadMapList(MapsPaths[i], EngineContent);
                }
                #endregion
            }
            catch (Exception e)
            {
                Log.WriteLineRed("Engine.LoadContentLists() Exception.");
                Log.WriteLineYellow(e.Message);
            }
        }