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);
    }
示例#2
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 = "";
        }
    }