Example #1
0
 private void RightTriggerPressed(object sender, VRTK.ControllerInteractionEventArgs e)
 {
     activeEdge = null;
     if (sceneManager.activeEntity.entity == null || sceneManager.activeEntity.entity.entityType != MEntity.MEntityType.POINT)
     {
         connecting = false;
         curObject  = null;
         ClearSelectPoint();
     }
     else if (connecting)
     {
         if (curObject != sceneManager.activeEntity.obj)
         {
             curObject = sceneManager.activeEntity.obj;
             SelectPoint((MPoint)sceneManager.activeEntity.entity);
         }
         else if ((MPoint)sceneManager.activeEntity.entity == selectPoint)
         {
             connecting = false;
             curObject  = null;
             ClearSelectPoint();
         }
         else
         {
             MPoint p = (MPoint)sceneManager.activeEntity.entity;
             curObject.CreateLinearEdge(selectPoint, p);
             connecting = false;
             curObject  = null;
             ClearSelectPoint();
         }
     }
     else
     {
         connecting = true;
         curObject  = sceneManager.activeEntity.obj;
         SelectPoint((MPoint)sceneManager.activeEntity.entity);
     }
 }
    private void RightTriggerPressed(object sender, VRTK.ControllerInteractionEventArgs e)
    {
        if (sceneManager.pointerOnMenu)
        {
            return;
        }
        switch (status)
        {
        case STATUS.DEFAULT:
            if (sceneManager.activeEntity.entity != null)
            {
                if (sceneManager.activeEntity.entity.entityType == MEntity.MEntityType.POINT)
                {
                    status     = STATUS.CONNECTING;
                    activeEdge = null;
                    SelectEntity(sceneManager.activeEntity.entity);
                    curObj = sceneManager.activeEntity.obj;
                }
                else if (((MFace)sceneManager.activeEntity.entity).faceType == MFace.MFaceType.POLYGON ||
                         ((MFace)sceneManager.activeEntity.entity).faceType == MFace.MFaceType.CIRCLE ||
                         ((MFace)sceneManager.activeEntity.entity).faceType == MFace.MFaceType.GENERAL_FLAT)
                {
                    status = STATUS.SELECT_POINT;
                    SelectEntity(sceneManager.activeEntity.entity);
                    curObj = sceneManager.activeEntity.obj;
                }
            }
            break;

        case STATUS.SELECT_POINT:
            if (sceneManager.activeEntity.entity == null)
            {
                ResetStatus();
            }
            else
            {
                SelectEntity(sceneManager.activeEntity.entity);
                activeTextMesh.SetActive(true);
                status     = STATUS.ADJUST_LEN;
                activeEdge = null;
            }
            break;

        case STATUS.CONNECTING:
            if (sceneManager.activeEntity.entity == null ||
                (sceneManager.activeEntity.entity.entityType == MEntity.MEntityType.EDGE &&
                 ((MEdge)sceneManager.activeEntity.entity).edgeType != MEdge.MEdgeType.LINEAR) ||
                (sceneManager.activeEntity.entity.entityType == MEntity.MEntityType.FACE &&
                 ((MFace)sceneManager.activeEntity.entity).faceType == MFace.MFaceType.GENERAL_CURVE)
                )
            {
                ResetStatus();
            }
            else
            {
                curObj.CreateLinearEdge((MPoint)selectedEntity[0], new MPoint(activePoint.position));
                ResetStatus();
            }
            break;

        case STATUS.ADJUST_LEN:
            curObj.CreateLinearEdge((MPoint)selectedEntity[1], new MPoint(activePoint.position));
            ResetStatus();
            break;
        }
    }
Example #3
0
    private void RightTriggerPressed(object sender, VRTK.ControllerInteractionEventArgs e)
    {
        if (sceneManager.pointerOnMenu)
        {
            return;
        }
        switch (status)
        {
        case STATUS.SELECT_FACE:
            if (sceneManager.activeEntity.entity != null && ((MFace)sceneManager.activeEntity.entity).faceType == MFace.MFaceType.POLYGON)
            {
                status = STATUS.SELECT_POINT;
                SelectEntity(ref selectFace, sceneManager.activeEntity.entity);
                curObj = sceneManager.activeEntity.obj;
            }
            break;

        case STATUS.SELECT_POINT:
            MPolygonFace polyf = selectFace as MPolygonFace;
            if (sceneManager.activeEntity.entity == null || !polyf.PointInFace((MPoint)sceneManager.activeEntity.entity))
            {
                ResetStatus();
            }
            else
            {
                MPoint p = (MPoint)sceneManager.activeEntity.entity;
                int    i = 0;
                foreach (MLinearEdge le in polyf.edgeList)
                {
                    if (le.start == p)
                    {
                        anglePoints[i] = le.end;
                        i++;
                        if (i == 2)
                        {
                            break;
                        }
                    }
                    else if (le.end == p)
                    {
                        anglePoints[i] = le.start;
                        i++;
                        if (i == 2)
                        {
                            break;
                        }
                    }
                }
                if (i == 2)
                {
                    status         = STATUS.ADJUST_ANGLE;
                    anglePoints[2] = p;
                    activeTextMesh.SetActive(true);
                }
                else
                {
                    Debug.Log("CreateAngleState: wrong refEdges");
                    ResetStatus();
                }
            }
            break;

        case STATUS.ADJUST_ANGLE:
            if (validAngle)
            {
                curObj.CreateLinearEdge(anglePoints[2], new MPoint(activePoint.position));
                ResetStatus();
            }
            break;
        }
    }