Showing the changes to interface/src/Application.cpp (1 of 140 files). Show all
Unified · Split
| @@ -140,8 +140,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 139 unmodified lines | |||
| 140 | _touchAvgY(0.0f), | 140 | _touchAvgY(0.0f), |
| 141 | _isTouchPressed(false), | 141 | _isTouchPressed(false), |
| 142 | _mousePressed(false), | 142 | _mousePressed(false), |
| 143 | _isHoverVoxel(false), | ||
| 144 | _isHighlightVoxel(false), | ||
| 145 | _chatEntryOn(false), | 143 | _chatEntryOn(false), |
| 146 | _audio(&_audioScope, STARTUP_JITTER_SAMPLES), | 144 | _audio(&_audioScope, STARTUP_JITTER_SAMPLES), |
| 147 | _enableProcessVoxelsThread(true), | 145 | _enableProcessVoxelsThread(true), |
| @@ -364,6 +362,8 @@ Application::~Application() { · 216 unmodified lines | |||
| 364 | _myAvatar = NULL; | 362 | _myAvatar = NULL; |
| 365 | 363 | ||
| 366 | delete _glWidget; | 364 | delete _glWidget; |
| 365 | |||
| 366 | AccountManager::getInstance().destroy(); | ||
| 367 | } | 367 | } |
| 368 | 368 | ||
| 369 | void Application::restoreSizeAndPosition() { | 369 | void Application::restoreSizeAndPosition() { |
| @@ -746,9 +746,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 376 unmodified lines | |||
| 746 | break; | 746 | break; |
| 747 | 747 | ||
| 748 | case Qt::Key_S: | 748 | case Qt::Key_S: |
| 749 | if (isShifted && !isMeta) { | 749 | if (isShifted && isMeta) { |
| 750 | _voxels.collectStatsForTreesAndVBOs(); | ||
| 751 | } else if (isShifted && isMeta) { | ||
| 752 | Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings); | 750 | Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings); |
| 753 | } else if (!isShifted && isMeta) { | 751 | } else if (!isShifted && isMeta) { |
| 754 | takeSnapshot(); | 752 | takeSnapshot(); |
| @@ -1035,11 +1033,6 @@ void Application::mousePressEvent(QMouseEvent* event) { · 280 unmodified lines | |||
| 1035 | return; | 1033 | return; |
| 1036 | } | 1034 | } |
| 1037 | 1035 | ||
| 1038 | if (!_isHoverVoxel || _myAvatar->getLookAtTargetAvatar()) { | ||
| 1039 | // disable for now | ||
| 1040 | // _pieMenu.mousePressEvent(_mouseX, _mouseY); | ||
| 1041 | } | ||
| 1042 | |||
| 1043 | } else if (event->button() == Qt::RightButton) { | 1036 | } else if (event->button() == Qt::RightButton) { |
| 1044 | // right click items here | 1037 | // right click items here |
| 1045 | } | 1038 | } |
| @@ -1159,7 +1152,7 @@ void Application::dropEvent(QDropEvent *event) { · 113 unmodified lines | |||
| 1159 | } | 1152 | } |
| 1160 | 1153 | ||
| 1161 | SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath); | 1154 | SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath); |
| 1162 | if (snapshotData != NULL) { | 1155 | if (snapshotData) { |
| 1163 | if (!snapshotData->getDomain().isEmpty()) { | 1156 | if (!snapshotData->getDomain().isEmpty()) { |
| 1164 | Menu::getInstance()->goToDomain(snapshotData->getDomain()); | 1157 | Menu::getInstance()->goToDomain(snapshotData->getDomain()); |
| 1165 | } | 1158 | } |
| @@ -1294,7 +1287,7 @@ void Application::removeVoxel(glm::vec3 position, · 128 unmodified lines | |||
| 1294 | _voxelEditSender.sendVoxelEditMessage(PacketTypeVoxelErase, voxel); | 1287 | _voxelEditSender.sendVoxelEditMessage(PacketTypeVoxelErase, voxel); |
| 1295 | 1288 | ||
| 1296 | // delete it locally to see the effect immediately (and in case no voxel server is present) | 1289 | // delete it locally to see the effect immediately (and in case no voxel server is present) |
| 1297 | _voxels.deleteVoxelAt(voxel.x, voxel.y, voxel.z, voxel.s); | 1290 | _voxels.getTree()->deleteVoxelAt(voxel.x, voxel.y, voxel.z, voxel.s); |
| 1298 | } | 1291 | } |
| 1299 | 1292 | ||
| 1300 | 1293 | ||
| @@ -1316,8 +1309,7 @@ void Application::makeVoxel(glm::vec3 position, · 15 unmodified lines | |||
| 1316 | _voxelEditSender.sendVoxelEditMessage(message, voxel); | 1309 | _voxelEditSender.sendVoxelEditMessage(message, voxel); |
| 1317 | 1310 | ||
| 1318 | // create the voxel locally so it appears immediately | 1311 | // create the voxel locally so it appears immediately |
| 1319 | 1312 | _voxels.getTree()->createVoxel(voxel.x, voxel.y, voxel.z, voxel.s, | |
| 1320 | _voxels.createVoxel(voxel.x, voxel.y, voxel.z, voxel.s, | ||
| 1321 | voxel.red, voxel.green, voxel.blue, | 1313 | voxel.red, voxel.green, voxel.blue, |
| 1322 | isDestructive); | 1314 | isDestructive); |
| 1323 | } | 1315 | } |
| @@ -1376,10 +1368,11 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { · 52 unmodified lines | |||
| 1376 | tr("Sparse Voxel Octree Files (*.svo)")); | 1368 | tr("Sparse Voxel Octree Files (*.svo)")); |
| 1377 | QByteArray fileNameAscii = fileNameString.toLocal8Bit(); | 1369 | QByteArray fileNameAscii = fileNameString.toLocal8Bit(); |
| 1378 | const char* fileName = fileNameAscii.data(); | 1370 | const char* fileName = fileNameAscii.data(); |
| 1379 | VoxelTreeElement* selectedNode = _voxels.getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s); | 1371 | |
| 1372 | VoxelTreeElement* selectedNode = _voxels.getTree()->getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s); | ||
| 1380 | if (selectedNode) { | 1373 | if (selectedNode) { |
| 1381 | VoxelTree exportTree; | 1374 | VoxelTree exportTree; |
| 1382 | _voxels.copySubTreeIntoNewTree(selectedNode, &exportTree, true); | 1375 | getVoxelTree()->copySubTreeIntoNewTree(selectedNode, &exportTree, true); |
| 1383 | exportTree.writeToSVOFile(fileName); | 1376 | exportTree.writeToSVOFile(fileName); |
| 1384 | } | 1377 | } |
| 1385 | 1378 | ||
| @@ -1421,9 +1414,10 @@ void Application::copyVoxels(const VoxelDetail& sourceVoxel) { · 35 unmodified lines | |||
| 1421 | } | 1414 | } |
| 1422 | 1415 | ||
| 1423 | // then copy onto it if there is something to copy | 1416 | // then copy onto it if there is something to copy |
| 1424 | VoxelTreeElement* selectedNode = _voxels.getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s); | 1417 | VoxelTreeElement* selectedNode = _voxels.getTree()->getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s); |
| 1425 | if (selectedNode) { | 1418 | if (selectedNode) { |
| 1426 | _voxels.copySubTreeIntoNewTree(selectedNode, &_sharedVoxelSystem, true); | 1419 | getVoxelTree()->copySubTreeIntoNewTree(selectedNode, _sharedVoxelSystem.getTree(), true); |
| 1420 | _sharedVoxelSystem.forceRedrawEntireTree(); | ||
| 1427 | } | 1421 | } |
| 1428 | } | 1422 | } |
| 1429 | 1423 | ||
| @@ -1445,7 +1439,7 @@ void Application::pasteVoxelsToOctalCode(const unsigned char* octalCodeDestinati · 15 unmodified lines | |||
| 1445 | 1439 | ||
| 1446 | void Application::pasteVoxels(const VoxelDetail& sourceVoxel) { | 1440 | void Application::pasteVoxels(const VoxelDetail& sourceVoxel) { |
| 1447 | unsigned char* calculatedOctCode = NULL; | 1441 | unsigned char* calculatedOctCode = NULL; |
| 1448 | VoxelTreeElement* selectedNode = _voxels.getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s); | 1442 | VoxelTreeElement* selectedNode = _voxels.getTree()->getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s); |
| 1449 | 1443 | ||
| 1450 | // we only need the selected voxel to get the newBaseOctCode, which we can actually calculate from the | 1444 | // we only need the selected voxel to get the newBaseOctCode, which we can actually calculate from the |
| 1451 | // voxel size/position details. If we don't have an actual selectedNode then use the mouseVoxel to create a | 1445 | // voxel size/position details. If we don't have an actual selectedNode then use the mouseVoxel to create a |
| @@ -1465,7 +1459,7 @@ void Application::pasteVoxels(const VoxelDetail& sourceVoxel) { · 13 unmodified lines | |||
| 1465 | } | 1459 | } |
| 1466 | 1460 | ||
| 1467 | void Application::nudgeVoxelsByVector(const VoxelDetail& sourceVoxel, const glm::vec3& nudgeVec) { | 1461 | void Application::nudgeVoxelsByVector(const VoxelDetail& sourceVoxel, const glm::vec3& nudgeVec) { |
| 1468 | VoxelTreeElement* nodeToNudge = _voxels.getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s); | 1462 | VoxelTreeElement* nodeToNudge = _voxels.getTree()->getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s); |
| 1469 | if (nodeToNudge) { | 1463 | if (nodeToNudge) { |
| 1470 | _voxels.getTree()->nudgeSubTree(nodeToNudge, nudgeVec, _voxelEditSender); | 1464 | _voxels.getTree()->nudgeSubTree(nodeToNudge, nudgeVec, _voxelEditSender); |
| 1471 | } | 1465 | } |
| @@ -1623,20 +1617,6 @@ bool Application::isLookingAtMyAvatar(Avatar* avatar) { · 151 unmodified lines | |||
| 1623 | return false; | 1617 | return false; |
| 1624 | } | 1618 | } |
| 1625 | 1619 | ||
| 1626 | void Application::renderHighlightVoxel(VoxelDetail voxel) { | ||
| 1627 | glDisable(GL_LIGHTING); | ||
| 1628 | glPushMatrix(); | ||
| 1629 | glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE); | ||
| 1630 | const float EDGE_EXPAND = 1.02f; | ||
| 1631 | glColor3ub(voxel.red + 128, voxel.green + 128, voxel.blue + 128); | ||
| 1632 | glTranslatef(voxel.x + voxel.s * 0.5f, | ||
| 1633 | voxel.y + voxel.s * 0.5f, | ||
| 1634 | voxel.z + voxel.s * 0.5f); | ||
| 1635 | glLineWidth(2.0f); | ||
| 1636 | glutWireCube(voxel.s * EDGE_EXPAND); | ||
| 1637 | glPopMatrix(); | ||
| 1638 | } | ||
| 1639 | |||
| 1640 | void Application::updateMouseRay() { | 1620 | void Application::updateMouseRay() { |
| 1641 | 1621 | ||
| 1642 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 1622 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| @@ -1707,9 +1687,6 @@ void Application::updateMyAvatarLookAtPosition() { · 64 unmodified lines | |||
| 1707 | if (_myAvatar->getLookAtTargetAvatar()) { | 1687 | if (_myAvatar->getLookAtTargetAvatar()) { |
| 1708 | distance = glm::distance(_mouseRayOrigin, | 1688 | distance = glm::distance(_mouseRayOrigin, |
| 1709 | static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead()->calculateAverageEyePosition()); | 1689 | static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead()->calculateAverageEyePosition()); |
| 1710 | |||
| 1711 | } else if (_isHoverVoxel) { | ||
| 1712 | distance = glm::distance(_mouseRayOrigin, getMouseVoxelWorldCoordinates(_hoverVoxel)); | ||
| 1713 | } | 1690 | } |
| 1714 | const float FIXED_MIN_EYE_DISTANCE = 0.3f; | 1691 | const float FIXED_MIN_EYE_DISTANCE = 0.3f; |
| 1715 | float minEyeDistance = FIXED_MIN_EYE_DISTANCE + (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON ? 0.0f : | 1692 | float minEyeDistance = FIXED_MIN_EYE_DISTANCE + (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON ? 0.0f : |
| @@ -1740,17 +1717,6 @@ void Application::updateMyAvatarLookAtPosition() { · 24 unmodified lines | |||
| 1740 | _myAvatar->getHead()->setLookAtPosition(lookAtSpot); | 1717 | _myAvatar->getHead()->setLookAtPosition(lookAtSpot); |
| 1741 | } | 1718 | } |
| 1742 | 1719 | ||
| 1743 | void Application::updateHoverVoxels(float deltaTime, float& distance, BoxFace& face) { | ||
| 1744 | |||
| 1745 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | ||
| 1746 | PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels()"); | ||
| 1747 | |||
| 1748 | if (!_mousePressed) { | ||
| 1749 | PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels() _voxels.findRayIntersection()"); | ||
| 1750 | _isHoverVoxel = _voxels.findRayIntersection(_mouseRayOrigin, _mouseRayDirection, _hoverVoxel, distance, face); | ||
| 1751 | } | ||
| 1752 | } | ||
| 1753 | |||
| 1754 | void Application::updateHandAndTouch(float deltaTime) { | 1720 | void Application::updateHandAndTouch(float deltaTime) { |
| 1755 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 1721 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1756 | PerformanceWarning warn(showWarnings, "Application::updateHandAndTouch()"); | 1722 | PerformanceWarning warn(showWarnings, "Application::updateHandAndTouch()"); |
| @@ -1899,11 +1865,6 @@ void Application::update(float deltaTime) { · 142 unmodified lines | |||
| 1899 | _myAvatar->updateLookAtTargetAvatar(); | 1865 | _myAvatar->updateLookAtTargetAvatar(); |
| 1900 | updateMyAvatarLookAtPosition(); | 1866 | updateMyAvatarLookAtPosition(); |
| 1901 | 1867 | ||
| 1902 | // Find the voxel we are hovering over, and respond if clicked | ||
| 1903 | float distance; | ||
| 1904 | BoxFace face; | ||
| 1905 | |||
| 1906 | updateHoverVoxels(deltaTime, distance, face); // clicking on voxels and making sounds | ||
| 1907 | updateHandAndTouch(deltaTime); // Update state for touch sensors | 1868 | updateHandAndTouch(deltaTime); // Update state for touch sensors |
| 1908 | updateLeap(deltaTime); // Leap finger-sensing device | 1869 | updateLeap(deltaTime); // Leap finger-sensing device |
| 1909 | updateSixense(deltaTime); // Razer Hydra controllers | 1870 | updateSixense(deltaTime); // Razer Hydra controllers |
| @@ -1988,7 +1949,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 78 unmodified lines | |||
| 1988 | 1949 | ||
| 1989 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { | 1950 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { |
| 1990 | // only send to the NodeTypes that are serverType | 1951 | // only send to the NodeTypes that are serverType |
| 1991 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { | 1952 | if (node->getActiveSocket() && node->getType() == serverType) { |
| 1992 | totalServers++; | 1953 | totalServers++; |
| 1993 | 1954 | ||
| 1994 | // get the server bounds for this server | 1955 | // get the server bounds for this server |
| @@ -2048,7 +2009,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 53 unmodified lines | |||
| 2048 | 2009 | ||
| 2049 | foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { | 2010 | foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { |
| 2050 | // only send to the NodeTypes that are serverType | 2011 | // only send to the NodeTypes that are serverType |
| 2051 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { | 2012 | if (node->getActiveSocket() && node->getType() == serverType) { |
| 2052 | 2013 | ||
| 2053 | 2014 | ||
| 2054 | // get the server bounds for this server | 2015 | // get the server bounds for this server |
| @@ -2410,11 +2371,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 355 unmodified lines | |||
| 2410 | 2371 | ||
| 2411 | // restore default, white specular | 2372 | // restore default, white specular |
| 2412 | glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR); | 2373 | glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR); |
| 2413 | |||
| 2414 | // Render the highlighted voxel | ||
| 2415 | if (_isHighlightVoxel) { | ||
| 2416 | renderHighlightVoxel(_highlightVoxel); | ||
| 2417 | } | ||
| 2418 | } | 2374 | } |
| 2419 | 2375 | ||
| 2420 | bool forceRenderMyHead = (whichCamera.getInterpolatedMode() == CAMERA_MODE_MIRROR); | 2376 | bool forceRenderMyHead = (whichCamera.getInterpolatedMode() == CAMERA_MODE_MIRROR); |
| @@ -2476,7 +2432,7 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom · 55 unmodified lines | |||
| 2476 | _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); | 2432 | _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); |
| 2477 | } | 2433 | } |
| 2478 | 2434 | ||
| 2479 | const float WHITE_TEXT[] = { 0.93, 0.93, 0.93 }; | 2435 | const float WHITE_TEXT[] = { 0.93f, 0.93f, 0.93f }; |
| 2480 | 2436 | ||
| 2481 | void Application::displayOverlay() { | 2437 | void Application::displayOverlay() { |
| 2482 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displayOverlay()"); | 2438 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displayOverlay()"); |
| @@ -2525,15 +2481,6 @@ void Application::displayOverlay() { · 42 unmodified lines | |||
| 2525 | } | 2481 | } |
| 2526 | } | 2482 | } |
| 2527 | 2483 | ||
| 2528 | // testing rendering coverage map | ||
| 2529 | if (Menu::getInstance()->isOptionChecked(MenuOption::CoverageMapV2)) { | ||
| 2530 | renderCoverageMapV2(); | ||
| 2531 | } | ||
| 2532 | |||
| 2533 | if (Menu::getInstance()->isOptionChecked(MenuOption::CoverageMap)) { | ||
| 2534 | renderCoverageMap(); | ||
| 2535 | } | ||
| 2536 | |||
| 2537 | // Show chat entry field | 2484 | // Show chat entry field |
| 2538 | if (_chatEntryOn) { | 2485 | if (_chatEntryOn) { |
| 2539 | _chatEntry.render(_glWidget->width(), _glWidget->height()); | 2486 | _chatEntry.render(_glWidget->width(), _glWidget->height()); |
| @@ -2975,115 +2922,6 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { · 435 unmodified lines | |||
| 2975 | return screenPoint; | 2922 | return screenPoint; |
| 2976 | } | 2923 | } |
| 2977 | 2924 | ||
| 2978 | // render the coverage map on screen | ||
| 2979 | void Application::renderCoverageMapV2() { | ||
| 2980 | glDisable(GL_LIGHTING); | ||
| 2981 | glLineWidth(2.0); | ||
| 2982 | glBegin(GL_LINES); | ||
| 2983 | glColor3f(0,1,1); | ||
| 2984 | |||
| 2985 | renderCoverageMapsV2Recursively(&_voxels.myCoverageMapV2); | ||
| 2986 | |||
| 2987 | glEnd(); | ||
| 2988 | glEnable(GL_LIGHTING); | ||
| 2989 | } | ||
| 2990 | |||
| 2991 | void Application::renderCoverageMapsV2Recursively(CoverageMapV2* map) { | ||
| 2992 | // render ourselves... | ||
| 2993 | if (map->isCovered()) { | ||
| 2994 | BoundingBox box = map->getBoundingBox(); | ||
| 2995 | |||
| 2996 | glm::vec2 firstPoint = getScaledScreenPoint(box.getVertex(0)); | ||
| 2997 | glm::vec2 lastPoint(firstPoint); | ||
| 2998 | |||
| 2999 | for (int i = 1; i < box.getVertexCount(); i++) { | ||
| 3000 | glm::vec2 thisPoint = getScaledScreenPoint(box.getVertex(i)); | ||
| 3001 | |||
| 3002 | glVertex2f(lastPoint.x, lastPoint.y); | ||
| 3003 | glVertex2f(thisPoint.x, thisPoint.y); | ||
| 3004 | lastPoint = thisPoint; | ||
| 3005 | } | ||
| 3006 | |||
| 3007 | glVertex2f(lastPoint.x, lastPoint.y); | ||
| 3008 | glVertex2f(firstPoint.x, firstPoint.y); | ||
| 3009 | } else { | ||
| 3010 | // iterate our children and call render on them. | ||
| 3011 | for (int i = 0; i < CoverageMapV2::NUMBER_OF_CHILDREN; i++) { | ||
| 3012 | CoverageMapV2* childMap = map->getChild(i); | ||
| 3013 | if (childMap) { | ||
| 3014 | renderCoverageMapsV2Recursively(childMap); | ||
| 3015 | } | ||
| 3016 | } | ||
| 3017 | } | ||
| 3018 | } | ||
| 3019 | |||
| 3020 | // render the coverage map on screen | ||
| 3021 | void Application::renderCoverageMap() { | ||
| 3022 | |||
| 3023 | glDisable(GL_LIGHTING); | ||
| 3024 | glLineWidth(2.0); | ||
| 3025 | glBegin(GL_LINES); | ||
| 3026 | glColor3f(0,0,1); | ||
| 3027 | |||
| 3028 | renderCoverageMapsRecursively(&_voxels.myCoverageMap); | ||
| 3029 | |||
| 3030 | glEnd(); | ||
| 3031 | glEnable(GL_LIGHTING); | ||
| 3032 | } | ||
| 3033 | |||
| 3034 | void Application::renderCoverageMapsRecursively(CoverageMap* map) { | ||
| 3035 | for (int i = 0; i < map->getPolygonCount(); i++) { | ||
| 3036 | |||
| 3037 | OctreeProjectedPolygon* polygon = map->getPolygon(i); | ||
| 3038 | |||
| 3039 | if (polygon->getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR | PROJECTION_BOTTOM)) { | ||
| 3040 | glColor3f(.5,0,0); // dark red | ||
| 3041 | } else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_RIGHT)) { | ||
| 3042 | glColor3f(.5,.5,0); // dark yellow | ||
| 3043 | } else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_LEFT)) { | ||
| 3044 | glColor3f(.5,.5,.5); // gray | ||
| 3045 | } else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_LEFT | PROJECTION_BOTTOM)) { | ||
| 3046 | glColor3f(.5,0,.5); // dark magenta | ||
| 3047 | } else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_BOTTOM)) { | ||
| 3048 | glColor3f(.75,0,0); // red | ||
| 3049 | } else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_TOP)) { | ||
| 3050 | glColor3f(1,0,1); // magenta | ||
| 3051 | } else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_LEFT | PROJECTION_TOP)) { | ||
| 3052 | glColor3f(0,0,1); // Blue | ||
| 3053 | } else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_RIGHT | PROJECTION_TOP)) { | ||
| 3054 | glColor3f(0,1,0); // green | ||
| 3055 | } else if (polygon->getProjectionType() == (PROJECTION_NEAR)) { | ||
| 3056 | glColor3f(1,1,0); // yellow | ||
| 3057 | } else if (polygon->getProjectionType() == (PROJECTION_FAR | PROJECTION_RIGHT | PROJECTION_BOTTOM)) { | ||
| 3058 | glColor3f(0,.5,.5); // dark cyan | ||
| 3059 | } else { | ||
| 3060 | glColor3f(1,0,0); | ||
| 3061 | } | ||
| 3062 | |||
| 3063 | glm::vec2 firstPoint = getScaledScreenPoint(polygon->getVertex(0)); | ||
| 3064 | glm::vec2 lastPoint(firstPoint); | ||
| 3065 | |||
| 3066 | for (int i = 1; i < polygon->getVertexCount(); i++) { | ||
| 3067 | glm::vec2 thisPoint = getScaledScreenPoint(polygon->getVertex(i)); | ||
| 3068 | |||
| 3069 | glVertex2f(lastPoint.x, lastPoint.y); | ||
| 3070 | glVertex2f(thisPoint.x, thisPoint.y); | ||
| 3071 | lastPoint = thisPoint; | ||
| 3072 | } | ||
| 3073 | |||
| 3074 | glVertex2f(lastPoint.x, lastPoint.y); | ||
| 3075 | glVertex2f(firstPoint.x, firstPoint.y); | ||
| 3076 | } | ||
| 3077 | |||
| 3078 | // iterate our children and call render on them. | ||
| 3079 | for (int i = 0; i < CoverageMapV2::NUMBER_OF_CHILDREN; i++) { | ||
| 3080 | CoverageMap* childMap = map->getChild(i); | ||
| 3081 | if (childMap) { | ||
| 3082 | renderCoverageMapsRecursively(childMap); | ||
| 3083 | } | ||
| 3084 | } | ||
| 3085 | } | ||
| 3086 | |||
| 3087 | void Application::renderRearViewMirror(const QRect& region, bool billboard) { | 2925 | void Application::renderRearViewMirror(const QRect& region, bool billboard) { |
| 3088 | bool eyeRelativeCamera = false; | 2926 | bool eyeRelativeCamera = false; |
| 3089 | if (billboard) { | 2927 | if (billboard) { |
| @@ -3333,7 +3171,7 @@ void Application::deleteVoxelAt(const VoxelDetail& voxel) { · 243 unmodified lines | |||
| 3333 | _voxelEditSender.sendVoxelEditMessage(PacketTypeVoxelErase, voxel); | 3171 | _voxelEditSender.sendVoxelEditMessage(PacketTypeVoxelErase, voxel); |
| 3334 | 3172 | ||
| 3335 | // delete it locally to see the effect immediately (and in case no voxel server is present) | 3173 | // delete it locally to see the effect immediately (and in case no voxel server is present) |
| 3336 | _voxels.deleteVoxelAt(voxel.x, voxel.y, voxel.z, voxel.s); | 3174 | _voxels.getTree()->deleteVoxelAt(voxel.x, voxel.y, voxel.z, voxel.s); |
| 3337 | } | 3175 | } |
| 3338 | } | 3176 | } |
| 3339 | 3177 | ||