//============================================================ // <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); }
//============================================================ // <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 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> // // @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"); _source = _source.Replace('/', '\\'); _sourceType = xconfig.Nvl("source_type"); }
//============================================================ // <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) { // 读取主题 _theme = RContent3dManager.ThemeConsole.Find(xconfig.Nvl("theme_name")); if (_theme == null) { _theme = RContent3dManager.ThemeConsole.DefaultTheme; } _themeName = _theme.Name; // 读取属性 LoadConfigInfo(xconfig); }
//============================================================ // <T>加载配置信息。</T> // // @param config 配置信息 //============================================================ public void LoadConfig(FXmlNode xconfig) { _name = xconfig.Nvl("name"); _playCd = xconfig.GetInteger("play_cd", _playCd); _frameBegin = xconfig.GetInteger("frame_begin"); _frameEnd = xconfig.GetInteger("frame_end"); if (xconfig.Contains("rate")) { _frameRate = xconfig.GetFloat("rate"); } if (xconfig.Contains("frame_rate")) { _frameRate = xconfig.GetFloat("frame_rate"); } }
//============================================================ // <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 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 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); } } } }