Skip to content
This repository was archived by the owner on Feb 11, 2024. It is now read-only.

Quake1 Map Importer #167

Merged
merged 3 commits into from
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 16 additions & 36 deletions Gizmos/ButtonCapsule.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Gizmos/ImporterQuake1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions Gizmos/ImporterQuake1.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 34 additions & 1 deletion Scripts/Editor/Inspectors/CSGModelInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public override void OnInspectorGUI()
EditorGUILayout.Space();
//

GuiLayoutBeginImporterSection(SabreCSGResources.ImporterImporterValveMapFormat2006Texture, "Source Engine 2006 Importer", "Henry de Jongh");
GuiLayoutBeginImporterSection(SabreCSGResources.ImporterValveMapFormat2006Texture, "Source Engine 2006 Importer", "Henry de Jongh");

EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("Import Source Engine Map (*.vmf)"))
Expand Down Expand Up @@ -254,7 +254,40 @@ public override void OnInspectorGUI()
EditorUtility.DisplayDialog("Source Engine 2006 Importer", "This importer was created using Source SDK maps and Hammer 4.1.\n\nImportant Notes:\n* It will try to find the materials in your project automatically. First it looks for the full name with forward slashes '/' replaced by periods '.' like 'BRICK.BRICKFLOOR001A' then the last word 'BRICKFLOOR001A'. The latter option could cause some false positives, try creating a material with the full name if this happens.", "Okay");
}
EditorGUILayout.EndHorizontal();
GuiLayoutEndImporterSection();

//
EditorGUILayout.Space();
//

GuiLayoutBeginImporterSection(SabreCSGResources.ImporterQuake1Texture, "Quake 1 Importer", "Jasmine Mickle");

EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("Import Quake 1 Map (*.map)"))
{
try
{
string path = EditorUtility.OpenFilePanel("Import Quake 1 Map", "", "map");
if (path.Length != 0)
{
EditorUtility.DisplayProgressBar("SabreCSG: Importing Quake 1 Map", "Parsing Quake 1 Map File (*.map)...", 0.0f);
var importer = new Importers.Quake1.MapImporter();
var map = importer.Import(path);
Importers.Quake1.MapWorldConverter.Import(csgModel, map);
}
}
catch (Exception ex)
{
EditorUtility.ClearProgressBar();
EditorUtility.DisplayDialog("Quake 1 Map Import", "An exception occurred while importing the map:\r\n" + ex.Message, "Ohno!");
}
}

if (GUILayout.Button("?", GUILayout.Width(16)))
{
EditorUtility.DisplayDialog("Quake 1 Importer", "This importer (parser by Henry de Jongh) was created using Trenchbroom 2.0.6.\n\nImportant Notes:\n* It will try to find the materials in your project automatically. It will replace any leading '*' with '#' like '#teleport'.\n\nKnown Issues:\n* 45 degree angled walls may not have correct UV texture coordinates (are not correctly picking the dominant axis because there are two).\n* Negative vertex coordinates may not have correct UV texture coordinates (feel free to contribute improved UV mapping code if you know how it works, we had to guess most of the maths).", "Okay");
}
EditorGUILayout.EndHorizontal();
GuiLayoutEndImporterSection();
}

Expand Down
10 changes: 10 additions & 0 deletions Scripts/Importers/Quake1.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions Scripts/Importers/Quake1/MapBrush.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#if UNITY_EDITOR || RUNTIME_CSG

using System.Collections.Generic;

namespace Sabresaurus.SabreCSG.Importers.Quake1
{
/// <summary>
/// Represents a Quake 1 Brush.
/// </summary>
public class MapBrush
{
/// <summary>
/// The sides of the brush.
/// </summary>
public List<MapBrushSide> Sides = new List<MapBrushSide>();

/// <summary>
/// Returns a <see cref="System.String"/> that represents this instance.
/// </summary>
/// <returns>A <see cref="System.String"/> that represents this instance.</returns>
public override string ToString()
{
return "Quake 1 Brush " + " (" + Sides.Count + " Sides)";
}
}
}

#endif
13 changes: 13 additions & 0 deletions Scripts/Importers/Quake1/MapBrush.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions Scripts/Importers/Quake1/MapBrushSide.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#if UNITY_EDITOR || RUNTIME_CSG

namespace Sabresaurus.SabreCSG.Importers.Quake1
{
/// <summary>
/// Represents a Quake 1 Brush Side.
/// </summary>
public class MapBrushSide
{
public MapPlane Plane;
public string Material;
public MapVector2 Offset;
public float Rotation;
public MapVector2 Scale;

/// <summary>
/// Returns a <see cref="System.String"/> that represents this instance.
/// </summary>
/// <returns>A <see cref="System.String"/> that represents this instance.</returns>
public override string ToString()
{
return "Quake 1 Brush Side " + " '" + Material + "' " + " " + Plane;
}
}
}

#endif
13 changes: 13 additions & 0 deletions Scripts/Importers/Quake1/MapBrushSide.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions Scripts/Importers/Quake1/MapEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#if UNITY_EDITOR || RUNTIME_CSG

using System.Collections.Generic;

namespace Sabresaurus.SabreCSG.Importers.Quake1
{
/// <summary>
/// Represents a Quake 1 Entity.
/// </summary>
public class MapEntity
{
/// <summary>
/// The class name of the entity.
/// </summary>
public string ClassName;

/// <summary>
/// The brushes in the entity if available.
/// </summary>
public List<MapBrush> Brushes = new List<MapBrush>();

/// <summary>
/// Returns a <see cref="System.String"/> that represents this instance.
/// </summary>
/// <returns>A <see cref="System.String"/> that represents this instance.</returns>
public override string ToString()
{
return "Quake 1 Entity " + ClassName + " (" + Brushes.Count + " Brushes)";
}
}
}

#endif
13 changes: 13 additions & 0 deletions Scripts/Importers/Quake1/MapEntity.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading