History

Render voxel cursor on heightfields, too.

Andrzej Kapolka committed 12 years ago

Commit fba383f1 parent 394bf2b5 files · +25 −41Browse files

Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 5 files). Show all

Unified · Split

interface/src/MetavoxelSystem.cpp+18−5
@@ -533,8 +533,10 @@ void MetavoxelSystem::renderHeightfieldCursor(const glm::vec3& position, float r · 532 unmodified lines
533 float scale = 1.0f / radius;533 float scale = 1.0f / radius;
534 glm::vec4 sCoefficients(scale, 0.0f, 0.0f, -scale * position.x);534 glm::vec4 sCoefficients(scale, 0.0f, 0.0f, -scale * position.x);
535 glm::vec4 tCoefficients(0.0f, 0.0f, scale, -scale * position.z);535 glm::vec4 tCoefficients(0.0f, 0.0f, scale, -scale * position.z);
536 glm::vec4 rCoefficients(0.0f, 0.0f, 0.0f, 0.0f);
536 glTexGenfv(GL_S, GL_EYE_PLANE, (const GLfloat*)&sCoefficients);537 glTexGenfv(GL_S, GL_EYE_PLANE, (const GLfloat*)&sCoefficients);
537 glTexGenfv(GL_T, GL_EYE_PLANE, (const GLfloat*)&tCoefficients);538 glTexGenfv(GL_T, GL_EYE_PLANE, (const GLfloat*)&tCoefficients);
539 glTexGenfv(GL_R, GL_EYE_PLANE, (const GLfloat*)&rCoefficients);
538 glActiveTexture(GL_TEXTURE0);540 glActiveTexture(GL_TEXTURE0);
539 541
540 glm::vec3 extents(radius, radius, radius);542 glm::vec3 extents(radius, radius, radius);
@@ -575,12 +577,23 @@ void MetavoxelSystem::renderVoxelCursor(const glm::vec3& position, float radius) · 34 unmodified lines
575 glActiveTexture(GL_TEXTURE0);577 glActiveTexture(GL_TEXTURE0);
576 578
577 glm::vec3 extents(radius, radius, radius);579 glm::vec3 extents(radius, radius, radius);
578 CursorRenderVisitor visitor(Application::getInstance()->getMetavoxels()->getVoxelBufferAttribute(),580 Box bounds(position - extents, position + extents);
579 Box(position - extents, position + extents));581 CursorRenderVisitor voxelVisitor(Application::getInstance()->getMetavoxels()->getVoxelBufferAttribute(), bounds);
580 guideToAugmented(visitor);582 guideToAugmented(voxelVisitor);
581 583
582 DefaultMetavoxelRendererImplementation::getVoxelCursorProgram().release();584 DefaultMetavoxelRendererImplementation::getVoxelCursorProgram().release();
583 585
586 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
587
588 DefaultMetavoxelRendererImplementation::getHeightfieldCursorProgram().bind();
589
590 CursorRenderVisitor heightfieldVisitor(Application::getInstance()->getMetavoxels()->getHeightfieldBufferAttribute(),
591 bounds);
592 guideToAugmented(heightfieldVisitor);
593
594 DefaultMetavoxelRendererImplementation::getHeightfieldCursorProgram().release();
595
596 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
584 glDisableClientState(GL_VERTEX_ARRAY);597 glDisableClientState(GL_VERTEX_ARRAY);
585 598
586 glDisable(GL_POLYGON_OFFSET_FILL);599 glDisable(GL_POLYGON_OFFSET_FILL);
@@ -1450,7 +1463,7 @@ void DefaultMetavoxelRendererImplementation::init() { · 863 unmodified lines
1450 _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() +1463 _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() +
1451 "shaders/metavoxel_heightfield_cursor.vert");1464 "shaders/metavoxel_heightfield_cursor.vert");
1452 _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() +1465 _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() +
1453 "shaders/metavoxel_heightfield_cursor.frag");1466 "shaders/metavoxel_cursor.frag");
1454 _heightfieldCursorProgram.link();1467 _heightfieldCursorProgram.link();
1455 1468
1456 _heightfieldCursorProgram.bind();1469 _heightfieldCursorProgram.bind();
@@ -1468,7 +1481,7 @@ void DefaultMetavoxelRendererImplementation::init() { · 11 unmodified lines
1468 _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() +1481 _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() +
1469 "shaders/metavoxel_voxel_cursor.vert");1482 "shaders/metavoxel_voxel_cursor.vert");
1470 _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() +1483 _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() +
1471 "shaders/metavoxel_voxel_cursor.frag");1484 "shaders/metavoxel_cursor.frag");
1472 _voxelCursorProgram.link();1485 _voxelCursorProgram.link();
1473 }1486 }
1474}1487}