From e999264c39def1f56c8dcfdff90b19284b852f73 Mon Sep 17 00:00:00 2001 From: Marius Kern <mariusskern@gmail.com> Date: Sat, 3 Aug 2024 13:35:51 +0200 Subject: [PATCH] Pyramid fixed --- .../FactHandling/Facts/PyramidFact.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/InteractionEngine/FactHandling/Facts/PyramidFact.cs b/Assets/Scripts/InteractionEngine/FactHandling/Facts/PyramidFact.cs index 121a7246..2aadb6b1 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/Facts/PyramidFact.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/Facts/PyramidFact.cs @@ -35,7 +35,7 @@ protected void calculate_vectors(){ C = GetR.C + Vector3.zero; D = GetD.Point + Vector3.zero; - D_offset = D - B; + D_offset = Quaternion.AngleAxis(-90, Vector3.right) * (D - B); /* Vector3 d_AB = A + Vector3.Project(D - A, B - A); @@ -52,9 +52,17 @@ protected void calculate_vectors(){ Volume = 1/3 * GetR.Area * Vector3.Distance(M, D); - Position = GetR.Position; + Position = B; - Rotation = GetR.Rotation; + Vector3 forward = Vector3.Cross((C - B), (A - B)); + Vector3 up = A - B; + + if ((A - B).y < 0) + { + up = -up; + } + + Rotation = Quaternion.LookRotation(forward, up); } public PyramidFact() : base(){ -- GitLab