示例#1
0
void Loader::setupPropertyKeysJson(Property<float>& prop, const ofJson& json, float scale, float offset)
{
	for(auto key = json.begin(); key != json.end(); ++key) {
		const string& name = key.key();
		int key_frame = ofToInt(name);
		float value = json.value(name, 0)*scale+offset;
		prop.addKey(key_frame, value);
	}
}
示例#2
0
void Loader::setupPropertyKeysJson(Property<ofFloatColor>& prop, const ofJson& json, const ofFloatColor& scale, const ofFloatColor& offset)
{
	for(auto key = json.begin(); key != json.end(); ++key) {
		const string& name = key.key();
		int key_frame = ofToInt(name);
		ofFloatColor value = ofFloatColor(json[name][0], json[name][1], json[name][2])*scale+offset;
		prop.addKey(key_frame, value);
	}
}
示例#3
0
void Loader::setupPropertyKeysJson(Property<bool>& prop, const ofJson& json)
{
	for(auto key = json.begin(); key != json.end(); ++key) {
		const string& name = key.key();
		int key_frame = ofToInt(name);
		bool value = json[name];
		prop.addKey(key_frame, value);
	}
}
示例#4
0
文件: Scenes.cpp 项目: t3kt/memory
void Scene::readJson(const ofJson &obj) {
  _name = JsonUtil::fromJsonField<std::string>(obj, "name", "scene");
  _nodes.clear();
  auto iter = obj.find("nodes");
  if (iter != obj.end() && !iter.value().is_null()) {
    const auto& nodesArray = iter.value();
    JsonUtil::assertIsArray(nodesArray);
    for (const auto& nodeObj : nodesArray) {
      JsonUtil::assertIsObject(nodeObj);
      std::string typeName = nodeObj["type"];
      auto node = createNode(typeName);
      if (!node) {
        continue;
      }
      _nodes.insert(std::make_pair(node->id(), node));
    }
  }
}