Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 8 files). Show all
Unified · Split
| @@ -608,19 +608,19 @@ const int HeightfieldBuffer::SHARED_EDGE = 1; · 607 unmodified lines | ||
| 608 | 608 | const int HeightfieldBuffer::HEIGHT_EXTENSION = 2 * HeightfieldBuffer::HEIGHT_BORDER + HeightfieldBuffer::SHARED_EDGE; |
| 609 | 609 | |
| 610 | 610 | HeightfieldBuffer::HeightfieldBuffer(const glm::vec3& translation, float scale, |
| 611 | − const QByteArray& height, const QByteArray& color, const QByteArray& texture, | |
| 612 | − const QVector<SharedObjectPointer>& textures) : | |
| 611 | + const QByteArray& height, const QByteArray& color, const QByteArray& material, | |
| 612 | + const QVector<SharedObjectPointer>& materials) : | |
| 613 | 613 | _translation(translation), |
| 614 | 614 | _scale(scale), |
| 615 | 615 | _heightBounds(translation, translation + glm::vec3(scale, scale, scale)), |
| 616 | 616 | _colorBounds(_heightBounds), |
| 617 | 617 | _height(height), |
| 618 | 618 | _color(color), |
| 619 | − _texture(texture), | |
| 620 | − _textures(textures), | |
| 619 | + _material(material), | |
| 620 | + _materials(materials), | |
| 621 | 621 | _heightTextureID(0), |
| 622 | 622 | _colorTextureID(0), |
| 623 | − _textureTextureID(0), | |
| 623 | + _materialTextureID(0), | |
| 624 | 624 | _heightSize(glm::sqrt(height.size())), |
| 625 | 625 | _heightIncrement(scale / (_heightSize - HEIGHT_EXTENSION)), |
| 626 | 626 | _colorSize(glm::sqrt(color.size() / DataBlock::COLOR_BYTES)), |
| @@ -639,11 +639,11 @@ HeightfieldBuffer::~HeightfieldBuffer() { · 12 unmodified lines | ||
| 639 | 639 | // the textures have to be deleted on the main thread (for its opengl context) |
| 640 | 640 | if (QThread::currentThread() != Application::getInstance()->thread()) { |
| 641 | 641 | QMetaObject::invokeMethod(Application::getInstance()->getMetavoxels(), "deleteTextures", |
| 642 | − Q_ARG(int, _heightTextureID), Q_ARG(int, _colorTextureID), Q_ARG(int, _textureTextureID)); | |
| 642 | + Q_ARG(int, _heightTextureID), Q_ARG(int, _colorTextureID), Q_ARG(int, _materialTextureID)); | |
| 643 | 643 | } else { |
| 644 | 644 | glDeleteTextures(1, &_heightTextureID); |
| 645 | 645 | glDeleteTextures(1, &_colorTextureID); |
| 646 | − glDeleteTextures(1, &_textureTextureID); | |
| 646 | + glDeleteTextures(1, &_materialTextureID); | |
| 647 | 647 | } |
| 648 | 648 | } |
| 649 | 649 | |
| @@ -709,23 +709,23 @@ void HeightfieldBuffer::render(bool cursor) { · 59 unmodified lines | ||
| 709 | 709 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, colorSize, colorSize, 0, GL_RGB, GL_UNSIGNED_BYTE, _color.constData()); |
| 710 | 710 | } |
| 711 | 711 | |
| 712 | − if (!_texture.isEmpty()) { | |
| 713 | − glGenTextures(1, &_textureTextureID); | |
| 714 | − glBindTexture(GL_TEXTURE_2D, _textureTextureID); | |
| 712 | + if (!_material.isEmpty()) { | |
| 713 | + glGenTextures(1, &_materialTextureID); | |
| 714 | + glBindTexture(GL_TEXTURE_2D, _materialTextureID); | |
| 715 | 715 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 716 | 716 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 717 | 717 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 718 | 718 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 719 | − int textureSize = glm::sqrt(_texture.size()); | |
| 720 | − glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, textureSize, textureSize, 0, | |
| 721 | − GL_LUMINANCE, GL_UNSIGNED_BYTE, _texture.constData()); | |
| 719 | + int materialSize = glm::sqrt(_material.size()); | |
| 720 | + glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, materialSize, materialSize, 0, | |
| 721 | + GL_LUMINANCE, GL_UNSIGNED_BYTE, _material.constData()); | |
| 722 | 722 | |
| 723 | − _networkTextures.resize(_textures.size()); | |
| 724 | − for (int i = 0; i < _textures.size(); i++) { | |
| 725 | − const SharedObjectPointer texture = _textures.at(i); | |
| 726 | − if (texture) { | |
| 723 | + _networkTextures.resize(_materials.size()); | |
| 724 | + for (int i = 0; i < _materials.size(); i++) { | |
| 725 | + const SharedObjectPointer material = _materials.at(i); | |
| 726 | + if (material) { | |
| 727 | 727 | _networkTextures[i] = Application::getInstance()->getTextureCache()->getTexture( |
| 728 | − static_cast<HeightfieldTexture*>(texture.data())->getURL(), SPLAT_TEXTURE); | |
| 728 | + static_cast<MaterialObject*>(material.data())->getDiffuse(), SPLAT_TEXTURE); | |
| 729 | 729 | } |
| 730 | 730 | } |
| 731 | 731 | } |
| @@ -799,7 +799,7 @@ void HeightfieldBuffer::render(bool cursor) { · 67 unmodified lines | ||
| 799 | 799 | if (cursor) { |
| 800 | 800 | glDrawRangeElements(GL_TRIANGLES, 0, vertexCount - 1, indexCount, GL_UNSIGNED_INT, 0); |
| 801 | 801 | |
| 802 | − } else if (!_textures.isEmpty()) { | |
| 802 | + } else if (!_materials.isEmpty()) { | |
| 803 | 803 | DefaultMetavoxelRendererImplementation::getBaseHeightfieldProgram().bind(); |
| 804 | 804 | DefaultMetavoxelRendererImplementation::getBaseHeightfieldProgram().setUniformValue( |
| 805 | 805 | DefaultMetavoxelRendererImplementation::getBaseHeightScaleLocation(), 1.0f / _heightSize); |
| @@ -826,10 +826,10 @@ void HeightfieldBuffer::render(bool cursor) { · 20 unmodified lines | ||
| 826 | 826 | DefaultMetavoxelRendererImplementation::getSplatTextureOffsetLocation(), |
| 827 | 827 | _translation.x / _scale, _translation.z / _scale); |
| 828 | 828 | |
| 829 | − glBindTexture(GL_TEXTURE_2D, _textureTextureID); | |
| 829 | + glBindTexture(GL_TEXTURE_2D, _materialTextureID); | |
| 830 | 830 | |
| 831 | 831 | const int TEXTURES_PER_SPLAT = 4; |
| 832 | − for (int i = 0; i < _textures.size(); i += TEXTURES_PER_SPLAT) { | |
| 832 | + for (int i = 0; i < _materials.size(); i += TEXTURES_PER_SPLAT) { | |
| 833 | 833 | QVector4D scalesS, scalesT; |
| 834 | 834 | |
| 835 | 835 | for (int j = 0; j < SPLAT_COUNT; j++) { |
| @@ -838,9 +838,9 @@ void HeightfieldBuffer::render(bool cursor) { · 2 unmodified lines | ||
| 838 | 838 | if (index < _networkTextures.size()) { |
| 839 | 839 | const NetworkTexturePointer& texture = _networkTextures.at(index); |
| 840 | 840 | if (texture) { |
| 841 | − HeightfieldTexture* heightfieldTexture = static_cast<HeightfieldTexture*>(_textures.at(index).data()); | |
| 842 | − scalesS[j] = _scale / heightfieldTexture->getScaleS(); | |
| 843 | − scalesT[j] = _scale / heightfieldTexture->getScaleT(); | |
| 841 | + MaterialObject* material = static_cast<MaterialObject*>(_materials.at(index).data()); | |
| 842 | + scalesS[j] = _scale / material->getScaleS(); | |
| 843 | + scalesT[j] = _scale / material->getScaleT(); | |
| 844 | 844 | glBindTexture(GL_TEXTURE_2D, texture->getID()); |
| 845 | 845 | } else { |
| 846 | 846 | glBindTexture(GL_TEXTURE_2D, 0); |
| @@ -1349,7 +1349,7 @@ private: · 502 unmodified lines | ||
| 1349 | 1349 | HeightfieldRegionVisitor::HeightfieldRegionVisitor(const MetavoxelLOD& lod) : |
| 1350 | 1350 | MetavoxelVisitor(QVector<AttributePointer>() << AttributeRegistry::getInstance()->getHeightfieldAttribute() << |
| 1351 | 1351 | AttributeRegistry::getInstance()->getHeightfieldColorAttribute() << |
| 1352 | − AttributeRegistry::getInstance()->getHeightfieldTextureAttribute() << | |
| 1352 | + AttributeRegistry::getInstance()->getHeightfieldMaterialAttribute() << | |
| 1353 | 1353 | Application::getInstance()->getMetavoxels()->getHeightfieldBufferAttribute(), QVector<AttributePointer>() << |
| 1354 | 1354 | Application::getInstance()->getMetavoxels()->getHeightfieldBufferAttribute(), lod), |
| 1355 | 1355 | regionBounds(glm::vec3(FLT_MAX, FLT_MAX, FLT_MAX), glm::vec3(-FLT_MAX, -FLT_MAX, -FLT_MAX)), |
| @@ -1377,12 +1377,12 @@ int HeightfieldRegionVisitor::visit(MetavoxelInfo& info) { · 21 unmodified lines | ||
| 1377 | 1377 | colorContentsSize = extendedColorSize * extendedColorSize * DataBlock::COLOR_BYTES; |
| 1378 | 1378 | } |
| 1379 | 1379 | |
| 1380 | − HeightfieldTextureDataPointer texture = info.inputValues.at(2).getInlineValue<HeightfieldTextureDataPointer>(); | |
| 1381 | − QByteArray textureContents; | |
| 1382 | − QVector<SharedObjectPointer> textures; | |
| 1383 | − if (texture) { | |
| 1384 | − textureContents = texture->getContents(); | |
| 1385 | − textures = texture->getTextures(); | |
| 1380 | + HeightfieldMaterialDataPointer material = info.inputValues.at(2).getInlineValue<HeightfieldMaterialDataPointer>(); | |
| 1381 | + QByteArray materialContents; | |
| 1382 | + QVector<SharedObjectPointer> materials; | |
| 1383 | + if (material) { | |
| 1384 | + materialContents = material->getContents(); | |
| 1385 | + materials = material->getMaterials(); | |
| 1386 | 1386 | } |
| 1387 | 1387 | |
| 1388 | 1388 | const HeightfieldBuffer* existingBuffer = static_cast<const HeightfieldBuffer*>( |
| @@ -1393,12 +1393,12 @@ int HeightfieldRegionVisitor::visit(MetavoxelInfo& info) { · 4 unmodified lines | ||
| 1393 | 1393 | // we already have a buffer of the correct resolution |
| 1394 | 1394 | addRegion(bounds, existingBuffer->getHeightBounds()); |
| 1395 | 1395 | buffer = new HeightfieldBuffer(info.minimum, info.size, existingBuffer->getHeight(), |
| 1396 | − existingBuffer->getColor(), textureContents, textures); | |
| 1396 | + existingBuffer->getColor(), materialContents, materials); | |
| 1397 | 1397 | |
| 1398 | 1398 | } else { |
| 1399 | 1399 | // we must create a new buffer and update its borders |
| 1400 | 1400 | buffer = new HeightfieldBuffer(info.minimum, info.size, QByteArray(heightContentsSize, 0), |
| 1401 | − QByteArray(colorContentsSize, 0), textureContents, textures); | |
| 1401 | + QByteArray(colorContentsSize, 0), materialContents, materials); | |
| 1402 | 1402 | const Box& heightBounds = buffer->getHeightBounds(); |
| 1403 | 1403 | addRegion(bounds, heightBounds); |
| 1404 | 1404 | |
| @@ -1472,7 +1472,7 @@ int HeightfieldUpdateVisitor::visit(MetavoxelInfo& info) { · 67 unmodified lines | ||
| 1472 | 1472 | return STOP_RECURSION; |
| 1473 | 1473 | } |
| 1474 | 1474 | HeightfieldBuffer* newBuffer = new HeightfieldBuffer(info.minimum, info.size, |
| 1475 | − buffer->getHeight(), buffer->getColor(), buffer->getTexture(), buffer->getTextures()); | |
| 1475 | + buffer->getHeight(), buffer->getColor(), buffer->getMaterial(), buffer->getMaterials()); | |
| 1476 | 1476 | _fetchVisitor.init(newBuffer); |
| 1477 | 1477 | _data->guide(_fetchVisitor); |
| 1478 | 1478 | info.outputValues[0] = AttributeValue(_outputs.at(0), encodeInline(BufferDataPointer(newBuffer))); |