Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/particlesystemscript.cc')
-rw-r--r--src/render/particlesystemscript.cc297
1 files changed, 156 insertions, 141 deletions
diff --git a/src/render/particlesystemscript.cc b/src/render/particlesystemscript.cc
index 7344aab..2f90f1b 100644
--- a/src/render/particlesystemscript.cc
+++ b/src/render/particlesystemscript.cc
@@ -100,9 +100,38 @@ ParticleSystemScript *ParticleSystemScript::load(const std::string &label)
}
ejector = 0;
continue;
- } else if (inifile.got_section("ejector")) {
+ } else if (inifile.got_section("sprites")) {
if (script) {
ejector = script->add_ejector();
+ ejector->set_type(ParticleEjectorScript::Sprite);
+ } else {
+ inifile.unknown_error("ejector section without particles section");
+ }
+ } else if (inifile.got_section("flares")) {
+ if (script) {
+ ejector = script->add_ejector();
+ ejector->set_type(ParticleEjectorScript::Flare);
+ } else {
+ inifile.unknown_error("ejector section without particles section");
+ }
+ } else if (inifile.got_section("trail")) {
+ if (script) {
+ ejector = script->add_ejector();
+ ejector->set_type(ParticleEjectorScript::Trail);
+ } else {
+ inifile.unknown_error("ejector section without particles section");
+ }
+ } else if (inifile.got_section("flame")) {
+ if (script) {
+ ejector = script->add_ejector();
+ ejector->set_type(ParticleEjectorScript::Flame);
+ } else {
+ inifile.unknown_error("ejector section without particles section");
+ }
+ } else if (inifile.got_section("streak")) {
+ if (script) {
+ ejector = script->add_ejector();
+ ejector->set_type(ParticleEjectorScript::Streak);
} else {
inifile.unknown_error("ejector section without particles section");
}
@@ -115,153 +144,139 @@ ParticleSystemScript *ParticleSystemScript::load(const std::string &label)
if (inifile.in_section("particles")) {
inifile.unknown_key();
- } else if (inifile.in_section("ejector") && ejector) {
+ } else if (script) {
+
+ if (inifile.in_section("sprites") || inifile.in_section("flares") || inifile.in_section("trail") || inifile.in_section("flame") || inifile.in_section("streak")) {
+
+ if (inifile.got_key_string("cull", strval)) {
+ aux::to_label(strval);
+ if (strval.compare("none") == 0) {
+ ejector->set_cull(model::CullNone);
+ } else if (strval.compare("back") == 0) {
+ ejector->set_cull(model::CullBack);
+ } else if (strval.compare("front") == 0) {
+ ejector->set_cull(model::CullFront);
+ } else {
+ inifile.unknown_value();
+ }
+ continue;
- if (inifile.got_key_string("type", strval)) {
- aux::to_label(strval);
- if (strval.compare("sprite") == 0) {
- ejector->set_type(ParticleEjectorScript::Sprite);
- } else if (strval.compare("flare") == 0) {
- ejector->set_type(ParticleEjectorScript::Flare);
- } else if (strval.compare("trail") == 0) {
- ejector->set_type(ParticleEjectorScript::Trail);
- } else if (strval.compare("flame") == 0) {
- ejector->set_type(ParticleEjectorScript::Flame);
- } else if (strval.compare("streak") == 0) {
- ejector->set_type(ParticleEjectorScript::Streak);
- } else {
- inifile.unknown_value();
- }
- continue;
-
- } else if (inifile.got_key_string("cull", strval)) {
- aux::to_label(strval);
- if (strval.compare("none") == 0) {
- ejector->set_cull(model::CullNone);
- } else if (strval.compare("back") == 0) {
- ejector->set_cull(model::CullBack);
- } else if (strval.compare("front") == 0) {
- ejector->set_cull(model::CullFront);
- } else {
- inifile.unknown_value();
- }
- continue;
+ } else if (inifile.got_key_string("texture", strval)) {
+ ejector->set_texture("textures/" + strval);
+ Textures::load(ejector->texture());
+ continue;
+
+ } else if (inifile.got_key_vector2f_opt("speed", ejector->get_speed_vec())) {
+ // convert speed from meters/second to game units/second
+ ejector->get_speed_vec() *= 0.01f;
+ continue;
+
+ } else if (inifile.got_key_float("acceleration", f)) {
+ // convert speed from meters/second to game units/second
+ ejector->set_acceleration(f * 0.01f);
+ continue;
+
+ } else if (inifile.got_key_float("offset", f)) {
+ math::clamp(f, 0.0f, 1.0f);
+ ejector->set_offset(f);
+ continue;
+
+ } else if (inifile.got_key_vector3f_opt("alpha", ejector->get_alpha_vec())) {
+ math::clamp(ejector->get_alpha_vec()[0], 0.0f, 1.0f);
+ math::clamp(ejector->get_alpha_vec()[1], 0.0f, 1.0f);
+ math::clamp(ejector->get_alpha_vec()[2], 0.0f, 1.0f);
+ continue;
+
+ } else if (inifile.got_key_vector3f_opt("radius", ejector->get_radius_vec())) {
+ ejector->get_radius_vec() *= model::SCALE;
+ continue;
+
+ } else if (inifile.got_key_float("spawnradius", f)) {
+ ejector->set_spawn_radius(f * model::SCALE);
+ continue;
+
+ } else if (inifile.got_key_float("cone", f)) {
+ ejector->set_cone(f);
+ continue;
+
+ } else if (inifile.got_key_long("interval", l)) {
+ ejector->set_interval((unsigned long) l);
+ continue;
+
+ } else if (inifile.got_key_long("lifespan", l)) {
+ ejector->set_lifespan((unsigned long) l);
+ continue;
+
+ } else if (inifile.got_key_color("color", ejector->get_color())) {
+ continue;
+
+ } else if (inifile.got_key_bool("engine", b)) {
+ ejector->set_engine(b);
+ continue;
- } else if (inifile.got_key_string("texture", strval)) {
- ejector->set_texture("textures/" + strval);
- Textures::load(ejector->texture());
- continue;
-
- } else if (inifile.got_key_float("speed", f)) {
- // convert speed from meters/second to game units/second
- ejector->set_speed(f * 0.01f);
- continue;
-
- } else if (inifile.got_key_float("acceleration", f)) {
- // convert speed from meters/second to game units/second
- ejector->set_acceleration(f * 0.01f);
- continue;
+ } else if (inifile.got_key_bool("thrust", b)) {
+ ejector->set_thrust(b);
+ continue;
+
+ } else if (inifile.got_key_bool("impulse", b)) {
+ ejector->set_impulse(b);
+ continue;
+
+ } else if (inifile.got_key_bool("entity", b)) {
+ ejector->set_entity(b);
+ continue;
+
+ } else if (inifile.got_key_bool("entitysecond", b)) {
+ ejector->set_entity_second(b);
+ continue;
+
+ } else if (inifile.got_key_bool("entitythird", b)) {
+ if (b) {
+ ejector->set_entity(true);
+ ejector->set_entity_second(true);
+ }
+ continue;
+
+ } else if (inifile.got_key_bool("attached", b)) {
+ ejector->set_attached(b);
+ continue;
+
+ } else if (inifile.got_key_float("angle", yaw)) {
- } else if (inifile.got_key_float("offset", f)) {
- math::clamp(f, 0.0f, 1.0f);
- ejector->set_offset(f);
- continue;
-
- } else if (inifile.got_key_vector3f_opt("alpha", ejector->get_alpha_vec())) {
- math::clamp(ejector->get_alpha_vec()[0], 0.0f, 1.0f);
- math::clamp(ejector->get_alpha_vec()[1], 0.0f, 1.0f);
- math::clamp(ejector->get_alpha_vec()[2], 0.0f, 1.0f);
- continue;
-
- } else if (inifile.got_key_vector3f_opt("radius", ejector->get_radius_vec())) {
- ejector->get_radius_vec() *= model::SCALE;
- continue;
-
- } else if (inifile.got_key_float("spawnradius", f)) {
- ejector->set_spawn_radius(f * model::SCALE);
- continue;
-
- } else if (inifile.got_key_float("cone", f)) {
- ejector->set_cone(f);
- continue;
-
- } else if (inifile.got_key_long("interval", l)) {
- ejector->set_interval((unsigned long) l);
- continue;
-
- } else if (inifile.got_key_long("lifespan", l)) {
- ejector->set_lifespan((unsigned long) l);
- continue;
-
- } else if (inifile.got_key_color("color", ejector->get_color())) {
- continue;
-
- } else if (inifile.got_key_bool("engine", b)) {
- ejector->set_engine(b);
- continue;
+ if (yaw == model::ANGLEUP) {
+ ejector->get_axis().change_pitch(-90.0f);
+ } else if (yaw == model::ANGLEDOWN) {
+ ejector->get_axis().change_pitch(90.0f);
+ } else {
+ ejector->get_axis().change_direction(yaw);
+ }
+ continue;
+
+ } else if (inifile.got_key("angles")) {
+
+ std::istringstream str(inifile.value());
+ if (str >> pitch >> yaw >> roll) {
+ ejector->get_axis().assign(yaw, pitch, roll);
+ } else {
+ inifile.unknown_value();
+ }
+ continue;
- } else if (inifile.got_key_bool("thrust", b)) {
- ejector->set_thrust(b);
- continue;
-
- } else if (inifile.got_key_bool("impulse", b)) {
- ejector->set_impulse(b);
- continue;
-
- } else if (inifile.got_key_bool("entity", b)) {
- ejector->set_entity(b);
- continue;
-
- } else if (inifile.got_key_bool("entitysecond", b)) {
- ejector->set_entity_second(b);
- continue;
-
- } else if (inifile.got_key_bool("entitythird", b)) {
- if (b) {
- ejector->set_entity(true);
- ejector->set_entity_second(true);
- }
- continue;
-
- } else if (inifile.got_key_bool("attached", b)) {
- ejector->set_attached(b);
- continue;
-
- } else if (inifile.got_key_float("angle", yaw)) {
-
- if (yaw == model::ANGLEUP) {
- ejector->get_axis().change_pitch(-90.0f);
- } else if (yaw == model::ANGLEDOWN) {
- ejector->get_axis().change_pitch(90.0f);
- } else {
+ } else if (inifile.got_key_float("pitch", pitch)) {
+ ejector->get_axis().change_pitch(-pitch);
+ continue;
+
+ } else if (inifile.got_key_float("yaw", yaw)) {
ejector->get_axis().change_direction(yaw);
- }
- continue;
-
- } else if (inifile.got_key("angles")) {
-
- std::istringstream str(inifile.value());
- if (str >> pitch >> yaw >> roll) {
- ejector->get_axis().assign(yaw, pitch, roll);
+ continue;
+
+ } else if (inifile.got_key_float("roll", roll)) {
+ ejector->get_axis().change_roll(-roll);
+ continue;
+
} else {
- inifile.unknown_value();
+ inifile.unknown_key();
}
- continue;
-
- } else if (inifile.got_key_float("pitch", pitch)) {
- ejector->get_axis().change_pitch(-pitch);
- continue;
-
- } else if (inifile.got_key_float("yaw", yaw)) {
- ejector->get_axis().change_direction(yaw);
- continue;
-
- } else if (inifile.got_key_float("roll", roll)) {
- ejector->get_axis().change_roll(-roll);
- continue;
-
- } else {
- inifile.unknown_key();
}
}
}