Exemplo n.º 1
0
 //============================================================
 // <T>加载模型信息。</T>
 //
 // @param model 模型对象
 //============================================================
 public void SaveModel()
 {
     // 隐藏几何体属性
     if (qdrModelGeometryProperty.Visible)
     {
         qdrModelGeometryProperty.SaveGeometry();
     }
     // 存储几何体信息
     foreach (DataGridViewRow row in dgvGeometries.Rows)
     {
         FDrGeometry geometry = row.Tag as FDrGeometry;
         if (null != geometry)
         {
             geometry.OptionInstanced  = EDrFlag.FromBoolean((bool)row.Cells["dgcGeometryInstanced"].Value);
             geometry.OptionDynamic    = EDrFlag.FromBoolean((bool)row.Cells["dgcGeometryDynamic"].Value);
             geometry.OptionShadow     = EDrFlag.FromBoolean((bool)row.Cells["dgcGeometryShadow"].Value);
             geometry.OptionSelfShadow = EDrFlag.FromBoolean((bool)row.Cells["dgcGeometrySelfShadow"].Value);
             geometry.OptionNormalFull = EDrFlag.FromBoolean((bool)row.Cells["dgcGeometryNormal"].Value);
             geometry.OptionDouble     = EDrFlag.FromBoolean((bool)row.Cells["dgcGeometryDouble"].Value);
             geometry.OptionSelect     = EDrFlag.FromBoolean((bool)row.Cells["dgcGeometrySelect"].Value);
         }
     }
 }
Exemplo n.º 2
0
        //============================================================
        // <T>加载模型信息。</T>
        //
        // @param model 模型对象
        //============================================================
        public void LoadModel(FDrModel model)
        {
            model.Open();
            _model = model;
            //............................................................
            txtName.Text      = _model.Name;
            txtLabel.Text     = _model.Label;
            txtBoneCount.Text = _model.Skeleton.Bones.Count.ToString();
            //............................................................
            // 清空节点
            tvwCatalog.Nodes.Clear();
            tvwCatalog.BeginUpdate();
            //............................................................
            TreeNode materialsNode = new TreeNode("材质列表");

            materialsNode.ImageKey         = "Floder";
            materialsNode.SelectedImageKey = "Floder";
            materialsNode.Tag = model;
            dgvMaterials.Rows.Clear();
            // 建立材质集合
            foreach (INamePair <FDrModelMaterial> pair in model.Materials.Names)
            {
                FDrModelMaterial material = pair.Value;
                // 建立树目录节点
                TreeNode materialNode = new TreeNode(material.Name);
                materialNode.ImageKey         = "Material";
                materialNode.SelectedImageKey = "Material";
                materialNode.Tag = pair.Value;
                materialsNode.Nodes.Add(materialNode);
                // 建立数据行对象
                DataGridViewRow         row      = new DataGridViewRow();
                DataGridViewTextBoxCell cellName = new DataGridViewTextBoxCell();
                cellName.Value = material.Name;
                row.Cells.Add(cellName);
                DataGridViewTextBoxCell cellLabel = new DataGridViewTextBoxCell();
                if (null != material.Material)
                {
                    cellLabel.Value = material.Material.Label;
                }
                row.Cells.Add(cellLabel);
                dgvMaterials.Rows.Add(row);
            }
            tvwCatalog.Nodes.Add(materialsNode);
            //............................................................
            FDrMesh  mesh           = model.Mesh;
            TreeNode geometriesNode = new TreeNode("网格列表");

            geometriesNode.ImageKey         = "Floder";
            geometriesNode.SelectedImageKey = "Floder";
            geometriesNode.Tag = model;
            dgvGeometries.Rows.Clear();
            // 建立几何集合
            foreach (INamePair <FDrGeometry> pair in model.Mesh.GeometryDictionary)
            {
                FDrGeometry geometry = pair.Value;
                // 建立树目录节点
                string   displayName  = geometry.Name + " (" + geometry.MaterialName + ")";
                TreeNode geometryNode = new TreeNode(displayName);
                geometryNode.ImageKey         = "Geometry";
                geometryNode.SelectedImageKey = "Geometry";
                geometryNode.Tag = geometry;
                geometriesNode.Nodes.Add(geometryNode);
                // 建立数据行对象
                DataGridViewRow         row      = new DataGridViewRow();
                DataGridViewTextBoxCell cellName = new DataGridViewTextBoxCell();
                cellName.Value = geometry.Name;
                row.Cells.Add(cellName);
                // 实体配置
                DataGridViewCheckBoxCell cellOptionInstanced = new DataGridViewCheckBoxCell();
                cellOptionInstanced.Value = EDrFlag.ToBoolean(geometry.OptionInstanced);
                row.Cells.Add(cellOptionInstanced);
                DataGridViewTextBoxCell cellInstanceCount = new DataGridViewTextBoxCell();
                cellInstanceCount.Value = geometry.InstanceCount;
                row.Cells.Add(cellInstanceCount);
                // 动态配置
                DataGridViewCheckBoxCell cellOptionDynamic = new DataGridViewCheckBoxCell();
                cellOptionDynamic.Value = EDrFlag.ToBoolean(geometry.OptionDynamic);
                row.Cells.Add(cellOptionDynamic);
                // 骨骼缩放
                DataGridViewCheckBoxCell cellOptionBoneScale = new DataGridViewCheckBoxCell();
                cellOptionBoneScale.Value = EDrFlag.ToBoolean(geometry.OptionBoneScale);
                row.Cells.Add(cellOptionBoneScale);
                DataGridViewTextBoxCell cellBoneCount = new DataGridViewTextBoxCell();
                cellBoneCount.Value = geometry.AdjustBones.Count;
                row.Cells.Add(cellBoneCount);
                DataGridViewTextBoxCell cellWeightCount = new DataGridViewTextBoxCell();
                cellWeightCount.Value = geometry.WeightMaxCount.ToString();
                row.Cells.Add(cellWeightCount);
                // 影子配置
                DataGridViewCheckBoxCell cellOptionShadow = new DataGridViewCheckBoxCell();
                cellOptionShadow.Value = EDrFlag.ToBoolean(geometry.OptionShadow);
                row.Cells.Add(cellOptionShadow);
                // 自影子配置
                DataGridViewCheckBoxCell cellOptionSelfShadow = new DataGridViewCheckBoxCell();
                cellOptionSelfShadow.Value = EDrFlag.ToBoolean(geometry.OptionSelfShadow);
                row.Cells.Add(cellOptionSelfShadow);
                // 法线配置
                DataGridViewCheckBoxCell cellOptionNormal = new DataGridViewCheckBoxCell();
                cellOptionNormal.Value = EDrFlag.ToBoolean(geometry.OptionNormalFull);
                row.Cells.Add(cellOptionNormal);
                // 双面配置
                DataGridViewCheckBoxCell cellOptionDouble = new DataGridViewCheckBoxCell();
                cellOptionDouble.Value = EDrFlag.ToBoolean(geometry.OptionDouble);
                row.Cells.Add(cellOptionDouble);
                // 选择配置
                DataGridViewCheckBoxCell cellOptionSelect = new DataGridViewCheckBoxCell();
                cellOptionSelect.Value = EDrFlag.ToBoolean(geometry.OptionSelect);
                row.Cells.Add(cellOptionSelect);
                // 材质名称
                DataGridViewTextBoxCell cellMaterialName = new DataGridViewTextBoxCell();
                cellMaterialName.Value = geometry.MaterialName;
                row.Cells.Add(cellMaterialName);
                // 顶点信息
                DataGridViewTextBoxCell cellVertexCount = new DataGridViewTextBoxCell();
                cellVertexCount.Value = geometry.VertexList.Count + "/" + geometry.AdjustVertexDictionary.Count;
                row.Cells.Add(cellVertexCount);
                // 面信息
                DataGridViewTextBoxCell cellFaceCount = new DataGridViewTextBoxCell();
                cellFaceCount.Value = geometry.FaceList.Count;
                row.Cells.Add(cellFaceCount);
                // 法线信息
                DataGridViewTextBoxCell cellNormalCount = new DataGridViewTextBoxCell();
                cellNormalCount.Value = geometry.NormalList.Count;
                row.Cells.Add(cellNormalCount);
                // 副法线信息
                DataGridViewTextBoxCell cellBinormalCount = new DataGridViewTextBoxCell();
                cellBinormalCount.Value = geometry.BinormalList.Count;
                row.Cells.Add(cellBinormalCount);
                // 切线信息
                DataGridViewTextBoxCell cellTangentCount = new DataGridViewTextBoxCell();
                cellTangentCount.Value = geometry.TangentList.Count;
                row.Cells.Add(cellTangentCount);
                row.Tag = geometry;
                dgvGeometries.Rows.Add(row);
            }
            tvwCatalog.Nodes.Add(geometriesNode);
            //............................................................
            TreeNode animationsNode = new TreeNode("动画列表");

            // 建立动画集合
            foreach (FDrMovie movie in model.Animation.Movies)
            {
                TreeNode animationNode = new TreeNode(movie.Name);
                animationNode.ImageKey         = "Movie";
                animationNode.SelectedImageKey = "Movie";
                animationNode.Tag = movie;
                animationsNode.Nodes.Add(animationNode);
            }
            tvwCatalog.Nodes.Add(animationsNode);
            //............................................................
            tvwCatalog.EndUpdate();
            tvwCatalog.ExpandAll();
            // 选择项目
            SelectItem(null);
        }
Exemplo n.º 3
0
        //============================================================
        // <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);
            }
        }