//============================================================ // <T>加载配置文件。</T> //============================================================ public void LoadConfig(FXmlNode config) { // 加载基本设置 _tid = config.GetInteger("tid", _tid); _name = config.Get("name", _name); _label = config.Get("label", _label); if (config.Contains("size")) { _size.Parse(config.Get("size")); } if (config.Contains("birth_location")) { _birthLocation.Parse(config.Get("birth_location")); } // 加载层 _layerListNode = config.Find("Layers"); if (null == _layerListNode) { return; } foreach (FXmlNode layerNode in _layerListNode.Nodes) { FDsMapLayer layer = new FDsMapLayer(); layer.Resource.LoadConfig(layerNode); _layers.Push(layer.Resource); } // 加载出生点 _birthListNode = config.Find("Births"); if (null == _birthListNode) { return; } foreach (FXmlNode birthNode in _birthListNode.Nodes) { FDsMapBirth birth = new FDsMapBirth(); birth.Resource.LoadConfig(birthNode); _births.Push(birth.Resource); } }
//============================================================ // <T>加载模型设置。</T> //============================================================ public void LoadModelSceneConfig(FXmlNode config) { // 加载材质信息 FXmlNode xmaterials = config.Find("MaterialCollection"); if (xmaterials != null) { _materials.LoadModelConfig(xmaterials); } // 加载骨骼信息 FXmlNode xskeleton = config.Find("Skeleton"); if (xskeleton != null) { _skeleton.LoadModelConfig(xskeleton); } // 加载网格信息 FXmlNode xmesh = config.Find("Mesh"); if (xmesh != null) { _mesh.LoadModelConfig(xmesh); } // 加载网格信息 FXmlNode xanimation = config.Find("Animation"); if (xanimation != null) { _animation.LoadModelConfig(xanimation); } }
//============================================================ // <T>加载配置信息。</T> // // @param xconfig 配置信息 //============================================================ public void LoadConfig(FXmlNode xconfig) { // 读取属性 _name = xconfig.Nvl("name"); _label = String.Empty; // 读取设置 LoadConfigInfo(xconfig); // 读取高度 FXmlNode xheight = xconfig.Find("Height"); if (null != xheight) { //_optionHeight = xconfig.GetInteger("option_height", _optionHeight); _heightDepth = xheight.GetFloat("depth"); } // 读取表面 FXmlNode xsurface = xconfig.Find("Surface"); if (null != xsurface) { _surfaceRate = xsurface.GetFloat("rate"); _surfaceReflect = xsurface.GetFloat("reflect"); _surfaceBright = xsurface.GetFloat("bright"); _surfaceBrightLevel = xsurface.GetFloat("bright_level"); _surfaceCoarse = xsurface.GetFloat("coarse"); _surfaceCoarseLevel = xsurface.GetFloat("coarse_level"); _surfaceMerge = xsurface.GetFloat("merge"); _surfacePower = xsurface.GetFloat("power"); } if (!RString.IsEmpty(_name)) { _material = RContent3dManager.MaterialConsole.FindDefault(_scene.ThemeName, _name); if (null == _material) { RMoCore.TrackConsole.Write(this, "LoadConfig", "Scene material is not exists. (scene={0}, material={1})", _scene.Code, Code); } else { _label = _material.Group.Label; _transformName = _material.TransformName; _optionLight = _material.OptionLight; _optionMerge = _material.OptionMerge; _optionSort = _material.OptionSort; _sortLevel = _material.SortLevel; _optionAlpha = _material.OptionAlpha; _optionDepth = _material.OptionDepth; _optionCompare = _material.OptionCompare; _optionDouble = _material.OptionDouble; _optionShadow = _material.OptionShadow; _optionShadowSelf = _material.OptionShadowSelf; _optionDynamic = _material.OptionDynamic; _optionTransmittance = _material.OptionTransmittance; _optionOpacity = _material.OptionOpacity; } } }
//============================================================ // <T>加载配置信息。</T> // // @param config 配置信息 //============================================================ public void LoadConfig(FXmlNode xconfig) { _optionLoaded = xconfig.GetInteger("option_loaded", EDrFlag.Inherit); _optionSelect = xconfig.GetInteger("option_select", EDrFlag.Inherit); _optionGround = xconfig.GetInteger("option_ground", EDrFlag.Inherit); if (xconfig.Contains("option_merge")) { _optionMergeVertex = xconfig.GetInteger("option_merge"); } if (xconfig.Contains("option_merge_vertex")) { _optionMergeVertex = xconfig.GetInteger("option_merge_vertex"); } _optionMergeMaterial = xconfig.GetInteger("option_merge_material", EDrFlag.Inherit); _optionLightMap = xconfig.GetInteger("option_light_map", EDrFlag.Inherit); //............................................................ //............................................................ // 加载引用列表 FXmlNode xreferences = xconfig.Find("References"); if (null != xreferences) { foreach (FXmlNode xreference in xreferences.Nodes) { if (xreference.IsName("Reference")) { FDrTemplateReference reference = new FDrTemplateReference(); reference.LoadConfig(xreference); _references.Push(reference); } } } //............................................................ // 加载动画列表 FXmlNode xanimation = xconfig.Find("Animation"); if (null != xanimation) { _animation.Model = _model; _animation.LoadConfig(xanimation); } //............................................................ // 材质集合排序 if (!_materials.IsEmpty) { _materials.Sort(_materials.First); } }
//============================================================ // <T>加载设置信息。</T> // // @param xconfig 设置节点 //============================================================ public override void LoadConfig(FXmlNode xconfig) { base.LoadConfig(xconfig); // 读取属性 _optionAlpha = xconfig.GetBoolean("option_alpha", _optionAlpha); _optionPadding = xconfig.GetBoolean("option_padding", _optionPadding); _qualityCd = xconfig.Get("quality_cd", _qualityCd); _qualityPalette = xconfig.GetInteger("quality_palette", _qualityPalette); _qualityAlpha = xconfig.GetInteger("quality_alpha", _qualityAlpha); _frameDelay = xconfig.GetInteger("frame_delay", _frameDelay); // 读取剪辑集合 FXmlNode xclips = xconfig.Find("Clips"); if (xclips != null) { foreach (FXmlNode xnode in xclips.Nodes) { if (xnode.IsName("Clip")) { // 检查参数 if (!xnode.Contains("direction_cd")) { continue; } // 加载剪辑信息 int directionCd = xnode.GetInteger("direction_cd"); FRsResourceClip clip = _clips[directionCd]; if (clip != null) { clip.LoadConfig(xnode); } } } } }
//============================================================ // <T>加载设置信息。</T> // // @param xconfig 设置节点 //============================================================ public void LoadConfig(FXmlNode xconfig) { // 读取属性 _isReversed = xconfig.GetBoolean("is_reversed", _isReversed); if (xconfig.Contains("reverse_direction")) { int reverseDirection = xconfig.GetInteger("reverse_direction"); _reverseDirection = IntToDirction(reverseDirection); } _frameDelay = xconfig.GetInteger("frame_delay", _frameDelay); // 读取剪辑集合 FXmlNode xframes = xconfig.Find("Frames"); if (xframes != null) { foreach (FXmlNode xnode in xframes.Nodes) { if (xnode.IsName("Frame")) { int index = xnode.GetInteger("index"); FRsResourceFrame frame = _frames.Get(index, null); if (frame != null) { frame.LoadConfig(xnode); } } } } }
//============================================================ // <T>加载配置信息。</T> // // @param config 配置信息 //============================================================ public void LoadExportConfig(FXmlNode xconfig) { FXmlNode xmatrix = xconfig.Find("Matrix"); FXmlNode xworldmatrix = xmatrix.Find("WorldMatrix"); _matrix.LoadSimpleDegreeConfig(xworldmatrix); }
//============================================================ // <T>加载配置信息。</T> // // @param config 配置信息 //============================================================ public void LoadConfig(FXmlNode xconfig) { // 读取设置 _id = xconfig.GetInteger("id", 0); _name = xconfig.Get("name", _name); _modelName = xconfig.Nvl("model"); _modelName = _modelName.Replace('/', '\\'); _model = RContent3dManager.ModelConsole.Find(_modelName); if (null == _model) { RMoCore.TrackConsole.Write(this, "LoadConfig", "Model is not exists in tempalte. (template={0}, model={1})", _template.Name, _modelName); return; } _geometryName = xconfig.Nvl("geometry"); _geometry = _model.Mesh.Find(_geometryName); if (null == _geometry) { RMoCore.TrackConsole.Write(this, "LoadConfig", "Model geometry is not exists. (template={0}, model={1}, geometry={2})", _template.Name, _modelName, _geometryName); } else { _optionSelect = _geometry.OptionSelect; _optionGround = _geometry.OptionGround; _optionBoneScale = _geometry.OptionBoneScale; _optionInstnaced = _geometry.OptionInstanced; _instanceCount = _geometry.InstanceCount; _outline.min.Assign(_geometry.OutlineMin); _outline.max.Assign(_geometry.OutlineMax); } _materialName = xconfig.Nvl("material"); _materialName = _materialName.Replace('/', '\\'); _material = RContent3dManager.MaterialConsole.FindGroup(_materialName); if (null == _material) { RMoCore.TrackConsole.Write(this, "LoadConfig", "Material is not exists in tempalte. (template={0}, model={1}, material={2})", _template.Name, _modelName, _materialName); } else { if (!_material.Materials.IsEmpty) { FDrMaterial material = _material.Materials.First; _optionDynamic = material.OptionDynamic; _optionMerge = material.OptionMerge; } } _lightMapName = xconfig.Get("light_map", ""); // 读取选项 if (xconfig.Contains("option_visible")) { _optionVisible = xconfig.GetInteger("option_visible"); } // 读取矩阵 FXmlNode xmatrix = xconfig.Find("Matrix"); if (null != xmatrix) { _matrix.LoadSimpleConfig(xmatrix); } }
//============================================================ // <T>加载配置信息。</T> // // @param config 配置信息 //============================================================ public void LoadConfig(FXmlNode xconfig) { // 加载编号 _id = xconfig.GetInteger("id"); // 加载名称 _name = xconfig.Get("name"); // 加载层数 _layerCount = xconfig.GetInteger("layer_count"); // 加载尺寸 _size.Parse(xconfig.Get("size")); // 加载切割尺寸 _range.Parse(xconfig.Get("range")); // 加载深度 _deep = xconfig.GetFloat("deep"); _incise = RInt.Parse(xconfig.GetFloat("deep")); //............................................................ // 加载高度纹理 FXmlNode xheight = xconfig.Find("Height"); if (null != xheight) { _textureHeight = xheight.Get("source"); } // 加载颜色纹理 FXmlNode xcolor = xconfig.Find("Color"); if (null != xcolor) { _textureColor = xcolor.Get("source"); } //............................................................ // 加载层信息 FXmlNode xlayers = xconfig.Find("Layers"); if (null != xlayers) { foreach (FXmlNode xlayer in xlayers.Nodes) { FDrMapLayer layer = new FDrMapLayer(); layer.Index = _layers.Count; layer.LoadConfig(xlayer); _layers.Push(layer); } } }
//============================================================ public SIntRectangle GetRect(string key) { FXmlNode config = _config.Find(key); if (config != null) { return(new SIntRectangle(config)); } return(null); }
//============================================================ public void LoadConfigFile(string fileName) { FXmlDocument xdoc = new FXmlDocument(fileName); FXmlNode xroot = xdoc.Root; FXmlNode xmap = xroot.Find("Map"); if (null != xmap) { LoadConfig(xmap); } }
//============================================================ // <T>加载设置文件。</T> //============================================================ public void LoadConfigFile(string fileName) { FXmlDocument xdoc = new FXmlDocument(fileName); FXmlNode xroot = xdoc.Root; FXmlNode xmaterial = xroot.Find("Theme"); if (xmaterial != null) { LoadConfig(xmaterial); } }
//============================================================ // <T>加载设置文件。</T> //============================================================ public void LoadConfigFile(string fileName) { FXmlDocument xdoc = new FXmlDocument(fileName); FXmlNode xroot = xdoc.Root; FXmlNode xtexture = xroot.Find("Texture"); if (null != xtexture) { LoadConfig(xtexture); } }
//============================================================ // <T>加载配置信息。</T> // // @param config 配置信息 //============================================================ public void LoadConfig(FXmlNode config) { _name = config.Nvl("name"); _label = config.Nvl("label"); // 读取环境光 FXmlNode xambient = config.Find("Ambient"); if (null != xambient) { _ambientColor.LoadConfig(xambient, "r", "g", "b", "power"); } }
//============================================================ // <T>加载配置文件。</T> //============================================================ public void LoadConfig(FXmlNode config) { if (config.Contains("cell_count")) { _cellCount.Parse(config.Get("cell_count")); } if (config.Contains("cell_size")) { _cellSize.Parse(config.Get("cell_size")); } if (config.Contains("type_cd")) { _typeCd = REnum.ToValue <EMapLayerType>(config.Get("type_cd")); } if (config.Contains("scroll_cd")) { _scrollCd = REnum.ToValue <EMapLayerScroll>(config.Get("scroll_cd")); } if (config.Contains("wrap_cd")) { _wrapCd = REnum.ToValue <EMapLayerWrap>(config.Get("wrap_cd")); } if (config.Contains("scroll_speed")) { _scrollSpeed = config.GetFloat("scroll_speed"); } _tileNode = config.Find("Tiles"); if (null == _tileNode) { return; } // 创建所有格子 for (int m = 0; m < _cellCount.Height; m++) { for (int n = 0; n < _cellCount.Width; n++) { FMbMapCell cell = new FMbMapCell(); cell.Index = new SIntPoint2(n, m); _mapCell.Push(cell); } } // 加载格子资源图片编号 foreach (FXmlNode cellNode in _tileNode.Nodes) { FDsMapCell cell = new FDsMapCell(); cell.Resource.LoadConfig(cellNode); SIntPoint2 cellIndex = cell.Resource.Index; FMbMapCell c = FingCellByIndex(cellIndex.X, cellIndex.Y); c.ResourceId = cell.Resource.ResourceId; } }
//============================================================ // <T>序列化数据。</T> //============================================================ public void Import() { string fileName = _directory + "\\model.m3x"; FXmlDocument xdoc = new FXmlDocument(fileName); FXmlNode xscene = xdoc.Root.Find("Scene"); // 重新导入所有集合体(可以重复) _renderables.Clear(); int n = 0; FXmlNode xmesh = xscene.Find("Mesh"); foreach (FXmlNode xgeometry in xmesh.Nodes) { if (xgeometry.IsName("Geometry")) { string name = xgeometry.Get("name"); string[] items = name.Split('|'); if (items.Length >= 2) { // 获得模型和集合体对象 string modelCode = items[0]; string geometryName = items[1]; FDrModel model = RContent3dManager.ModelConsole.Find(modelCode); if (null == model) { RMoCore.TrackConsole.Write(this, "Import", "Model is not exists. (model={0})", modelCode); continue; } model.Open(); FDrGeometry geometry = model.Mesh.Find(geometryName); if (null == geometry) { RMoCore.TrackConsole.Write(this, "Import", "Model geometry is not exists. (model={0}, geometry={1})", modelCode, geometryName); continue; } // 新建渲染对象 FDrTemplateRenderable renderable = new FDrTemplateRenderable(); renderable.Id = n++; renderable.Name = name; renderable.LightMapName = RString.Right(name, "|"); renderable.ModelName = model.Name; renderable.GeometryName = geometry.Name; renderable.MaterialName = geometry.MaterialName; renderable.LoadExportConfig(xgeometry); _renderables.Push(renderable); } } } _logger.Debug(this, "Import", "Import template success. (file_name={0})", fileName); Store(); }
///============================================================ public void LoadResource(Type type) { _document = new FXmlDocument(); _document.LoadResource(type); _config = _document.Root; // Build contents map FXmlNode resConfig = _config.Find(TAG_RESOURCE); if (resConfig != null) { FXmlNode ctsConfig = resConfig.Find(TAG_CONTENTS); if (ctsConfig != null) { RXml.BuildMap(ctsConfig, _contents, TAG_CONTENT, PTY_ID); } } }
///============================================================ public string FindDisplay(string name) { if (_contents != null) { FXmlNode config = _contents[name]; if (config != null) { FXmlNode lanCfg = config.Find(RCulture.Language); string display = (lanCfg != null) ? lanCfg.Text : config[FIX_MULTISTRING + RCulture.Language]; if (display != null) { display = RString.TrimLines(display, MESSAGE_FLAG); } return(display); } } return(null); }
//============================================================ // <T>加载模型设置。</T> // // @param xconfig 设置信息 //============================================================ public void LoadModelConfig(FXmlNode xconfig) { _dataName = xconfig.Get("name"); // 读取环境光 FXmlNode ambientNode = xconfig.Find("Ambient"); if (null != ambientNode) { _ambient.LoadConfig3(ambientNode); } // 读取散射光 FXmlNode diffuseNode = xconfig.Find("Diffuse"); if (null != diffuseNode) { _diffuse.LoadConfig3(diffuseNode); } // 读取全反射 FXmlNode specularNode = xconfig.Find("Specular"); if (null != specularNode) { _specular.LoadConfig3(specularNode); } // 读取全反射级别 FXmlNode specularLevelNode = xconfig.Find("SpecularLevel"); if (null != specularLevelNode) { _specular.A = specularLevelNode.GetFloat("value"); } // 读取自发光 FXmlNode emissiveNode = xconfig.Find("Emissive"); if (null != emissiveNode) { _emissive.LoadConfig3(emissiveNode); } FXmlNode emissiveAmtNode = xconfig.Find("EmissiveAmt"); if (null != emissiveAmtNode) { _emissive.A = emissiveAmtNode.GetFloat("value"); } }
public FXmlNode Find(string name) { return(_config.Find(name)); }
//============================================================ // <T>加载配置信息。</T> // // @param config 配置信息 //============================================================ public void LoadConfigInfo(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 xcoord = xconfig.Find("Coord"); if (null != xcoord) { _coordRateWidth = xcoord.GetFloat("rate_width", _coordRateWidth); _coordRateHeight = xcoord.GetFloat("rate_height", _coordRateHeight); } // 读取颜色 FXmlNode xcolor = xconfig.Find("Color"); if (null != xcolor) { _colorMin = xcolor.GetFloat("min", _colorMin); _colorMax = xcolor.GetFloat("max", _colorMax); _colorRate = xcolor.GetFloat("rate", _colorRate); _colorMerge = xcolor.GetFloat("merge", _colorMerge); } // 读取透明信息 FXmlNode xalpha = xconfig.Find("Alpha"); if (null != xalpha) { _alphaBase = xalpha.GetFloat("base", _alphaBase); _alphaRate = xalpha.GetFloat("rate", _alphaRate); _alphaLevel = xalpha.GetFloat("level", _alphaLevel); _alphaMerge = xalpha.GetFloat("merge", _alphaMerge); } // 读取环境光 FXmlNode xambient = xconfig.Find("Ambient"); if (null != xambient) { _ambientColor.LoadConfigPower(xambient); _ambientShadow = xambient.GetFloat("shadow", _ambientShadow); } // 读取散射光 FXmlNode xdiffuse = xconfig.Find("Diffuse"); if (null != xdiffuse) { _diffuseColor.LoadConfigPower(xdiffuse); _diffuseShadow = xdiffuse.GetFloat("shadow", _diffuseShadow); } // 读取视角散射光 FXmlNode xdiffuseview = xconfig.Find("DiffuseView"); if (null != xdiffuseview) { _diffuseViewColor.LoadConfigPower(xdiffuseview); _diffuseViewShadow = xdiffuseview.GetFloat("shadow", _diffuseViewShadow); } // 读取高光 FXmlNode xspecular = xconfig.Find("Specular"); if (null != xspecular) { _specularColor.LoadConfigPower(xspecular); _specularBase = xspecular.GetFloat("base", _specularBase); _specularRate = xspecular.GetFloat("rate", _specularRate); _specularAverage = xspecular.GetFloat("average", _specularAverage); _specularShadow = xspecular.GetFloat("shadow", _specularShadow); } // 读取视角高光 FXmlNode xspecularview = xconfig.Find("SpecularView"); if (null != xspecularview) { _specularViewColor.LoadConfigPower(xspecularview); _specularViewBase = xspecularview.GetFloat("base", _specularViewBase); _specularViewRate = xspecularview.GetFloat("rate", _specularViewRate); _specularViewAverage = xspecularview.GetFloat("average", _specularViewAverage); _specularViewShadow = xspecularview.GetFloat("shadow", _specularViewShadow); } // 读取反射光 FXmlNode xreflect = xconfig.Find("Reflect"); if (null != xreflect) { _reflectColor.LoadConfigPower(xreflect); _reflectMerge = xreflect.GetFloat("merge", _reflectMerge); _reflectShadow = xreflect.GetFloat("shadow", _reflectShadow); } // 读取前折射光 FXmlNode xrefractFront = xconfig.Find("RefractFront"); if (null != xrefractFront) { _refractFrontColor.LoadConfigPower(xrefractFront); } // 读取后折射光 FXmlNode xrefractBack = xconfig.Find("RefractBack"); if (null != xrefractBack) { _refractBackColor.LoadConfigPower(xrefractBack); } // 读取不透明度 FXmlNode xopacity = xconfig.Find("Opacity"); if (null != xopacity) { _opacityColorColor.LoadConfigPower(xopacity); _opacityRate = xopacity.GetFloat("rate", _opacityRate); _opacityAlpha = xopacity.GetFloat("alpha", _opacityAlpha); _opacityDepth = xopacity.GetFloat("depth", _opacityDepth); _opacityTransmittance = xopacity.GetFloat("transmittance", _opacityTransmittance); } // 读取自发光 FXmlNode xemissive = xconfig.Find("Emissive"); if (null != xemissive) { _emissiveColor.LoadConfigPower(xemissive); } }
//============================================================ // <T>加载配置信息。</T> // // @param config 配置信息 //============================================================ public void LoadConfig(FXmlNode xconfig) { _optionLoaded = xconfig.GetInteger("option_loaded", EDrFlag.Inherit); _optionSelect = xconfig.GetInteger("option_select", EDrFlag.Inherit); _optionGround = xconfig.GetInteger("option_ground", EDrFlag.Inherit); if (xconfig.Contains("option_merge")) { _optionMergeVertex = xconfig.GetInteger("option_merge"); } if (xconfig.Contains("option_merge_vertex")) { _optionMergeVertex = xconfig.GetInteger("option_merge_vertex"); } _optionMergeMaterial = xconfig.GetInteger("option_merge_material", EDrFlag.Inherit); _optionLightMap = xconfig.GetInteger("option_light_map", EDrFlag.Inherit); //............................................................ // 加载渲染列表 FXmlNode xrenderables = xconfig.Find("Renderables"); if (null != xrenderables) { _outline.InitializeMin(); foreach (FXmlNode xrenderable in xrenderables.Nodes) { if (xrenderable.IsName("Renderable")) { // 建立渲染对象 FDrTemplateRenderable renderable = new FDrTemplateRenderable(); renderable.Template = this; renderable.LoadConfig(xrenderable); if (null == _model) { _model = renderable.Model; } _outline.InnerMax(renderable.Outline); // 设置材质 FDrMaterialGroup material = renderable.Material; if (null == material) { RMoCore.TrackConsole.Write(this, "LoadConfig", "Material is not exists. (template={0}, geometry={1}, material={2})", _name, renderable.GeometryName, renderable.MaterialName); return; } if (!_materials.Contains(material)) { _materials.Push(material); } _renderables.Push(renderable); } } } //............................................................ // 加载引用列表 FXmlNode xreferences = xconfig.Find("References"); if (null != xreferences) { foreach (FXmlNode xreference in xreferences.Nodes) { if (xreference.IsName("Reference")) { FDrTemplateReference reference = new FDrTemplateReference(); reference.LoadConfig(xreference); _references.Push(reference); } } } //............................................................ // 加载动画列表 FXmlNode xanimation = xconfig.Find("Animation"); if (null != xanimation) { _animation.Model = _model; _animation.LoadConfig(xanimation); } //............................................................ // 材质集合排序 if (!_materials.IsEmpty) { _materials.Sort(_materials.First); } }
//============================================================ // <T>加载配置信息。</T> // // @param xconfig 配置信息 //============================================================ public void LoadOrignConfig(FXmlNode xconfig) { // 读取属性 _name = xconfig.Nvl("name"); _effectName = xconfig.Nvl("effect_name"); if (xconfig.Contains("option_double")) { _optionDouble = EDrFlag.FromBoolean(xconfig.GetBoolean("option_double")); } if (xconfig.Contains("option_opacity")) { _optionOpacity = EDrFlag.FromBoolean(xconfig.GetBoolean("option_opacity")); } if (xconfig.Contains("option_shadow")) { _optionShadow = EDrFlag.FromBoolean(xconfig.GetBoolean("option_shadow")); } if (xconfig.Contains("option_transmittance")) { _optionTransmittance = EDrFlag.FromBoolean(xconfig.GetBoolean("option_transmittance")); } // 读取颜色 FXmlNode xcolor = xconfig.Find("Color"); if (null != xcolor) { _colorMin = xcolor.GetFloat("min"); _colorMax = xcolor.GetFloat("max"); if (xcolor.Contains("merge")) { _colorMerge = xcolor.GetFloat("merge"); } if (xcolor.Contains("rate")) { _colorRate = xcolor.GetFloat("rate"); } } // 读取环境光 FXmlNode xalpha = xconfig.Find("Alpha"); if (null != xalpha) { _optionAlpha = EDrFlag.FromBoolean(xalpha.GetBoolean("enable")); _alphaBase = xalpha.GetFloat("base"); _alphaRate = xalpha.GetFloat("rate"); _alphaLevel = xalpha.GetFloat("level"); _alphaMerge = xalpha.GetFloat("merge"); } // 读取环境光 FXmlNode xambient = xconfig.Find("Ambient"); if (null != xambient) { _ambientColor.LoadConfig(xambient, "r", "g", "b", "power"); _ambientShadow = xambient.GetFloat("shadow", _ambientShadow); } // 读取散射光 FXmlNode xdiffuse = xconfig.Find("Diffuse"); if (null != xdiffuse) { _diffuseColor.LoadConfig(xdiffuse, "r", "g", "b", "power"); _diffuseShadow = xdiffuse.GetFloat("shadow", _diffuseShadow); _diffuseViewColor.LoadConfig(xdiffuse, "camera_r", "camera_g", "camera_b", "camera_power"); _diffuseViewShadow = xdiffuse.GetFloat("camera_shadow", _diffuseViewShadow); } // 读取反射光 FXmlNode xspecular = xconfig.Find("Specular"); if (null != xspecular) { _specularColor.LoadConfig(xspecular, "r", "g", "b", "power"); _specularBase = xspecular.GetFloat("base", _specularBase); _specularRate = xspecular.GetFloat("rate", _specularRate); _specularAverage = xspecular.GetFloat("average", _specularAverage); _specularShadow = xspecular.GetFloat("shadow", _specularShadow); _specularViewColor.LoadConfig(xspecular, "camera_r", "camera_g", "camera_b", "camera_power"); _specularViewBase = xspecular.GetFloat("camera_base", _specularViewBase); _specularViewRate = xspecular.GetFloat("camera_rate", _specularViewRate); _specularViewAverage = xspecular.GetFloat("camera_average", _specularViewAverage); _specularViewShadow = xspecular.GetFloat("camera_shadow", _specularViewShadow); } // 读取自发光 FXmlNode xreflect = xconfig.Find("Reflect"); if (null != xreflect) { _reflectColor.LoadConfig(xreflect, "r", "g", "b", "power"); _reflectMerge = xreflect.GetFloat("merge", _reflectMerge); _reflectShadow = xreflect.GetFloat("shadow", _reflectShadow); } // 读取折射 FXmlNode xrefract = xconfig.Find("Refract"); if (null != xrefract) { _refractFrontColor.LoadConfig(xrefract, "front_r", "front_g", "front_b", "front_power"); _refractFrontMerge = xrefract.GetFloat("front_merge", _refractFrontMerge); _refractFrontShadow = xrefract.GetFloat("front_shadow", _refractFrontShadow); _refractBackColor.LoadConfig(xrefract, "back_r", "back_g", "back_b", "back_power"); _refractBackMerge = xrefract.GetFloat("back_merge", _refractBackMerge); _refractBackShadow = xrefract.GetFloat("back_shadow", _refractBackShadow); } // 读取不透明度 FXmlNode xopacity = xconfig.Find("Opacity"); if (null != xopacity) { _optionOpacity = EDrFlag.FromBoolean(xopacity.GetBoolean("enable")); _opacityColorColor.LoadConfigPower(xopacity); _opacityRate = xopacity.GetFloat("rate", _opacityRate); _opacityAlpha = xopacity.GetFloat("alpha", _opacityAlpha); _opacityDepth = xopacity.GetFloat("depth", _opacityDepth); _opacityTransmittance = xopacity.GetFloat("transmittance", _opacityTransmittance); } // 读取自发光 FXmlNode xemissive = xconfig.Find("Emissive"); if (null != xemissive) { _emissiveColor.LoadConfigPower(xemissive); } // 读取高度 FXmlNode xheight = xconfig.Find("Height"); if (null != xheight) { //_optionHeight = EDrFlag.FromBoolean(xheight.GetBoolean("enable")); _heightDepth = xheight.GetFloat("depth", _heightDepth); } // 读取表面 FXmlNode xsurface = xconfig.Find("Surface"); if (null != xsurface) { _surfaceRate = xsurface.GetFloat("rate", _surfaceRate); _surfaceReflect = xsurface.GetFloat("reflect", _surfaceReflect); _surfaceBright = xsurface.GetFloat("bright", _surfaceBright); _surfaceBrightLevel = xsurface.GetFloat("bright_level", _surfaceBrightLevel); _surfaceCoarse = xsurface.GetFloat("coarse", _surfaceCoarse); _surfaceCoarseLevel = xsurface.GetFloat("coarse_level", _surfaceCoarseLevel); _surfaceMerge = xsurface.GetFloat("merge", _surfaceMerge); _surfacePower = xsurface.GetFloat("power", _surfacePower); } }
//============================================================ // <T>加载配置信息。</T> // // @param config 配置信息 //============================================================ public void LoadConfig(FXmlNode config) { _translation.LoadConfig(config.Find("Translation")); _euler.LoadConfig(config.Find("Euler")); _scale.LoadConfig(config.Find("Scale")); }
//============================================================ // <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); } } } }