Skip to content
Snippets Groups Projects
Select Git revision
  • 6748b406d1af107b78b94772cfa4a95799bd3bf0
  • master default
  • JS-based-scroll-rendering
  • Paul_Marius_Level
  • Paul_Marius_2
  • Paul_Marius
  • Andi_Mark
  • be-UnityWebView
  • gitignoreFrameitServer
  • ZimmerBSc
  • Bugfix_StageLoading
  • stages
  • MAZIFAU_Experimental
  • tsc/coneworld
  • tsc/fact-interaction
  • marcel
  • MaZiFAU_TopSort
  • mergeHelper
  • zwischenSpeichern
  • tempAndrToMaster
  • SebBranch
  • 3.0
  • v2.1
  • v2.0
  • v1.0
25 results

CircleFact.cs

Blame
  • CircleFact.cs 34.07 KiB
    using Newtonsoft.Json;
    using REST_JSON_API;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using UnityEditor.Callbacks;
    using UnityEngine;
    
    /// <summary>
    /// A Circle that is made out of a middle point, a plane and a radius
    /// </summary>
    public class CircleFact : FactWrappedCRTP<CircleFact>
    {
        /// <summary> defining the middle point of the circle  </summary>
        public string PidCenter;
        /// <summary>  defining the base point of the circle plane </summary>
        public string PidBase;
    
        [JsonIgnore]
        public PointFact PointCenter { get => (PointFact)FactRecorder.AllFacts[PidCenter]; }
        [JsonIgnore]
        public PointFact PointBase { get => (PointFact)FactRecorder.AllFacts[PidBase]; }
    
        /// <summary>  radius of the circle </summary>
        public float radius;
        /// <summary> normal vector of the plane </summary>
        public Vector3 normal;
    
        /// <summary> \copydoc Fact.Fact </summary>
        public CircleFact() : base()
        {
            this.normal = Vector3.zero;
            this.PidCenter = null;
            this.PidBase = null;
            this.radius = 0;
        }
    
        /// <summary>
        /// Standard Constructor:
        /// Initiates <see cref="PidCenter"/>, <see cref="PidBase"/>, <see cref="radius"/>,<see cref="dir1"/>,<see cref="dir2"/>, <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
        /// </summary>
        /// <param name="pid1">sets <see cref="PidCenter"/></param>
        /// <param name="pid2">sets <see cref="PidBase"/></param>
        /// <param name="radius">sets <see cref="radius"/></param>
        /// <param name="normal">sets <see cref="normal"/></param>
        public CircleFact(string pid1, string pid2, float radius, Vector3 normal) : base()
        {
            this.PidCenter = pid1;
            this.PidBase = pid2;
    
            this.radius = radius;
            this.normal = normal;
        }
    
        protected override void RecalculateTransform()
        {
            Position = PointCenter.Position;
            { //Rotation
                Vector3 arbitary_not_normal = normal == Vector3.forward ? Vector3.right : Vector3.forward;
                Vector3 forwoard = Vector3.Cross(arbitary_not_normal, normal);
    
                Rotation = Quaternion.LookRotation(forwoard, normal);
            }
            LocalScale = new Vector3(radius, 1, radius);
        }
    
        /// <summary>
        /// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
        /// </summary>
        /// <param name="Pid1">sets <see cref="PidCenter"/></param>