add particles.emit(...) (WIP)
This commit is contained in:
@@ -4,17 +4,32 @@
|
||||
|
||||
dv::value ParticlesPreset::serialize() const {
|
||||
auto root = dv::object();
|
||||
root["texture"] = texture;
|
||||
root["collision"] = collision;
|
||||
root["lighting"] = lighting;
|
||||
root["max_distance"] = maxDistance;
|
||||
root["spawn_interval"] = spawnInterval;
|
||||
root["lifetime"] = lifetime;
|
||||
root["acceleration"] = dv::to_value(acceleration);
|
||||
root["explosion"] = dv::to_value(explosion);
|
||||
root["size"] = dv::to_value(size);
|
||||
return root;
|
||||
}
|
||||
|
||||
void ParticlesPreset::deserialize(const dv::value& src) {
|
||||
src.at("texture").get(texture);
|
||||
src.at("collision").get(collision);
|
||||
src.at("lighting").get(lighting);
|
||||
src.at("max_distance").get(maxDistance);
|
||||
src.at("spawn_interval").get(spawnInterval);
|
||||
src.at("lifetime").get(lifetime);
|
||||
if (src.has("acceleration")) {
|
||||
dv::get_vec(src["acceleration"], acceleration);
|
||||
}
|
||||
if (src.has("size")) {
|
||||
dv::get_vec(src["size"], size);
|
||||
}
|
||||
if (src.has("explosion")) {
|
||||
dv::get_vec(src["explosion"], explosion);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,20 @@ struct ParticlesPreset : public Serializable {
|
||||
bool lighting = true;
|
||||
/// @brief Max distance of actually spawning particles.
|
||||
float maxDistance = 32.0f;
|
||||
/// @brief Particles spawn interval
|
||||
float spawnInterval = 0.1f;
|
||||
/// @brief Particle life time
|
||||
float lifetime = 5.0f;
|
||||
/// @brief Initial velocity
|
||||
glm::vec3 velocity {};
|
||||
/// @brief Velocity acceleration
|
||||
glm::vec3 acceleration {0.0f, -16.0f, 0.0f};
|
||||
/// @brief Random velocity magnitude applying to spawned particles.
|
||||
glm::vec3 explosion {2.0f};
|
||||
/// @brief Particle size
|
||||
glm::vec3 size {0.1f};
|
||||
/// @brief Texture name
|
||||
std::string texture = "";
|
||||
|
||||
dv::value serialize() const override;
|
||||
void deserialize(const dv::value& src) override;
|
||||
|
||||
Reference in New Issue
Block a user