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


C++ MapList::empty方法代码示例

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


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

示例1: compile


//.........这里部分代码省略.........
        "vec4 sampleDiffuse(float map, vec2 coord) {\n"
        "	return texture(diffuseArray, vec3(coord, map));\n"
        "}\n";

    source +=
        "vec4 sampleNormal(float map, vec2 coord) {\n"
        "	vec4 n = texture(diffuseArray, vec3(coord, map));\n"
        "	return vec4(n.xyz * 2.0 - 1.0, n.w);\n"
        "}\n\n\n";

    // Main function
    source +=
        "// Main shader function\n"
        "void main() {\n"
        "	vec4 diffuse = vec4(1,1,1,1);\n"
        "	vec4 normal = vec4(0,1,0,0);\n"
        "	float gloss = 0.0;\n"
        "	float height;\n"
        "	float weight;\n"
        "	vec4 diff, norm;\n"
        "	vec3 triplanar = max( (abs(worldNormal) - 0.2) * 0.7, 0.0);\n"
        "	triplanar /= dot(triplanar, vec3(1,1,1));\n"
        "	vec3 autoValue = vec3(worldPos.y, 1.0 - worldNormal.y, 0.0);\n"
        "	\n";

    // Vertical projection data
    source +=
        "	vec3 vertical = vec3(triplanar.x, 0, triplanar.z);\n"
        "	vertical /= triplanar.y>0.99? 1: dot(vertical, vec3(1,1,1));\n\n";



    // Sample maps
    if(!maps.empty()) {
        source +=  "	// Sample maps\n";
        for(MapList::iterator i=maps.begin(); i!=maps.end(); ++i) {
            source +=  "	vec4 " + *i + "Sample = sampleMap(" + *i + "Map, " + *i + "Info, worldPos.xz);\n";
        }
        source += "\n";
    }

    // Apply layers
    const std::string rgba[] = { "r", "g", "b", "a" };
    for(size_t i=0; i<m_layers.size(); ++i) {
        std::string index = str(i);
        MaterialLayer* layer = m_layers[i];
        Colour colour(layer->colour);
        bool valid = true;

        source +=  "	// Layer " + str(layer->name) + "\n";

        switch(layer->type) {
        case LAYER_AUTO:
            source +=  "	weight = getAutoWeight(autoValue, autoMin"+index+", autoMax"+index+", autoBlend"+index+");\n";
            break;

        case LAYER_WEIGHT:
            if(!layer->map || !layer->map[0]) valid = false;
            else if(layer->mapData<4)
                source +=  "	weight = " + str(layer->map) + "Sample." + rgba[layer->mapData] + ";\n";
            else
                source +=  "	weight = 1.0 - dot(" + str(layer->map) + "Sample, vec4(1,1,1,1));\n";
            break;

        case LAYER_COLOUR:
            if(!layer->map || !layer->map[0]) valid = false;
开发者ID:sgynn,项目名称:worldeditor,代码行数:67,代码来源:dynamicmaterial.cpp


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