Пример #1
0
void CameraProperty::inportChanged() {
    if (!adjustCameraOnDataChange_) return;

    VolumeInport* volumeInport = dynamic_cast<VolumeInport*>(inport_);
    MeshInport* meshInport = dynamic_cast<MeshInport*>(inport_);

    // using SpatialEntity since Geometry is not derived from data
    const SpatialEntity<3>* data = nullptr;

    if (volumeInport) {
        data = volumeInport->getData().get();
    } else if (meshInport) {
        data = meshInport->getData().get();
    }

    if (data_ == nullptr && prevDataToWorldMatrix_ == mat4(0.0f)) {  // first time only
        if (volumeInport && volumeInport->hasData()) {
            prevDataToWorldMatrix_ =
                volumeInport->getData()->getCoordinateTransformer().getDataToWorldMatrix();
        } else if (meshInport && meshInport->hasData()) {
            prevDataToWorldMatrix_ =
                meshInport->getData()->getCoordinateTransformer().getDataToWorldMatrix();
        }
    } else if (data && data_ != data) {
        adjustCameraToData(prevDataToWorldMatrix_,
                           data->getCoordinateTransformer().getDataToWorldMatrix());
    }

    data_ = data;
}
Пример #2
0
void setShaderUniforms(Shader& shader, const VolumeInport& port, const std::string& samplerID) {
    setShaderUniforms(shader, *port.getData(), samplerID);
}
Пример #3
0
void bindTexture(const VolumeInport& inport, const TextureUnit& texUnit) {
    bindTexture(*inport.getData(), texUnit);
}