Esempio n. 1
0
 //============================================================
 // <T>序列化内部数据到输出流。</T>
 //
 // @param output 输出流
 //============================================================
 public void Serialize(IOutput output)
 {
     // 存储属性
     output.WriteString(RDrUtil.FormatPathToCode(_source));
     output.WriteInt8((sbyte)_template.OptionMergeVertex);
     output.WriteInt8((sbyte)_template.OptionMergeMaterial);
     // 存储矩阵
     //_matrix.SerializeData(output);
     _matrix.Serialize(output);
     // 存储动画集合
     output.WriteInt32(_movies.Count);
     foreach (FDrSceneMovie movie in _movies)
     {
         movie.Serialize(output);
     }
     // 存储材质集合
     output.WriteInt32(_materials.Count);
     foreach (FDrSceneMaterial material in _materials)
     {
         material.Serialize(output);
     }
     // 存储渲染集合
     output.WriteInt32(_renderables.Count);
     foreach (FDrSceneRenderable renderable in _renderables)
     {
         renderable.Serialize(output);
     }
 }
Esempio n. 2
0
        //============================================================
        // <T>根据名称查找打开主题。</T>
        //
        // @param name 名称
        // @return 主题
        //============================================================
        public FDrTheme FindOpen(string name)
        {
            string   code  = RDrUtil.FormatPathToCode(name);
            FDrTheme theme = _themes.Find(code);

            if (theme != null)
            {
                theme.Open();
            }
            return(theme);
        }
Esempio n. 3
0
        //============================================================
        // <T>根据材质组合主题名称查找材质。</T>
        //
        // @param themeName 主题名称
        // @param groupName 材质组名称
        // @return 材质
        //============================================================
        public FDrMaterial Find(string themeName, string groupName)
        {
            string           groupCode = RDrUtil.FormatPathToCode(groupName);
            string           themeCode = RDrUtil.FormatPathToCode(themeName);
            FDrMaterialGroup group     = _materials.Find(groupCode);

            if (null != group)
            {
                return(group.FindMaterial(themeCode));
            }
            return(null);
        }
Esempio n. 4
0
        //============================================================
        // <T>查找指定主题的材质。</T>
        //============================================================
        public FDrMaterial FindMaterial(string themeName)
        {
            string themeCode = RDrUtil.FormatPathToCode(themeName);

            foreach (FDrMaterial material in _materials)
            {
                if (material.ThemeCode == themeCode)
                {
                    return(material);
                }
            }
            return(null);
        }
Esempio n. 5
0
        //============================================================
        // <T>序列化数据。</T>
        //============================================================
        public void Export()
        {
            // 加载高度图
            _heightData.LoadFile(_path + "/texture/" + _textureHeight);
            _colorData.LoadFile(_path + "/texture/" + _textureColor);
            for (int n = 1; n <= _layerCount; n++)
            {
                FBitmap layerBitmap = _layers[n - 1].Bitmap;
                layerBitmap.LoadFile(_path + "/texture/level-" + n + ".jpg");
            }
            //............................................................
            FCompressFile file = new FCompressFile();

            // 存储编号
            file.WriteUint32((uint)_id);
            // 存储层数
            file.WriteUint16((ushort)_layerCount);
            // 当前地图的宽度和高度
            file.WriteUint16((ushort)_size.Width);
            file.WriteUint16((ushort)_size.Height);
            // 当前范围的宽度和高度
            file.WriteUint16((ushort)_range.Width);
            file.WriteUint16((ushort)_range.Height);
            file.WriteFloat(_deep);
            // 存储材质列表
            file.WriteInt16((short)_layers.Count);
            foreach (FDrMapLayer layer in _layers)
            {
                string materialCode = RDrUtil.FormatPathToCode(layer.MaterialName);
                file.WriteInt16((short)layer.Index);
                file.WriteString(materialCode);
                FDrMaterialGroup material = RContent3dManager.MaterialConsole.FindGroup(layer.MaterialName);
                material.Serialize(file);
            }
            // 输出文件
            file.SaveFile(_exportFilePath + "\\config.swf");
            //............................................................
            // 导出地图块
            int cx = _size.Width / _range.Width;
            int cy = _size.Height / _range.Height;

            for (int y = 0; y < cy; y++)
            {
                for (int x = 0; x < cx; x++)
                {
                    ExportRange(x, y);
                }
            }
            // RangeIncise();
            _logger.Debug(this, "Export", "Export template success. (file_name={0})", _exportFileName);
        }
Esempio n. 6
0
        //============================================================
        // <T>查找指定主题的材质。</T>
        //============================================================
        public FDrMaterial SyncMaterial(string themeName)
        {
            string themeCode = RDrUtil.FormatPathToCode(themeName);

            foreach (FDrMaterial material in _materials)
            {
                if (material.ThemeCode == themeCode)
                {
                    return(material);
                }
            }
            FDrMaterial createMaterial = new FDrMaterial();

            createMaterial.Group = this;
            createMaterial.Assign(_materials.First);
            createMaterial.ThemeName = themeName;
            _materials.Push(createMaterial);
            _materials.Sort(new FDrMaterial());
            return(createMaterial);
        }
Esempio n. 7
0
        //============================================================
        // <T>根据材质组合主题名称查找材质。</T>
        //
        // @param themeName 主题名称
        // @param groupName 材质组名称
        // @return 材质
        //============================================================
        public FDrMaterial FindDefault(string themeName, string groupName)
        {
            string           groupCode = RDrUtil.FormatPathToCode(groupName);
            string           themeCode = RDrUtil.FormatPathToCode(themeName);
            FDrMaterialGroup group     = _materials.Find(groupCode);
            FDrMaterial      material  = null;

            if (null != group)
            {
                material = group.FindMaterial(themeCode);
            }
            if (null == material)
            {
                if (null != group)
                {
                    if (!group.Materials.IsEmpty)
                    {
                        material = group.Materials.First;
                    }
                }
            }
            return(material);
        }
Esempio n. 8
0
        //============================================================
        // <T>根据名称查找场景。</T>
        //
        // @param name 名称
        // @return 场景
        //============================================================
        public FDrSceneGroup Find(string name)
        {
            string code = RDrUtil.FormatPathToCode(name);

            return(_sceneGroups.Find(code));
        }
Esempio n. 9
0
        //============================================================
        // <T>根据名称查找材质。</T>
        //
        // @param name 名称
        // @return 材质
        //============================================================
        public FDrMaterialGroup FindGroup(string name)
        {
            string code = RDrUtil.FormatPathToCode(name);

            return(_materials.Find(code));
        }
Esempio n. 10
0
        //============================================================
        // <T>根据名称查找纹理。</T>
        //
        // @param name 名称
        // @return 纹理
        //============================================================
        public FDrTexture Find(string name)
        {
            string code = RDrUtil.FormatPathToCode(name);

            return(_textures.Find(code));
        }
Esempio n. 11
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);
                    }
                }
            }
        }
Esempio n. 12
0
        //============================================================
        // <T>根据名称查找模型。</T>
        //
        // @param name 名称
        // @return 模型
        //============================================================
        public FDrModel Find(string name)
        {
            string code = RDrUtil.FormatPathToCode(name);

            return(_models.Find(code));
        }
Esempio n. 13
0
        //============================================================
        // <T>根据名称查找模板。</T>
        //
        // @param name 名称
        // @return 模板
        //============================================================
        public FDrCamera Find(string name)
        {
            string code = RDrUtil.FormatPathToCode(name);

            return(_cameras.Find(code));
        }