//============================================================ // <T>打开资源。</T> //============================================================ public void SelectItem(object item) { // 存储改变 SaveModel(); // 隐藏属性控件 qdrModelGeometryProperty.Visible = false; qdrMaterialProperty.Visible = false; pnlModelProperty.Visible = false; // 显示选中对象 if (item is FDrMaterialGroup) { FDrMaterialGroup material = item as FDrMaterialGroup; qdrMaterialProperty.Dock = DockStyle.Fill; qdrMaterialProperty.Visible = true; qdrMaterialProperty.LoadMaterialGroup(material); } else if (item is FDrGeometry) { FDrGeometry geometry = item as FDrGeometry; qdrModelGeometryProperty.Dock = DockStyle.Fill; qdrModelGeometryProperty.Visible = true; qdrModelGeometryProperty.LoadGeometry(geometry); } else { pnlModelProperty.Visible = true; pnlModelProperty.Dock = DockStyle.Fill; } }
//============================================================ public bool DataUnserialize(FByteStream input) { int count = input.ReadInt32(); for (int n = 0; n < count; n++) { string name = input.ReadStringA16(); if (_geometryDictionary.Contains(name)) { FDrGeometry geometry = _geometryDictionary.Get(name); if (!geometry.DataUnserialize(input)) { return(false); } } else { FDrGeometry geometry = new FDrGeometry(_model); if (!geometry.DataUnserialize(input)) { return(false); } RMoCore.TrackConsole.Write(this, "DataUnserialize", "Can't find geometry config in model. (model={0}, geometry={1})", _model.Code, name); } } return(true); }
//============================================================ // <T>加载配置信息。</T> // // @param xconfig 配置信息 //============================================================ public void LoadModelConfig(FXmlNode xconfig) { foreach (FXmlNode xnode in xconfig.Nodes) { if (xnode.IsName("Geometry")) { string geometryName = xnode.Get("name"); // 查找几何体 FDrGeometry geometry = _geometryDictionary.Find(geometryName); if (geometry == null) { RMoCore.TrackConsole.Write(this, "LoadConfig", "Geomery is not exists in model. (model={0}, geometry={1}", _model.Name, geometryName); // 加载模型信息 geometry = new FDrGeometry(_model); geometry.LoadModelConfig(xnode); _geometryDictionary.Set(geometryName, geometry); } else { // 加载模型信息 geometry.LoadModelConfig(xnode); } } } }
//============================================================ // <T>加载配置信息。</T> // // @param xconfig 配置信息 //============================================================ public void LoadConfig(FXmlNode xconfig) { // 读取列表 foreach (FXmlNode xnode in xconfig.Nodes) { if (xnode.IsName("Geometry")) { // 获得有效性 bool valid = false; if (xnode.Contains("valid")) { valid = xnode.GetBoolean("valid"); } else { valid = xnode.GetBoolean("is_valid"); } // 读取属性 if (valid) { // 检查存在性 string geometryName = xnode.Get("name"); if (_geometryDictionary.Contains(geometryName)) { RMoCore.TrackConsole.Write(this, "LoadConfig", "Model geometry name is already exists. (model={0}, geometry={1})", _model.Name, geometryName); } // 创建几何体 FDrGeometry geometry = new FDrGeometry(_model); geometry.LoadConfig(xnode); geometry.Index = _geometryDictionary.Count; _geometryDictionary.Set(geometryName, geometry); } } } }
//============================================================ public void Export3d(FDrGeometry geometry, string filename) { string directory = geometry.Model.Directory; Bitmap low = new Bitmap(directory + "/ms_001.low.png"); Bitmap high = new Bitmap(directory + "/ms_001.high.png"); // 创建设备 Bitmap normal = new Bitmap(1024, 1024, PixelFormat.Format32bppArgb); for (int y = 0; y < 1024; y++) { for (int x = 0; x < 1024; x++) { Color lc = low.GetPixel(x, y); Color hc = high.GetPixel(x, y); SFloatVector3 n = new SFloatVector3(); n.X = (float)(hc.R - lc.R) / 128; n.Y = (float)(hc.G - lc.G) / 128; n.Z = (float)(hc.B - lc.B) / 256; //n.Normalize(); int r = (int)((n.X * 0.5 + 0.5) * 255); r = Math.Max(Math.Min(r, 255), 0); int g = (int)((n.Y * 0.5 + 0.5) * 255); g = Math.Max(Math.Min(g, 255), 0); int b = (int)(((1 - n.Z) * 0.5 + 0.5) * 255); b = Math.Max(Math.Min(b, 255), 0); normal.SetPixel(x, y, Color.FromArgb(r, g, b)); } } normal.Save(directory + "/ms_001.normal.png"); //QNormalMapForm form = new QNormalMapForm(); //form.geometry = geometry; //Application.Run(form); }
//============================================================ public void Export3d2(FDrGeometry geometry, string filename) { SIntSize size = new SIntSize(1024, 1024); Form form = new Form(); FDxDevice3D device = RDxCore.Adapter.CreateDevice(form.Handle, size.Width, size.Height); device.ModeWireFrame = false; // 设置几何体 FDxRegion region = new FDxRegion(); FDsNormalGeometry normalGeometry = new FDsNormalGeometry(); normalGeometry.Device = device; normalGeometry.LoadResource(geometry); region.Renderables.Push(normalGeometry); // 设置目标 FDxBufferedTexture texture = new FDxBufferedTexture(); texture.Device = device; texture.Create(size.Width, size.Height); device.SetRenderTarget(texture); // 绘制结果 FDxTechnique technique = RDxCore.TechniqueConsole.Get(device, "normal.map"); technique.Draw(region); // 保存内容 texture.SaveFile(filename); // 创建设备 // QNormalMapForm form = new QNormalMapForm(); // form.geometry = geometry; // Application.Run(form); }
//============================================================ // <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> //============================================================ 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 SerializeBoneWeight(FDrGeometry submesh, IOutput output) { int count = _weights.Count; for (int n = 0; n < _maxWeightCount; n++) { float value = 0; if (n < count) { value = _weights[n].Weight; } output.WriteUint8((byte)(value * 255)); //output.WriteFloat(value); } }
//============================================================ public void SerializeBoneIndex(FDrGeometry submesh, IOutput output) { int count = _weights.Count; for (int n = 0; n < _maxWeightCount; n++) { int value = 0; if (n < count) { value = submesh.FindAdjustBoneIndex(_weights[n].BoneId); } //output.WriteFloat(value); output.WriteUint8((byte)value); } }
//============================================================ public void LoadResource(FDrGeometry geometry) { // 创建数据 int faceCount = geometry.FaceList.Count; FByteStream vertexs = new FByteStream(4 * 10 * 3 * faceCount); FByteStream faces = new FByteStream(3 * faceCount); for (int f = 0; f < faceCount; f++) { FDrFace face = geometry.FaceList[f]; for (int n = 0; n < 3; n++) { // 输出顶点数据 FDrVertex vertex = geometry.VertexList[face.VertexIndex[n]]; FDrCoord coord = geometry.CoordList[face.CoordIndex[n]]; float coordX = coord.Coord.X; float coordY = coord.Coord.Y + 1.0f; if (geometry.Channels.Count > 1) { FDrChannelFace channelFace = geometry.Channels[2].Indexs[face.Index]; SFloatPoint3 channelPoint = channelFace.Points[n]; coordX = channelPoint.X; coordY = channelPoint.Y; } FDrColor color = geometry.ColorList[face.ColorIndex[n]]; vertexs.WriteFloat(vertex.Position.X); vertexs.WriteFloat(vertex.Position.Y); vertexs.WriteFloat(vertex.Position.Z); vertexs.WriteFloat(1.0f); vertexs.WriteFloat(coordX); vertexs.WriteFloat(coordY); vertexs.WriteFloat(color.Color.R); vertexs.WriteFloat(color.Color.G); vertexs.WriteFloat(color.Color.B); vertexs.WriteFloat(1.0f); // 输出索引数据 faces.WriteInt32(3 * f + n); } } // 创建顶点流 _vertexBuffer = new FDxVertexBuffer(); _vertexBuffer.Device = _device; _vertexBuffer.UploadNormal(10, vertexs.Memory, 0, vertexs.Length); // 创建索引流 _faceBuffer = new FDxFaceBuffer(); _faceBuffer.Device = _device; _faceBuffer.Upload32(faces.Memory, 0, faces.Length); }
//============================================================ // <T>加载几何体信息。</T> // // @prama geometry 几何体 //============================================================ public void LoadGeometry(FDrGeometry geometry) { _geometry = geometry; // 设置属性 txtGeometryName.Text = _geometry.Name; txtMaterialName.Text = _geometry.MaterialName; // 设置选项 qdrOptionInstanced.DataValue = _geometry.OptionInstanced; qdrOptionDynamic.DataValue = _geometry.OptionDynamic; qdrOptionBoneScale.DataValue = _geometry.OptionBoneScale; qdrOptionShadow.DataValue = _geometry.OptionShadow; qdrOptionSelfShadow.DataValue = _geometry.OptionSelfShadow; qdrOptionNormal.DataValue = _geometry.OptionNormalFull; qdrOptionDouble.DataValue = _geometry.OptionDouble; qdrOptionSymmetry.DataValue = _geometry.OptionSymmetry; qdrOptionTransmittance.DataValue = _geometry.OptionTransmittance; qdrOptionSelect.DataValue = _geometry.OptionSelect; qdrOptionGround.DataValue = _geometry.OptionGround; }
//============================================================ public void LoadResource(FDrGeometry geometry) { // 创建数据 int faceCount = geometry.FaceList.Count; FByteStream vertexs = new FByteStream(4 * 10 * 3 * faceCount); FByteStream faces = new FByteStream(3 * faceCount); for (int f = 0; f < faceCount; f++) { FDrFace face = geometry.FaceList[f]; for (int n = 0; n < 3; n++) { // 输出顶点数据 FDrVertex vertex = geometry.VertexList[face.VertexIndex[n]]; FDrCoord coord = geometry.CoordList[face.CoordIndex[n]]; FDrNormal normal = geometry.NormalList[face.NormalIndex[n]]; vertexs.WriteFloat(vertex.Position.X); vertexs.WriteFloat(vertex.Position.Y); vertexs.WriteFloat(vertex.Position.Z); vertexs.WriteFloat(1.0f); vertexs.WriteFloat(coord.Coord.X); vertexs.WriteFloat(coord.Coord.Y + 1); vertexs.WriteFloat(normal.Direction.X); vertexs.WriteFloat(normal.Direction.Y); vertexs.WriteFloat(normal.Direction.Z); vertexs.WriteFloat(1.0f); // 输出索引数据 faces.WriteInt32(3 * f + n); } } // 创建顶点流 _vertexBuffer = new FDxVertexBuffer(); _vertexBuffer.Device = _device; _vertexBuffer.UploadNormal(10, vertexs.Memory, 0, vertexs.Length); // 创建索引流 _faceBuffer = new FDxFaceBuffer(); _faceBuffer.Device = _device; _faceBuffer.Upload32(faces.Memory, 0, faces.Length); }
//============================================================ // <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); } } }
//============================================================ public void Serialize(FDrGeometry submesh, int flags, IOutput output) { // 输出顶点 if (0 != (EDrVertex.Position & flags)) { _position.Serialize(output); } // 输出颜色 if (0 != (EDrVertex.Color & flags)) { _color.SerializeByteUnsigned4(output); } // 输出坐标 if (0 != (EDrVertex.Coord & flags)) { output.WriteFloat(_coord.X); output.WriteFloat(1 + _coord.Y); if (0 != (EDrVertex.CoordLight & flags)) { output.WriteFloat(_lightCoord.X); output.WriteFloat(_lightCoord.Y); } } // 输出法线,副法线,切线 if (0 != (EDrVertex.Normal & flags)) { _normal.SerializeByteSigned3(output); output.WriteUint8(1); //output.WriteUint8((byte)Illum); } if (0 != (EDrVertex.Binormal & flags)) { _binormal.SerializeByteSigned3(output); output.WriteUint8(1); } if (0 != (EDrVertex.Tangent & flags)) { _tangent.SerializeByteSigned3(output); output.WriteUint8(1); } // 使用两条管道,每条管道4个数据,前管道为索引内容,后管道为权重 int count = _weights.Count; if (0 != (EDrVertex.BoneIndex & flags)) { for (int n = 0; n < _maxWeightCount; n++) { int value = 0; if (n < count) { value = submesh.FindAdjustBoneIndex(_weights[n].BoneId); } output.WriteUint8((byte)value); } } if (0 != (EDrVertex.BoneWeight & flags)) { for (int n = 0; n < _maxWeightCount; n++) { float value = 0; if (n < count) { value = _weights[n].Weight; } output.WriteUint8((byte)(value * 255)); } } }
//============================================================ // <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); }
//============================================================ public void DataUnserialize(FDrGeometry geometry, IInput input) { // 读取面信息 _faceIndex = input.ReadInt32(); _flags = input.ReadInt32(); _materialId = input.ReadInt32(); _smoothGroup = input.ReadInt32(); // 读取顶点索引 if (!geometry.VertexList.IsEmpty) { _vertexIndex.Unserialize(input); } // 读取颜色索引 if (!geometry.ColorList.IsEmpty) { _colorIndex.Unserialize(input); } // 读取透明索引 if (!geometry.AlphaList.IsEmpty) { _alphaIndex.Unserialize(input); } // 读取纹理索引 if (!geometry.CoordList.IsEmpty) { _coordIndex.Unserialize(input); geometry.VertexList[_vertexIndex.V1].CoordIds.Push(_coordIndex.V1); geometry.VertexList[_vertexIndex.V2].CoordIds.Push(_coordIndex.V2); geometry.VertexList[_vertexIndex.V3].CoordIds.Push(_coordIndex.V3); geometry.VertexList[_vertexIndex.V1].CoordUids.PushUnique(_coordIndex.V1); geometry.VertexList[_vertexIndex.V2].CoordUids.PushUnique(_coordIndex.V2); geometry.VertexList[_vertexIndex.V3].CoordUids.PushUnique(_coordIndex.V3); } // 读取法线索引 if (!geometry.NormalList.IsEmpty) { _normalIndex.Unserialize(input); geometry.VertexList[_vertexIndex.V1].NormalIds.Push(_normalIndex.V1); geometry.VertexList[_vertexIndex.V2].NormalIds.Push(_normalIndex.V2); geometry.VertexList[_vertexIndex.V3].NormalIds.Push(_normalIndex.V3); geometry.VertexList[_vertexIndex.V1].NormalUids.PushUnique(_normalIndex.V1); geometry.VertexList[_vertexIndex.V2].NormalUids.PushUnique(_normalIndex.V2); geometry.VertexList[_vertexIndex.V3].NormalUids.PushUnique(_normalIndex.V3); } // 读取切线副法线索引 if (!geometry.TangentList.IsEmpty) { _tangentBinormalIndex.Unserialize(input); geometry.VertexList[_vertexIndex.V1].BinormalTangentIds.Push(_tangentBinormalIndex.V1); geometry.VertexList[_vertexIndex.V2].BinormalTangentIds.Push(_tangentBinormalIndex.V2); geometry.VertexList[_vertexIndex.V3].BinormalTangentIds.Push(_tangentBinormalIndex.V3); geometry.VertexList[_vertexIndex.V1].BinormalTangentUids.PushUnique(_tangentBinormalIndex.V1); geometry.VertexList[_vertexIndex.V2].BinormalTangentUids.PushUnique(_tangentBinormalIndex.V2); geometry.VertexList[_vertexIndex.V3].BinormalTangentUids.PushUnique(_tangentBinormalIndex.V3); } // 读取照明索引 if (!geometry.IllumList.IsEmpty) { _illumIndex.Unserialize(input); } // 读取可见性 _visibleIndex.Unserialize(input); }