First person exploration of archaeological sites using Sketchup and Unity3D

ezgif-1-451cf65d0eb7.gif

When presenting 3D reconstructions to the public, it is common to use either static images or at most models that rotate along an axis or point (such as those shown on Sketchfab). However it is possible to create more immersive and interesting models simply by using a navigation system that is more accessible and intuitive.

Unity3D offers the possibility of using a first person perspective to navigate a site which requires little effort and no coding. It can even be used to explore a site in VR.

In this article I will look at how to create an archaeological site that can be explored in the first person in Unity3D.

1. Modelling

I like modelling in Sketchup Pro, as it is very simple and intuitive while still being very flexible. I believe the free version now doesn’t support any useful export tools anymore, so if you don’t have a Pro version, feel free to use any other software to create your model (blender etc.). Otherwise, the video below provides information on how to model using Sketchup.

2. Importing

Unity3D has a free version that has most functionalities unlocked, so there is no need to purchase the pro version for this project.

Once you have your model in Sketchup, use the export settings to export the model as a .obj or .fbx file. Other files formats may work too, but I have found that .obj or .fbx is the most suited for the transfer of textures from one software to another.

Create a new project in Unity3D and make sure it is 3D. Then, drag the model files into the Unity asset panel. There should be an .obj file, a .mtl file and a folder with textures, or a .fbx and a folder. Sometimes Unity may have problems associating the textures with the model, so reexport it if there are any issues. If Unity crashes, copy the files directly into the project folder.

Once imported, drag the model file from assets into the hierarchy.

3. Add components

To allow users to “bump” into the model, it is necessary to add some components to the model itself. In the hierarchy search bar find all objects that have mesh in the name. Then, in the inspector panel add components. We need a Mesh Collider and a Rigidbody.

Make sure the mesh collider is not convex, and untick the Use Gravity toggle in the rigidbody. Finally, toggle the Is Kinematic toggle. If you have objects that should be moved by interacting with the user, it may be worth leaving the gravity on and making it not kinematic, so that the objects may move around.

col.JPG

4. Import First Person Assets

In the Unity Store search for Standard Assets. Download the package, which is free to use.

Within the asset panel, locate the FPSController, which is commonly located at Assets>StandardAssets>Characters>FirstPersonCharacter>Prefab. Drag it into the hierarchy. If there is already a main camera in the hierarchy, delete it.

col 2.JPG

5. Explore!

Press the play button above the main screen. Now use arrow keys and mouse to explore the site!

Bonus

If you want to use an Oculus to explore your model, the process is very similar. You need to download the Oculus software from the website and have it open when using Unity3D. Then, follow the same steps as above, but download the Oculus Integration assets instead of the Standard assets. Import the equivalent First Person Controller and enjoy.

Additionally, you may use the Input Mapping to allow the use of a game controller for easier navigation.

There is a lot more that can be done with Unity3D, from interactive tools to information panels. But this is a simple and effective way to explore archaeological models without the need to write any code.

Advertisements

Another publication: Celebrations in prehistoric Malta.

Hi all,

This week has been a good week: here is another paper I have just published for World Archaeology, entitled Celebrations in prehistoric Malta. It’s a collaboration with many authors, but there is some good information on 3D stuff.

50 copies are available at https://www.tandfonline.com/eprint/KTC67bb9MHxIeA2jYV5D/full so go get them quick!

 

Rob

How Video Games help present and interpret Neolithic Malta.

 

Hi all,

I gave a talk yesterday as part of Queen’s University Belfast PGR Talks. I had it recorded as I thought it would be interesting to share here some of my recent results.

I intended this presentation for those who may not be familiar with the topic, so it may be a bit vague at times, but it should provide a useful introduction to 3D reconstruction and gaming software.

Please feel free to share your thoughts and questions in the comment section.

Rob

Paper on Using Unity3D for Archaeological Interpretation

image paper.jpeg

Just a quick note to say that I have published an article for Archaeological Science: Reports regarding the use of a Unity3D script to calculate solar alignment at Ggantija, Gozo.

It is unfortunately not as open access as I would like, but I’ve been told that the article will be available for viewing for the next 50 days at https://authors.elsevier.com/a/1WFZO,rVDBK0IJ

If you have an interest in using 3D Reconstruction for analysis do check it out, and feel free to get in contact at rbarratt01@qub.ac.uk for more information.

Rob

A Unity 3D script for displaying uncertainty in 3D Reconstructions.

Following up from my latest post, I wanted to share with you one of the solutions I used as part of my MPhil project.

As discussed, a real problem with 3D Reconstruction in archaeology is the subjectivity of the modelling process. While Photogrammetry and Laser Scanning record archaeological features as they are, reconstructions rely on information that is more or less inaccurate. Strothotte et al. (1999) pointed out that uncertainty in Visualisation is caused by imprecision and incompleteness. Site reports tend to present a limited range of data, usually in a 2D format that may not translate to 3D which causes imprecision (Worthing and Counsell 1999). And while interpretation of a site can be built on incomplete information, 3D Reconstruction requires answers to very specific questions that rarely can be answered by the archaeological evidence.

In a bid to display this uncertainty, projects have displayed the model entirely using wireframes or point clouds (Richards 1998). I propose a similar solution: by using a Unity 3D script heavily based on work by Naojitaniguchi (2015), we have different toggles to switch between fully rendered, wireframe and removed. The most uncertain elements are tagged for removal, leaving the more accurate features intact.

Within the scene, the wireframe looks like so:

wireframe

Wireframe 2Wireframe

The Player script initiates the script by attaching it to the objects targeted for removal upon the input of a button:

void RemoveArchaeology(){
		if (Input.GetAxisRaw ("Remove") != 0 && archaeologyRemoved == 0 &&
			removeAxisInUse == false) {
			archaeologyRemoved = 1;
			removeAxisInUse = true;

			foreach (GameObject go in gameObjectArray) {

				go.gameObject.AddComponent ();
			}
		} else if (Input.GetAxisRaw ("Remove") != 0 && archaeologyRemoved == 1 &&
			removeAxisInUse == false) {
			archaeologyRemoved = 2;
			removeAxisInUse = true;

			foreach (GameObject go in gameObjectArray) {

				VertexRenderer vertexRenderer = go.GetComponent ();
				vertexRenderer.RevertToStart ();
				Destroy (vertexRenderer);
				go.SetActive (false);
			}
		}	else if (Input.GetAxisRaw ("Remove") != 0 && archaeologyRemoved == 2 &&
			removeAxisInUse == false){
			archaeologyRemoved = 0;
			removeAxisInUse = true;

			foreach (GameObject go in gameObjectArray) {
				go.SetActive (true);
			}
		}

		if (Input.GetAxisRaw ("Remove") == 0){
			removeAxisInUse = false;
		}
	}

Then, the VertexRenderer script replaces the model with lines:

using UnityEngine;
using System.Collections;

		//Code written by R. P. Barratt
		//robbarratt1@outlook.com
		//
		//Heavily based on a script by Naojitaniguchi (2015).

		//Renders the selected elements as lines.

public class VertexRenderer : MonoBehaviour {

	public Color lineColor;
	public Color backgroundColor;

	private Vector3[] lines;
	private ArrayList linesArray;
	private Material lineMaterial;
	private MeshRenderer meshRenderer;
	private Material initialMaterial;

	public void Start () {

		//Finds the components.
		GetComponent<Renderer> ().enabled = false;
		meshRenderer = GetComponent<MeshRenderer> ();
		if (!meshRenderer) {
			meshRenderer = gameObject.AddComponent<MeshRenderer> ();
		}

		//Saves the initial material.
		SaveInfo ();

		//Finds the line material and sets it.
		Shader shader1 = Shader.Find ("Lines/Background");
		meshRenderer.material = new Material (shader1);
		Shader shader2 = Shader.Find ("Lines/Colored Blended");
		lineMaterial = new Material (shader2);
		lineMaterial.hideFlags = HideFlags.HideAndDontSave;
		lineMaterial.shader.hideFlags = HideFlags.HideAndDontSave; 

		//Creates a list of lines based on the mesh.
		linesArray = new ArrayList ();
		MeshFilter filter = GetComponent<MeshFilter> ();
		Mesh mesh = filter.sharedMesh;
		Vector3[] vertices = mesh.vertices;
		int[] triangles = mesh.triangles; 

		for (int i = 0; i < triangles.Length / 3; i++) {
			linesArray.Add (vertices [triangles [i * 3]]);
			linesArray.Add (vertices [triangles [i * 3 + 1]]);
			linesArray.Add (vertices [triangles [i * 3 + 2]]);
		} 

		lines = new Vector3[triangles.Length];
		for (int i = 0; i < triangles.Length; i++) {
			lines [i] = (Vector3)linesArray [i];
		}

		//Sets material.
		meshRenderer.sharedMaterial.color = backgroundColor;
		lineMaterial.SetPass (0);
	}

	public void OnRenderObject(){

		//Draws lines based on mesh.
		GL.PushMatrix ();
		GL.MultMatrix (transform.localToWorldMatrix);
		GL.Begin (GL.LINES);
		GL.Color (lineColor); 

		for (int i = 0; i < lines.Length / 3; i++) {
			GL.Vertex (lines [i * 3]);
			GL.Vertex (lines [i * 3 + 1]); 

			GL.Vertex (lines [i * 3 + 1]);
			GL.Vertex (lines [i * 3 + 2]); 

			GL.Vertex (lines [i * 3 + 2]);
			GL.Vertex (lines [i * 3]);
		} 

		GL.End ();
		GL.PopMatrix ();
	}

	void SaveInfo(){

		//Saves initial material.
		initialMaterial = meshRenderer.material;
	}

	public void RevertToStart(){

		//Returns to initial material.
		GetComponent<Renderer> ().enabled = true;
		meshRenderer.material = initialMaterial;
	}
}

The script requires Unity3D to run at the moment, but I am sure it can be adapted for other platforms.

The reason for this script is to allow users to choose different options, displaying the finished model with a more realistic skin but also allowing for a more accurate representation.

References:

Naojitaniguchi (2015). WireFrame. Available: https://gist.github.com/naojitaniguchi/862724c55bd322695511. Last accessed 20th Oct 2017.

Richards, J. D. (1998). Recent Trends in Computer Applications in Archaeology. Journal of Archaeological Research Vol.6 No.4 pp.331-382.

Strothotte, T., Masuch, M. and Isenberg, T. (1999). Visualizing Knowledge about Virtual Reconstructions of Ancient Architecture. Computer Graphics International.

Worthing, D. and Counsell, J. (1999). Issues arising from computer-based recording of heritage sites. Structural Survey Vol.17 No.4 pp.200-210.