示例#1
0
        public override bool Convert(ConvertOperation convert)
        {
            bool finishConvertOp = false;
            List<Pixmap> availData = convert.Perform<Pixmap>().ToList();

            // Generate objects
            foreach (Pixmap baseRes in availData)
            {
                if (convert.IsObjectHandled(baseRes)) continue;

                // Find target Resource matching the source - or create one.
                Texture targetRes = this.FindMatch(baseRes);
                if (targetRes == null && convert.AllowedOperations.HasFlag(ConvertOperation.Operation.CreateRes))
                {
                    string texPath = PathHelper.GetFreePath(baseRes.FullName, Resource.GetFileExtByType<Texture>());
                    targetRes = new Texture(baseRes);
                    targetRes.Save(texPath);
                }

                if (targetRes == null) continue;
                convert.AddResult(targetRes);
                finishConvertOp = true;
                convert.MarkObjectHandled(baseRes);
            }

            return finishConvertOp;
        }
示例#2
0
        /// <summary>
        /// Creates a new Texture Resource based on the specified Pixmap, saves it and returns a reference to it.
        /// </summary>
        /// <param name="pixmap"></param>
        /// <returns></returns>
        public static ContentRef <Texture> CreateFromPixmap(ContentRef <Pixmap> pixmap)
        {
            string  texPath = PathHelper.GetFreePath(pixmap.FullName, FileExt);
            Texture tex     = new Texture(pixmap);

            tex.Save(texPath);
            return(tex);
        }
示例#3
0
文件: Texture.cs 项目: KSLcom/duality
		/// <summary>
		/// Creates a new Texture Resource based on the specified Pixmap, saves it and returns a reference to it.
		/// </summary>
		/// <param name="pixmap"></param>
		/// <returns></returns>
		public static ContentRef<Texture> CreateFromPixmap(ContentRef<Pixmap> pixmap)
		{
			string texPath = PathHelper.GetFreePath(pixmap.FullName, FileExt);
			Texture tex = new Texture(pixmap);
			tex.Save(texPath);
			return tex;
		}