Пример #1
0
tgt::vec4 TransFunc1DKeys::getMeanValue(float segStart, float segEnd) const {
    ivec4 result(0);
    float width = static_cast<float>(tex_->getWidth());
    for (int i = static_cast<int>(segStart*width); i < segEnd*width; ++i)
        result += ivec4(tex_->texel<col4>(i));

    return static_cast<tgt::vec4>(result)/(segEnd*width-segStart*width);
}
Пример #2
0
tgt::vec4 TransFunc1DKeys::getMeanValue(float segStart, float segEnd) const {
    ivec4 result(0);
    if (!tex_ || textureInvalid_) {
        LWARNING("getMeanValue(): texture is invalid");
        return result;
    }

    float width = static_cast<float>(tex_->getWidth());
    for (int i = static_cast<int>(segStart*width); i < segEnd*width; ++i)
        result += ivec4(tex_->texel<col4>(i));

    return static_cast<tgt::vec4>(result)/(segEnd*width-segStart*width);
}
Serializable* KeyValueFactory::createType(const std::string& typeString) {
    using tgt::ivec2;
    using tgt::ivec3;
    using tgt::ivec4;
    using tgt::vec2;
    using tgt::vec3;
    using tgt::vec4;
    using tgt::mat2;
    using tgt::mat3;
    using tgt::mat4;

    if (typeString == "KeyValue_float")
        return new PropertyKeyValue<float>(0, 0);
    else if (typeString == "KeyValue_int")
        return new PropertyKeyValue<int>(0, 0);
    else if (typeString == "KeyValue_bool")
        return new PropertyKeyValue<bool>(0, 0);
    else if (typeString == "KeyValue_ivec2")
        return new PropertyKeyValue<ivec2>(ivec2(0), 0);
    else if (typeString == "KeyValue_ivec3")
        return new PropertyKeyValue<ivec3>(ivec3(0), 0);
    else if (typeString == "KeyValue_ivec4")
        return new PropertyKeyValue<ivec4>(ivec4(0), 0);
    else if (typeString == "KeyValue_vec2")
        return new PropertyKeyValue<vec2>(vec2(0.0f), 0);
    else if (typeString == "KeyValue_vec3")
        return new PropertyKeyValue<vec3>(vec3(0.0f), 0);
    else if (typeString == "KeyValue_vec4")
        return new PropertyKeyValue<vec4>(vec4(0.0f), 0);
    else if (typeString == "KeyValue_mat2")
        return new PropertyKeyValue<mat2>(mat2(0.0f), 0);
    else if (typeString == "KeyValue_mat3")
        return new PropertyKeyValue<mat3>(mat3(0.0f), 0);
    else if (typeString == "KeyValue_mat4")
        return new PropertyKeyValue<mat4>(mat4(0.0f), 0);
    else if (typeString == "KeyValue_Camera")
        return new PropertyKeyValue<tgt::Camera>(tgt::Camera(vec3(0.0f), vec3(0.0f), vec3(0.0f)), 0);
    else if (typeString == "KeyValue_string")
        return new PropertyKeyValue<std::string>("", 0);
    else if (typeString == "KeyValue_ShaderSource")
        return new PropertyKeyValue<ShaderSource>(ShaderSource(), 0);
    else if (typeString == "KeyValue_TransFunc")
        return new PropertyKeyValue<TransFunc*>(new TransFunc(), 0);
    else if (typeString == "KeyValue_VolumeCollection")
        return new PropertyKeyValue<VolumeCollection*>(new VolumeCollection(), 0);
    else if (typeString == "KeyValue_VolumeHandle")
        return new PropertyKeyValue<VolumeHandle*>(new VolumeHandle(), 0);
    else
        return 0;
}