コード例 #1
0
ファイル: ShinyThings.cs プロジェクト: SESch93/UFrameIT
    public void StopHighlighting()
    {
        if (typeof(PointFact).IsInstanceOfType(highlightedPushoutFact))
        {
            PointFact fact = (PointFact)highlightedPushoutFact;
            fact.Representation.transform.GetChild(0).GetComponent <MeshRenderer>().material = tempMaterial;
        }
        else if (typeof(LineFact).IsInstanceOfType(highlightedPushoutFact))
        {
            LineFact fact = (LineFact)highlightedPushoutFact;
            fact.Representation.transform.GetChild(0).GetChild(1).GetComponent <MeshRenderer>().material = tempMaterial;
        }
        else if (typeof(AngleFact).IsInstanceOfType(highlightedPushoutFact))
        {
            AngleFact fact = (AngleFact)highlightedPushoutFact;
            fact.Representation.transform.GetChild(0).GetComponent <MeshRenderer>().material = tempMaterial;
        }

        if (this.extraHighlight != null)
        {
            GameObject.Destroy(this.extraHighlight);
            this.extraHighlight = null;
        }

        //Event for the happy Task-Charakter
        CommunicationEvents.PushoutFactEndEvent.Invoke(null);
    }
コード例 #2
0
    private void init(string pid1, string pid2, string pid3)
    {
        this.Pid1 = pid1;
        this.Pid2 = pid2;
        this.Pid3 = pid3;

        PointFact pf1 = _Facts[pid1] as PointFact;
        PointFact pf2 = _Facts[pid2] as PointFact;
        PointFact pf3 = _Facts[pid3] as PointFact;

        float v = GetAngle(); // sets is_right_angle

        MMTDeclaration mmtDecl;
        string         p1URI = pf1.Id;
        string         p2URI = pf2.Id;
        string         p3URI = pf3.Id;

        if (is_right_angle)
        {
            mmtDecl = generate90DegreeAngleDeclaration(v, p1URI, p2URI, p3URI);
        }
        else
        {
            mmtDecl = generateNot90DegreeAngleDeclaration(v, p1URI, p2URI, p3URI);
        }

        AddFactResponse.sendAdd(mmtDecl, out this._URI);
    }
コード例 #3
0
ファイル: ShinyThings.cs プロジェクト: SESch93/UFrameIT
    public void HighlightFact(Fact startFact)
    {
        highlightedPushoutFact = startFact;

        if (typeof(PointFact).IsInstanceOfType(highlightedPushoutFact))
        {
            PointFact fact = (PointFact)highlightedPushoutFact;
            tempMaterial = fact.Representation.transform.GetChild(0).GetComponent <MeshRenderer>().material;
            fact.Representation.transform.GetChild(0).GetComponent <MeshRenderer>().material = pushoutMaterial;
        }
        else if (typeof(LineFact).IsInstanceOfType(highlightedPushoutFact))
        {
            LineFact fact = (LineFact)highlightedPushoutFact;
            tempMaterial = fact.Representation.transform.GetChild(0).GetChild(1).GetComponent <MeshRenderer>().material;
            fact.Representation.transform.GetChild(0).GetChild(1).GetComponent <MeshRenderer>().material = pushoutMaterial;
        }
        else if (typeof(AngleFact).IsInstanceOfType(highlightedPushoutFact))
        {
            AngleFact fact = (AngleFact)highlightedPushoutFact;
            tempMaterial = fact.Representation.transform.GetChild(0).GetComponent <MeshRenderer>().material;
            fact.Representation.transform.GetChild(0).GetComponent <MeshRenderer>().material = pushoutMaterial;
        }

        //Activate Timer
        this.pushoutFail     = false;
        this.slowDownCounter = 0;
        this.timerActive     = true;
    }
コード例 #4
0
    private void init(string pid, string rid)
    {
        this.Pid = pid;
        this.Rid = rid;

        PointFact pf   = _Facts[pid] as PointFact;
        RayFact   rf   = _Facts[rid] as RayFact;
        string    pURI = pf.Id;
        string    rURI = rf.Id;

        List <MMTTerm> innerArguments = new List <MMTTerm>
        {
            new OMS(rURI),
            new OMS(pURI)
        };

        List <MMTTerm> outerArguments = new List <MMTTerm>
        {
            new OMA(new OMS(MMTURIs.OnLine), innerArguments)
        };

        //OMS constructor generates full URI
        MMTTerm tp = new OMA(new OMS(MMTURIs.Ded), outerArguments);
        MMTTerm df = null;

        MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);

        AddFactResponse.sendAdd(mmtDecl, out this._URI);
    }
コード例 #5
0
    private void init(string pid1, string pid2)
    {
        SetDistance();

        PointFact pf1 = _Facts[pid1] as PointFact;
        PointFact pf2 = _Facts[pid2] as PointFact;

        string p1URI = pf1.Id;
        string p2URI = pf2.Id;
        float  v     = (pf1.Point - pf2.Point).magnitude;

        MMTTerm lhs =
            new OMA(
                new OMS(MMTURIs.Metric),
                new List <MMTTerm> {
            new OMS(p1URI),
            new OMS(p2URI)
        }
                );

        MMTTerm valueTp = new OMS(MMTURIs.RealLit);
        MMTTerm value   = new OMF(v);

        //see point label
        MMTValueDeclaration mmtDecl = new MMTValueDeclaration(this.Label, lhs, valueTp, value);

        AddFactResponse.sendAdd(mmtDecl, out this._URI);
    }
コード例 #6
0
ファイル: AngleTool.cs プロジェクト: SESch93/UFrameIT
 private void ResetGadget()
 {
     this.angleModeIsFirstPointSelected  = false;
     this.angleModeFirstPointSelected    = null;
     this.angleModeIsSecondPointSelected = false;
     this.angleModeSecondPointSelected   = null;
     DeactivateCurveDrawing();
 }
コード例 #7
0
    private void set_public_members(string pid1, string pid2)
    {
        this.Pid1 = pid1;
        this.Pid2 = pid2;
        PointFact pf1 = _Facts[pid1] as PointFact;
        PointFact pf2 = _Facts[pid2] as PointFact;

        this.Dir = (pf2.Point - pf1.Point).normalized;
    }
コード例 #8
0
ファイル: AngleTool.cs プロジェクト: SESch93/UFrameIT
    public override void OnHit(RaycastHit hit)
    {
        if (!this.isActiveAndEnabled)
        {
            return;
        }
        if (hit.transform.gameObject.layer == LayerMask.NameToLayer("Point"))
        {
            PointFact tempFact = (PointFact)StageStatic.stage.factState[hit.transform.GetComponent <FactObject>().URI];

            //If two points were already selected and now the third point got selected
            if (this.angleModeIsFirstPointSelected && this.angleModeIsSecondPointSelected)
            {
                //Create AngleFact
                //Check if new Point is equal to one of the previous points -> if true -> cancel
                if (!(this.angleModeFirstPointSelected.Id == tempFact.Id || this.angleModeSecondPointSelected.Id == tempFact.Id))
                {
                    FactManager.AddAngleFact(((PointFact)this.angleModeFirstPointSelected).Id, ((PointFact)this.angleModeSecondPointSelected).Id, ((PointFact)tempFact).Id);
                }

                ResetGadget();
            }
            //If only one point was already selected
            else if (this.angleModeIsFirstPointSelected && !this.angleModeIsSecondPointSelected)
            {
                //Check if the 2 selected points are the same: If not
                if (this.angleModeFirstPointSelected.Id != tempFact.Id)
                {
                    this.angleModeIsSecondPointSelected = true;
                    this.angleModeSecondPointSelected   = tempFact;

                    ActivateCurveDrawing();
                }
                else
                {
                    this.angleModeFirstPointSelected   = null;
                    this.angleModeIsFirstPointSelected = false;
                }
            }
            //If no point was selected before
            else
            {
                //Save the first point selected
                this.angleModeIsFirstPointSelected = true;
                this.angleModeFirstPointSelected   = tempFact;
            }
        }
        //No point was hit
        else
        {
            ResetGadget();

            //TODO: Hint that only an angle can be created between 3 already existing points
        }
    }
コード例 #9
0
ファイル: WorldCursor.cs プロジェクト: SESch93/UFrameIT
    void Update()
    {
        Ray ray = useCamCurser ? new Ray(Cam.transform.position, Cam.transform.forward) : Cam.ScreenPointToRay(Input.mousePosition);

        this.Hit           = new RaycastHit();
        transform.up       = Cam.transform.forward;
        transform.position = ray.GetPoint(GlobalBehaviour.GadgetPhysicalDistance);

        int rayCastMask;

        if (Input.GetButton(this.deactivateSnapKey))
        {
            rayCastMask = this.layerMask & ~this.snapLayerMask.value;
        }
        else
        {
            rayCastMask = this.layerMask;
        }

        if (Physics.Raycast(ray, out Hit, MaxRange, rayCastMask) ||
            (MaxRange <= GlobalBehaviour.GadgetPhysicalDistance &&
             Physics.Raycast(transform.position, Vector3.down, out Hit, GlobalBehaviour.GadgetPhysicalDistance, rayCastMask)))
        {
            if ((Hit.collider.transform.CompareTag("SnapZone") || Hit.collider.transform.CompareTag("Selectable")) &&
                !Input.GetButton(this.deactivateSnapKey))
            {
                if (Hit.collider.gameObject.layer == LayerMask.NameToLayer("Ray") ||
                    Hit.collider.gameObject.layer == LayerMask.NameToLayer("Line"))
                {
                    var id = Hit.collider.gameObject.GetComponent <FactObject>().URI;
                    AbstractLineFact lineFact = StageStatic.stage.factState[id] as AbstractLineFact;
                    PointFact        p1       = StageStatic.stage.factState[lineFact.Pid1] as PointFact;

                    Hit.point = Math3d.ProjectPointOnLine(p1.Point, lineFact.Dir, Hit.point);
                }
                else
                {
                    Hit.point  = Hit.collider.transform.position;
                    Hit.normal = Vector3.up;
                }

                transform.position = Hit.point;
                transform.up       = Hit.normal;
            }
            else
            {
                transform.position  = Hit.point;
                transform.up        = Hit.normal;
                transform.position += .01f * Hit.normal;
            }

            CheckMouseButtons();
        }
    }
コード例 #10
0
    private float GetAngle()
    {
        PointFact pf1 = _Facts[Pid1] as PointFact;
        PointFact pf2 = _Facts[Pid2] as PointFact;
        PointFact pf3 = _Facts[Pid3] as PointFact;

        float v = Vector3.Angle((pf1.Point - pf2.Point), (pf3.Point - pf2.Point));

        this.is_right_angle = Mathf.Abs(v - 90.0f) < 0.01;

        return(is_right_angle ? 90f : v);
    }
コード例 #11
0
ファイル: LotTool.cs プロジェクト: SESch93/UFrameIT
    private void ResetGadget()
    {
        this.LotModeIsLineSelected = false;
        this.LotModeLineSelected   = null;

        this.LotModeLinePointA = null;

        this.LotModeIsPointSelected   = false;
        this.LotModeIntersectionPoint = null;
        //TODO? reset?
        //this.LotModeLineHit;
        DeactivateLineDrawing();
    }
コード例 #12
0
    protected override bool EquivalentWrapped(OnLineFact f1, OnLineFact f2)
    {
        if (f1.Pid == f2.Pid && f1.Rid == f2.Rid)
        {
            return(true);
        }

        PointFact pf1 = (PointFact)_Facts[f1.Pid];
        RayFact   rf1 = (RayFact)_Facts[f1.Rid];
        PointFact pf2 = (PointFact)_Facts[f2.Pid];
        RayFact   rf2 = (RayFact)_Facts[f2.Rid];

        return(pf1.Equivalent(pf2) && rf1.Equivalent(rf2));
    }
コード例 #13
0
    protected override bool EquivalentWrapped(RayFact f1, RayFact f2)
    {
        if (!Math3d.IsApproximatelyParallel(f1.Dir, f2.Dir))
        {
            return(false);
        }

        PointFact p1f1 = (PointFact)_Facts[f1.Pid1];
        PointFact p1f2 = (PointFact)_Facts[f2.Pid1];
        PointFact p2f2 = (PointFact)_Facts[f2.Pid2];

        return(Math3d.IsPointApproximatelyOnLine(p1f1.Point, f1.Dir, p1f2.Point) &&
               Math3d.IsPointApproximatelyOnLine(p1f1.Point, f1.Dir, p2f2.Point));
    }
コード例 #14
0
ファイル: FactSpawner.cs プロジェクト: SESch93/UFrameIT
    public Fact SpawnPoint(Fact pointFact)
    {
        PointFact fact = ((PointFact)pointFact);

        this.FactRepresentation = Sphere;

        GameObject point = GameObject.Instantiate(FactRepresentation);

        point.transform.position = fact.Point;
        point.transform.up       = fact.Normal;
        point.GetComponentInChildren <TextMeshPro>().text = fact.Label;
        point.GetComponent <FactObject>().URI             = fact.Id;
        fact.Representation = point;
        return(fact);
    }
コード例 #15
0
    public static void GenerateDemoA()
    {
        // Params
        float minimalSolutionHight = 6;

        // Generate Stage
        // TODO? use constructor
        Stage demo = new Stage();

        demo.number             = 0;
        demo.category           = "Demo Category";
        demo.name               = "TechDemo A";
        demo.scene              = "RiverWorld";
        demo.description        = "Improvised Level\n(Loadable)";
        demo.use_install_folder = true;
        demo.hierarchie         = new List <Directories> { /*Directories.Stages*/
        };

        // needed to generate facts
        StageStatic.StageOfficial = new Dictionary <string, Stage>
        {
            { demo.name, demo },
        };
        StageStatic.SetStage(demo.name, false);

        // Populate Solution
        PointFact
            buttom = new PointFact(Vector3.zero, Vector3.up, StageStatic.stage.solution),
            top    = new PointFact(Vector3.zero + Vector3.up * minimalSolutionHight, Vector3.up, StageStatic.stage.solution);

        StageStatic.stage.solution.Add(buttom, out _);
        StageStatic.stage.solution.Add(top, out _, true);

        LineFact target    = new LineFact(buttom.Id, top.Id, StageStatic.stage.solution);
        var      target_Id = StageStatic.stage.solution.Add(target, out _, true);

        // Set Solution
        StageStatic.stage.solution.ValidationSet =
            new List <SolutionOrganizer.SubSolution>
        {
            new SolutionOrganizer.SubSolution(new HashSet <string> {
                target_Id
            }, null, null, new LineFactHightDirectionComparer())
        };

        // Save
        StageStatic.stage.store();
    }
コード例 #16
0
    protected override bool EquivalentWrapped(LineFact f1, LineFact f2)
    {
        if ((f1.Pid1 == f2.Pid1 && f1.Pid2 == f2.Pid2))// ||
        //(f1.Pid1 == f2.Pid2 && f1.Pid2 == f2.Pid1))
        {
            return(true);
        }

        PointFact p1f1 = (PointFact)_Facts[f1.Pid1];
        PointFact p2f1 = (PointFact)_Facts[f1.Pid2];
        PointFact p1f2 = (PointFact)_Facts[f2.Pid1];
        PointFact p2f2 = (PointFact)_Facts[f2.Pid2];

        return(p1f1.Equivalent(p1f2) && p2f1.Equivalent(p2f2))
        ;    //|| (p1f1.Equivalent(p2f2) && p2f1.Equivalent(p1f2));
    }
コード例 #17
0
ファイル: FactSpawner.cs プロジェクト: SESch93/UFrameIT
    public Fact SpawnRay(Fact fact)
    {
        RayFact rayFact = ((RayFact)fact);

        PointFact pointFact1 = (StageStatic.stage.factState[rayFact.Pid1] as PointFact);
        PointFact pointFact2 = (StageStatic.stage.factState[rayFact.Pid2] as PointFact);


        Vector3 point1 = pointFact1.Point;
        Vector3 point2 = pointFact2.Point;

        Vector3 dir = (point2 - point1).normalized;

        point1 -= dir * 100;
        point2 += dir * 100;

        //Change FactRepresentation to Line
        this.FactRepresentation = Ray;
        GameObject line = GameObject.Instantiate(FactRepresentation);

        //Place the Line in the centre of the two points
        line.transform.position = Vector3.Lerp(point1, point2, 0.5f);
        //Change scale and rotation, so that the two points are connected by the line
        //Get the Line-GameObject as the first Child of the Line-Prefab -> That's the Collider
        var v3T = line.transform.GetChild(0).localScale;

        v3T.x = (point2 - point1).magnitude;

        //For every Coordinate x,y,z we have to devide it by the LocalScale of the Child,
        //because actually the Child should be of this length and not the parent, which is only the Collider
        v3T.x = v3T.x / line.transform.GetChild(0).GetChild(0).localScale.x;
        //y and z of the line/Cube-GameObject here hard coded = ratio of sphere-prefab
        v3T.y = 0.1f / line.transform.GetChild(0).GetChild(0).localScale.y;
        v3T.z = 0.1f / line.transform.GetChild(0).GetChild(0).localScale.z;
        //Change Scale/Rotation of the Line-GameObject without affecting Scale of the Text
        line.transform.GetChild(0).localScale = v3T;
        line.transform.GetChild(0).rotation   = Quaternion.FromToRotation(Vector3.right, point2 - point1);

        line.GetComponentInChildren <TextMeshPro>().text = rayFact.Label;
        line.GetComponentInChildren <FactObject>().URI   = rayFact.Id;

        rayFact.Representation = line;
        return(rayFact);
    }
コード例 #18
0
ファイル: Pendulum.cs プロジェクト: SESch93/UFrameIT
    public override void OnHit(RaycastHit hit)
    {
        if (!this.isActiveAndEnabled)
        {
            return;
        }

        if (hit.transform.gameObject.layer == LayerMask.NameToLayer("Point"))
        {
            PointFact tempFact = StageStatic.stage.factState[hit.transform.GetComponent <FactObject>().URI] as PointFact;

            //Raycast downwoard
            RaycastHit ground;
            if (Physics.Raycast(tempFact.Point, Vector3.down, out ground, Mathf.Infinity, this.LayerPendulumHits.value))
            {
                FactManager.AddPointFact(ground);
            }
        }
    }
コード例 #19
0
ファイル: FactManager.cs プロジェクト: SESch93/UFrameIT
    public RayFact AddRayFact(string pid1, string pid2, bool samestep = false)
    {
        RayFact rayFact = (RayFact)AddFactIfNotFound(new RayFact(pid1, pid2, StageStatic.stage.factState), out bool exists, samestep);

        if (exists)
        {
            return(rayFact);
        }

        //Add all PointFacts on Ray as OnLineFacts
        PointFact rayP1     = (PointFact)StageStatic.stage.factState[rayFact.Pid1];
        PointFact rayP2     = (PointFact)StageStatic.stage.factState[rayFact.Pid2];
        int       layerMask = LayerMask.GetMask("Point");

        RaycastHit[] hitsA = Physics.RaycastAll(rayP1.Point, rayFact.Dir, Mathf.Infinity, layerMask);
        RaycastHit[] hitsB = Physics.RaycastAll(rayP2.Point, -rayFact.Dir, Mathf.Infinity, layerMask);

        void AddHitIfOnLine(RaycastHit hit)
        {
            if (Math3d.IsPointApproximatelyOnLine(rayP1.Point, rayFact.Dir, hit.transform.position))
            {
                AddOnLineFact(hit.transform.gameObject.GetComponent <FactObject>().URI, rayFact.Id, true);
            }
        }

        foreach (RaycastHit hit in hitsA)
        {
            AddHitIfOnLine(hit);
        }

        foreach (RaycastHit hit in hitsB)
        {
            AddHitIfOnLine(hit);
        }

        // for good measure
        AddOnLineFact(rayFact.Pid1, rayFact.Id, true);
        AddOnLineFact(rayFact.Pid2, rayFact.Id, true);

        return(rayFact);
    }
コード例 #20
0
    private void init(string pid1, string pid2)
    {
        PointFact pf1 = _Facts[pid1] as PointFact;
        PointFact pf2 = _Facts[pid2] as PointFact;

        string p1URI = pf1.Id;
        string p2URI = pf2.Id;

        List <MMTTerm> arguments = new List <MMTTerm>
        {
            new OMS(p1URI),
            new OMS(p2URI)
        };

        //OMS constructor generates full URI
        MMTTerm tp = new OMS(MMTURIs.LineType);
        MMTTerm df = new OMA(new OMS(MMTURIs.LineOf), arguments);

        MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);

        AddFactResponse.sendAdd(mmtDecl, out this._URI);
    }
コード例 #21
0
ファイル: LotTool.cs プロジェクト: SESch93/UFrameIT
    public override void OnHit(RaycastHit hit)
    {
        void CreateRayAndAngles(string pidIntersectionPoint, string pidLotPoint, bool samestep)
        {
            FactManager.AddRayFact(pidIntersectionPoint, pidLotPoint, samestep);

            //TODO: create at all? / for all points on basline?
            FactManager.AddAngleFact(
                this.LotModeLineSelected.Pid1 == pidIntersectionPoint ? this.LotModeLineSelected.Pid2 : this.LotModeLineSelected.Pid1,
                pidIntersectionPoint, pidLotPoint, true);
        }

        if (!this.isActiveAndEnabled)
        {
            return;
        }

        //If LotPoint is on baseLine
        if (this.LotModeIsPointSelected && (hit.transform.gameObject.layer == LayerMask.NameToLayer("Default") || hit.transform.gameObject.layer == LayerMask.NameToLayer("Tree")))
        {
            Vector3 LotPoint = Math3d.ProjectPointOnLine(hit.point, this.LotModeLineSelected.Dir, this.LotModeIntersectionPoint.Point);

            //TODO: which normal?
            CreateRayAndAngles(this.LotModeIntersectionPoint.Id, FactManager.AddPointFact(LotPoint, hit.normal).Id, true);
            this.ResetGadget();
        }

        //If baseline already selected and point selected
        else if (this.LotModeIsLineSelected && !this.LotModeIsPointSelected && hit.transform.gameObject.layer == LayerMask.NameToLayer("Point"))
        {
            PointFact tempFact = StageStatic.stage.factState[hit.transform.GetComponent <FactObject>().URI] as PointFact;

            Vector3 intersectionPoint = Math3d.ProjectPointOnLine(this.LotModeLinePointA.Point, this.LotModeLineSelected.Dir, tempFact.Point);

            if (intersectionPoint == tempFact.Point) // Vector3.operator== tests for almost Equal()
            {                                        //TempFact is on baseLine
                this.LotModeIsPointSelected   = true;
                this.LotModeIntersectionPoint = tempFact;
                return;
            }

            //TODO: test Facts existance
            //add Facts
            var intersectionId = FactManager.AddPointFact(intersectionPoint, this.LotModeLineHit.normal).Id;

            if (this.LotModeLineSelected is RayFact) //Add OnLineFact only on Ray not Line
            {
                FactManager.AddOnLineFact(intersectionId, this.LotModeLineSelected.Id, true);
            }

            CreateRayAndAngles(intersectionId, tempFact.Id, true);
            this.ResetGadget();
        }

        //If nothing yet selected
        else if (!this.LotModeIsLineSelected &&
                 (hit.transform.gameObject.layer == LayerMask.NameToLayer("Ray") ||
                  hit.transform.gameObject.layer == LayerMask.NameToLayer("Line")))
        {
            Fact tempFact = StageStatic.stage.factState[hit.transform.GetComponent <FactObject>().URI];

            //Activate LineDrawing for preview
            this.LotModeIsLineSelected = true;
            this.LotModeLineSelected   = tempFact as AbstractLineFact;
            this.LotModeLinePointA     = (PointFact)StageStatic.stage.factState[this.LotModeLineSelected.Pid1];
            this.LotModeLineHit        = hit;
            this.ActivateLineDrawing();
        }

        //unexpected usage
        else
        {
            if (this.LotModeIsLineSelected)
            {
                //Deactivate LineDrawing and first point selection
                this.ResetGadget();
            }
        }
    }