2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* particles_editor_plugin.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:11:45 +00:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2017-01-01 21:01:57 +00:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-07 22:45:00 +00:00
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
2014-02-10 01:10:30 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
|
|
|
#include "particles_editor_plugin.h"
|
2017-03-18 23:36:26 +00:00
|
|
|
#include "editor/plugins/spatial_editor_plugin.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "io/resource_loader.h"
|
|
|
|
#include "servers/visual/particle_system_sw.h"
|
|
|
|
|
|
|
|
void ParticlesEditor::_node_removed(Node *p_node) {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (p_node == node) {
|
|
|
|
node = NULL;
|
2014-02-10 01:10:30 +00:00
|
|
|
hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void ParticlesEditor::_resource_seleted(const String &p_res) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
//print_line("selected resource path: "+p_res);
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void ParticlesEditor::_node_selected(const NodePath &p_path) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
Node *sel = get_node(p_path);
|
|
|
|
if (!sel)
|
|
|
|
return;
|
|
|
|
|
|
|
|
VisualInstance *vi = sel->cast_to<VisualInstance>();
|
|
|
|
if (!vi) {
|
|
|
|
|
2016-05-04 01:25:37 +00:00
|
|
|
err_dialog->set_text(TTR("Node does not contain geometry."));
|
2015-04-08 17:02:13 +00:00
|
|
|
err_dialog->popup_centered_minsize();
|
2014-02-10 01:10:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
geometry = vi->get_faces(VisualInstance::FACES_SOLID);
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (geometry.size() == 0) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-05-04 01:25:37 +00:00
|
|
|
err_dialog->set_text(TTR("Node does not contain geometry (faces)."));
|
2015-04-08 17:02:13 +00:00
|
|
|
err_dialog->popup_centered_minsize();
|
2014-02-10 01:10:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Transform geom_xform = node->get_global_transform().affine_inverse() * vi->get_global_transform();
|
|
|
|
|
|
|
|
int gc = geometry.size();
|
|
|
|
DVector<Face3>::Write w = geometry.write();
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < gc; i++) {
|
|
|
|
for (int j = 0; j < 3; j++) {
|
|
|
|
w[i].vertex[j] = geom_xform.xform(w[i].vertex[j]);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
w = DVector<Face3>::Write();
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
emission_dialog->popup_centered(Size2(300, 130));
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
void ParticlesEditor::_populate() {
|
|
|
|
|
|
|
|
if(!node)
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (node->get_particles().is_null())
|
|
|
|
return;
|
|
|
|
|
|
|
|
node->get_particles()->set_instance_count(populate_amount->get_text().to_int());
|
|
|
|
node->populate_parent(populate_rotate_random->get_val(),populate_tilt_random->get_val(),populate_scale_random->get_text().to_double(),populate_scale->get_text().to_double());
|
|
|
|
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ParticlesEditor::_notification(int p_notification) {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (p_notification == NOTIFICATION_ENTER_TREE) {
|
|
|
|
options->set_icon(options->get_popup()->get_icon("Particles", "EditorIcons"));
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ParticlesEditor::_menu_option(int p_option) {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
switch (p_option) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
case MENU_OPTION_GENERATE_AABB: {
|
|
|
|
|
|
|
|
Transform globalizer = node->get_global_transform();
|
|
|
|
ParticleSystemSW pssw;
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < VS::PARTICLE_VAR_MAX; i++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
pssw.particle_vars[i] = node->get_variable((Particles::Variable)i);
|
|
|
|
pssw.particle_randomness[i] = node->get_randomness((Particles::Variable)i);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
pssw.emission_half_extents = node->get_emission_half_extents();
|
|
|
|
pssw.emission_points = node->get_emission_points();
|
|
|
|
pssw.emission_base_velocity = node->get_emission_base_velocity();
|
|
|
|
pssw.amount = node->get_amount();
|
|
|
|
pssw.gravity_normal = node->get_gravity_normal();
|
|
|
|
pssw.emitting = true;
|
|
|
|
pssw.height_from_velocity = node->has_height_from_velocity();
|
|
|
|
pssw.color_phase_count = 1;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
ParticleSystemProcessSW pp;
|
2017-03-18 23:36:26 +00:00
|
|
|
float delta = 0.01;
|
|
|
|
float lifetime = pssw.particle_vars[VS::PARTICLE_LIFETIME];
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
Transform localizer = globalizer.affine_inverse();
|
|
|
|
AABB aabb;
|
2017-03-18 23:36:26 +00:00
|
|
|
for (float t = 0; t < lifetime; t += delta) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
pp.process(&pssw, globalizer, delta);
|
|
|
|
for (int i = 0; i < pp.particle_data.size(); i++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
Vector3 p = localizer.xform(pp.particle_data[i].pos);
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (t == 0 && i == 0)
|
|
|
|
aabb.pos = p;
|
2014-02-10 01:10:30 +00:00
|
|
|
else
|
|
|
|
aabb.expand_to(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
aabb.grow_by(aabb.get_longest_axis_size() * 0.2);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
node->set_visibility_aabb(aabb);
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH: {
|
|
|
|
|
|
|
|
emission_file_dialog->popup_centered_ratio();
|
|
|
|
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE: {
|
2017-03-18 23:36:26 +00:00
|
|
|
/*
|
2014-02-10 01:10:30 +00:00
|
|
|
Node *root = get_scene()->get_root_node();
|
|
|
|
ERR_FAIL_COND(!root);
|
|
|
|
EditorNode *en = root->cast_to<EditorNode>();
|
|
|
|
ERR_FAIL_COND(!en);
|
|
|
|
Node * node = en->get_edited_scene();
|
|
|
|
*/
|
|
|
|
emission_tree_dialog->popup_centered_ratio();
|
|
|
|
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ParticlesEditor::edit(Particles *p_particles) {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
node = p_particles;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ParticlesEditor::_generate_emission_points() {
|
|
|
|
|
|
|
|
/// hacer codigo aca
|
|
|
|
DVector<Vector3> points;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (emission_fill->get_selected() == 0) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
float area_accum = 0;
|
|
|
|
Map<float, int> triangle_area_map;
|
|
|
|
print_line("geometry size: " + itos(geometry.size()));
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < geometry.size(); i++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-01-14 17:03:38 +00:00
|
|
|
float area = geometry[i].get_area();
|
2017-03-18 23:36:26 +00:00
|
|
|
if (area < CMP_EPSILON)
|
2014-02-10 01:10:30 +00:00
|
|
|
continue;
|
2017-03-18 23:36:26 +00:00
|
|
|
triangle_area_map[area_accum] = i;
|
|
|
|
area_accum += area;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (!triangle_area_map.size() || area_accum == 0) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-05-04 01:25:37 +00:00
|
|
|
err_dialog->set_text(TTR("Faces contain no area!"));
|
2015-04-08 17:02:13 +00:00
|
|
|
err_dialog->popup_centered_minsize();
|
2014-02-10 01:10:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
int emissor_count = emission_amount->get_val();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < emissor_count; i++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
float areapos = Math::random(0, area_accum);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
Map<float, int>::Element *E = triangle_area_map.find_closest(areapos);
|
2014-02-10 01:10:30 +00:00
|
|
|
ERR_FAIL_COND(!E)
|
|
|
|
int index = E->get();
|
2017-03-18 23:36:26 +00:00
|
|
|
ERR_FAIL_INDEX(index, geometry.size());
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
// ok FINALLY get face
|
|
|
|
Face3 face = geometry[index];
|
|
|
|
//now compute some position inside the face...
|
|
|
|
|
|
|
|
Vector3 pos = face.get_random_point_inside();
|
|
|
|
|
|
|
|
points.push_back(pos);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
int gcount = geometry.size();
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (gcount == 0) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-05-18 22:08:12 +00:00
|
|
|
err_dialog->set_text(TTR("No faces!"));
|
2015-04-08 17:02:13 +00:00
|
|
|
err_dialog->popup_centered_minsize();
|
2014-02-10 01:10:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DVector<Face3>::Read r = geometry.read();
|
|
|
|
|
|
|
|
AABB aabb;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < gcount; i++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int j = 0; j < 3; j++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (i == 0 && j == 0)
|
|
|
|
aabb.pos = r[i].vertex[j];
|
2014-02-10 01:10:30 +00:00
|
|
|
else
|
|
|
|
aabb.expand_to(r[i].vertex[j]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
int emissor_count = emission_amount->get_val();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < emissor_count; i++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
int attempts = 5;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int j = 0; j < attempts; j++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
Vector3 dir;
|
2017-03-18 23:36:26 +00:00
|
|
|
dir[Math::rand() % 3] = 1.0;
|
|
|
|
Vector3 ofs = Vector3(1, 1, 1) - dir;
|
|
|
|
ofs = (Vector3(1, 1, 1) - dir) * Vector3(Math::randf(), Math::randf(), Math::randf()) * aabb.size;
|
|
|
|
ofs += aabb.pos;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
Vector3 ofsv = ofs + aabb.size * dir;
|
|
|
|
|
|
|
|
//space it a little
|
|
|
|
ofs -= dir;
|
|
|
|
ofsv += dir;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
float max = -1e7, min = 1e7;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int k = 0; k < gcount; k++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
const Face3 &f3 = r[k];
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
Vector3 res;
|
2017-03-18 23:36:26 +00:00
|
|
|
if (f3.intersects_segment(ofs, ofsv, &res)) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
res -= ofs;
|
2014-02-10 01:10:30 +00:00
|
|
|
float d = dir.dot(res);
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (d < min)
|
|
|
|
min = d;
|
|
|
|
if (d > max)
|
|
|
|
max = d;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (max < min)
|
2014-02-10 01:10:30 +00:00
|
|
|
continue; //lost attempt
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
float val = min + (max - min) * Math::randf();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
Vector3 point = ofs + dir * val;
|
|
|
|
|
|
|
|
points.push_back(point);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//print_line("point count: "+itos(points.size()));
|
|
|
|
node->set_emission_points(points);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ParticlesEditor::_bind_methods() {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
ObjectTypeDB::bind_method("_menu_option", &ParticlesEditor::_menu_option);
|
|
|
|
ObjectTypeDB::bind_method("_resource_seleted", &ParticlesEditor::_resource_seleted);
|
|
|
|
ObjectTypeDB::bind_method("_node_selected", &ParticlesEditor::_node_selected);
|
|
|
|
ObjectTypeDB::bind_method("_generate_emission_points", &ParticlesEditor::_generate_emission_points);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
//ObjectTypeDB::bind_method("_populate",&ParticlesEditor::_populate);
|
|
|
|
}
|
|
|
|
|
|
|
|
ParticlesEditor::ParticlesEditor() {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
particles_editor_hb = memnew(HBoxContainer);
|
2014-07-10 02:55:03 +00:00
|
|
|
SpatialEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb);
|
2017-03-18 23:36:26 +00:00
|
|
|
options = memnew(MenuButton);
|
2014-07-10 02:55:03 +00:00
|
|
|
particles_editor_hb->add_child(options);
|
|
|
|
particles_editor_hb->hide();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
options->set_text("Particles");
|
2017-03-18 23:36:26 +00:00
|
|
|
options->get_popup()->add_item(TTR("Generate AABB"), MENU_OPTION_GENERATE_AABB);
|
2014-02-10 01:10:30 +00:00
|
|
|
options->get_popup()->add_separator();
|
2017-03-18 23:36:26 +00:00
|
|
|
options->get_popup()->add_item(TTR("Create Emitter From Mesh"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH);
|
|
|
|
options->get_popup()->add_item(TTR("Create Emitter From Node"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE);
|
|
|
|
options->get_popup()->add_item(TTR("Clear Emitter"), MENU_OPTION_CLEAR_EMISSION_VOLUME);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
options->get_popup()->connect("item_pressed", this, "_menu_option");
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
emission_dialog = memnew(ConfirmationDialog);
|
2016-05-04 01:25:37 +00:00
|
|
|
emission_dialog->set_title(TTR("Create Emitter"));
|
2014-02-10 01:10:30 +00:00
|
|
|
add_child(emission_dialog);
|
|
|
|
Label *l = memnew(Label);
|
2017-03-18 23:36:26 +00:00
|
|
|
l->set_pos(Point2(5, 5));
|
2016-05-04 01:25:37 +00:00
|
|
|
l->set_text(TTR("Emission Positions:"));
|
2014-02-10 01:10:30 +00:00
|
|
|
emission_dialog->add_child(l);
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
emission_amount = memnew(SpinBox);
|
|
|
|
emission_amount->set_anchor(MARGIN_RIGHT, ANCHOR_END);
|
|
|
|
emission_amount->set_begin(Point2(20, 23));
|
|
|
|
emission_amount->set_end(Point2(5, 25));
|
2014-02-10 01:10:30 +00:00
|
|
|
emission_amount->set_min(1);
|
|
|
|
emission_amount->set_max(65536);
|
|
|
|
emission_amount->set_val(512);
|
|
|
|
emission_dialog->add_child(emission_amount);
|
2016-05-04 01:25:37 +00:00
|
|
|
emission_dialog->get_ok()->set_text(TTR("Create"));
|
2017-03-18 23:36:26 +00:00
|
|
|
emission_dialog->connect("confirmed", this, "_generate_emission_points");
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
l = memnew(Label);
|
2017-03-18 23:36:26 +00:00
|
|
|
l->set_pos(Point2(5, 50));
|
2016-05-04 01:25:37 +00:00
|
|
|
l->set_text(TTR("Emission Fill:"));
|
2014-02-10 01:10:30 +00:00
|
|
|
emission_dialog->add_child(l);
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
emission_fill = memnew(OptionButton);
|
|
|
|
emission_fill->set_anchor(MARGIN_RIGHT, ANCHOR_END);
|
|
|
|
emission_fill->set_begin(Point2(20, 70));
|
|
|
|
emission_fill->set_end(Point2(5, 75));
|
2016-05-04 01:25:37 +00:00
|
|
|
emission_fill->add_item(TTR("Surface"));
|
|
|
|
emission_fill->add_item(TTR("Volume"));
|
2014-02-10 01:10:30 +00:00
|
|
|
emission_dialog->add_child(emission_fill);
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
err_dialog = memnew(ConfirmationDialog);
|
2014-02-10 01:10:30 +00:00
|
|
|
//err_dialog->get_cancel()->hide();
|
|
|
|
add_child(err_dialog);
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
emission_file_dialog = memnew(EditorFileDialog);
|
2014-02-10 01:10:30 +00:00
|
|
|
add_child(emission_file_dialog);
|
2017-03-18 23:36:26 +00:00
|
|
|
emission_file_dialog->connect("file_selected", this, "_resource_seleted");
|
|
|
|
emission_tree_dialog = memnew(SceneTreeDialog);
|
2014-02-10 01:10:30 +00:00
|
|
|
add_child(emission_tree_dialog);
|
2017-03-18 23:36:26 +00:00
|
|
|
emission_tree_dialog->connect("selected", this, "_node_selected");
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
List<String> extensions;
|
2017-03-18 23:36:26 +00:00
|
|
|
ResourceLoader::get_recognized_extensions_for_type("Mesh", &extensions);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
emission_file_dialog->clear_filters();
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < extensions.size(); i++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
emission_file_dialog->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2015-06-06 12:44:38 +00:00
|
|
|
emission_file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
//options->set_anchor(MARGIN_LEFT,Control::ANCHOR_END);
|
|
|
|
//options->set_anchor(MARGIN_RIGHT,Control::ANCHOR_END);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ParticlesEditorPlugin::edit(Object *p_object) {
|
|
|
|
|
|
|
|
particles_editor->edit(p_object->cast_to<Particles>());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ParticlesEditorPlugin::handles(Object *p_object) const {
|
|
|
|
|
|
|
|
return p_object->is_type("Particles");
|
|
|
|
}
|
|
|
|
|
|
|
|
void ParticlesEditorPlugin::make_visible(bool p_visible) {
|
|
|
|
|
|
|
|
if (p_visible) {
|
|
|
|
particles_editor->show();
|
2014-07-10 02:55:03 +00:00
|
|
|
particles_editor->particles_editor_hb->show();
|
2014-02-10 01:10:30 +00:00
|
|
|
} else {
|
2014-07-10 02:55:03 +00:00
|
|
|
particles_editor->particles_editor_hb->hide();
|
2014-02-10 01:10:30 +00:00
|
|
|
particles_editor->hide();
|
|
|
|
particles_editor->edit(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ParticlesEditorPlugin::ParticlesEditorPlugin(EditorNode *p_node) {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
editor = p_node;
|
|
|
|
particles_editor = memnew(ParticlesEditor);
|
2014-02-10 01:10:30 +00:00
|
|
|
editor->get_viewport()->add_child(particles_editor);
|
|
|
|
|
|
|
|
particles_editor->hide();
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
ParticlesEditorPlugin::~ParticlesEditorPlugin() {
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|