Inheritance: idRenderModel_Static
Ejemplo n.º 1
0
        private idRenderModel GetModel(string name, bool createIfNotFound)
        {
            idRenderModel model;
            string        extension;

            if (_models.ContainsKey(name) == true)
            {
                model = _models[name];

                if (model.IsLoaded == false)
                {
                    // reload it if it was purged
                    model.Load();
                }
                else if ((_insideLevelLoad == true) && (model.IsLevelLoadReferenced == false))
                {
                    // we are reusing a model already in memory, but
                    // touch all the materials to make sure they stay
                    // in memory as well
                    model.TouchData();
                }

                model.IsLevelLoadReferenced = true;

                return(model);
            }

            model     = null;
            extension = Path.GetExtension(name).ToLower();

            // see if we can load it
            // determine which subclass of idRenderModel to initialize
            switch (extension)
            {
            case ".ase":
            case ".lwo":
            case ".flt":
            case ".ma":
                model = new idRenderModel_Static();
                model.InitFromFile(name);
                break;

            case ".md5mesh":
                model = new idRenderModel_MD5();
                model.InitFromFile(name);
                break;

            case ".md3":
                idConsole.Warning("TODO: md3");
                break;

            case ".prt":
                model = new idRenderModel_PRT();
                model.InitFromFile(name);
                break;

            case ".liquid":
                idConsole.Warning("TODO: liquid");
                break;
            }

            if (model == null)
            {
                if (extension != string.Empty)
                {
                    idConsole.Warning("unknown model type '{0}'", name);
                }

                if (createIfNotFound == false)
                {
                    return(null);
                }

                model = new idRenderModel_Static();
                model.InitEmpty(name);
                model.MakeDefault();
            }

            model.IsLevelLoadReferenced = true;

            if ((createIfNotFound == false) && (model.IsDefault == true))
            {
                model.Dispose();

                return(null);
            }


            AddModel(model);

            return(model);
        }
Ejemplo n.º 2
0
		private idRenderModel GetModel(string name, bool createIfNotFound)
		{
			idRenderModel model;
			string extension;

			if(_models.ContainsKey(name) == true)
			{
				model = _models[name];

				if(model.IsLoaded == false)
				{
					// reload it if it was purged
					model.Load();
				}
				else if((_insideLevelLoad == true) && (model.IsLevelLoadReferenced == false))
				{
					// we are reusing a model already in memory, but
					// touch all the materials to make sure they stay
					// in memory as well
					model.TouchData();
				}

				model.IsLevelLoadReferenced = true;

				return model;
			}
		
			model = null;
			extension = Path.GetExtension(name).ToLower();

			// see if we can load it	
			// determine which subclass of idRenderModel to initialize
			switch(extension)
			{
				case ".ase":
				case ".lwo":
				case ".flt":
				case ".ma":
					model = new idRenderModel_Static();
					model.InitFromFile(name);
					break;

				case ".md5mesh":
					model = new idRenderModel_MD5();
					model.InitFromFile(name);
					break;

				case ".md3":
					idConsole.Warning("TODO: md3");
					break;

				case ".prt":
					model = new idRenderModel_PRT();
					model.InitFromFile(name);
					break;

				case ".liquid":
					idConsole.Warning("TODO: liquid");
					break;
			}

			if(model == null)
			{
				if(extension != string.Empty)
				{
					idConsole.Warning("unknown model type '{0}'", name);
				}

				if(createIfNotFound == false)
				{
					return null;
				}

				model = new idRenderModel_Static();
				model.InitEmpty(name);
				model.MakeDefault();
			}

			model.IsLevelLoadReferenced = true;

			if((createIfNotFound == false) && (model.IsDefault == true))
			{
				model.Dispose();

				return null;
			}


			AddModel(model);

			return model;
		}