コード例 #1
0
ファイル: MaterialProcessor.cs プロジェクト: ttou73/IronStar
        /// <summary>
        ///
        /// </summary>
        /// <param name="sourceStream"></param>
        /// <param name="targetStream"></param>
        public override void Process(AssetSource assetFile, BuildContext context)
        {
            var mtrl = BaseIllum.ImportFromXml(File.ReadAllText(assetFile.FullSourcePath));

            //	get dependencies :
            var deps = mtrl.GetDependencies().ToArray();

            var file = BaseIllum.ExportToXml(mtrl);

            using (var target = assetFile.OpenTargetStream(deps)) {
                using (var bw = new BinaryWriter(target)) {
                    bw.Write(file);
                }
            }
        }
コード例 #2
0
ファイル: FScene.cs プロジェクト: ttou73/IronStar
        static void ResolveMaterial(MaterialRef material, string relativeSceneDir, string fullSceneDir)
        {
            var mtrlName = ContentUtils.CreateSafeName(material.Name);
            var texPath  = material.Texture ?? "";

            material.Name    = Path.Combine(relativeSceneDir, mtrlName);
            material.Texture = Path.Combine(relativeSceneDir, texPath);
            var mtrlFileName = Path.Combine(fullSceneDir, mtrlName + ".material");


            if (!File.Exists(mtrlFileName))
            {
                var newMtrl = new BaseIllum();

                newMtrl.ColorTexture.Path     = ResolveTexture(relativeSceneDir, fullSceneDir, texPath, "", newMtrl.ColorTexture.Path);
                newMtrl.SurfaceTexture.Path   = ResolveTexture(relativeSceneDir, fullSceneDir, texPath, "_surf", newMtrl.SurfaceTexture.Path);
                newMtrl.NormalMapTexture.Path = ResolveTexture(relativeSceneDir, fullSceneDir, texPath, "_local", "_bump", newMtrl.NormalMapTexture.Path);
                newMtrl.EmissionTexture.Path  = ResolveTexture(relativeSceneDir, fullSceneDir, texPath, "_glow", newMtrl.EmissionTexture.Path);

                File.WriteAllText(mtrlFileName, BaseIllum.ExportToXml(newMtrl));
            }
        }