private void ReplaceAllBonesFromFile() { var boneCount = _bones.Count; using (FileDialog dialog = new OpenFileDialog()) { dialog.InitialDirectory = PathC.GetDirectoryNameTry(_tool.DestinationWad.FileName); dialog.FileName = PathC.GetFileNameTry(_tool.DestinationWad.FileName); dialog.Filter = BaseGeometryImporter.FileExtensions.GetFilter(); dialog.Title = "Select a 3D file that you want to see imported."; if (dialog.ShowDialog(this) != DialogResult.OK) { return; } using (var form = new GeometryIOSettingsDialog(new IOGeometrySettings())) { form.AddPreset(IOSettingsPresets.GeometryImportSettingsPresets); if (form.ShowDialog(this) != DialogResult.OK) { return; } var meshes = WadMesh.ImportFromExternalModel(dialog.FileName, form.Settings, false); if (meshes == null || meshes.Count == 0) { ImportFailed(); return; } int meshCount; if (meshes.Count > _bones.Count) { meshCount = _bones.Count; popup.ShowError(panelRendering, "Mesh count is higher in imported model. Only first " + _bones.Count + " will be imported."); } else if (meshes.Count < _bones.Count) { meshCount = meshes.Count; popup.ShowError(panelRendering, "Mesh count is lower in imported model. Only meshes up to " + meshes.Count + " will be replaced."); } else { meshCount = _bones.Count; } for (int i = 0; i < meshCount; i++) { ReplaceExistingBone(meshes[i], _bones[i]); } } } }
private void butImportMeshFromFile_Click(object sender, EventArgs e) { using (FileDialog dialog = new OpenFileDialog()) { dialog.InitialDirectory = PathC.GetDirectoryNameTry(_tool.DestinationWad.FileName); dialog.FileName = PathC.GetFileNameTry(_tool.DestinationWad.FileName); dialog.Filter = BaseGeometryImporter.FileExtensions.GetFilter(); dialog.Title = "Select a 3D file that you want to see imported."; if (dialog.ShowDialog(this) != DialogResult.OK) { return; } using (var form = new GeometryIOSettingsDialog(new IOGeometrySettings())) { form.AddPreset(IOSettingsPresets.GeometryImportSettingsPresets); if (form.ShowDialog(this) != DialogResult.OK) { return; } var mesh = WadMesh.ImportFromExternalModel(dialog.FileName, form.Settings); if (mesh == null) { DarkMessageBox.Show(this, "Error while loading 3D model. Check that the file format \n" + "is supported, meshes are textured and texture file is present.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _workingStatic.Mesh = mesh; _workingStatic.VisibilityBox = _workingStatic.Mesh.CalculateBoundingBox(panelRendering.GizmoTransform); _workingStatic.CollisionBox = _workingStatic.Mesh.CalculateBoundingBox(panelRendering.GizmoTransform); _workingStatic.Version = DataVersion.GetNext(); _workingStatic.Mesh.CalculateNormals(); panelRendering.Invalidate(); UpdatePositionUI(); UpdateCollisionBoxUI(); UpdateVisibilityBoxUI(); UpdateLightUI(); } } }
private void AddChildBoneFromFile() { if (treeSkeleton.SelectedNodes.Count == 0) { return; } var theNode = (WadMeshBoneNode)treeSkeleton.SelectedNodes[0].Tag; using (FileDialog dialog = new OpenFileDialog()) { dialog.InitialDirectory = PathC.GetDirectoryNameTry(_tool.DestinationWad.FileName); dialog.FileName = PathC.GetFileNameTry(_tool.DestinationWad.FileName); dialog.Filter = BaseGeometryImporter.FileExtensions.GetFilter(); dialog.Title = "Select a 3D file that you want to see imported."; if (dialog.ShowDialog(this) != DialogResult.OK) { return; } using (var form = new GeometryIOSettingsDialog(new IOGeometrySettings())) { form.AddPreset(IOSettingsPresets.GeometryImportSettingsPresets); if (form.ShowDialog(this) != DialogResult.OK) { return; } var mesh = WadMesh.ImportFromExternalModel(dialog.FileName, form.Settings); if (mesh == null) { ImportFailed(); return; } InsertNewBone(mesh, theNode); } } }