message: Parse point lights from .vsnray files
diff: @@ -29,6 +29,9 @@ void parse_children(std::shared_ptr<sg::node> parent, rapidjson::Value const& en
  template <typename Object>
  std::shared_ptr<sg::node> parse_camera(Object const& obj);
  +template <typename Object>
  +std::shared_ptr<sg::node> parse_point_light(Object const& obj);
  +
  template <typename Object>
  std::shared_ptr<sg::node> parse_reference(Object const& obj);
  @@ -64,6 +67,10 @@ void parse_children(std::shared_ptr<sg::node> parent, rapidjson::Value const& en
  {
  parent->children().at(i++) = parse_camera(obj);
  }
  + else if (strncmp(type_string.GetString(), "point_light", 11) == 0)
  + {
  + parent->children().at(i++) = parse_camera(obj);
  + }
  else if (strncmp(type_string.GetString(), "reference", 9) == 0)
  {
  parent->children().at(i++) = parse_reference(obj);
  @@ -223,6 +230,85 @@ std::shared_ptr<sg::node> parse_camera(Object const& obj)
  return cam;
  }
  +template <typename Object>
  +std::shared_ptr<sg::node> parse_point_light(Object const& obj)
  +{
  + auto light = std::make_shared<sg::point_light>();
  +
  + vec3 position(0.0f);
  + if (obj.HasMember("position"))
  + {
  + auto const& pos = obj["position"];
  +
  + int i = 0;
  + for (auto const& item : pos.GetArray())
  + {
  + position[i++] = item.GetFloat();
  + }
  +
  + if (i != 3)
  + {
  + throw std::runtime_error("");
  + }
  + }
  +
  + vec3 cl(0.0f);
  + if (obj.HasMember("cl"))
  + {
  + auto const& color = obj["cl"];
  +
  + int i = 0;
  + for (auto const& item : color.GetArray())
  + {
  + cl[i++] = item.GetFloat();
  + }
  +
  + if (i != 3)
  + {
  + throw std::runtime_error("");
  + }
  + }
  +
  + float kl = 1.0f;
  + if (obj.HasMember("kl"))
  + {
  + kl = obj["kl"].GetFloat();
  + }
  +
  + float constant_attenuation = 1.0f;
  + if (obj.HasMember("constant_attenuation"))
  + {
  + constant_attenuation = obj["constant_attenuation"].GetFloat();
  + }
  +
  + float linear_attenuation = 0.0f;
  + if (obj.HasMember("linear_attenuation"))
  + {
  + linear_attenuation = obj["linear_attenuation"].GetFloat();
  + }
  +
  + float quadratic_attenuation = 0.0f;
  + if (obj.HasMember("quadratic_attenuation"))
  + {
  + quadratic_attenuation = obj["quadratic_attenuation"].GetFloat();
  + }
  +
  + light->set_position(position);
  + light->set_cl(cl);
  + light->set_kl(kl);
  + light->set_constant_attenuation(constant_attenuation);
  + light->set_linear_attenuation(linear_attenuation);
  + light->set_quadratic_attenuation(quadratic_attenuation);
  +
  + if (obj.HasMember("children"))
  + {
  + rapidjson::Value const& children = obj["children"];
  + parse_children(light, children);
  + }
  +
  + return light;
  +}
  +
  template <typename Object>
  std::shared_ptr<sg::node> parse_reference(Object const& obj)
  {
  