Ejemplo n.º 1
0
Texture::Specification::Specification(const Any& any, bool assumesRGBForAuto, Dimension defaultDimension) {
    *this = Specification();
    assumeSRGBSpaceForAuto = assumesRGBForAuto;
    dimension              = defaultDimension;

    if (any.type() == Any::STRING) {
        filename = any.string();
        if (filename == "<whiteCube>") {
            filename = "<white>";
            dimension = Texture::DIM_CUBE_MAP;
        }

        if (! beginsWith(filename, "<")) {
            filename = any.resolveStringAsFilename();
            if (FilePath::containsWildcards(filename)) {

                // Assume this is a cube map
                dimension = Texture::DIM_CUBE_MAP;
            }
        }
    } else if ((any.type() == Any::NUMBER) ||
               any.nameBeginsWith("Color4") || 
			   anyNameIsColor3Variant(any)) {
        filename = "<white>";
        encoding.readMultiplyFirst = Color4(any);
    } else {

        any.verifyNameBeginsWith("Texture::Specification");
        AnyTableReader r(any);
        r.getFilenameIfPresent("filename", filename);
        r.getFilenameIfPresent("alphaFilename", alphaFilename);
        r.getIfPresent("encoding", encoding);
        r.getIfPresent("assumeSRGBSpaceForAuto", assumeSRGBSpaceForAuto);
        {
            Any a;
            if (r.getIfPresent("dimension", a)) {
                dimension = toDimension(a);
            }
        }
        r.getIfPresent("generateMipMaps", generateMipMaps);
        r.getIfPresent("preprocess", preprocess);
        r.getIfPresent("visualization", visualization);
        r.getIfPresent("cachable", cachable);
        r.verifyDone();

        if (! any.containsKey("dimension") && FilePath::containsWildcards(filename)) {
            // Assume this is a cube map
            dimension = Texture::DIM_CUBE_MAP;
        }
    }
}
ArticulatedModel::Specification::Specification(const Any& a) {
    *this = Specification();
    AnyTableReader r(a);
    Any f;
    r.getIfPresent("filename",                  f);
    filename = f.resolveStringAsFilename();

    r.getIfPresent("stripMaterials",            stripMaterials);
    r.getIfPresent("mergeMeshesByMaterial",     mergeMeshesByMaterial);
    r.getIfPresent("cleanGeometrySettings",     cleanGeometrySettings);
    r.getIfPresent("scale",                     scale);
    r.getIfPresent("preprocess",                preprocess);

    r.verifyDone();
}
Ejemplo n.º 3
0
BumpMap::Specification::Specification(const Any& any) {
    if (any.type() == Any::STRING) {
        // Treat as a filename
        texture.filename = any.resolveStringAsFilename();
        texture.preprocess = Texture::Preprocess::normalMap();
    } else {
        for (Any::AnyTable::Iterator it = any.table().begin(); it.hasMore(); ++it) {
            const std::string& key = toLower(it->key);
            if (key == "texture") {
                texture = it->value;
                if (it->value.type() == Any::STRING) {
                    // Set bump map defaults
                    texture.preprocess = Texture::Preprocess::normalMap();
                }
            } else if (key == "settings") {
                settings = it->value;
            } else {
                any.verify(false, "Illegal key: " + it->key);        
            }
        }
    }
}