Пример #1
0
 private void RightTriggerPressed(object sender, VRTK.ControllerInteractionEventArgs e)
 {
     if (sceneManager.activeEntity.entity != null && ((MEdge)sceneManager.activeEntity.entity).edgeType == MEdge.MEdgeType.LINEAR)
     {
         if (curObject == null)
         {
             curObject = sceneManager.activeEntity.obj;
         }
         else
         {
             if (sceneManager.activeEntity.obj != curObject)
             {
                 ResetStatus();
                 return;
             }
         }
         MLinearEdge le = sceneManager.activeEntity.entity as MLinearEdge;
         if (selectEdges.Count > 1)
         {
             Vector3 normal = Vector3.Cross(selectEdges[0].direction, selectEdges[1].direction).normalized;
             if (!MHelperFunctions.Perpendicular(normal, le.direction))
             {
                 ResetStatus();
                 return;
             }
         }
         SelectEdge(le);
         if (selectEdges.Count < 3)
         {
             curObject = null;
             return;
         }
         MPolygonFace face = new MPolygonFace(selectEdges);
         if (face.IsValid())
         {
             curObject.CreatePolygonFace(new List <MLinearEdge>(selectEdges));
             ResetStatus();
         }
     }
     else
     {
         ResetStatus();
     }
 }
Пример #2
0
    private void RightTriggerPressed(object sender, VRTK.ControllerInteractionEventArgs e)
    {
        switch (status)
        {
        case STATUS.DEFAULT:
            obj.transform.position = sceneManager.rightControllerPosition;
            stablePoint            = obj.worldToLocalMatrix.MultiplyPoint(sceneManager.rightControllerPosition);
            status         = STATUS.CREATE_EDGE;
            activeEdges[0] = new MLinearEdge(new MPoint(stablePoint), new MPoint(activePoint.position));
            activeEdges[0].end.edges.Add(activeEdges[0]);
            break;

        case STATUS.CREATE_EDGE:
            activeEdges[1] = new MLinearEdge(activeEdges[0].start, new MPoint(activePoint.position + activeEdges[0].start.position - activeEdges[0].end.position));
            activeEdges[1].end.edges.Add(activeEdges[1]);
            activeEdges[2] = new MLinearEdge(activeEdges[0].end, new MPoint(activePoint.position));
            activeEdges[2].end.edges.Add(activeEdges[2]);
            activeEdges[3] = new MLinearEdge(activeEdges[1].end, activeEdges[2].end);
            activeEdges[3].start.edges.Add(activeEdges[3]);
            activeEdges[3].end.edges.Add(activeEdges[3]);
            activeFace = new MPolygonFace(new List <MLinearEdge>(activeEdges));
            activeEdges[1].faces.Add(activeFace);
            activeEdges[2].faces.Add(activeFace);
            activeEdges[3].faces.Add(activeFace);
            activeTextMesh.SetActive(true);
            status = STATUS.STRETCH;
            break;

        case STATUS.STRETCH:
            if (activeFace != null && activeFace.IsValid())
            {
                status = STATUS.FINISH;
                obj.CreatePolygonFace(new List <MLinearEdge>(activeEdges));
                sceneManager.objects.Add(obj);
                sceneManager.sceneStateMachine.SwitchState((uint)SceneManager.SceneStatus.TRANSFORM, null);
            }
            else
            {
                ResetStatus();
            }
            break;
        }
    }