/* * Chunk data structure: * [chunk=(x,y,z)] * [vrts] * [cols] * [tris] */ public VoxChunk(string[] data) { Debug.Log("Parsing chunk data: \n" + data.to_line_string() + "\ntest test"); List <Vector3> verts = new List <Vector3>(); List <Color> cols = new List <Color>(); List <int> tris = new List <int>(); ModelSection model_section = ModelSection.VERTS; string[] chunkPos = data[0].Split('=')[1].Split(')')[0].Split('(')[1].Split(','); Position = new Vector3(float.Parse(chunkPos[0]), float.Parse(chunkPos[1]), float.Parse(chunkPos[2])); for (int i = 1; i < data.Length; i++) { string line = data[i].Trim(); if (line == "[vrts]") { model_section = ModelSection.VERTS; } else if (line == "[cols]") { model_section = ModelSection.COLS; } else if (line == "[tris]") { model_section = ModelSection.TRIS; } else { switch (model_section) { case ModelSection.VERTS: string[] axes = line.Split(' '); verts.Add(new Vector3(float.Parse(axes[0]), float.Parse(axes[1]), float.Parse(axes[2]))); break; case ModelSection.COLS: cols.Add(line.to_color()); break; case ModelSection.TRIS: tris.Add(int.Parse(line)); break; } } } Vertices = verts.ToArray(); Colors = cols.ToArray(); Triangles = tris.ToArray(); DebugConsole.Log(string.Format("Created chunk with {0} vertices, {1} colors, and {2} triangles.", Vertices.Length, Colors.Length, Triangles.Length / 3), true); }
public frmAddSection(ModelSection modelSection) { InitializeComponent(); _modelSection = modelSection; txtName.Text = _modelSection.Name; txtCode.Text = _modelSection.Code; }
internal G1MGMesh(Span <byte> data, ModelSection section) { Section = section; var offset = 0; for (var i = 0; i < section.Count; ++i) { var group = MemoryMarshal.Read <ModelGeometryMeshGroup>(data.Slice(offset)); offset += SizeHelper.SizeOf <ModelGeometryMeshGroup>(); var meshes = new List <(string, ModelGeometryMesh, int[])>(); for (var j = 0; j < group.SubMeshCount + group.UnknownCount; ++j) { var name = data.Slice(offset, 0x10).ReadStringNonNull(); offset += 0x10; var mesh = MemoryMarshal.Read <ModelGeometryMesh>(data.Slice(offset)); offset += SizeHelper.SizeOf <ModelGeometryMesh>(); Logger.Assert(mesh.IndexCount > 0, "mesh.IndexCount > 0"); var indices = MemoryMarshal.Cast <byte, int>(data.Slice(offset, mesh.IndexCount * 4)).ToArray(); offset += mesh.IndexCount * 4; meshes.Add((name, mesh, indices)); } Meshes.Add((group, meshes)); } }
/// <summary> /// Creates a new MSB3 with all sections empty. /// </summary> public MSB3() { Models = new ModelSection(); Events = new EventSection(); Regions = new PointSection(); Routes = new RouteSection(); Layers = new LayerSection(); Parts = new PartsSection(); PartsPoses = new PartsPoseSection(); BoneNames = new BoneNameSection(); }
private void EditCompany(DataGridView gridToEdit) { ModelSection sectionForEdit = new ModelSection(); sectionForEdit.Id = Convert.ToInt32(gridToEdit.SelectedRows[0].Cells[0].Value); sectionForEdit.Name = (gridToEdit.SelectedRows[0].Cells[1].Value).ToString(); sectionForEdit.Code = (gridToEdit.SelectedRows[0].Cells[2].Value).ToString(); frmAddSection addSection = new frmAddSection(sectionForEdit); addSection.ShowDialog(); RefreshGrids(); }
internal G1MGBone(Span <byte> data, ModelSection section) { Section = section; var offset = 0; for (var i = 0; i < section.Count; ++i) { var count = MemoryMarshal.Read <int>(data.Slice(offset)); offset += 4; Bones.Add(MemoryMarshal.Cast <byte, ModelGeometryBone>(data.Slice(offset, count * SizeHelper.SizeOf <ModelGeometryBone>())).ToArray()); offset += count * SizeHelper.SizeOf <ModelGeometryBone>(); } }
private void SetDirectorForSection(DataGridView dgw) { frmEmployee employee = new frmEmployee(); if (employee.ShowDialog() == DialogResult.OK) { _sectionDirectorId = employee.DirectorId; } ModelSection section = new ModelSection(); section.DirectorId = _sectionDirectorId; section.Id = Convert.ToInt32(dgw.SelectedRows[0].Cells[0].Value); _sectionManagerViewModel.SetSectionDirector(section); }
internal G1MGMaterial(Span <byte> data, ModelSection sectionInfo) { Section = sectionInfo; var offset = 0; for (var i = 0; i < sectionInfo.Count; ++i) { var material = MemoryMarshal.Read <ModelGeometryMaterial>(data.Slice(offset)); offset += SizeHelper.SizeOf <ModelGeometryMaterial>(); var bufferSize = SizeHelper.SizeOf <ModelGeometryTextureSet>() * material.Count; var textureSet = MemoryMarshal.Cast <byte, ModelGeometryTextureSet>(data.Slice(offset, bufferSize)).ToArray(); offset += bufferSize; Materials.Add((material, textureSet)); } }
internal G1MGVertexBuffer(Span <byte> block, ModelSection subSectionHeader) { Section = subSectionHeader; var offset = 0; for (var i = 0; i < subSectionHeader.Count; ++i) { var info = MemoryMarshal.Read <ModelGeometryVertexBuffer>(block.Slice(offset)); offset += SizeHelper.SizeOf <ModelGeometryVertexBuffer>(); var memory = new Memory <byte>(block.Slice(offset, info.Stride * info.Count).ToArray()); offset += memory.Length; Buffers.Add((info, memory)); } }
public bool UpdateDirectorIdOfSection(ModelSection modelSection) { bool success = false; Execute((command) => { command.CommandText = "Update section SET DirectorId=@idDirector where id=@idSection"; command.Parameters.Add("@idDirector", SqlDbType.Int).Value = modelSection.DirectorId; command.Parameters.Add("@idSection", SqlDbType.Int).Value = modelSection.Id; if (command.ExecuteNonQuery() > 0) { success = true; } }); return(success); }
public bool UpdateSection(ModelSection modelSection) { bool success = false; Execute((command) => { command.CommandText = "Update section set name = @name, code = @code where id=@id"; command.Parameters.Add("@id", SqlDbType.Int).Value = modelSection.Id; command.Parameters.Add("@name", SqlDbType.VarChar).Value = modelSection.Name; command.Parameters.Add("@code", SqlDbType.VarChar).Value = modelSection.Code; if (command.ExecuteNonQuery() > 0) { success = true; } }); return(success); }
internal G1MGVertexAttribute(Span <byte> data, ModelSection section) { Section = section; var offset = 0; for (var i = 0; i < section.Count; ++i) { var count = MemoryMarshal.Read <int>(data.Slice(offset)); offset += 4; var index = MemoryMarshal.Cast <byte, int>(data.Slice(offset, count * 4)).ToArray(); offset += count * 4; count = MemoryMarshal.Read <int>(data.Slice(offset)); offset += 4; var attributes = MemoryMarshal.Cast <byte, ModelGeometryAttribute>(data.Slice(offset, count * SizeHelper.SizeOf <ModelGeometryAttribute>())).ToArray(); offset += count * SizeHelper.SizeOf <ModelGeometryAttribute>(); Attributes.Add((index, attributes)); } }
internal G1MGShaderParam(Span <byte> data, ModelSection sectionHeader) { Section = sectionHeader; var offset = 0; for (var i = 0; i < sectionHeader.Count; ++i) { var count = MemoryMarshal.Read <int>(data.Slice(offset)); offset += sizeof(int); var @params = new List <(ModelGeometryShaderParam, string, Array?)>(); for (var j = 0; j < count; ++j) { var blockHeader = MemoryMarshal.Read <ModelGeometryShaderParam>(data.Slice(offset)); var localOffset = SizeHelper.SizeOf <ModelGeometryShaderParam>(); var name = string.Empty; try { var block = data.Slice(offset + localOffset, blockHeader.Size - localOffset); name = block.ReadStringNonNull(); localOffset = (name.Length + 1).Align(4); var paramsBlock = block.Slice(localOffset); var paramData = blockHeader.Type switch { ShaderType.Float32 => MemoryMarshal.Cast <byte, float>(paramsBlock).ToArray(), ShaderType.Matrix4X4X2 => (Array)MemoryMarshal.Cast <byte, Matrix4x4>(paramsBlock).ToArray(), _ => throw new NotSupportedException($"Can't handle ShaderParam {blockHeader.Type:G}") }; @params.Add((blockHeader, name, paramData)); } catch (Exception e) { Logger.Error("G1MG_SHADER", e); @params.Add((blockHeader, name, null)); } finally { offset += blockHeader.Size; } } ParamGroups.Add(@params); } }
public ModelSection SelectSectionById(int sectionId) { ModelSection selectedSection = new ModelSection(); Execute((command) => { command.CommandText = "select name, code from section where id=@idSection"; command.Parameters.Add("@idSection", SqlDbType.Int).Value = selectedSection.Id; using (SqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { selectedSection.Name = reader.GetString(0); selectedSection.Code = reader.GetString(1); } } }); return(selectedSection); }
public bool InsertSection(ModelSection modelSection) { bool success = false; Execute((command) => { command.CommandText = @"Insert into section ([Name], [Code], [HierarchyLevel], [ParentSectionID]) Values(@Name, @Code, @Hierarchy, @Parent)"; command.Parameters.Add("@Name", SqlDbType.VarChar).Value = modelSection.Name; command.Parameters.Add("@Code", SqlDbType.VarChar).Value = modelSection.Code; command.Parameters.Add("@Hierarchy", SqlDbType.Int).Value = modelSection.HierarchyLevel; command.Parameters.Add("@Parent", SqlDbType.Int).Value = (object)modelSection.ParentSectionId ?? DBNull.Value; if (command.ExecuteNonQuery() > 0) { success = true; } }); return(success); }
private void btnConfirm_Click(object sender, EventArgs e) { if (MustBeFilled()) { if (_modelSection == null) { ModelSection section = new ModelSection(); section.HierarchyLevel = _level; section.ParentSectionId = _parentId; section.Name = txtName.Text; section.Code = txtCode.Text; _addSectionViewModel.AddSection(section); } else { _modelSection.Name = txtName.Text; _modelSection.Code = txtCode.Text; _addSectionViewModel.UpdateSection(_modelSection); } Close(); } }
internal G1MGIndexBuffer(Span <byte> block, ModelSection subSectionHeader) { Section = subSectionHeader; var offset = 0; for (var i = 0; i < subSectionHeader.Count; ++i) { var info = MemoryMarshal.Read <ModelGeometryIndexBuffer>(block.Slice(offset)); offset += SizeHelper.SizeOf <ModelGeometryIndexBuffer>(); var buffer = info.Width switch { 16 => MemoryMarshal.Cast <byte, ushort>(block.Slice(offset, info.Count * 2)).ToArray(), _ => null }; offset += info.Count * (info.Width / 8); offset = offset.Align(4); if (buffer == null) { continue; } Buffers.Add((info, buffer)); } }
internal override void Read(BinaryReaderEx br) { br.BigEndian = false; br.AssertASCII("MSB "); br.AssertInt32(1); // Header size/data start br.AssertInt32(0x10); // Probably bytes, just guessing br.AssertByte(0); br.AssertByte(0); br.AssertByte(1); br.AssertByte(0xFF); Entries entries = default; long nextSectionOffset = br.Position; while (nextSectionOffset != 0) { br.Position = nextSectionOffset; int unk1 = br.ReadInt32(); int offsets = br.ReadInt32() - 1; long typeOffset = br.ReadInt64(); string type = br.GetUTF16(typeOffset); switch (type) { case "MODEL_PARAM_ST": Models = new ModelSection(br, unk1); entries.Models = Models.Read(br, offsets); break; case "EVENT_PARAM_ST": Events = new EventSection(br, unk1); entries.Events = Events.Read(br, offsets); break; case "POINT_PARAM_ST": Regions = new PointSection(br, unk1); entries.Regions = Regions.Read(br, offsets); break; case "ROUTE_PARAM_ST": Routes = new RouteSection(br, unk1); entries.Routes = Routes.Read(br, offsets); break; case "LAYER_PARAM_ST": Layers = new LayerSection(br, unk1); entries.Layers = Layers.Read(br, offsets); break; case "PARTS_PARAM_ST": Parts = new PartsSection(br, unk1); entries.Parts = Parts.Read(br, offsets); break; case "MAPSTUDIO_PARTS_POSE_ST": PartsPoses = new PartsPoseSection(br, unk1, offsets); break; case "MAPSTUDIO_BONE_NAME_STRING": BoneNames = new BoneNameSection(br, unk1); entries.BoneNames = BoneNames.Read(br, offsets); break; default: throw new NotImplementedException($"Unimplemented section: {type}"); } nextSectionOffset = br.ReadInt64(); } DisambiguateNames(entries.Events); DisambiguateNames(entries.Models); DisambiguateNames(entries.Parts); DisambiguateNames(entries.Regions); Events.GetNames(this, entries); Parts.GetNames(this, entries); Regions.GetNames(this, entries); }
public bool SetSectionDirector(ModelSection modelSection) { return(_logic.UpdateDirectorIdOfSection(modelSection)); }
/// <summary> /// Deserializes file data from a stream. /// </summary> protected override void Read(BinaryReaderEx br) { br.BigEndian = false; Entries entries = default; int nextSectionOffset = (int)br.Position; do { br.Position = nextSectionOffset; int unk1 = br.ReadInt32(); int typeOffset = br.ReadInt32(); int offsets = br.ReadInt32() - 1; string type = br.GetASCII(typeOffset); switch (type) { case "MODEL_PARAM_ST": Models = new ModelSection(br, unk1); entries.Models = Models.Read(br, offsets); break; //case "EVENT_PARAM_ST": // Events = new EventSection(br, unk1); // entries.Events = Events.Read(br, offsets); // break; //case "POINT_PARAM_ST": // Regions = new PointSection(br, unk1); // entries.Regions = Regions.Read(br, offsets); // break; case "PARTS_PARAM_ST": Parts = new PartsSection(br, unk1); entries.Parts = Parts.Read(br, offsets); break; //case "MAPSTUDIO_TREE_ST": // Trees = new TreeSection(br, unk1); // entries.Trees = Trees.Read(br, offsets); // break; default: //throw new NotImplementedException($"Unimplemented section: {type}"); br.Skip(offsets * 4); break; } nextSectionOffset = br.ReadInt32(); } while (nextSectionOffset != 0); //DisambiguateNames(entries.Events); MSB.DisambiguateNames(entries.Models); MSB.DisambiguateNames(entries.Parts); //DisambiguateNames(entries.Regions); //Events.GetNames(this, entries); Parts.GetNames(this, entries); //Regions.GetNames(this, entries); }
public bool InsertSection(ModelSection modelSection) { return(RepositoryManager.SectionRepository.InsertSection(modelSection)); }
internal G1MGSubMesh(Span <byte> data, ModelSection section) { Section = section; SubMeshes = MemoryMarshal.Cast <byte, ModelGeometrySubMesh>(data).ToArray(); }
internal G1MGSocket(Span <byte> data, ModelSection sectionInfo) { Section = sectionInfo; Sockets = MemoryMarshal.Cast <byte, ModelGeometrySocket>(data).ToArray(); }
public bool UpdateSection(ModelSection modelSection) { return(_logic.UpdateSection(modelSection)); }
public bool UpdateSection(ModelSection modelSection) { return(RepositoryManager.SectionRepository.UpdateSection(modelSection)); }
public bool AddSection(ModelSection modelSection) { return(_logic.InsertSection(modelSection)); }