private void UpdateStretch()
    {
        Vector3 pos   = obj.worldToLocalMatrix.MultiplyPoint(sceneManager.rightControllerPosition);
        MPoint  a     = activeEdges[0].start;
        MPoint  b     = activeEdges[0].end;
        MPoint  c     = activeEdges[1].end;
        float   width = Vector3.Distance(a.position, b.position);
        Vector3 p     = MHelperFunctions.VectorL2P(pos, activeEdges[0].direction, a.position);

        p = ReviseLength(p, width);
        c.SetPosition(p + b.position);
        if (activeFace != null && activeFace.IsValid())
        {
            activeFace.Render(obj.localToWorldMatrix);
            foreach (MLinearEdge edge in activeEdges)
            {
                edge.Render(obj.localToWorldMatrix);
            }
            a.Render(obj.localToWorldMatrix);
            b.Render(obj.localToWorldMatrix);
            c.Render(obj.localToWorldMatrix);
            activeTextMesh.GetComponentInChildren <TextMesh>().text = "1:" + (p.magnitude / width).ToString();
            activeTextMesh.transform.position = sceneManager.rightControllerPosition + MDefinitions.DEFAULT_ACTIVE_TEXT_OFFSET;
            if (sceneManager.camera != null)
            {
                activeTextMesh.transform.rotation = Quaternion.LookRotation((sceneManager.camera.transform.position - activeTextMesh.transform.position) * -1, Vector3.up);
            }
        }
        else
        {
            activeTextMesh.GetComponentInChildren <TextMesh>().text = "";
        }
    }
    private void UpdateConnecting()
    {
        Vector3 pos = curObj.worldToLocalMatrix.MultiplyPoint(sceneManager.rightControllerPosition);
        MPoint  p   = selectedEntity[0] as MPoint;

        if (sceneManager.activeEntity.entity != null)
        {
            pos = sceneManager.activeEntity.entity.GetProjection(p.position, pos);
        }
        activePoint.SetPosition(pos);
        if (activeEdge == null)
        {
            activeEdge = new MLinearEdge(p, activePoint);
            activeEdge.entityStatus = MEntity.MEntityStatus.ACTIVE;
            activeEdge.end.edges.Add(activeEdge);
        }
        activePoint.Render(curObj.localToWorldMatrix);
        if (activeEdge != null && activeEdge.IsValid())
        {
            activeEdge.Render(curObj.localToWorldMatrix);
        }
    }
    private void UpdateActivePointPosition()
    {
        Vector3 pos    = sceneManager.rightControllerPosition;
        MEntity entity = sceneManager.activeEntity.entity;

        if (entity != null)
        {
            pos = entity.SpecialPointFind(curObj.worldToLocalMatrix.MultiplyPoint(pos));
        }
        else
        {
            pos = curObj.worldToLocalMatrix.MultiplyPoint(pos);
        }
        activePoint.SetPosition(pos);
        activePoint.Render(curObj.localToWorldMatrix);
    }
Beispiel #4
0
    private void UpdateAdjustAngle()
    {
        validAngle = false;
        Vector3      pos   = curObj.worldToLocalMatrix.MultiplyPoint(sceneManager.rightControllerPosition);
        MPolygonFace polyf = selectFace as MPolygonFace;

        pos = MHelperFunctions.PointProjectionInFace(pos, polyf.normal, anglePoints[0].position);
        Vector3 axisPoint  = anglePoints[2].position;
        Vector3 dir1       = pos - axisPoint;
        Vector3 dir2       = anglePoints[0].position - axisPoint;
        Vector3 dir3       = anglePoints[1].position - axisPoint;
        float   totalAngle = MHelperFunctions.CalcRadAngle(dir2, dir3);
        float   angle1     = MHelperFunctions.CalcRadAngle(dir2, dir1);
        float   angle2     = MHelperFunctions.CalcRadAngle(dir3, dir1);

        if (Mathf.Abs(angle1 + angle2 - totalAngle) < MDefinitions.VECTOR3_PRECISION)
        {
            dir1 = ReviseAngle(dir1, dir2, dir3);
            Vector3 intersect = new Vector3();
            foreach (MLinearEdge le in polyf.edgeList)
            {
                if (le.start == anglePoints[2] || le.end == anglePoints[2])
                {
                    continue;
                }
                Vector3 v;
                if (MHelperFunctions.LineLineIntersection(out v, le.start.position, le.direction, anglePoints[2].position, dir1))
                {
                    if (Vector3.Dot(le.start.position - v, le.end.position - v) <= 0)
                    {
                        validAngle = true;
                        intersect  = v;
                        break;
                    }
                }
            }
            if (validAngle)
            {
                activePoint.SetPosition(intersect);
                activeTextMesh.GetComponentInChildren <TextMesh>().text = MHelperFunctions.CalcRealAngle(dir1, dir2).ToString() + " " + MHelperFunctions.CalcRealAngle(dir1, dir3).ToString();
                activeTextMesh.transform.position = sceneManager.rightControllerPosition + MDefinitions.DEFAULT_ACTIVE_TEXT_OFFSET;
                if (sceneManager.camera != null)
                {
                    activeTextMesh.transform.rotation = Quaternion.LookRotation((sceneManager.camera.transform.position - activeTextMesh.transform.position) * -1, Vector3.up);
                }
                if (activeEdge == null)
                {
                    activeEdge = new MLinearEdge(anglePoints[2], activePoint);
                    activeEdge.entityStatus = MEntity.MEntityStatus.ACTIVE;
                    activeEdge.end.edges.Add(activeEdge);
                }
                activePoint.Render(curObj.localToWorldMatrix);
                if (activeEdge != null && activeEdge.IsValid())
                {
                    activeEdge.Render(curObj.localToWorldMatrix);
                }
            }
        }
        if (!validAngle)
        {
            activeTextMesh.GetComponentInChildren <TextMesh>().text = "";
        }
    }