Voxel editing with hands, flying by pointing hands
Showing the changes to interface/src/Application.cpp (1 of 9 files). Show all
Unified · Split
| @@ -1480,6 +1480,54 @@ void Application::doKillLocalVoxels() { · 1479 unmodified lines | |||
| 1480 | _wantToKillLocalVoxels = true; | 1480 | _wantToKillLocalVoxels = true; |
| 1481 | } | 1481 | } |
| 1482 | 1482 | ||
| 1483 | void Application::removeVoxel(glm::vec3 position, | ||
| 1484 | float scale) { | ||
| 1485 | VoxelDetail voxel; | ||
| 1486 | voxel.x = position.x / TREE_SCALE; | ||
| 1487 | voxel.y = position.y / TREE_SCALE; | ||
| 1488 | voxel.z = position.z / TREE_SCALE; | ||
| 1489 | voxel.s = scale / TREE_SCALE; | ||
| 1490 | _voxelEditSender.sendVoxelEditMessage(PACKET_TYPE_ERASE_VOXEL, voxel); | ||
| 1491 | |||
| 1492 | // delete it locally to see the effect immediately (and in case no voxel server is present) | ||
| 1493 | _voxels.deleteVoxelAt(voxel.x, voxel.y, voxel.z, voxel.s); | ||
| 1494 | } | ||
| 1495 | |||
| 1496 | void Application::makeVoxel(glm::vec3 position, | ||
| 1497 | float scale, | ||
| 1498 | unsigned char red, | ||
| 1499 | unsigned char green, | ||
| 1500 | unsigned char blue, | ||
| 1501 | bool isDestructive) { | ||
| 1502 | VoxelDetail voxel; | ||
| 1503 | voxel.x = position.x / TREE_SCALE; | ||
| 1504 | voxel.y = position.y / TREE_SCALE; | ||
| 1505 | voxel.z = position.z / TREE_SCALE; | ||
| 1506 | voxel.s = scale / TREE_SCALE; | ||
| 1507 | voxel.red = red; | ||
| 1508 | voxel.green = green; | ||
| 1509 | voxel.blue = blue; | ||
| 1510 | PACKET_TYPE message = isDestructive ? PACKET_TYPE_SET_VOXEL_DESTRUCTIVE : PACKET_TYPE_SET_VOXEL; | ||
| 1511 | _voxelEditSender.sendVoxelEditMessage(message, voxel); | ||
| 1512 | |||
| 1513 | // create the voxel locally so it appears immediately | ||
| 1514 | |||
| 1515 | _voxels.createVoxel(voxel.x, voxel.y, voxel.z, voxel.s, | ||
| 1516 | voxel.red, voxel.green, voxel.blue, | ||
| 1517 | isDestructive); | ||
| 1518 | |||
| 1519 | // Implement voxel fade effect | ||
| 1520 | VoxelFade fade(VoxelFade::FADE_OUT, 1.0f, 1.0f, 1.0f); | ||
| 1521 | const float VOXEL_BOUNDS_ADJUST = 0.01f; | ||
| 1522 | float slightlyBigger = voxel.s * VOXEL_BOUNDS_ADJUST; | ||
| 1523 | fade.voxelDetails.x = voxel.x - slightlyBigger; | ||
| 1524 | fade.voxelDetails.y = voxel.y - slightlyBigger; | ||
| 1525 | fade.voxelDetails.z = voxel.z - slightlyBigger; | ||
| 1526 | fade.voxelDetails.s = voxel.s + slightlyBigger + slightlyBigger; | ||
| 1527 | _voxelFades.push_back(fade); | ||
| 1528 | |||
| 1529 | } | ||
| 1530 | |||
| 1483 | const glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail _mouseVoxel) { | 1531 | const glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail _mouseVoxel) { |
| 1484 | return glm::vec3((_mouseVoxel.x + _mouseVoxel.s / 2.f) * TREE_SCALE, | 1532 | return glm::vec3((_mouseVoxel.x + _mouseVoxel.s / 2.f) * TREE_SCALE, |
| 1485 | (_mouseVoxel.y + _mouseVoxel.s / 2.f) * TREE_SCALE, | 1533 | (_mouseVoxel.y + _mouseVoxel.s / 2.f) * TREE_SCALE, |
| @@ -2214,11 +2262,11 @@ void Application::updateLeap(float deltaTime) { · 728 unmodified lines | |||
| 2214 | LeapManager::nextFrame(); | 2262 | LeapManager::nextFrame(); |
| 2215 | } | 2263 | } |
| 2216 | 2264 | ||
| 2217 | void Application::updateSixense() { | 2265 | void Application::updateSixense(float deltaTime) { |
| 2218 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2266 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2219 | PerformanceWarning warn(showWarnings, "Application::updateSixense()"); | 2267 | PerformanceWarning warn(showWarnings, "Application::updateSixense()"); |
| 2220 | 2268 | ||
| 2221 | _sixenseManager.update(); | 2269 | _sixenseManager.update(deltaTime); |
| 2222 | } | 2270 | } |
| 2223 | 2271 | ||
| 2224 | void Application::updateSerialDevices(float deltaTime) { | 2272 | void Application::updateSerialDevices(float deltaTime) { |
| @@ -2428,7 +2476,7 @@ void Application::update(float deltaTime) { · 203 unmodified lines | |||
| 2428 | updateMouseVoxels(deltaTime, mouseRayOrigin, mouseRayDirection, distance, face); // UI/UX related to voxels | 2476 | updateMouseVoxels(deltaTime, mouseRayOrigin, mouseRayDirection, distance, face); // UI/UX related to voxels |
| 2429 | updateHandAndTouch(deltaTime); // Update state for touch sensors | 2477 | updateHandAndTouch(deltaTime); // Update state for touch sensors |
| 2430 | updateLeap(deltaTime); // Leap finger-sensing device | 2478 | updateLeap(deltaTime); // Leap finger-sensing device |
| 2431 | updateSixense(); // Razer Hydra controllers | 2479 | updateSixense(deltaTime); // Razer Hydra controllers |
| 2432 | updateSerialDevices(deltaTime); // Read serial port interface devices | 2480 | updateSerialDevices(deltaTime); // Read serial port interface devices |
| 2433 | updateAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes | 2481 | updateAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes |
| 2434 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... | 2482 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... |
| @@ -3945,29 +3993,18 @@ bool Application::maybeEditVoxelUnderCursor() { · 1510 unmodified lines | |||
| 3945 | if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode) | 3993 | if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode) |
| 3946 | || Menu::getInstance()->isOptionChecked(MenuOption::VoxelColorMode)) { | 3994 | || Menu::getInstance()->isOptionChecked(MenuOption::VoxelColorMode)) { |
| 3947 | if (_mouseVoxel.s != 0) { | 3995 | if (_mouseVoxel.s != 0) { |
| 3948 | PACKET_TYPE message = Menu::getInstance()->isOptionChecked(MenuOption::DestructiveAddVoxel) | 3996 | makeVoxel(glm::vec3(_mouseVoxel.x * TREE_SCALE, |
| 3949 | ? PACKET_TYPE_SET_VOXEL_DESTRUCTIVE | 3997 | _mouseVoxel.y * TREE_SCALE, |
| 3950 | : PACKET_TYPE_SET_VOXEL; | 3998 | _mouseVoxel.z * TREE_SCALE), |
| 3951 | _voxelEditSender.sendVoxelEditMessage(message, _mouseVoxel); | 3999 | _mouseVoxel.s * TREE_SCALE, |
| 3952 | 4000 | _mouseVoxel.red, | |
| 3953 | // create the voxel locally so it appears immediately | 4001 | _mouseVoxel.green, |
| 3954 | _voxels.createVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s, | 4002 | _mouseVoxel.blue, |
| 3955 | _mouseVoxel.red, _mouseVoxel.green, _mouseVoxel.blue, | 4003 | Menu::getInstance()->isOptionChecked(MenuOption::DestructiveAddVoxel)); |
| 3956 | Menu::getInstance()->isOptionChecked(MenuOption::DestructiveAddVoxel)); | 4004 | |
| 3957 | |||
| 3958 | // Implement voxel fade effect | ||
| 3959 | VoxelFade fade(VoxelFade::FADE_OUT, 1.0f, 1.0f, 1.0f); | ||
| 3960 | const float VOXEL_BOUNDS_ADJUST = 0.01f; | ||
| 3961 | float slightlyBigger = _mouseVoxel.s * VOXEL_BOUNDS_ADJUST; | ||
| 3962 | fade.voxelDetails.x = _mouseVoxel.x - slightlyBigger; | ||
| 3963 | fade.voxelDetails.y = _mouseVoxel.y - slightlyBigger; | ||
| 3964 | fade.voxelDetails.z = _mouseVoxel.z - slightlyBigger; | ||
| 3965 | fade.voxelDetails.s = _mouseVoxel.s + slightlyBigger + slightlyBigger; | ||
| 3966 | _voxelFades.push_back(fade); | ||
| 3967 | |||
| 3968 | // inject a sound effect | 4005 | // inject a sound effect |
| 3969 | injectVoxelAddedSoundEffect(); | 4006 | injectVoxelAddedSoundEffect(); |
| 3970 | 4007 | ||
| 3971 | // remember the position for drag detection | 4008 | // remember the position for drag detection |
| 3972 | _justEditedVoxel = true; | 4009 | _justEditedVoxel = true; |
| 3973 | 4010 | ||