ArticulatedModel::PoseSpline::PoseSpline(const Any& any) : castsShadows(true) { any.verifyName("ArticulatedModel::PoseSpline"); for (Any::AnyTable::Iterator it = any.table().begin(); it.isValid(); ++it) { if (it->key == "castsShadows") { castsShadows = it->value; } else { partSpline.getCreate(it->key) = it->value; } } }
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."); } } }
Any Scene::load(const std::string& scene) { std::string filename; clear(); m_modelTable.clear(); m_name = scene; bool isFilename = endsWith(toLower(scene), ".scn.any") || endsWith(toLower(scene), ".Scene.Any"); if (isFilename) { filename = scene; } else { const std::string* f = filenameTable().getPointer(scene); if (f == NULL) { throw "No scene with name '" + scene + "' found in (" + stringJoin(filenameTable().getKeys(), ", ") + ")"; } filename = *f; } Any any; any.load(filename); { const std::string& n = any.get("name", filename); // Ensure that this name appears in the filename table if it does not already, // so that it can be loaded by name in the future. if (! filenameTable().containsKey(n)) { filenameTable().set(n, filename); } } m_sourceAny = any; // Load the lighting environment (do this before loading entities, since some of them may // be lights that will enter this array) bool hasEnvironmentMap = false; if (any.containsKey("localLightingEnvironment")) { m_localLightingEnvironment = any["localLightingEnvironment"]; hasEnvironmentMap = any["localLightingEnvironment"].containsKey("environmentMap"); } // Load the models if (any.containsKey("models")) { Any models = any["models"]; if (models.size() > 0) { for (Any::AnyTable::Iterator it = models.table().begin(); it.isValid(); ++it) { const std::string name = it->key; Any v = it->value; createModel(v, name); } } } // Instance the models if (any.containsKey("entities")) { Any entities = any["entities"]; if (entities.size() > 0) { for (Table<std::string, Any>::Iterator it = entities.table().begin(); it.isValid(); ++it) { const std::string& name = it->key; const std::string& entityType = it->value.name(); createEntity(entityType, name, it->value); } } } shared_ptr<Texture> skyboxTexture = Texture::whiteCube(); Any skyAny; // Use the environment map as a skybox if there isn't one already, and vice versa Array<shared_ptr<Skybox> > skyboxes; getTypedEntityArray<Skybox>(skyboxes); if ( skyboxes.size() == 0 ) { if (any.containsKey("skybox")) { createEntity("Skybox", "skybox", any["skybox"]); m_skybox = typedEntity<Skybox>("skybox"); } else if (hasEnvironmentMap) { m_skybox = Skybox::create("skybox", this, Array<ScaledTexture>(m_localLightingEnvironment.environmentMapArray[0]), Array<SimTime>(0.0), 0, SplineExtrapolationMode::CLAMP, false, false); insert(m_skybox); } else { m_skybox = Skybox::create("skybox", this, Array<ScaledTexture>(ScaledTexture(Texture::whiteCube(), 1.0f)), Array<SimTime>(0.0), 0, SplineExtrapolationMode::CLAMP, false, false); insert(m_skybox); } } if (any.containsKey("environmentMap")) { throw std::string("environmentMap field has been replaced with localLightingEnvironment"); } // Default to using the skybox as an environment map if none is specified. if (! hasEnvironmentMap) { m_localLightingEnvironment.environmentMapArray.append(ScaledTexture(m_skybox->keyframeArray()[0].texture, m_skybox->keyframeArray()[0].constant)); } ////////////////////////////////////////////////////// if (m_cameraArray.size() == 0) { // Create a default camera, back it up from the origin m_cameraArray.append(Camera::create("camera")); m_cameraArray.last()->setFrame(CFrame::fromXYZYPRDegrees(0,1,-5,0,-5)); } setTime(any.get("time", 0.0)); m_lastVisibleChangeTime = m_lastLightChangeTime = m_lastStructuralChangeTime = System::time(); m_defaultCameraName = (std::string)any.get("defaultCamera", ""); // Set the initial positions, repeating a few times to allow // objects defined relative to others to reach a fixed point for (int i = 0; i < 3; ++i) { for (int e = 0; e < m_entityArray.size(); ++e) { m_entityArray[e]->onSimulation(m_time, nan()); } } // Pose objects so that they have bounds. { Array< shared_ptr<Surface> > ignore; onPose(ignore); } return any; }