Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 8 files). Show all
Unified · Split
| @@ -454,10 +454,10 @@ float MetavoxelSystem::getHeightfieldHeight(const glm::vec3& location) { · 453 unmodified lines | ||
| 454 | 454 | return visitor.height; |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | −class HeightfieldCursorRenderVisitor : public MetavoxelVisitor { | |
| 457 | +class CursorRenderVisitor : public MetavoxelVisitor { | |
| 458 | 458 | public: |
| 459 | 459 | |
| 460 | − HeightfieldCursorRenderVisitor(const Box& bounds); | |
| 460 | + CursorRenderVisitor(const AttributePointer& attribute, const Box& bounds); | |
| 461 | 461 | |
| 462 | 462 | virtual int visit(MetavoxelInfo& info); |
| 463 | 463 | |
| @@ -466,13 +466,12 @@ private: · 2 unmodified lines | ||
| 466 | 466 | Box _bounds; |
| 467 | 467 | }; |
| 468 | 468 | |
| 469 | −HeightfieldCursorRenderVisitor::HeightfieldCursorRenderVisitor(const Box& bounds) : | |
| 470 | − MetavoxelVisitor(QVector<AttributePointer>() << | |
| 471 | − Application::getInstance()->getMetavoxels()->getHeightfieldBufferAttribute()), | |
| 469 | +CursorRenderVisitor::CursorRenderVisitor(const AttributePointer& attribute, const Box& bounds) : | |
| 470 | + MetavoxelVisitor(QVector<AttributePointer>() << attribute), | |
| 472 | 471 | _bounds(bounds) { |
| 473 | 472 | } |
| 474 | 473 | |
| 475 | −int HeightfieldCursorRenderVisitor::visit(MetavoxelInfo& info) { | |
| 474 | +int CursorRenderVisitor::visit(MetavoxelInfo& info) { | |
| 476 | 475 | if (!info.getBounds().intersects(_bounds)) { |
| 477 | 476 | return STOP_RECURSION; |
| 478 | 477 | } |
| @@ -508,7 +507,8 @@ void MetavoxelSystem::renderHeightfieldCursor(const glm::vec3& position, float r · 29 unmodified lines | ||
| 508 | 507 | glActiveTexture(GL_TEXTURE0); |
| 509 | 508 | |
| 510 | 509 | glm::vec3 extents(radius, radius, radius); |
| 511 | − HeightfieldCursorRenderVisitor visitor(Box(position - extents, position + extents)); | |
| 510 | + CursorRenderVisitor visitor(Application::getInstance()->getMetavoxels()->getHeightfieldBufferAttribute(), | |
| 511 | + Box(position - extents, position + extents)); | |
| 512 | 512 | guideToAugmented(visitor); |
| 513 | 513 | |
| 514 | 514 | DefaultMetavoxelRendererImplementation::getHeightfieldCursorProgram().release(); |
| @@ -521,6 +521,42 @@ void MetavoxelSystem::renderHeightfieldCursor(const glm::vec3& position, float r · 6 unmodified lines | ||
| 521 | 521 | glDepthFunc(GL_LESS); |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | +void MetavoxelSystem::renderVoxelCursor(const glm::vec3& position, float radius) { | |
| 525 | + glDepthFunc(GL_LEQUAL); | |
| 526 | + glEnable(GL_CULL_FACE); | |
| 527 | + glEnable(GL_POLYGON_OFFSET_FILL); | |
| 528 | + glPolygonOffset(-1.0f, -1.0f); | |
| 529 | + | |
| 530 | + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | |
| 531 | + | |
| 532 | + glEnableClientState(GL_VERTEX_ARRAY); | |
| 533 | + | |
| 534 | + DefaultMetavoxelRendererImplementation::getVoxelCursorProgram().bind(); | |
| 535 | + | |
| 536 | + glActiveTexture(GL_TEXTURE4); | |
| 537 | + float scale = 1.0f / radius; | |
| 538 | + glm::vec4 sCoefficients(scale, 0.0f, 0.0f, -scale * position.x); | |
| 539 | + glm::vec4 tCoefficients(0.0f, scale, 0.0f, -scale * position.y); | |
| 540 | + glm::vec4 rCoefficients(0.0f, 0.0f, scale, -scale * position.z); | |
| 541 | + glTexGenfv(GL_S, GL_EYE_PLANE, (const GLfloat*)&sCoefficients); | |
| 542 | + glTexGenfv(GL_T, GL_EYE_PLANE, (const GLfloat*)&tCoefficients); | |
| 543 | + glTexGenfv(GL_R, GL_EYE_PLANE, (const GLfloat*)&rCoefficients); | |
| 544 | + glActiveTexture(GL_TEXTURE0); | |
| 545 | + | |
| 546 | + glm::vec3 extents(radius, radius, radius); | |
| 547 | + CursorRenderVisitor visitor(Application::getInstance()->getMetavoxels()->getVoxelBufferAttribute(), | |
| 548 | + Box(position - extents, position + extents)); | |
| 549 | + guideToAugmented(visitor); | |
| 550 | + | |
| 551 | + DefaultMetavoxelRendererImplementation::getVoxelCursorProgram().release(); | |
| 552 | + | |
| 553 | + glDisableClientState(GL_VERTEX_ARRAY); | |
| 554 | + | |
| 555 | + glDisable(GL_POLYGON_OFFSET_FILL); | |
| 556 | + glDisable(GL_CULL_FACE); | |
| 557 | + glDepthFunc(GL_LESS); | |
| 558 | +} | |
| 559 | + | |
| 524 | 560 | void MetavoxelSystem::deleteTextures(int heightID, int colorID, int textureID) { |
| 525 | 561 | glDeleteTextures(1, (GLuint*)&heightID); |
| 526 | 562 | glDeleteTextures(1, (GLuint*)&colorID); |
| @@ -1170,7 +1206,7 @@ void VoxelBuffer::render(bool cursor) { · 643 unmodified lines | ||
| 1170 | 1206 | |
| 1171 | 1207 | glDrawRangeElements(GL_QUADS, 0, _vertexCount - 1, _indexCount, GL_UNSIGNED_INT, 0); |
| 1172 | 1208 | |
| 1173 | − if (!_materials.isEmpty()) { | |
| 1209 | + if (!(_materials.isEmpty() || cursor)) { | |
| 1174 | 1210 | Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false); |
| 1175 | 1211 | |
| 1176 | 1212 | glDepthFunc(GL_LEQUAL); |
| @@ -1252,7 +1288,7 @@ void VoxelBuffer::render(bool cursor) { · 75 unmodified lines | ||
| 1252 | 1288 | _vertexBuffer.release(); |
| 1253 | 1289 | _indexBuffer.release(); |
| 1254 | 1290 | |
| 1255 | − if (_hermiteCount > 0 && Menu::getInstance()->isOptionChecked(MenuOption::DisplayHermiteData)) { | |
| 1291 | + if (_hermiteCount > 0 && Menu::getInstance()->isOptionChecked(MenuOption::DisplayHermiteData) && !cursor) { | |
| 1256 | 1292 | if (!_hermiteBuffer.isCreated()) { |
| 1257 | 1293 | _hermiteBuffer.create(); |
| 1258 | 1294 | _hermiteBuffer.bind(); |
| @@ -1348,6 +1384,12 @@ void DefaultMetavoxelRendererImplementation::init() { · 89 unmodified lines | ||
| 1348 | 1384 | _baseVoxelProgram.link(); |
| 1349 | 1385 | |
| 1350 | 1386 | loadSplatProgram("voxel", _splatVoxelProgram, _splatVoxelLocations); |
| 1387 | + | |
| 1388 | + _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + | |
| 1389 | + "shaders/metavoxel_voxel_cursor.vert"); | |
| 1390 | + _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + | |
| 1391 | + "shaders/metavoxel_voxel_cursor.frag"); | |
| 1392 | + _voxelCursorProgram.link(); | |
| 1351 | 1393 | } |
| 1352 | 1394 | } |
| 1353 | 1395 | |
| @@ -2577,6 +2619,7 @@ ProgramObject DefaultMetavoxelRendererImplementation::_heightfieldCursorProgram; · 1223 unmodified lines | ||
| 2577 | 2619 | ProgramObject DefaultMetavoxelRendererImplementation::_baseVoxelProgram; |
| 2578 | 2620 | ProgramObject DefaultMetavoxelRendererImplementation::_splatVoxelProgram; |
| 2579 | 2621 | DefaultMetavoxelRendererImplementation::SplatLocations DefaultMetavoxelRendererImplementation::_splatVoxelLocations; |
| 2622 | +ProgramObject DefaultMetavoxelRendererImplementation::_voxelCursorProgram; | |
| 2580 | 2623 | |
| 2581 | 2624 | static void enableClipPlane(GLenum plane, float x, float y, float z, float w) { |
| 2582 | 2625 | GLdouble coefficients[] = { x, y, z, w }; |