当前位置: 首页>>代码示例>>C++>>正文


C++ QStringRef::toFloat方法代码示例

本文整理汇总了C++中QStringRef::toFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringRef::toFloat方法的具体用法?C++ QStringRef::toFloat怎么用?C++ QStringRef::toFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QStringRef的用法示例。


在下文中一共展示了QStringRef::toFloat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LoadBxDF

BxDF* XMLReader::LoadBxDF(QXmlStreamReader &xml_reader)
{
    BxDF* result = NULL;
    //First check what type of material we're supposed to load
    QXmlStreamAttributes attribs(xml_reader.attributes());
    QStringRef type = attribs.value(QString(), QString("type"));
    if(QStringRef::compare(type, QString("lambert")) == 0)
    {
        glm::vec3 diffuseColor(0.5f);
        QStringRef color = attribs.value(QString(), QString("diffuseColor"));
        if(QStringRef::compare(color, QString("")) != 0)
        {
            diffuseColor = ToVec3(color);
        }
        result = new LambertBxDF(diffuseColor);
    }
    else if(QStringRef::compare(type, QString("specularReflection")) == 0)
    {
        glm::vec3 refl_color(0.5f);
        QStringRef color = attribs.value(QString(), QString("reflectionColor"));
        if(QStringRef::compare(color, QString("")) != 0)
        {
            refl_color = ToVec3(color);
        }
        result = new SpecularReflectionBxDF(refl_color);
    }
    else if(QStringRef::compare(type, QString("blinnMicrofacet")) == 0)
    {
        glm::vec3 refl_color(0.5f);
        QStringRef color = attribs.value(QString(), QString("reflectionColor"));
        if(QStringRef::compare(color, QString("")) != 0)
        {
            refl_color = ToVec3(color);
        }
        result = new BlinnMicrofacetBxDF(refl_color);

        QStringRef exponent = attribs.value(QString(), QString("exponent"));
        if(QStringRef::compare(exponent, QString("")) != 0)
        {
            ((BlinnMicrofacetBxDF*)result)->exponent = exponent.toFloat();
        }
    }

    else if(QStringRef::compare(type, QString("anisotropic")) == 0)
    {
        glm::vec3 refl_color(0.5f);
        QStringRef color = attribs.value(QString(), QString("reflectionColor"));
        if(QStringRef::compare(color, QString("")) != 0)
        {
            refl_color = ToVec3(color);
        }

        float exp1 = 4.0f;
        QStringRef e1 = attribs.value(QString(), QString("exponent1"));
        if(QStringRef::compare(e1, QString("")) != 0)
        {
            exp1 =  e1.toFloat();
        }

        float exp2 = 20.0f;
        QStringRef e2 = attribs.value(QString(), QString("exponent2"));
        if(QStringRef::compare(e2, QString("")) != 0)
        {
            exp2 =  e2.toFloat();
        }
        result = new AnisotropicBxDF(refl_color, exp1, exp2);
    }

    else if(QStringRef::compare(type, QString("phong")) == 0)
    {
        glm::vec3 diffuseColor(0.5f);
        QStringRef diffuse_color = attribs.value(QString(), QString("diffuseColor"));
        if(QStringRef::compare(diffuse_color, QString("")) != 0)
        {
            diffuseColor = ToVec3(diffuse_color);
        }

        glm::vec3 specularColor(1);
        QStringRef specular_color = attribs.value(QString(), QString("specularColor"));
        if(QStringRef::compare(specular_color, QString("")) != 0)
        {
            specularColor = ToVec3(specular_color);
        }

        float specularPower = 5.0f;
        QStringRef specular_power = attribs.value(QString(), QString("specularPower"));
        if(QStringRef::compare(specular_power, QString("")) != 0)
        {
            specularPower = specular_power.toFloat();
        }

        result = new PhongBxDF(diffuseColor, specularColor, specularPower);
    }
    else if(QStringRef::compare(type, QString("transmission")) == 0)
    {

        float ei = 1.0f;
        float et = 1.0f;

        QStringRef eta_i = attribs.value(QString(), QString("etai"));
//.........这里部分代码省略.........
开发者ID:zimengyang,项目名称:Graphics_MIS_PT,代码行数:101,代码来源:xmlreader.cpp

示例2: parse

bool MmRendererMetaData::parse(const QString &contextName)
{
    clear();
    QString fileName =
            QString("/pps/services/multimedia/renderer/context/%1/metadata").arg(contextName);

    // In newer OS versions, the filename is "metadata0", not metadata, so try both.
    if (!QFile::exists(fileName))
        fileName += '0';

    QFile metaDataFile(fileName);
    if (!metaDataFile.open(QFile::ReadOnly)) {
        qWarning() << "Unable to open media metadata file" << fileName << ":"
                   << metaDataFile.errorString();
        return false;
    }

    const QString separator("::");
    QTextStream stream(&metaDataFile);
    Q_FOREVER {
        const QString line = stream.readLine();
        if (line.isNull())
            break;

        const int separatorPos = line.indexOf(separator);
        if (separatorPos != -1) {
            const QStringRef key = line.leftRef(separatorPos);
            const QStringRef value = line.midRef(separatorPos + separator.length());

            if (key == durationKey)
                m_duration = value.toLongLong();
            else if (key == widthKey)
                m_width = value.toInt();
            else if (key == heightKey)
                m_height = value.toInt();
            else if (key == mediaTypeKey)
                m_mediaType = value.toInt();
            else if (key == pixelWidthKey)
                m_pixelWidth = value.toFloat();
            else if (key == pixelHeightKey)
                m_pixelHeight = value.toFloat();
            else if (key == titleKey)
                m_title = value.toString();
            else if (key == seekableKey)
                m_seekable = !(value == QLatin1String("0"));
            else if (key == artistKey)
                m_artist = value.toString();
            else if (key == commentKey)
                m_comment = value.toString();
            else if (key == genreKey)
                m_genre = value.toString();
            else if (key == yearKey)
                m_year = value.toInt();
            else if (key == bitRateKey)
                m_audioBitRate = value.toInt();
            else if (key == sampleKey)
                m_sampleRate = value.toInt();
            else if (key == albumKey)
                m_album = value.toString();
            else if (key == trackKey)
                m_track = value.toInt();
        }
    }

    return true;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:66,代码来源:mmrenderermetadata.cpp

示例3: LoadMaterial

Material* XMLReader::LoadMaterial(QXmlStreamReader &xml_reader, const QStringRef &local_path, QMap<QString, QList<Material *> > &map)
{
    Material* result;
    bool weighted_material = false;
    //First check what type of material we're supposed to load
    QXmlStreamAttributes attribs(xml_reader.attributes());
    QStringRef type = attribs.value(QString(), QString("type"));
    if(QStringRef::compare(type, QString("default")) == 0)
    {
        result = new Material();
    }
    else if(QStringRef::compare(type, QString("light")) == 0)
    {
        result = new LightMaterial();
        result->is_light_source = true;
        QStringRef intensity = attribs.value(QString(), QString("intensity"));
        if(QStringRef::compare(intensity, QString("")) != 0)
        {
            result->intensity = intensity.toFloat();
        }
    }
    else if(QStringRef::compare(type, QString("weighted")) == 0)
    {
        result = new WeightedMaterial();
        weighted_material = true;
        //weights are handled below
    }
    else
    {
        std::cout << "Could not parse the material!" << std::endl;
        return NULL;
    }

    result->name = attribs.value(QString(), QString("name")).toString();

    while(!xml_reader.isEndElement() || QStringRef::compare(xml_reader.name(), QString("material")) != 0)
    {
        xml_reader.readNext();
        QString tag(xml_reader.name().toString());
        if(QString::compare(tag, QString("baseColor")) == 0)
        {
            xml_reader.readNext();
            if(xml_reader.isCharacters())
            {
                result->base_color = ToVec3(xml_reader.text());
            }
            xml_reader.readNext();
        }
        else if(QString::compare(tag, QString("bxdf")) == 0)
        {
            //Add the Material to the map of BxDF names to Materials so that we can assign it a BxDF later
            xml_reader.readNext();
            if(xml_reader.isCharacters())
            {
                QString bxdf_name = xml_reader.text().toString();
                QList<Material*> list = map.value(bxdf_name);
                list.append(result);
                map.insert(bxdf_name, list);
                xml_reader.readNext();

            }
        }
        else if(QString::compare(tag, QString("texture")) == 0)
        {
            result->texture = LoadTextureFile(xml_reader, local_path);
        }
        else if(QString::compare(tag, QString("normalMap")) == 0)
        {
            result->normal_map = LoadTextureFile(xml_reader, local_path);
        }
        else if(QString::compare(tag, QString("weight")) == 0 && weighted_material)
        {
            xml_reader.readNext();
            float weight;
            if(xml_reader.isCharacters())
            {
                weight = xml_reader.text().toFloat();
            }
            ((WeightedMaterial*)result)->bxdf_weights.append(weight);
            xml_reader.readNext(); // add this line
        }
    }
    return result;
}
开发者ID:zimengyang,项目名称:Graphics_MIS_PT,代码行数:84,代码来源:xmlreader.cpp


注:本文中的QStringRef::toFloat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。