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

            //If first point was already selected AND second point != first point
            if (this.LineModeIsFirstPointSelected && this.LineModeFirstPointSelected.Id != tempFact.Id)
            {
                //Create LineFact
                FactManager.AddRayFact(this.LineModeFirstPointSelected.Id, tempFact.Id);

                this.ResetGadget();
            }
            else
            {
                //Activate LineDrawing for preview
                this.LineModeIsFirstPointSelected = true;
                this.LineModeFirstPointSelected   = tempFact;
                this.ActivateLineDrawing();
            }
        }

        //if we hit the top snap zone
        //TODO: check behaviour
        else if (hit.transform.gameObject.CompareTag("SnapZone"))
        {
            if (this.LineModeIsFirstPointSelected)
            {
                RaycastHit downHit;

                if (Physics.Raycast(hit.transform.gameObject.transform.position - Vector3.down * 2, Vector3.down, out downHit))
                {
                    //Create LineFact
                    var idA = downHit.transform.gameObject.GetComponent <FactObject>().URI;
                    var idB = this.LineModeFirstPointSelected.Id;
                    FactManager.AddAngleFact(idA, idB, FactManager.AddPointFact(hit).Id);

                    this.ResetGadget();
                }
            }
        }

        //If no Point was hit
        else
        {
            if (this.LineModeIsFirstPointSelected)
            {
                //Deactivate LineDrawing and first point selection
                this.ResetGadget();
            }

            //TODO: Hint that only a line can be drawn between already existing points
        }
    }
コード例 #2
0
ファイル: Pointer.cs プロジェクト: SESch93/UFrameIT
    public override void OnHit(RaycastHit hit)
    {
        if (!this.isActiveAndEnabled)
        {
            return;
        }
        var pid = FactManager.AddPointFact(hit).Id;

        if (hit.transform.gameObject.layer == LayerMask.NameToLayer("Ray"))
        {
            FactManager.AddOnLineFact(pid, hit.transform.GetComponent <FactObject>().URI, true);
        }
    }
コード例 #3
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);
            }
        }
    }
コード例 #4
0
ファイル: PoleTool.cs プロジェクト: SESch93/UFrameIT
    public override void OnHit(RaycastHit hit)
    {
        if (!this.isActiveAndEnabled ||
            !Physics.Raycast(Cursor.transform.position + Vector3.up * (float)Math3d.vectorPrecission,
                             Vector3.down, maxHeight + (float)Math3d.vectorPrecission, LayerMask.GetMask(new string[] { "Default", "Tree" })))
        {
            return;
        }

        UpdateLineDrawing();

        if (hit.transform.gameObject.layer == LayerMask.NameToLayer("Point"))
        {
            var pid2 = FactManager.AddPointFact(linePositions[1], Vector3.up).Id;
            FactManager.AddLineFact(hit.transform.gameObject.GetComponent <FactObject>().URI, pid2, true);
        }
        else
        {
            FactManager.AddPointFact(hit);
        }
    }
コード例 #5
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();
            }
        }
    }