示例#1
0
Sampler::Sampler(const Any& any) {
    *this = Sampler::defaults();
    any.verifyNameBeginsWith("Sampler");
    if (any.type() == Any::TABLE) {
        AnyTableReader r(any);
        r.getIfPresent("maxAnisotropy", maxAnisotropy);
        r.getIfPresent("maxMipMap", maxMipMap);
        r.getIfPresent("minMipMap", minMipMap);
        r.getIfPresent("mipBias", mipBias);
        r.getIfPresent("xWrapMode", xWrapMode);
        if (! r.getIfPresent("yWrapMode", yWrapMode)) {
            yWrapMode = xWrapMode;
        }
        r.getIfPresent("depthReadMode", depthReadMode);
        r.getIfPresent("interpolateMode", interpolateMode);
        r.verifyDone();
    } else {
        any.verifySize(0);
        const String& n = any.name();
        if (n == "Sampler::defaults") {
            // Done!
        } else if (n == "Sampler::buffer") {
            *this = Sampler::buffer();
        } else if (n == "Sampler::cubeMap") {
            *this = Sampler::cubeMap();
        } else if (n == "Sampler::shadow") {
            *this = Sampler::shadow();
        } else if (n == "Sampler::video") {
            *this = Sampler::video();
        } else {
            any.verify(false, "Unrecognized name for Sampler constructor or factory method.");
        }
    }
}
示例#2
0
ParticleSystemModel::Emitter::Specification::Specification(const Any& a) {
    a.verifyNameBeginsWith("ParticleSystemModel::Emitter");
    *this = Specification();
    AnyTableReader r(a);
    r.getIfPresent("location", location);
    r.getIfPresent("noisePower", noisePower);
    r.getIfPresent("initialDensity", initialDensity);
    r.getIfPresent("rateCurve", rateCurve);
    r.getIfPresent("coverageFadeInTime", coverageFadeInTime);
    r.getIfPresent("coverageFadeOutTime", coverageFadeOutTime);
    r.getIfPresent("particleLifetimeMean", particleLifetimeMean);
    r.getIfPresent("particleLifetimeVariance", particleLifetimeVariance);
    r.getIfPresent("angularVelocityMean", angularVelocityMean);
    r.getIfPresent("angularVelocityVariance", angularVelocityVariance);
    r.getIfPresent("material", material);
    r.getIfPresent("radiusMean", radiusMean);
    r.getIfPresent("radiusVariance", radiusVariance);
    r.getIfPresent("particleMassDensity", particleMassDensity);
    r.getIfPresent("dragCoefficient", dragCoefficient);

    shapeType = Shape::Type::NONE;
    Any shape;
    if (r.getIfPresent("shape", shape)) {
        if (shape.nameBeginsWith("ArticulatedModel") || (shape.type() == Any::STRING)) {
            shapeType = Shape::Type::MESH;
        } else {
            shapeType = Shape::Type(toUpper(shape.name()));
        }

        switch (shapeType) {
        case Shape::Type::BOX:
            box = Box(shape);
            break;

        case Shape::Type::CYLINDER:
            cylinder = Cylinder(shape);
            break;

        case Shape::Type::SPHERE:
            sphere = Sphere(shape);
            break;

        case Shape::Type::MESH:
            mesh = shape;
            break;

        default:
            shape.verify(false, "Shape must be a Box, Cylinder, Sphere, or ArticulatedModel specification");
        }
    }

    r.getIfPresent("velocityDirectionMean", velocityDirectionMean);
    r.getIfPresent("velocityConeAngleDegrees", velocityConeAngleDegrees);
    r.getIfPresent("velocityMagnitudeMean", velocityMagnitudeMean);
    r.getIfPresent("velocityMagnitudeVariance", velocityMagnitudeVariance);
    r.verifyDone();
}
示例#3
0
ParticleSystemModel::Specification::Specification(const Any& a) {
    *this = Specification();

    if (a.nameBeginsWith("ParticleSystemModel::Emitter")) {        
        emitterArray.append(a);
    } else { 
        a.verifyNameBeginsWith("ParticleSystemModel::Specification");
        Any array = a.get("emitterArray", Any(Any::ARRAY));
        array.getArray(emitterArray);
        hasPhysics = a.get("hasPhysics", true);
    }

}
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;
        }
    }
}
示例#5
0
Matrix4::Matrix4(const Any& any) {
    any.verifyNameBeginsWith("Matrix4", "CFrame", "CoordinateFrame");
    any.verifyType(Any::ARRAY);

    const std::string& name = any.name();
    if (name == "Matrix4") {
        any.verifySize(16);

        for (int r = 0; r < 4; ++r) {
            for (int c = 0; c < 4; ++c) {
                elt[r][c] = any[r * 4 + c];
            }
        }
    } else if (name == "Matrix4::scale") {
        if (any.size() == 1) {
            *this = scale(any[0].floatValue());
        } else if (any.size() == 3) {
            *this = scale(any[0], any[1], any[2]);
        } else {
            any.verify(false, "Matrix4::scale() takes either 1 or 3 arguments");
        }
    } else if (name == "Matrix4::rollDegrees") {
        any.verifySize(1);
        *this = rollDegrees(any[0].floatValue());
    } else if (name == "Matrix4::yawDegrees") {
        any.verifySize(1);
        *this = yawDegrees(any[0].floatValue());
    } else if (name == "Matrix4::pitchDegrees") {
        any.verifySize(1);
        *this = pitchDegrees(any[0].floatValue());
    } else if (name == "Matrix4::translation") {
        if (any.size() == 3) {
            *this = translation(any[0], any[1], any[2]);
        } else {
            any.verify(false, "Matrix4::translation() requires 3 arguments");
        }    
    } else if (name == "Matrix4::diagonal") {
        any.verifySize(4);
        *this = diagonal(any[0], any[1], any[2], any[3]);
    } else if (name == "Matrix4::identity") {
        *this = identity();
    } else if (beginsWith(name, "CFrame") || beginsWith(name, "CoordinateFrame")) {
        *this = CFrame(any);
    } else {
        any.verify(false, "Expected Matrix4 constructor");
    }
}
示例#6
0
Texture::Preprocess::Preprocess(const Any& any) {
    *this = Preprocess::defaults();
    any.verifyNameBeginsWith("Texture::Preprocess");
    if (any.type() == Any::TABLE) {
        for (Any::AnyTable::Iterator it = any.table().begin(); it.isValid(); ++it) {
            const String& key = it->key;
            if (key == "modulate") {
                modulate = Color4(it->value);
            } else if (key == "gammaAdjust") {
                gammaAdjust = it->value;
            } else if (key == "scaleFactor") {
                scaleFactor = it->value;
            } else if (key == "computeMinMaxMean") {
                computeMinMaxMean = it->value;
            } else if (key == "computeNormalMap") {
                computeNormalMap = it->value;
            } else if (key == "convertToPremultipliedAlpha") {
                convertToPremultipliedAlpha = it->value;
            } else if (key == "bumpMapPreprocess") {
                bumpMapPreprocess = it->value;
            } else {
                any.verify(false, "Illegal key: " + it->key);
            }
        }
    } else {
        const String& n = any.name();
        if (n == "Texture::Preprocess::defaults") {
            any.verifySize(0);
        } else if (n == "Texture::Preprocess::gamma") {
            any.verifySize(1);
            *this = Texture::Preprocess::gamma(any[0]);
        } else if (n == "Texture::preprocess::none") {
            any.verifySize(0);
            *this = Texture::Preprocess::none();
        } else if (n == "Texture::Preprocess::quake") {
            any.verifySize(0);
            *this = Texture::Preprocess::quake();
        } else if (n == "Texture::Preprocess::normalMap") {
            any.verifySize(0);
            *this = Texture::Preprocess::normalMap();
        } else {
            any.verify(false, "Unrecognized name for Texture::Preprocess constructor or factory method.");
        }
    }
}