//============================================================ // <T>加载配置信息。</T> // // @param xconfig 配置信息 //============================================================ public void LoadConfig(FXmlNode xconfig) { foreach (FXmlNode xnode in xconfig.Nodes) { if (xnode.IsName("Color")) { // 加载颜色 _color.LoadConfigPower(xnode); } else if (xnode.IsName("ColorLevel")) { // 加载颜色级别 _colorLevel.LoadConfigPower(xnode); } else if (xnode.IsName("Fog")) { // 加载雾化 _fogNear = xnode.GetFloat("near"); _fogFar = xnode.GetFloat("far"); _fogRate = xnode.GetFloat("rate"); _fogAttenuation = xnode.GetFloat("attenuation"); _fogColor.LoadConfigPower(xnode); } else if (xnode.IsName("Edge")) { // 加载边界 _edgeRate = xnode.GetFloat("rate"); _edgeLevel = xnode.GetFloat("level"); _edgeWidth = xnode.GetFloat("width"); _edgeColor.LoadConfigPower(xnode); } else if (xnode.IsName("Face")) { // 加载平面 _faceRange = xnode.GetFloat("range"); _faceLimit = xnode.GetFloat("limit"); _faceRate = xnode.GetFloat("rate"); } else if (xnode.IsName("Camera")) { // 加载相机信息 _camera.LoadConfig(xnode); } else if (xnode.IsName("Light")) { // 加载光源信息 _light.LoadConfig(xnode); } } }
//============================================================ // <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); } }