Exemple #1
0
 public static VoxelCommand Remove(Vector3Int pos)
 {
     VoxelCommand cmd = new VoxelCommand ();
     cmd._type = Type.Remove;
     cmd._pos = pos;
     return cmd;
 }
Exemple #2
0
 public static VoxelCommand Add(Voxel voxel)
 {
     VoxelCommand cmd = new VoxelCommand ();
     cmd._type = Type.Add;
     cmd._voxel = voxel;
     return cmd;
 }
Exemple #3
0
    public static VoxelCommand Remove(Vector3Int pos)
    {
        VoxelCommand cmd = new VoxelCommand();

        cmd._type = Type.Remove;
        cmd._pos  = pos;
        return(cmd);
    }
Exemple #4
0
    public static VoxelCommand Add(Voxel voxel)
    {
        VoxelCommand cmd = new VoxelCommand();

        cmd._type  = Type.Add;
        cmd._voxel = voxel;
        return(cmd);
    }
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;
            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
            {
                // If we've clicked on the model, then modify the model
                CurrentMouseActionType = MouseActionType.Edit;
                Client.SendTcp(VoxelCommand.Add(new Voxel(ConvertToWorldAdjPos(hit), _hsvColorPicker.currentColor)));
            }
            else
            {
                if (!EventSystem.current.IsPointerOverGameObject())
                {
                    // If we've clicked on nothing (the background), then move the camera
                    CurrentMouseActionType = MouseActionType.CameraMove;
                }
            }
        }
        else if (Input.GetMouseButtonUp(0))
        {
            CurrentMouseActionType = MouseActionType.None;
        }

        if (Input.GetMouseButtonDown(1))
        {
            RaycastHit hit;
            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
            {
                // If we've clicked on the model, then modify the model
                Client.SendTcp(VoxelCommand.Remove(ConvertToWorldHitPos(hit)));
            }
        }

        // TODO: Only zoom when the app has focus
        float scroll = Input.GetAxis(Constants.Input.MouseScrollWheel);

        if (scroll > 0)
        {
            CameraController.Instance.IncrementCamDistance();
        }
        else if (scroll < 0)
        {
            CameraController.Instance.DecrementCamDistance();
        }
    }