public void TestWriteCollectionData_ManyCollectionsManyArtefacts() { // Test the typical use case for the CollectionWriter CreateTwoCollectionsWithTwoArtefacts(); CollectionReader.LoadXmlFromFile(Paths.CollectionMetadata); for (int i = 0; i < 2; i++) { Dictionary <string, string[]> collectionMetadata = CollectionReader.GetCollectionMetadataWithIdentifier(String.Format("TEST-COLLECTION-0{0}", i)); Assert.That(collectionMetadata ["title"] [0] == "Test Title"); Assert.That(collectionMetadata ["title"] [1] == "A second title"); Assert.That(collectionMetadata ["creator"] [0] == "Test Creator"); Assert.That(collectionMetadata ["creator"] [1] == "A co-creator"); Assert.That(collectionMetadata ["date"] [0] == "2016-10-20"); for (int j = 0; j < 2; j++) { Dictionary <string, Dictionary <string, float> > transformData = CollectionReader.GetTransformForArtefactWithIdentifierInCollection(String.Format("TEST-COLLECTION-0{0}", i), String.Format("TEST-ARTEFACT-0{0}", j)); Assert.That(transformData ["position"] ["x"] == Vector3.one.x); Assert.That(transformData ["position"] ["y"] == Vector3.one.y); Assert.That(transformData ["position"] ["z"] == Vector3.one.z); Assert.That(transformData ["rotation"] ["x"] == Quaternion.identity.x); Assert.That(transformData ["rotation"] ["y"] == Quaternion.identity.y); Assert.That(transformData ["rotation"] ["z"] == Quaternion.identity.z); Assert.That(transformData ["rotation"] ["w"] == Quaternion.identity.w); Assert.That(transformData ["scale"] ["x"] == Vector3.one.x); Assert.That(transformData ["scale"] ["y"] == Vector3.one.y); Assert.That(transformData ["scale"] ["z"] == Vector3.one.z); } } }
/// <summary> /// Places artefact at one of the instance points defined in Editor /// </summary> /// <param name="instantNumber">Instantiation number to place artefact at</param> /// <param name="browseArtefact">Artefact to place</param> private void PlaceArtefact(int instantNumber, GameObject collectArtefact) { Dictionary <string, Dictionary <string, float> > transInfo; VerticeTransform VertTrans; try { transInfo = CollectionReader.GetTransformForArtefactWithIdentifierInCollection(collectionId, collectArtefact.name); VertTrans = new VerticeTransform(transInfo); } catch (System.Exception ex) { transInfo = null; VertTrans = new VerticeTransform(loadPlaneBoxCol.bounds.min.x, loadPlaneBoxCol.bounds.max.x, loadPlaneBoxCol.bounds.min.z, loadPlaneBoxCol.bounds.max.z); Debug.Log("No pos info available, random assignment"); Debug.Log("Random pos: " + VertTrans.position.x + " " + VertTrans.position.y + " " + VertTrans.position.z); } Instantiate(particleLocator, collectArtefact.transform); collectArtefact.transform.position = VertTrans.position;; Rigidbody rb = collectArtefact.AddComponent <Rigidbody> (); rb.mass = 3; collectArtefact.GetComponent <MeshRenderer>().enabled = true; ProgressBarCont.AddTask("Placing " + collectArtefact.name); }
public void GetTransformForArtefactWithIdentifierInCollection() { Dictionary <string, Dictionary <string, float> > transformData = CollectionReader.GetTransformForArtefactWithIdentifierInCollection("P14C3H01D3R-00", "Evans Bay Wharf"); Assert.That(transformData ["position"] ["x"] == 40.01599f); Assert.That(transformData ["position"] ["y"] == -11.58916f); Assert.That(transformData ["position"] ["z"] == 184.2516f); Assert.That(transformData ["rotation"] ["x"] == 1.0f); Assert.That(transformData ["rotation"] ["y"] == 1.0f); Assert.That(transformData ["rotation"] ["z"] == 1.0f); Assert.That(transformData ["rotation"] ["w"] == 1.0f); Assert.That(transformData ["scale"] ["x"] == 1.0f); Assert.That(transformData ["scale"] ["y"] == 1.0f); Assert.That(transformData ["scale"] ["z"] == 1.0f); }
public void TestInstantiateWithCollectionReaderDictionary() { // Get the list of collection identifiers, and subsequently the list of artefact identifiers for the first collection string[] collectionIdentifiers = CollectionReader.GetIdentifiersForCollections(); string[] artefactIdentifiers = CollectionReader.GetIdentifiersForArtefactsInCollectionWithIdentifier(collectionIdentifiers [0]); // Now get the transform data for the first artefact in the first collection, and attempt to construct a VerticeTransform with the data Dictionary <string, Dictionary <string, float> > transformData = CollectionReader.GetTransformForArtefactWithIdentifierInCollection(collectionIdentifiers [0], artefactIdentifiers [0]); VerticeTransform transform = new VerticeTransform(transformData); Assert.That(transform.position.x == 40.01599f); Assert.That(transform.position.y == -11.58916f); Assert.That(transform.position.z == 184.2516f); Assert.That(transform.rotation.x == 1.0f); Assert.That(transform.rotation.y == 1.0f); Assert.That(transform.rotation.z == 1.0f); Assert.That(transform.rotation.w == 1.0f); Assert.That(transform.scale.x == 1.0f); Assert.That(transform.scale.y == 1.0f); Assert.That(transform.scale.z == 1.0f); }
public void TestOverwriteCollection() { CreateTwoCollectionsWithTwoArtefacts(); Dictionary <string, string[]> descriptiveData = new Dictionary <string, string[]>(); Dictionary <string, VerticeTransform> structuralData = new Dictionary <string, VerticeTransform>(); descriptiveData.Add("title", new string[] { "Test Overwrite" }); descriptiveData.Add("creator", new string[] { "Test Creator Overwrite" }); descriptiveData.Add("date", new string[] { "2016-10-26" }); structuralData.Add("TEST-ARTEFACT-03", new VerticeTransform(Vector3.one, Quaternion.identity, Vector3.one)); CollectionWriter.WriteCollectionWithIdentifer("TEST-COLLECTION-00", descriptiveData, structuralData); CollectionReader.LoadXmlFromFile(Paths.CollectionMetadata); Dictionary <string, string[]> collectionMetadata = CollectionReader.GetCollectionMetadataWithIdentifier("TEST-COLLECTION-00"); Assert.That(collectionMetadata ["title"] [0] == "Test Overwrite"); Assert.That(collectionMetadata ["creator"] [0] == "Test Creator Overwrite"); Assert.That(collectionMetadata ["date"] [0] == "2016-10-26"); Dictionary <string, Dictionary <string, float> > transformData = CollectionReader.GetTransformForArtefactWithIdentifierInCollection("TEST-COLLECTION-00", "TEST-ARTEFACT-03"); Assert.That(transformData ["position"] ["x"] == Vector3.one.x); Assert.That(transformData ["position"] ["y"] == Vector3.one.y); Assert.That(transformData ["position"] ["z"] == Vector3.one.z); Assert.That(transformData ["rotation"] ["x"] == Quaternion.identity.x); Assert.That(transformData ["rotation"] ["y"] == Quaternion.identity.y); Assert.That(transformData ["rotation"] ["z"] == Quaternion.identity.z); Assert.That(transformData ["rotation"] ["w"] == Quaternion.identity.w); Assert.That(transformData ["scale"] ["x"] == Vector3.one.x); Assert.That(transformData ["scale"] ["y"] == Vector3.one.y); Assert.That(transformData ["scale"] ["z"] == Vector3.one.z); }
public void TestWriteCollectionData_OneToOne() { // Test that a collection whose descriptive elements are non-repeating write correctly Dictionary <string, string[]> descriptiveData = new Dictionary <string, string[]>(); Dictionary <string, VerticeTransform> structuralData = new Dictionary <string, VerticeTransform>(); descriptiveData.Add("title", new string[] { "Test Title" }); descriptiveData.Add("creator", new string[] { "Test Creator" }); descriptiveData.Add("date", new string[] { "2016-10-20" }); structuralData.Add("TEST-ARTEFACT-01", new VerticeTransform(Vector3.one, Quaternion.identity, Vector3.one)); CollectionWriter.WriteCollectionWithIdentifer("TEST-COLLECTION-01", descriptiveData, structuralData); CollectionReader.LoadXmlFromFile(Paths.CollectionMetadata); Dictionary <string, string[]> collectionMetadata = CollectionReader.GetCollectionMetadataWithIdentifier("TEST-COLLECTION-01"); Dictionary <string, Dictionary <string, float> > transformData = CollectionReader.GetTransformForArtefactWithIdentifierInCollection("TEST-COLLECTION-01", "TEST-ARTEFACT-01"); Assert.That(collectionMetadata ["title"] [0] == "Test Title"); Assert.That(collectionMetadata ["creator"] [0] == "Test Creator"); Assert.That(collectionMetadata ["date"] [0] == "2016-10-20"); Assert.That(transformData ["position"] ["x"] == Vector3.one.x); Assert.That(transformData ["position"] ["y"] == Vector3.one.y); Assert.That(transformData ["position"] ["z"] == Vector3.one.z); Assert.That(transformData ["rotation"] ["x"] == Quaternion.identity.x); Assert.That(transformData ["rotation"] ["y"] == Quaternion.identity.y); Assert.That(transformData ["rotation"] ["z"] == Quaternion.identity.z); Assert.That(transformData ["rotation"] ["w"] == Quaternion.identity.w); Assert.That(transformData ["scale"] ["x"] == Vector3.one.x); Assert.That(transformData ["scale"] ["y"] == Vector3.one.y); Assert.That(transformData ["scale"] ["z"] == Vector3.one.z); }
public void GetTransformForArtefactWithIdentifierInCollection_InvalidArtefact() { Dictionary <string, Dictionary <string, float> > transformData = CollectionReader.GetTransformForArtefactWithIdentifierInCollection("P14C3H01D3R-00", "NO SUCH ARTEFACT"); }
public void GetTransformForArtefactWithIdentifierInCollection_IncompleteTransform() { Dictionary <string, Dictionary <string, float> > transformData = CollectionReader.GetTransformForArtefactWithIdentifierInCollection("P14C3H01D3R-00", "Cog Wheel Evans Bay"); }