コード例 #1
0
    private bool DrawBoxSelection()
    {
        if (viewModel.PreviousModelFactory == null)
        {
            return(false);
        }
        NPVoxModel   previousTransformedModel = viewModel.PreviousModelFactory.GetProduct();
        NPVoxToUnity npVoxToUnity             = new NPVoxToUnity(previousTransformedModel, viewModel.Animation.MeshFactory.VoxelSize);

        List <NPVoxBox> boxes = viewModel.GetNonEditableBoxes();

        if (boxes != null)
        {
            foreach (NPVoxBox b in boxes)
            {
                NPVoxHandles.DrawBoxSelection(npVoxToUnity, b, false);
            }
        }

        if (!viewModel.IsAreaSelectionActive())
        {
            return(false);
        }


        NPVoxBox box = viewModel.GetAffectedBox();

        if (Event.current.shift)
        {
            // affected area picker
            NPVoxCoord someCoord    = box.RoundedCenter;
            NPVoxCoord someNewCoord = NPVoxHandles.VoxelPicker(new NPVoxToUnity(previousTransformedModel, viewModel.Animation.MeshFactory.VoxelSize), someCoord, 0, ((NPVoxAnimationEditorSession)target).previewFilter.transform);
            if (!someCoord.Equals(someNewCoord))
            {
                viewModel.ChangeAffectedBox(new NPVoxBox(someNewCoord, someNewCoord));
            }
        }
        else
        {
            // affected area box
            NPVoxBox newBox = NPVoxHandles.DrawBoxSelection(npVoxToUnity, box);
            if (!newBox.Equals(box))
            {
                viewModel.ChangeAffectedBox(newBox);
            }
        }

        return(true);
    }
コード例 #2
0
    public System.Func <NPVoxISceneEditable, bool> DrawSceneTool(NPVoxToUnity npVoxToUnity, Transform transform, int tool)
    {
        if (Input == null)
        {
            return(null);
        }

        NPVoxModel model = ((NPVoxIModelFactory)Input).GetProduct() as NPVoxModel;

        if (!model)
        {
            return(null);
        }

        // Start Coord 1
        if (tool == 0)
        {
            NPVoxCoord someNewCoord = NPVoxHandles.VoxelPicker(npVoxToUnity, startCoord1, 0, transform);
            if (!startCoord1.Equals(someNewCoord))
            {
                return((NPVoxISceneEditable t) =>
                {
                    (t as NPVoxTrailAttacher).startCoord1 = someNewCoord;
                    return true;
                });
            }
        }

        // Start Coord 2
        if (tool == 1)
        {
            NPVoxCoord someNewCoord = NPVoxHandles.VoxelPicker(npVoxToUnity, startCoord2, 0, transform);
            if (!startCoord2.Equals(someNewCoord))
            {
                return((NPVoxISceneEditable t) =>
                {
                    (t as NPVoxTrailAttacher).startCoord2 = someNewCoord;
                    return true;
                });
            }
        }

        // Direction 1
        if (tool == 2)
        {
            Quaternion newQuaternion = Handles.RotationHandle(rotation1, npVoxToUnity.ToUnityPosition(startCoord1));
            if (!newQuaternion.Equals(rotation1))
            {
                return((NPVoxISceneEditable t) =>
                {
                    (t as NPVoxTrailAttacher).rotation1 = newQuaternion;
                    return true;
                });
            }
        }

        // Direction 2
        if (tool == 3)
        {
            Quaternion newQuaternion = Handles.RotationHandle(rotation2, npVoxToUnity.ToUnityPosition(startCoord2));
            if (!newQuaternion.Equals(rotation2))
            {
                return((NPVoxISceneEditable t) =>
                {
                    (t as NPVoxTrailAttacher).rotation2 = newQuaternion;
                    return true;
                });
            }
        }

        return(null);
    }