示例#1
0
            /// <summary>
            /// Loads animated model based on the descriptio in the XML <paramref name="element"/>.
            /// </summary>
            /// <param name="element">XML describing the animated model.</param>
            /// <param name="package">GamePackage of the level.</param>
            /// <returns>Loader with the loaded model.</returns>
            /// <exception cref="ArgumentNullException">When the <paramref name="element"/> is null</exception>
            /// <exception cref="ArgumentException">Thrown when the <paramref name="element"/> does not conform to the xml schema</exception>
            /// <exception cref="ResourceLoadingException">Thrown when either the model or material resource could not be loaded</exception>
            public static StaticModelLoader Load(XElement element, GamePack package)
            {
                if (element == null)
                {
                    throw new ArgumentNullException(nameof(element), "Element was null");
                }

                if (element.Name != AssetsXml.Inst.Model)
                {
                    throw new ArgumentException("Invalid element", nameof(element));
                }

                string type = element.Attribute(ModelXml.Inst.TypeAttribute).Value;

                string modelPath = element.Element(ModelXml.Inst.ModelPath).Value;


                Model model = package.PackageManager.GetModel(modelPath, true);

                XElement materialElement = element.Element(ModelXml.Inst.Material);

                MaterialWrapper material = MaterialWrapper.FromXml(materialElement, package);

                if (type == ModelXml.StaticModelType)
                {
                    return(StaticModelLoader.CreateStaticModel(model, material));
                }
                else if (type == ModelXml.AnimatedModelType)
                {
                    return(new AnimatedModelLoader(model, material));
                }
                else
                {
                    throw new ArgumentException("Model xml contained unknown type", nameof(element));
                }
            }
示例#2
0
 protected AnimatedModelLoader(Model model, MaterialWrapper material)
     : base(model, material)
 {
 }
示例#3
0
 /// <summary>
 /// Provides derived classes with the ability to construct an instance of StaticModelLoader
 /// </summary>
 /// <param name="model"></param>
 /// <param name="material"></param>
 /// <returns></returns>
 protected static StaticModelLoader CreateStaticModel(Model model, MaterialWrapper material)
 {
     return(new StaticModelLoader(model, material));
 }
示例#4
0
 protected StaticModelLoader(Model model, MaterialWrapper material)
 {
     this.Model    = model;
     this.Material = material;
 }