Exemplo n.º 1
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);
    }
Exemplo n.º 2
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));
    }
Exemplo n.º 3
0
    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);
    }
Exemplo n.º 4
0
    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);
    }