From 09f48235aa3f6379570951d412e02c95e565f58d Mon Sep 17 00:00:00 2001
From: BenniHome <benjamin.boesl@studium.fau.de>
Date: Sat, 1 Feb 2020 16:01:15 +0100
Subject: [PATCH]  ITS ALIVE

---
 .../Inventory/Scripts.meta => Graphics.meta}  |  2 +-
 Assets/InteractionEngine/Fact.cs              | 19 ++++++++++++++-----
 Assets/InventoryStuff/ScrollDetails.cs        |  3 +++
 .../Items/scripts.meta => Scenes.meta}        |  2 +-
 README.md                                     | 16 ++++++++++++++++
 5 files changed, 35 insertions(+), 7 deletions(-)
 rename Assets/{InventoryStuff/Inventory/Scripts.meta => Graphics.meta} (77%)
 rename Assets/{InventoryStuff/Items/scripts.meta => Scenes.meta} (77%)

diff --git a/Assets/InventoryStuff/Inventory/Scripts.meta b/Assets/Graphics.meta
similarity index 77%
rename from Assets/InventoryStuff/Inventory/Scripts.meta
rename to Assets/Graphics.meta
index a14c2631..2f27852d 100644
--- a/Assets/InventoryStuff/Inventory/Scripts.meta
+++ b/Assets/Graphics.meta
@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 546b5a29afa8bd446ba254c04097d626
+guid: eec83b50c1e0c604aa91430f72c8dbb0
 folderAsset: yes
 DefaultImporter:
   externalObjects: {}
diff --git a/Assets/InteractionEngine/Fact.cs b/Assets/InteractionEngine/Fact.cs
index 88da4b85..d2da5cbc 100644
--- a/Assets/InteractionEngine/Fact.cs
+++ b/Assets/InteractionEngine/Fact.cs
@@ -7,6 +7,10 @@ public abstract class Fact
     public GameObject Representation;
     public string backendURI;
     public string backendValueURI; // supposed to be null, for Facts without values eg. Points, OpenLines, OnLineFacts...
+
+    public string format(float t) {
+        return t.ToString("0.0000").Replace(',', '.');
+    }
 }
 
 public class AddFactResponse
@@ -48,7 +52,8 @@ public PointFact(int i,Vector3 P, Vector3 N) {
         this.Point = P;
         this.Normal = N;
 
-        string body = @"{ ""a"":" +P.x + @"," + @"""b"":" +P.y + @","+@"""c"":" + P.z + "}";
+        string body = @"{ ""a"":" +format(P.x) + @"," + @"""b"":" + format(P.y) + @","+@"""c"":" + format(P.y) + "}";
+        Debug.Log(body);
         AddFactResponse res = AddFactResponse.sendAdd("localhost:8081/fact/add/vector", body);
         this.backendURI = res.factUri;
 
@@ -88,8 +93,8 @@ public LineFact(int i, int pid1, int pid2) {
         PointFact pf2 = CommunicationEvents.Facts.Find((x => x.Id == pid2)) as PointFact;
         string p1URI = pf1.backendURI;
         string p2URI = pf2.backendURI;
-        double v = (pf1.Point - pf2.Point).magnitude;
-        string body = @"{ ""pointA"":""" + p1URI + @"""," + @"""pointB"":""" + p2URI + @"""," + @"""value"":" + v + "}";
+        float v = (pf1.Point - pf2.Point).magnitude;
+        string body = @"{ ""pointA"":""" + p1URI + @"""," + @"""pointB"":""" + p2URI + @"""," + @"""value"":" + format(v) + "}";
         AddFactResponse res = AddFactResponse.sendAdd("localhost:8081/fact/add/distance", body);
         this.backendURI = res.factUri;
         this.backendValueURI = res.factValUri;
@@ -123,13 +128,17 @@ public AngleFact(int i, int pid1, int pid2, int pid3)
         PointFact pf1 = CommunicationEvents.Facts.Find((x => x.Id == pid1)) as PointFact;
         PointFact pf2 = CommunicationEvents.Facts.Find((x => x.Id == pid2)) as PointFact;
         PointFact pf3 = CommunicationEvents.Facts.Find((x => x.Id == pid3)) as PointFact;
-        double v = Vector3.Angle((pf1.Point - pf2.Point), (pf1.Point - pf2.Point));
+        
+        float v = Vector3.Angle((pf1.Point - pf2.Point), (pf3.Point - pf2.Point));
+        if (Mathf.Abs(v - 90.0f) < 0.01) v = 90.0f;
+        Debug.Log("angle: " + v);
         string body = @"{" +
           @"""left"":""" + pf1.backendURI + @"""," +
           @"""middle"":""" + pf2.backendURI + @"""," +
           @"""right"":""" + pf3.backendURI + @"""," +
-          @"""value"":" + v +
+          @"""value"":" + format(v) +
           "}";
+        Debug.Log(body);
         AddFactResponse res = AddFactResponse.sendAdd("localhost:8081/fact/add/angle", body);
         this.backendURI = res.factUri;
         this.backendValueURI = res.factValUri;
diff --git a/Assets/InventoryStuff/ScrollDetails.cs b/Assets/InventoryStuff/ScrollDetails.cs
index 78fd19ce..12dca2d2 100644
--- a/Assets/InventoryStuff/ScrollDetails.cs
+++ b/Assets/InventoryStuff/ScrollDetails.cs
@@ -117,6 +117,8 @@ class PushoutReturn {
         public string newSituation;
         public PushoutFact[] outputs;
     }
+
+    [System.Serializable]
     public  class PushoutFact {
         // generic class to make a common Supertype for all PushoutResponses
         public string uri;
@@ -195,6 +197,7 @@ private string pushout(string view) {
     }
 
     private void readPushout(string txt) {
+        Debug.Log(txt);
         PushoutReturn ret = JsonUtility.FromJson<PushoutReturn>(txt);
         this.situationTheory = ret.newSituation;
         FactManager factManager = cursor.GetComponent<FactManager>();
diff --git a/Assets/InventoryStuff/Items/scripts.meta b/Assets/Scenes.meta
similarity index 77%
rename from Assets/InventoryStuff/Items/scripts.meta
rename to Assets/Scenes.meta
index 7add7d73..157e8818 100644
--- a/Assets/InventoryStuff/Items/scripts.meta
+++ b/Assets/Scenes.meta
@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: df10919d3230595438beac5071d21387
+guid: ac72be71662640f4ab0aaf102090fb95
 folderAsset: yes
 DefaultImporter:
   externalObjects: {}
diff --git a/README.md b/README.md
index c1b1fe19..56e82b55 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,18 @@
 # UFrameIT
 the new unity-based implementation of FrameIT
+
+
+to make things work, pleas follow the following steps:
+- download the whole mathhub directory:
+	https://drive.google.com/open?id=1Vd7nHCRRRSo6NnvgDSz98V6lOdIm92KA
+- download the FrameIt-MMT-Server.jar :
+	https://drive.google.com/open?id=12aCu3LgXUuv96TAKL705BK9_45ytrv4q
+- call :
+	java -jar FrameIt-MMT-Server.jar <path to mathhub-dir> 8081
+-press play in Unity.
+
+
+The Code of the Server is hosted here:
+	https://github.com/bBoesl/UFrameTt_Server
+The FrameIt-Specific MMT files can be found here:
+	https://github.com/bBoesl/UFrameIt-MMT
\ No newline at end of file
-- 
GitLab