Showing the changes to interface/src/main.cpp (1 of 1 file). Show all
Unified · Split
| @@ -175,7 +175,7 @@ int mouseY = 0; · 174 unmodified lines | |||
| 175 | int mousePressed = 0; // true if mouse has been pressed (clear when finished) | 175 | int mousePressed = 0; // true if mouse has been pressed (clear when finished) |
| 176 | 176 | ||
| 177 | // The current mode for mouse interaction | 177 | // The current mode for mouse interaction |
| 178 | enum MouseMode { ADD_VOXEL_MODE, DELETE_VOXEL_MODE }; | 178 | enum MouseMode { ADD_VOXEL_MODE, DELETE_VOXEL_MODE, COLOR_VOXEL_MODE }; |
| 179 | MouseMode mouseMode = ADD_VOXEL_MODE; | 179 | MouseMode mouseMode = ADD_VOXEL_MODE; |
| 180 | VoxelDetail mouseVoxel; // details of the voxel under the mouse cursor | 180 | VoxelDetail mouseVoxel; // details of the voxel under the mouse cursor |
| 181 | 181 | ||
| @@ -1653,7 +1653,8 @@ void key(unsigned char k, int x, int y) { · 1471 unmodified lines | |||
| 1653 | if (k == '%') ::sendVoxelServerAddScene(); // sends add scene command to voxel server | 1653 | if (k == '%') ::sendVoxelServerAddScene(); // sends add scene command to voxel server |
| 1654 | if (k == '1') ::mouseMode = ADD_VOXEL_MODE; | 1654 | if (k == '1') ::mouseMode = ADD_VOXEL_MODE; |
| 1655 | if (k == '2') ::mouseMode = DELETE_VOXEL_MODE; | 1655 | if (k == '2') ::mouseMode = DELETE_VOXEL_MODE; |
| 1656 | if (k == '3') addVoxelInFrontOfAvatar(); | 1656 | if (k == '3') ::mouseMode = COLOR_VOXEL_MODE; |
| 1657 | if (k == '4') addVoxelInFrontOfAvatar(); | ||
| 1657 | if (k == 'n' || k == 'N') | 1658 | if (k == 'n' || k == 'N') |
| 1658 | { | 1659 | { |
| 1659 | noiseOn = !noiseOn; // Toggle noise | 1660 | noiseOn = !noiseOn; // Toggle noise |
| @@ -1796,7 +1797,12 @@ void idle(void) { · 136 unmodified lines | |||
| 1796 | ::mouseVoxel.y += offset.y * ::mouseVoxel.s; | 1797 | ::mouseVoxel.y += offset.y * ::mouseVoxel.s; |
| 1797 | ::mouseVoxel.z += offset.z * ::mouseVoxel.s; | 1798 | ::mouseVoxel.z += offset.z * ::mouseVoxel.s; |
| 1798 | 1799 | ||
| 1799 | } else { | 1800 | } else if (::mouseMode == COLOR_VOXEL_MODE) { |
| 1801 | ::mouseVoxel.red = 0; | ||
| 1802 | ::mouseVoxel.green = 255; | ||
| 1803 | ::mouseVoxel.blue = 0; | ||
| 1804 | |||
| 1805 | } else { // ::mouseMode == DELETE_VOXEL_MODE | ||
| 1800 | // red indicates deletion | 1806 | // red indicates deletion |
| 1801 | ::mouseVoxel.red = 255; | 1807 | ::mouseVoxel.red = 255; |
| 1802 | ::mouseVoxel.green = ::mouseVoxel.blue = 0; | 1808 | ::mouseVoxel.green = ::mouseVoxel.blue = 0; |
| @@ -1928,9 +1934,9 @@ void mouseFunc(int button, int state, int x, int y) { · 125 unmodified lines | |||
| 1928 | case GLUT_LEFT_BUTTON: | 1934 | case GLUT_LEFT_BUTTON: |
| 1929 | if (state == GLUT_DOWN && !menu.mouseClick(x, y)) { | 1935 | if (state == GLUT_DOWN && !menu.mouseClick(x, y)) { |
| 1930 | mousePressed = 1; | 1936 | mousePressed = 1; |
| 1931 | if (::mouseMode == ADD_VOXEL_MODE) { | 1937 | if (::mouseMode == ADD_VOXEL_MODE || ::mouseMode == COLOR_VOXEL_MODE) { |
| 1932 | addVoxelUnderCursor(); | 1938 | addVoxelUnderCursor(); |
| 1933 | 1939 | ||
| 1934 | } else { // ::mouseMode == DELETE_VOXEL_MODE | 1940 | } else { // ::mouseMode == DELETE_VOXEL_MODE |
| 1935 | deleteVoxelUnderCursor(); | 1941 | deleteVoxelUnderCursor(); |
| 1936 | } | 1942 | } |
| @@ -1941,12 +1947,7 @@ void mouseFunc(int button, int state, int x, int y) { · 4 unmodified lines | |||
| 1941 | 1947 | ||
| 1942 | case GLUT_RIGHT_BUTTON: | 1948 | case GLUT_RIGHT_BUTTON: |
| 1943 | if (state == GLUT_DOWN) { | 1949 | if (state == GLUT_DOWN) { |
| 1944 | if (::mouseMode == ADD_VOXEL_MODE) { | 1950 | deleteVoxelUnderCursor(); |
| 1945 | deleteVoxelUnderCursor(); | ||
| 1946 | |||
| 1947 | } else { // ::mouseMode == DELETE_VOXEL_MODE | ||
| 1948 | addVoxelUnderCursor(); | ||
| 1949 | } | ||
| 1950 | } | 1951 | } |
| 1951 | break; | 1952 | break; |
| 1952 | } | 1953 | } |