コード例 #1
0
void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) {
    setHazeMode((ComponentMode)entity->getHazeMode());

    const auto& haze = editHaze();

    const uint32_t hazeMode = entity->getHazeMode();
    haze->setHazeActive(hazeMode == COMPONENT_MODE_ENABLED);
    haze->setAltitudeBased(_hazeProperties.getHazeAltitudeEffect());

    haze->setHazeRangeFactor(graphics::Haze::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeRange()));
    glm::u8vec3 hazeColor = _hazeProperties.getHazeColor();
    haze->setHazeColor(toGlm(hazeColor));
    glm::u8vec3 hazeGlareColor = _hazeProperties.getHazeGlareColor();
    haze->setHazeGlareColor(toGlm(hazeGlareColor));
    haze->setHazeEnableGlare(_hazeProperties.getHazeEnableGlare());
    haze->setHazeGlareBlend(graphics::Haze::convertGlareAngleToPower(_hazeProperties.getHazeGlareAngle()));

    float hazeAltitude = _hazeProperties.getHazeCeiling() - _hazeProperties.getHazeBaseRef();
    haze->setHazeAltitudeFactor(graphics::Haze::convertHazeAltitudeToHazeAltitudeFactor(hazeAltitude));
    haze->setHazeBaseReference(_hazeProperties.getHazeBaseRef());

    haze->setHazeBackgroundBlend(_hazeProperties.getHazeBackgroundBlend());

    haze->setHazeAttenuateKeyLight(_hazeProperties.getHazeAttenuateKeyLight());
    haze->setHazeKeyLightRangeFactor(graphics::Haze::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeKeyLightRange()));
    haze->setHazeKeyLightAltitudeFactor(graphics::Haze::convertHazeAltitudeToHazeAltitudeFactor(_hazeProperties.getHazeKeyLightAltitude()));

    haze->setTransform(entity->getTransform().getMatrix());
}
コード例 #2
0
void ShapeEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) {
    withWriteLock([&] {
        auto userData = entity->getUserData();
        if (_lastUserData != userData) {
            _lastUserData = userData;
            _procedural.setProceduralData(ProceduralData::parse(_lastUserData));
        }

        _shape = entity->getShape();
        _pulseProperties = entity->getPulseProperties();
    });

    void* key = (void*)this;
    AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this] () {
        withWriteLock([&] {
            auto entity = getEntity();
            _position = entity->getWorldPosition();
            _dimensions = entity->getUnscaledDimensions(); // get unscaled to avoid scaling twice
            _orientation = entity->getWorldOrientation();
            updateModelTransformAndBound();
            _renderTransform = getModelTransform(); // contains parent scale, if this entity scales with its parent
            if (_shape == entity::Sphere) {
                _renderTransform.postScale(SPHERE_ENTITY_SCALE);
            }

            _renderTransform.postScale(_dimensions);
        });;
    });
}
コード例 #3
0
void TextEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
    _textColor = toGlm(entity->getTextColor());
    _backgroundColor = toGlm(entity->getBackgroundColor());
    _faceCamera = entity->getFaceCamera();
    _lineHeight = entity->getLineHeight();
    _text = entity->getText();
}
コード例 #4
0
void ZoneEntityRenderer::updateKeyBackgroundFromEntity(const TypedEntityPointer& entity) {
    setSkyboxMode((ComponentMode)entity->getSkyboxMode());

    editBackground();
    setSkyboxColor(toGlm(_skyboxProperties.getColor()));
    setProceduralUserData(entity->getUserData());
    setSkyboxURL(_skyboxProperties.getURL());
}
コード例 #5
0
bool PolyLineEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const {
    return (
        entity->pointsChanged() ||
        entity->strokeWidthsChanged() ||
        entity->normalsChanged() ||
        entity->texturesChanged() ||
        entity->strokeColorsChanged()
    );
}
コード例 #6
0
void LineEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
    entity->resetPointsChanged();
    _linePoints = entity->getLinePoints();
    auto geometryCache = DependencyManager::get<GeometryCache>();
    if (_lineVerticesID == GeometryCache::UNKNOWN_ID) {
        _lineVerticesID = geometryCache->allocateID();
    }
    glm::vec4 lineColor(toGlm(entity->getColor()), entity->getLocalRenderAlpha());
    geometryCache->updateVertices(_lineVerticesID, _linePoints, lineColor);
}
コード例 #7
0
bool ZoneEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const {
    if (entity->keyLightPropertiesChanged() ||
        entity->ambientLightPropertiesChanged() ||
        entity->hazePropertiesChanged() ||
        entity->bloomPropertiesChanged() ||
        entity->skyboxPropertiesChanged()) {

        return true;
    }

    if (_skyboxTextureURL != entity->getSkyboxProperties().getURL()) {
        return true;
    }

    if (entity->getWorldPosition() != _lastPosition) {
        return true;
    }
    if (entity->getScaledDimensions() != _lastDimensions) {
        return true;
    }
    if (entity->getWorldOrientation() != _lastRotation) {
        return true;
    }

    if (entity->getUserData() != _proceduralUserData) {
        return true;
    }

#if 0
    if (_typedEntity->getCompoundShapeURL() != _lastShapeURL) {
        return true;
    }

    if (_model) {
        if (!_model->needsFixupInScene() && (!ZoneEntityItem::getDrawZoneBoundaries() || _entity->getShapeType() != SHAPE_TYPE_COMPOUND)) {
            return true;
        }

        if (_model->needsFixupInScene() && (ZoneEntityItem::getDrawZoneBoundaries() || _entity->getShapeType() == SHAPE_TYPE_COMPOUND)) {
            return true;
        }

        if (_lastModelActive != _model->isActive()) {
            return true;
        }
    }
#endif

    return false;
}
コード例 #8
0
void ZoneEntityRenderer::updateKeySunFromEntity(const TypedEntityPointer& entity) {
    setKeyLightMode((ComponentMode)entity->getKeyLightMode());

    const auto& sunLight = editSunLight();
    sunLight->setType(graphics::Light::SUN);
    sunLight->setPosition(_lastPosition);
    sunLight->setOrientation(_lastRotation);

    // Set the keylight
    sunLight->setColor(ColorUtils::toVec3(_keyLightProperties.getColor()));
    sunLight->setIntensity(_keyLightProperties.getIntensity());
    sunLight->setDirection(entity->getTransform().getRotation() * _keyLightProperties.getDirection());
    sunLight->setCastShadows(_keyLightProperties.getCastShadows());
}
コード例 #9
0
void PolyLineEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) {
    static const QUrl DEFAULT_POLYLINE_TEXTURE = QUrl(PathUtils::resourcesPath() + "images/paintStroke.png");
    QUrl entityTextures = DEFAULT_POLYLINE_TEXTURE;
    if (entity->texturesChanged()) {
        entity->resetTexturesChanged();
        auto textures = entity->getTextures();
        if (!textures.isEmpty()) {
            entityTextures = QUrl(textures);
        }
        _texture = DependencyManager::get<TextureCache>()->getTexture(entityTextures);
    }
    
    
    if (!_texture) {
        _texture = DependencyManager::get<TextureCache>()->getTexture(entityTextures);
    }
}
コード例 #10
0
void ZoneEntityRenderer::updateBloomFromEntity(const TypedEntityPointer& entity) {
    setBloomMode((ComponentMode)entity->getBloomMode());

    const auto& bloom = editBloom();

    bloom->setBloomIntensity(_bloomProperties.getBloomIntensity());
    bloom->setBloomThreshold(_bloomProperties.getBloomThreshold());
    bloom->setBloomSize(_bloomProperties.getBloomSize());
}
コード例 #11
0
void TextEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) {
    void* key = (void*)this;
    AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, entity] () {
        withWriteLock([&] {
            _dimensions = entity->getScaledDimensions();
            updateModelTransformAndBound();
            _renderTransform = getModelTransform();
        });
    });
}
コード例 #12
0
void ZoneEntityRenderer::updateAmbientLightFromEntity(const TypedEntityPointer& entity) {
    setAmbientLightMode((ComponentMode)entity->getAmbientLightMode());

    const auto& ambientLight = editAmbientLight();
    ambientLight->setType(graphics::Light::AMBIENT);
    ambientLight->setPosition(_lastPosition);
    ambientLight->setOrientation(_lastRotation);


    // Set the ambient light
    ambientLight->setAmbientIntensity(_ambientLightProperties.getAmbientIntensity());

    if (_ambientLightProperties.getAmbientURL().isEmpty()) {
        setAmbientURL(_skyboxProperties.getURL());
    } else {
        setAmbientURL(_ambientLightProperties.getAmbientURL());
    }

    ambientLight->setTransform(entity->getTransform().getInverseMatrix());
}
コード例 #13
0
bool ShapeEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const {
    if (_lastUserData != entity->getUserData()) {
        return true;
    }

    if (_color != entity->getColor()) {
        return true;
    }
    if (_alpha != entity->getAlpha()) {
        return true;
    }

    if (_shape != entity->getShape()) {
        return true;
    }

    if (_dimensions != entity->getScaledDimensions()) {
        return true;
    }

    if (_pulseProperties != entity->getPulseProperties()) {
        return true;
    }

    return false;
}
コード例 #14
0
bool GridEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const {
    bool needsUpdate = resultWithReadLock<bool>([&] {
        if (_color != entity->getColor()) {
            return true;
        }

        if (_alpha != entity->getAlpha()) {
            return true;
        }

        if (_followCamera != entity->getFollowCamera()) {
            return true;
        }

        if (_majorGridEvery != entity->getMajorGridEvery()) {
            return true;
        }

        if (_minorGridEvery != entity->getMinorGridEvery()) {
            return true;
        }

        if (_pulseProperties != entity->getPulseProperties()) {
            return true;
        }

        return false;
    });

    return needsUpdate;
}
コード例 #15
0
bool TextEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const {
    if (_text != entity->getText()) {
        return true;
    }

    if (_lineHeight != entity->getLineHeight()) {
        return true;
    }

    if (_textColor != toGlm(entity->getTextColor())) {
        return true;
    }

    if (_backgroundColor != toGlm(entity->getBackgroundColor())) {
        return true;
    }

    if (_dimensions != entity->getScaledDimensions()) {
        return true;
    }

    if (_faceCamera != entity->getFaceCamera()) {
        return true;
    }
    return false;
}
コード例 #16
0
void ShapeEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
    withReadLock([&] {
        if (_procedural.isEnabled() && _procedural.isFading()) {
            float isFading = Interpolate::calculateFadeRatio(_procedural.getFadeStartTime()) < 1.0f;
            _procedural.setIsFading(isFading);
        }
    });

    glm::u8vec3 color = entity->getColor();
    float alpha = entity->getAlpha();
    if (_color != color || _alpha != alpha) {
        _color = color;
        _alpha = alpha;
        _material->setAlbedo(toGlm(_color));
        _material->setOpacity(_alpha);

        auto materials = _materials.find("0");
        if (materials != _materials.end()) {
            materials->second.setNeedsUpdate(true);
        }
    }
}
コード例 #17
0
void ZoneEntityRenderer::updateKeyZoneItemFromEntity(const TypedEntityPointer& entity) {
    // Update rotation values
    editSkybox()->setOrientation(entity->getTransform().getRotation());

    /* TODO: Implement the sun model behavior / Keep this code here for reference, this is how we
    {
    // Set the stage
    bool isSunModelEnabled = this->getStageProperties().getSunModelEnabled();
    sceneStage->setSunModelEnable(isSunModelEnabled);
    if (isSunModelEnabled) {
    sceneStage->setLocation(this->getStageProperties().getLongitude(),
    this->getStageProperties().getLatitude(),
    this->getStageProperties().getAltitude());

    auto sceneTime = sceneStage->getTime();
    sceneTime->setHour(this->getStageProperties().calculateHour());
    sceneTime->setDay(this->getStageProperties().calculateDay());
    }
    }*/
}
コード例 #18
0
void GridEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) {
    withWriteLock([&] {
        _color = entity->getColor();
        _alpha = entity->getAlpha();
        _pulseProperties = entity->getPulseProperties();

        _followCamera = entity->getFollowCamera();
        _majorGridEvery = entity->getMajorGridEvery();
        _minorGridEvery = entity->getMinorGridEvery();
    });

    void* key = (void*)this;
    AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, entity]() {
        withWriteLock([&] {
            _dimensions = entity->getScaledDimensions();
            updateModelTransformAndBound();
            _renderTransform = getModelTransform();
        });
    });
}
コード例 #19
0
void ZoneEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
    if (entity->getShapeType() == SHAPE_TYPE_SPHERE) {
        _renderTransform = getModelTransform();
        _renderTransform.postScale(SPHERE_ENTITY_SCALE);
    }
}
コード例 #20
0
void PolyLineEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
    PolyLineUniforms uniforms;
    uniforms.color = toGlm(entity->getXColor());
    memcpy(&_uniformBuffer.edit<PolyLineUniforms>(), &uniforms, sizeof(PolyLineUniforms));
    auto pointsChanged = entity->pointsChanged();
    auto strokeWidthsChanged = entity->strokeWidthsChanged();
    auto normalsChanged = entity->normalsChanged();
    auto strokeColorsChanged = entity->strokeColorsChanged();
    

    bool isUVModeStretch = entity->getIsUVModeStretch();
    entity->resetPolyLineChanged();

    _polylineTransform = Transform();
    _polylineTransform.setTranslation(entity->getWorldPosition());
    _polylineTransform.setRotation(entity->getWorldOrientation());

    if (pointsChanged) {
        _lastPoints = entity->getLinePoints();
    }
    if (strokeWidthsChanged) {
        _lastStrokeWidths = entity->getStrokeWidths();
    }
    if (normalsChanged) {
        _lastNormals = entity->getNormals();
    }
    if (strokeColorsChanged) {
        _lastStrokeColors = entity->getStrokeColors();
        _lastStrokeColors = _lastNormals.size() == _lastStrokeColors.size() ? _lastStrokeColors : QVector<glm::vec3>({ toGlm(entity->getXColor()) });
    }
    if (pointsChanged || strokeWidthsChanged || normalsChanged || strokeColorsChanged) {
        _empty = std::min(_lastPoints.size(), std::min(_lastNormals.size(), _lastStrokeWidths.size())) < 2;
        if (!_empty) {
            updateGeometry(updateVertices(_lastPoints, _lastNormals, _lastStrokeWidths, _lastStrokeColors, isUVModeStretch, _textureAspectRatio));
        }
    }
}
コード例 #21
0
void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) {
    DependencyManager::get<EntityTreeRenderer>()->updateZone(entity->getID());

    // FIXME one of the bools here could become true between being fetched and being reset, 
    // resulting in a lost update
    bool keyLightChanged = entity->keyLightPropertiesChanged();
    bool ambientLightChanged = entity->ambientLightPropertiesChanged();
    bool skyboxChanged = entity->skyboxPropertiesChanged();
    bool hazeChanged = entity->hazePropertiesChanged();
    bool bloomChanged = entity->bloomPropertiesChanged();

    entity->resetRenderingPropertiesChanged();
    _lastPosition = entity->getWorldPosition();
    _lastRotation = entity->getWorldOrientation();
    _lastDimensions = entity->getScaledDimensions();

    _keyLightProperties = entity->getKeyLightProperties();
    _ambientLightProperties = entity->getAmbientLightProperties();
    _skyboxProperties = entity->getSkyboxProperties();
    _hazeProperties = entity->getHazeProperties();
    _bloomProperties = entity->getBloomProperties();

#if 0
    if (_lastShapeURL != _typedEntity->getCompoundShapeURL()) {
        _lastShapeURL = _typedEntity->getCompoundShapeURL();
        _model.reset();
        _model = std::make_shared<Model>();
        _model->setIsWireframe(true);
        _model->init();
        _model->setURL(_lastShapeURL);
    }

    if (_model && _model->isActive()) {
        _model->setScaleToFit(true, _lastDimensions);
        _model->setSnapModelToRegistrationPoint(true, _entity->getRegistrationPoint());
        _model->setRotation(_lastRotation);
        _model->setTranslation(_lastPosition);
        _model->simulate(0.0f);
    }
#endif

    updateKeyZoneItemFromEntity(entity);

    if (keyLightChanged) {
        updateKeySunFromEntity(entity);
    }

    if (ambientLightChanged) {
        updateAmbientLightFromEntity(entity);
    }

    if (skyboxChanged || _proceduralUserData != entity->getUserData()) {
        updateKeyBackgroundFromEntity(entity);
    }

    if (hazeChanged) {
        updateHazeFromEntity(entity);
    }


    bool visuallyReady = true;
    uint32_t skyboxMode = entity->getSkyboxMode();
    if (skyboxMode == COMPONENT_MODE_ENABLED && !_skyboxTextureURL.isEmpty()) {
        bool skyboxLoadedOrFailed = (_skyboxTexture && (_skyboxTexture->isLoaded() || _skyboxTexture->isFailed()));

        visuallyReady = skyboxLoadedOrFailed;
    }

    entity->setVisuallyReady(visuallyReady);

    if (bloomChanged) {
        updateBloomFromEntity(entity);
    }
}
コード例 #22
0
bool LineEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const {
    return entity->pointsChanged();
}