示例#1
0
        //============================================================
        // <T>加载配置信息。</T>
        //
        // @param config 配置信息
        //============================================================
        public void LoadConfig(FXmlNode xconfig)
        {
            string typeName = null;

            if (xconfig.Contains("type"))
            {
                typeName = xconfig.Get("type");
            }
            else
            {
                typeName = xconfig.Get("type_name");
            }
            _typeCd = EDrTexture.Parse(typeName);
            _source = xconfig.Nvl("source").Replace('/', '\\');
            string sourceTypeName = xconfig.Nvl("source_type");

            _sourceTypeCd = EDrTexture.Parse(typeName);
            _sourceIndex  = xconfig.GetInteger("source_index", _sourceIndex);
            // 获得关联纹理
            _texture = RContent3dManager.TextureConsole.Find(Source);
            if (null == _texture)
            {
                _texture = RContent3dManager.TextureConsole.Find(Source);
                RMoCore.TrackConsole.Write(this, "LoadConfig", "Texture source is not exists. (material={0}, texture={1})",
                                           _material.Code, SourceCode);
                return;
            }
            _textureBitmap = _texture.FindByTypeCd(_sourceTypeCd, _sourceIndex);
        }
示例#2
0
 //============================================================
 // <T>打开资源。</T>
 //============================================================
 public void SelectItem(object item)
 {
     if (item is FDrTexture)
     {
         FDrTexture texture = item as FDrTexture;
         qdrTextureProperty.Dock    = DockStyle.Fill;
         qdrTextureProperty.Visible = true;
         qdrTextureProperty.LoadTexture(texture);
     }
     else
     {
         qdrTextureProperty.Visible = false;
     }
 }
示例#3
0
        //============================================================
        // <T>打开资源。</T>
        //============================================================
        public void ExportSelected()
        {
            FObjects <TreeNode> checkeds = tvwCatalog.FetchCheckedNodes();

            foreach (TreeNode node in checkeds)
            {
                FCfgFolder folder = node.Tag as FCfgFolder;
                if (null != folder)
                {
                    FDrTexture texture = folder.Tag as FDrTexture;
                    if (null != texture)
                    {
                        RContent3dManager.TextureConsole.TaskExport(texture);
                    }
                }
            }
        }
示例#4
0
        //============================================================
        // <T>按照选中保存。</T>
        //============================================================
        public void SaveSelect()
        {
            FObjects <TreeNode> checkeds = tvwCatalog.FetchCheckedNodes();

            foreach (TreeNode node in checkeds)
            {
                FCfgFolder folder = node.Tag as FCfgFolder;
                if (null != folder)
                {
                    FDrTexture texture = folder.Tag as FDrTexture;
                    if (null != texture)
                    {
                        texture.Store();
                    }
                }
            }
        }
示例#5
0
        //============================================================
        // <T>打开处理。</T>
        //============================================================
        public void ScanTextures()
        {
            string rootDirectory = _folder.Directory;

            foreach (INamePair <FDrTexture> pair in RContent3dManager.TextureConsole.Textures)
            {
                FDrTexture       texture       = pair.Value;
                String           name          = texture.Name;
                FDrMaterialGroup materialGroup = FindGroup(name);
                if (materialGroup != null)
                {
                    continue;
                }
                // 创建材质组
                FDrFolder             folder = texture.Folder;
                FObjects <FCfgFolder> stack  = folder.FetchFolderStack(false);
                string materialPath          = folder.FolderPath().Replace("tx-", "mt-");
                string materialDirectory     = rootDirectory + materialPath;
                RDirectory.MakeDirectories(materialDirectory);
                FDrTheme theme = RContent3dManager.ThemeConsole.DefaultTheme;
                // 创建材质组
                materialGroup                = new FDrMaterialGroup();
                materialGroup.Name           = name;
                materialGroup.ConfigFileName = materialDirectory + "/config.xml";
                // 创建材质
                FDrMaterial material = new FDrMaterial();
                material.Theme      = theme;
                material.EffectName = theme.EffectName;
                materialGroup.Materials.Push(material);
                foreach (FDrTextureBitmap bitmap in texture.Bitmaps)
                {
                    FDrMaterialTexture materialTexture = new FDrMaterialTexture();
                    materialTexture.TypeCd       = bitmap.TypeCd;
                    materialTexture.Source       = texture.Name;
                    materialTexture.SourceTypeCd = bitmap.TypeCd;
                    materialTexture.SourceIndex  = bitmap.Index;
                    materialGroup.Textures.Push(materialTexture);
                }
                // 存储材质
                materialGroup.Store();
                _materials.Set(name, materialGroup);
                _logger.Debug(this, "ScanTextures", "Create material. (name={0})", materialDirectory);
            }
        }
示例#6
0
 //============================================================
 // <T>加载纹理。</T>
 //
 // @prama texture 纹理对象
 //============================================================
 public void LoadTexture(FDrTexture texture)
 {
     texture.Open();
     _texture = texture;
     // 加载光照纹理
     if (_texture is FDrColorTexture)
     {
         LoadLightTexture(_texture as FDrColorTexture);
     }
     // 加载剪辑纹理
     if (_texture is FDrClipTexture)
     {
         LoadClipTexture(_texture as FDrClipTexture);
     }
     // 加载分层纹理
     if (_texture is FDrLayerTexture)
     {
         LoadLayerTexture(_texture as FDrLayerTexture);
     }
     Invalidate();
 }
示例#7
0
        //============================================================
        //<T>展现纹理图片<T>
        //============================================================
        private void TextureImage(FCfgFolder fol)
        {
            FDrTexture    text  = fol.Tag as FDrTexture;
            ListViewGroup group = new ListViewGroup();

            text.Open();
            string diePath = RContent3dManager.TempDirectory + "\\icon\\" + text.Name;
            int    count   = 0;

            foreach (FDrTextureBitmap bit in text.Bitmaps)
            {
                //if (bit.Bool != null && bit.Bool.Equals("Y")) {
                //   string Spath = diePath + "\\" + bit.Source;
                //   string Opath = text.Path + "\\" + bit.Source;
                //   if (!Directory.Exists(diePath)) {
                //      Directory.CreateDirectory(diePath);
                //   }
                //   DirectoryInfo directoryinfo = new DirectoryInfo(Spath);
                //   DateTime date = directoryinfo.LastWriteTime;
                //   DateTime now = DateTime.Now;
                //   TimeSpan ts = now.Subtract(date);
                //   if (ts.Hours > 0 || ts.Minutes > 10) {
                //      _sizeChange.CreateIcon(Opath, Spath, 128, 128);
                //   }
                //   if (RFile.Exists(Spath)) {
                //      count = GetImage(count, bit, Spath);
                //   } else {
                //      _sizeChange.CreateIcon(Opath, Spath, 128, 128);
                //      count = GetImage(count, bit, Spath);
                //   }
                //}
            }
            group.Tag  = text;
            group.Name = fol.Label + "-" + count.ToString();
            listView1.Groups.Add(group);
        }
示例#8
0
        //============================================================
        // <T>加载配置信息。</T>
        //
        // @param config 配置信息
        //============================================================
        public void LoadConfig(FXmlNode xconfig)
        {
            // 读取属性
            _effectName          = xconfig.Nvl("effect_name");
            _transformName       = xconfig.Nvl("transform_name");
            _optionLight         = xconfig.GetInteger("option_light", _optionLight);
            _optionMerge         = xconfig.GetInteger("option_merge", _optionMerge);
            _optionSort          = xconfig.GetInteger("option_sort", _optionSort);
            _sortLevel           = xconfig.GetInteger("sort_level", _sortLevel);
            _optionAlpha         = xconfig.GetInteger("option_alpha", _optionAlpha);
            _optionDepth         = xconfig.GetInteger("option_depth", _optionDepth);
            _optionCompare       = xconfig.Get("option_compare", _optionCompare);
            _optionDouble        = xconfig.GetInteger("option_double", _optionDouble);
            _optionShadow        = xconfig.GetInteger("option_shadow", _optionShadow);
            _optionShadowSelf    = xconfig.GetInteger("option_shadow_self", _optionShadowSelf);
            _optionDynamic       = xconfig.GetInteger("option_dynamic", _optionDynamic);
            _optionTransmittance = xconfig.GetInteger("option_transmittance", _optionTransmittance);
            _optionOpacity       = xconfig.GetInteger("option_opacity", _optionOpacity);
            // 查找节点
            FXmlNode xmaterialConfig = null;
            FXmlNode xmaterials      = xconfig.Find("Materials");
            FXmlNode xtextures       = xconfig.Find("Textures");

            // 读取纹理列表
            if (null == xmaterials)
            {
                FXmlNode xmaterial = xconfig.Find("Material");
                if (null != xmaterial)
                {
                    FDrMaterial material = new FDrMaterial();
                    material.Group = this;
                    material.LoadConfig(xmaterial);
                    _materials.Push(material);
                    // 查找纹理节点
                    xtextures       = xmaterial.Find("Textures");
                    xmaterialConfig = xmaterial;
                }
            }
            else
            {
                // 找到默认节点
                FXmlNode xdefault = null;
                foreach (FXmlNode xmaterial in xmaterials.Nodes)
                {
                    if (xmaterial.IsName("Material"))
                    {
                        string themeCode = RDrUtil.FormatPathToCode(xmaterial.Get("theme_name"));
                        xdefault        = xmaterial;
                        xmaterialConfig = xmaterial;
                        if ("shadow" == themeCode)
                        {
                            break;
                        }
                    }
                }
                foreach (FDrTheme theme in RContent3dManager.ThemeConsole.Themes.Values)
                {
                    string code = theme.Code;
                    // 查找加载信息
                    bool finded = false;
                    foreach (FXmlNode xmaterial in xmaterials.Nodes)
                    {
                        if (xmaterial.IsName("Material"))
                        {
                            string themeCode = RDrUtil.FormatPathToCode(xmaterial.Get("theme_name"));
                            if (code == themeCode)
                            {
                                FDrMaterial material = new FDrMaterial();
                                material.Group = this;
                                material.LoadConfig(xmaterial);
                                FDrMaterial findMaterial = FindMaterial(material.ThemeName);
                                if (null == findMaterial)
                                {
                                    _materials.Push(material);
                                }
                                finded = true;
                                break;
                            }
                        }
                    }
                    // 如果不存在,则新建材质
                    if (!finded)
                    {
                        if (null != xdefault)
                        {
                            FDrMaterial material = new FDrMaterial();
                            material.Group = this;
                            material.LoadConfig(xdefault);
                            material.Theme     = theme;
                            material.ThemeName = theme.Name;
                            _materials.Push(material);
                        }
                    }
                }
            }
            // 如果效果名称不存在,则获得首个材质设定
            if (!xconfig.Contains("effect_name") && (null != xmaterialConfig))
            {
                _effectName          = xmaterialConfig.Nvl("effect_name");
                _transformName       = xmaterialConfig.Nvl("transform_name");
                _optionLight         = xmaterialConfig.GetInteger("option_light", _optionLight);
                _optionMerge         = xmaterialConfig.GetInteger("option_merge", _optionMerge);
                _optionSort          = xmaterialConfig.GetInteger("option_sort", _optionSort);
                _sortLevel           = xmaterialConfig.GetInteger("sort_level", _sortLevel);
                _optionAlpha         = xmaterialConfig.GetInteger("option_alpha", _optionAlpha);
                _optionDepth         = xmaterialConfig.GetInteger("option_depth", _optionDepth);
                _optionCompare       = xmaterialConfig.Get("option_compare", _optionCompare);
                _optionDouble        = xmaterialConfig.GetInteger("option_double", _optionDouble);
                _optionShadow        = xmaterialConfig.GetInteger("option_shadow", _optionShadow);
                _optionShadowSelf    = xmaterialConfig.GetInteger("option_shadow_self", _optionShadowSelf);
                _optionDynamic       = xmaterialConfig.GetInteger("option_dynamic", _optionDynamic);
                _optionTransmittance = xmaterialConfig.GetInteger("option_transmittance", _optionTransmittance);
                _optionOpacity       = xmaterialConfig.GetInteger("option_opacity", _optionOpacity);
            }
            foreach (FDrMaterial material in _materials)
            {
                material.LoadGroup(this);
            }
            // 读取纹理列表
            if (null != xtextures)
            {
                foreach (FXmlNode xtexture in xtextures.Nodes)
                {
                    if (xtexture.IsName("Texture"))
                    {
                        FDrMaterialTexture materialTexture = new FDrMaterialTexture();
                        materialTexture.Material = this;
                        materialTexture.LoadConfig(xtexture);
                        FDrTexture texture = RContent3dManager.TextureConsole.Find(materialTexture.Source);
                        if (null != texture)
                        {
                            materialTexture.Texture = texture;
                            materialTexture.IsValid = true;
                        }
                        else
                        {
                            RMoCore.TrackConsole.Write(this, "LoadConfig", "Texture is not exists in material. (texture={0}, file_name={1})", materialTexture.Source, _configFileName);
                            materialTexture.IsValid = false;
                        }
                        _textures.Push(materialTexture);
                    }
                }
            }
        }