...
 
Commits (3)
This diff is collapsed.
......@@ -63,6 +63,9 @@ EditorPluginFutari::EditorPluginFutari(EditorNode *p_editor) {
Ref<FutariVortexGizmoPlugin> futari_vortex_plugin = Ref<FutariVortexGizmoPlugin>(memnew(FutariVortexGizmoPlugin));
SpatialEditor::get_singleton()->add_gizmo_plugin(futari_vortex_plugin);
Ref<FutariFloorGizmoPlugin> futari_floor_plugin = Ref<FutariFloorGizmoPlugin>(memnew(FutariFloorGizmoPlugin));
SpatialEditor::get_singleton()->add_gizmo_plugin(futari_floor_plugin);
Ref<FutariParticlesGizmoPlugin> futari_particles_plugin = Ref<FutariParticlesGizmoPlugin>(memnew(FutariParticlesGizmoPlugin));
SpatialEditor::get_singleton()->add_gizmo_plugin(futari_particles_plugin);
......
/*
*
*
* _________ ____ .-. _________/ ____ .-. ____
* __|__ (_)_/(_)( )____< \| ( ) (_)
* `-' `-'
*
*
* art & game engine
*
* ____________________________________ ? ____________________________________
* (._.)
*
*
* This file is part of PROJECT_NAME
* For the latest info, see http://polymorph.cool/
*
* Copyright (c) 2019 polymorph.cool
*
* 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.
*
* ___________________________________( ^3^)_____________________________________
*
* ascii font: rotated by MikeChat & myflix
* have fun and be cool :)
*
*
*/
/*
* File: futari_floor.cpp
* Author: frankiezafe
*
* Created on March 27, 2019, 2:53 PM
*/
#include "futari_floor.h"
FutariFloor::FutariFloor() :
infinite(false),
width(1.0),
height(1.0),
up(0, 1, 0)
{
range = FUTARI_FLOOR_MINRANGE;
FutariFloor::_data.ptr = this;
FutariFloor::_data.futari_type = FutariModifierData::FMT_FLOOR;
}
void FutariFloor::set_range(real_t r) {
if (r < FUTARI_FLOOR_MINRANGE) {
range = FUTARI_FLOOR_MINRANGE;
return;
}
range = r;
#ifdef TOOLS_ENABLED
update_gizmo();
#endif
}
void FutariFloor::set_infinite( bool b ) {
infinite = b;
#ifdef TOOLS_ENABLED
update_gizmo();
#endif
}
bool FutariFloor::is_infinite() const {
return infinite;
}
void FutariFloor::set_width( real_t w ) {
width = abs( w );
#ifdef TOOLS_ENABLED
update_gizmo();
#endif
}
real_t FutariFloor::get_width() const {
return width;
}
void FutariFloor::set_height( real_t h ) {
height = abs( h );
#ifdef TOOLS_ENABLED
update_gizmo();
#endif
}
real_t FutariFloor::get_height() const {
return height;
}
FutariModifierData* FutariFloor::data_ptr() {
return (FutariModifierData*) &(FutariFloor::_data);
}
void FutariFloor::refresh() {
_data.reset();
if (!enabled) {
_data.changed_enabled = _data.enabled != enabled;
_data.changed = _data.changed_enabled;
_data.enabled = enabled;
return;
}
Vector3 p = get_global_transform().origin;
Vector3 o = get_rotation();
float s = strength;
if (!is_visible()) {
s *= 0;
}
_data.changed_enabled = _data.enabled != enabled;
_data.changed_position = _data.position != p;
_data.changed_orientation = _data.orientation != o;
_data.changed_strength = _data.strength != s;
_data.changed_strength_decay =
_data.strength_decay != strength_decay_texture ||
_data.strength_decay.is_valid() != strength_decay_texture.is_valid();
_data.changed_lifetime =
_data.lifetime != lifetime_texture ||
_data.lifetime.is_valid() != lifetime_texture.is_valid();
_data.changed_infinite = _data.infinite != infinite;
_data.changed_width = _data.width != width;
_data.changed_height = _data.height != height;
_data.changed_range = _data.range != range;
_data.changed_velocity_mult = _data.velocity_mult != velocity_mult;
_data.changed_position_mult = _data.position_mult != position_mult;
_data.changed =
_data.changed_enabled ||
_data.changed_position ||
_data.changed_orientation ||
_data.changed_strength ||
_data.changed_strength_decay ||
_data.changed_lifetime ||
_data.changed_infinite ||
_data.changed_width ||
_data.changed_height ||
_data.changed_range ||
_data.changed_velocity_mult ||
_data.changed_position_mult;
if (_data.changed) {
_data.enabled = enabled;
_data.position = p;
_data.orientation = o;
_data.strength = s;
_data.strength_decay = strength_decay_texture;
_data.lifetime = lifetime_texture;
_data.infinite = infinite;
_data.width = width;
_data.height = height;
_data.range = range;
_data.velocity_mult = velocity_mult;
_data.position_mult = position_mult;
}
}
void FutariFloor::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_infinite", "infinit"), &FutariFloor::set_infinite);
ClassDB::bind_method(D_METHOD("is_infinite"), &FutariFloor::is_infinite);
ClassDB::bind_method(D_METHOD("set_width", "width"), &FutariFloor::set_width);
ClassDB::bind_method(D_METHOD("get_width"), &FutariFloor::get_width);
ClassDB::bind_method(D_METHOD("set_height", "height"), &FutariFloor::set_height);
ClassDB::bind_method(D_METHOD("get_height"), &FutariFloor::get_height);
ADD_GROUP("Attractor", "attractor_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "get_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "infinite"), "set_infinite", "is_infinite");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "width", PROPERTY_HINT_RANGE, "0,100,or_greater"), "set_width", "get_width");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "0,100,or_greater"), "set_height", "get_height");
String prop = String::num_real(FUTARI_FLOOR_MINRANGE) + ",100,0.01,or_greater";
ADD_PROPERTY(PropertyInfo(Variant::REAL, "range", PROPERTY_HINT_RANGE, prop), "set_range", "get_range");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "strength", PROPERTY_HINT_RANGE, "-500,500,or_greater,or_lesser"), "set_strength", "get_strength");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "strength_decay_texture", PROPERTY_HINT_RESOURCE_TYPE, "GradientTexture"), "set_strength_decay_texture", "get_strength_decay_texture");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "lifetime_texture", PROPERTY_HINT_RESOURCE_TYPE, "GradientTexture"), "set_lifetime_texture", "get_lifetime_texture");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "velocity_mult", PROPERTY_HINT_RANGE, "0,1"), "set_velocity_mult", "get_velocity_mult");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "position_mult", PROPERTY_HINT_RANGE, "0,1"), "set_position_mult", "get_position_mult");
}
\ No newline at end of file
/*
*
*
* _________ ____ .-. _________/ ____ .-. ____
* __|__ (_)_/(_)( )____< \| ( ) (_)
* `-' `-'
*
*
* art & game engine
*
* ____________________________________ ? ____________________________________
* (._.)
*
*
* This file is part of PROJECT_NAME
* For the latest info, see http://polymorph.cool/
*
* Copyright (c) 2019 polymorph.cool
*
* 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.
*
* ___________________________________( ^3^)_____________________________________
*
* ascii font: rotated by MikeChat & myflix
* have fun and be cool :)
*
*
*/
/*
* File: futari_floor.h
* Author: frankiezafe
*
* Created on March 27, 2019, 2:53 PM
*/
#ifndef FUTARI_FLOOR_H
#define FUTARI_FLOOR_H
#include "futari_modifier.h"
#define FUTARI_FLOOR_MINRANGE 0.0
class FutariFloorData : public FutariModifierData {
public:
bool infinite;
real_t width;
real_t height;
bool changed_infinite;
bool changed_width;
bool changed_height;
FutariFloorData( ) :
infinite(false),
width(1.0),
height(1.0),
changed_infinite( false ),
changed_width( false ),
changed_height( false )
{
range = FUTARI_FLOOR_MINRANGE;
}
void reset( ) {
FutariModifierData::reset( );
changed_infinite = false;
changed_width = false;
changed_height = false;
}
void operator=( const FutariFloorData& src ) {
FutariModifierData::operator=( src );
infinite = src.infinite;
width = src.width;
height = src.height;
changed_infinite = src.changed_infinite;
changed_width = src.changed_width;
changed_height = src.changed_height;
}
};
class FutariFloor : public FutariModifier {
GDCLASS( FutariFloor, FutariModifier )
public:
FutariFloor( );
void set_range( real_t r );
void set_infinite( bool b );
bool is_infinite() const;
void set_width( real_t w );
real_t get_width() const;
void set_height( real_t h );
real_t get_height() const;
FutariModifierData* data_ptr( );
protected:
static void _bind_methods( );
void refresh();
FutariFloorData _data;
bool infinite;
real_t width;
real_t height;
Vector3 up;
private:
};
#endif /* FUTARI_FLOOR_H */
......@@ -465,74 +465,58 @@ void FutariVortexGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_lines(lines, material);
// const int arrow_points = 7;
// const float arrow_length = 1.5;
// float m = wind->get_strength();
// if ( m > 1 ) {
// m = Math::sqrt( m );
// }
//
// Vector3 arrow[arrow_points] = {
// Vector3(0, 0, -1 * m),
// Vector3(0, 0.5 * m, 0),
// Vector3(0, 0.3 * m, 0),
// Vector3(0, 0.3 * m, arrow_length * m),
// Vector3(0, -0.3 * m, arrow_length * m),
// Vector3(0, -0.3 * m, 0),
// Vector3(0, -0.5 * m, 0)
// };
//
// int arrow_sides = 2;
}
// +++++++++++++++ FLOOR +++++++++++++++
FutariFloorGizmoPlugin::FutariFloorGizmoPlugin() {
// for (int i = 0; i < arrow_sides; i++) {
// for (int j = 0; j < arrow_points; j++) {
// Basis ma(Vector3(0, 0, 1), Math_PI * i / arrow_sides);
//
// Vector3 v1 = arrow[j] - Vector3(0, 0, arrow_length * m);
// Vector3 v2 = arrow[(j + 1) % arrow_points] - Vector3(0, 0, arrow_length * m);
//
// lines.push_back(ma.xform(v1));
// lines.push_back(ma.xform(v2));
// }
// }
Color gizmo_color = EDITOR_DEF(FUTARI_FLOOR_COLOR_NAME, Color(FUTARI_FLOOR_COLOR));
create_material(FUTARI_FLOOR_MATERIAL, gizmo_color);
create_handle_material(FUTARI_HANDLE_MATERIAL);
// range sphere
// const float radius = vortex->get_range();
// const float agap = (Math_PI / 16);
// float a = 0;
// Vector<Vector2> circle;
// for (int i = 0; i < 32; ++i) {
// circle.push_back(Vector2(Math::cos(a + agap) * radius, Math::sin(a + agap) * radius));
// a += agap;
// }
// for (int i = 0; i < 3; ++i) {
// for (int j = 0, k = 1; j < 32; ++j, ++k) {
// k %= 32;
// Vector2 v1 = circle[j];
// Vector2 v2 = circle[k];
// switch (i) {
// case 0: // floor
// lines.push_back(Vector3(v1.x, 0, v1.y));
// lines.push_back(Vector3(v2.x, 0, v2.y));
// break;
// case 1: // front wall
// lines.push_back(Vector3(v1.x, v1.y, 0));
// lines.push_back(Vector3(v2.x, v2.y, 0));
// break;
// case 2: // side wall
// lines.push_back(Vector3(0, v1.x, v1.y));
// lines.push_back(Vector3(0, v2.x, v2.y));
// break;
// default:
// break;
// }
// }
// }
//
// p_gizmo->add_lines(lines, material);
}
// p_gizmo->add_unscaled_billboard(icon, 0.05);
bool FutariFloorGizmoPlugin::has_gizmo(Spatial *p_spatial) {
return Object::cast_to<FutariFloor>(p_spatial);
}
String FutariFloorGizmoPlugin::get_name() const {
return "FutariFloor";
}
void FutariFloorGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
FutariFloor *floor = Object::cast_to<FutariFloor>(p_gizmo->get_spatial_node());
p_gizmo->clear();
Ref<Material> material;
if (floor->get_enabled()) {
material = get_material(FUTARI_FLOOR_MATERIAL, p_gizmo);
} else {
material = get_material(FUTARI_DISABLED_MATERIAL, p_gizmo);
}
Ref<Material> handles_material = get_material(FUTARI_HANDLE_MATERIAL);
Vector<Vector3> lines;
real_t w = floor->get_width() * 0.5;
real_t h = floor->get_height() * 0.5;
for ( int i = 0; i < 2; ++i ) {
Vector3 offset(0,0,0);
if ( i == 1 ) {
offset.y = floor->get_range();
}
lines.push_back( Vector3( -w,0,-h ) + offset );
lines.push_back( Vector3( w,0,-h ) + offset );
lines.push_back( Vector3( w,0,-h ) + offset );
lines.push_back( Vector3( w,0,h ) + offset );
lines.push_back( Vector3( w,0,h ) + offset );
lines.push_back( Vector3( -w,0,h ) + offset );
lines.push_back( Vector3( -w,0,h ) + offset );
lines.push_back( Vector3( -w,0,-h ) + offset );
}
p_gizmo->add_lines(lines, material);
}
......@@ -61,6 +61,7 @@
#include "futari_wind.h"
#include "futari_attractor.h"
#include "futari_vortex.h"
#include "futari_floor.h"
#define FUTARI_CIRCLE_DEFINITION 32
......@@ -72,11 +73,14 @@
#define FUTARI_ATTRACTOR_COLOR 0.125, 1.0, 0.875, 1.0
#define FUTARI_VORTEX_COLOR_NAME "editors/3d_gizmos/gizmo_colors/futari_vortex"
#define FUTARI_VORTEX_COLOR 0.25, 1.0, 0.75, 1.0
#define FUTARI_FLOOR_COLOR_NAME "editors/3d_gizmos/gizmo_colors/futari_floor"
#define FUTARI_FLOOR_COLOR 0.25, 1.0, 0.5, 1.0
#define FUTARI_DISABLED_MATERIAL "futari_disabled"
#define FUTARI_WIND_MATERIAL "futari_wind"
#define FUTARI_ATTRACTOR_MATERIAL "futari_attractor"
#define FUTARI_VORTEX_MATERIAL "futari_vortex"
#define FUTARI_FLOOR_MATERIAL "futari_floor"
#define FUTARI_HANDLE_MATERIAL "futari_handles"
class FutariModifierGizmoPlugin : public EditorSpatialGizmoPlugin {
......@@ -155,5 +159,19 @@ public:
};
#endif /* FUTARI_GIZMO_MODIFIERS_H */
class FutariFloorGizmoPlugin : public FutariModifierGizmoPlugin {
GDCLASS( FutariFloorGizmoPlugin, FutariModifierGizmoPlugin )
public:
FutariFloorGizmoPlugin( );
void init_materials( );
bool has_gizmo( Spatial *p_spatial );
String get_name( ) const;
void redraw( EditorSpatialGizmo *p_gizmo );
};
#endif /* FUTARI_GIZMO_MODIFIERS_H */
\ No newline at end of file
......@@ -232,7 +232,8 @@ void FutariMaterial::_update_shader() {
if ((
flags[FUFLA_ENABLE_WIND] ||
flags[FUFLA_ENABLE_ATTRACTOR] ||
flags[FUFLA_ENABLE_VORTEX]) &&
flags[FUFLA_ENABLE_VORTEX] ||
flags[FUFLA_ENABLE_FLOOR]) &&
!common_part.empty()
) {
code += common_part.declaration;
......@@ -246,6 +247,9 @@ void FutariMaterial::_update_shader() {
if (flags[FUFLA_ENABLE_VORTEX] && !vortex_part.empty()) {
code += vortex_part.declaration;
}
if (flags[FUFLA_ENABLE_FLOOR] && !floor_part.empty()) {
code += floor_part.declaration;
}
if (color_ramp.is_valid()) {
code += "uniform sampler2D color_ramp;\n";
......@@ -510,7 +514,8 @@ void FutariMaterial::_update_shader() {
if ((
flags[FUFLA_ENABLE_WIND] ||
flags[FUFLA_ENABLE_ATTRACTOR] ||
flags[FUFLA_ENABLE_VORTEX]) &&
flags[FUFLA_ENABLE_VORTEX] ||
flags[FUFLA_ENABLE_FLOOR]) &&
!common_part.empty()
) {
code += common_part.vertex_normal;
......@@ -528,6 +533,10 @@ void FutariMaterial::_update_shader() {
code += vortex_part.vertex_normal;
}
if (flags[FUFLA_ENABLE_FLOOR] && !floor_part.empty()) {
code += floor_part.vertex_normal;
}
code += " // apply linear acceleration\n";
code += " force += length(VELOCITY) > 0.0 ? normalize(VELOCITY) * (linear_accel + tex_linear_accel) * mix(1.0, rand_from_seed(alt_seed), linear_accel_random) : vec3(0.0);\n";
code += " // apply radial acceleration\n";
......@@ -1048,6 +1057,7 @@ void FutariMaterial::set_flag(FFlags p_flag, bool p_enable) {
p_flag == FUFLA_ENABLE_WIND ||
p_flag == FUFLA_ENABLE_ATTRACTOR ||
p_flag == FUFLA_ENABLE_VORTEX ||
p_flag == FUFLA_ENABLE_FLOOR ||
p_flag == FUFLA_ROTATE_X ||
p_flag == FUFLA_ROTATE_Y ||
p_flag == FUFLA_ROTATE_Z
......@@ -1272,6 +1282,13 @@ void FutariMaterial::set_vortex_shaderpart(const FutariShaderPart& part) {
}
}
void FutariMaterial::set_floor_shaderpart(const FutariShaderPart& part) {
if (floor_part != part) {
floor_part = part;
_queue_shader_change();
}
}
void FutariMaterial::set_futari_param_real(String name, const real_t& r) {
// std::wstring ws = name.c_str();
......@@ -1482,6 +1499,7 @@ void FutariMaterial::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flag_enable_wind"), "set_flag", "get_flag", FUFLA_ENABLE_WIND);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flag_enable_attractor"), "set_flag", "get_flag", FUFLA_ENABLE_ATTRACTOR);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flag_enable_vortex"), "set_flag", "get_flag", FUFLA_ENABLE_VORTEX);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flag_enable_floor"), "set_flag", "get_flag", FUFLA_ENABLE_FLOOR);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flag_messy_orientation"), "set_flag", "get_flag", FUFLA_MESSY_ORIENTATION);
ADD_GROUP("Spread", "");
......@@ -1571,6 +1589,7 @@ void FutariMaterial::_bind_methods() {
BIND_ENUM_CONSTANT(FUFLA_ENABLE_WIND);
BIND_ENUM_CONSTANT(FUFLA_ENABLE_ATTRACTOR);
BIND_ENUM_CONSTANT(FUFLA_ENABLE_VORTEX);
BIND_ENUM_CONSTANT(FUFLA_ENABLE_FLOOR);
BIND_ENUM_CONSTANT(FUFLA_MESSY_ORIENTATION);
BIND_ENUM_CONSTANT(FUFLA_ROTATE_X);
BIND_ENUM_CONSTANT(FUFLA_ROTATE_Z);
......
......@@ -129,6 +129,14 @@ public:
vertex_normal != src.vertex_normal
);
}
void print() const {
std::cout <<
"modifier_count: " << modifier_count << std::endl <<
"declaration: '" << ss_declaration.str() << "'" << std::endl <<
"vertex_start: '" << ss_vertex_start.str() << "'" << std::endl <<
"vertex_normal: '" << ss_vertex_normal.str() << "'" << std::endl;
}
};
......@@ -161,6 +169,7 @@ public:
FUFLA_MESSY_ORIENTATION,
FUFLA_ROTATE_X,
FUFLA_ROTATE_Z,
FUFLA_ENABLE_FLOOR,
FUFLA_MAX
};
......@@ -296,6 +305,7 @@ protected:
FutariShaderPart wind_part;
FutariShaderPart attractor_part;
FutariShaderPart vortex_part;
FutariShaderPart floor_part;
RID _shader;
bool dump_shader;
......@@ -390,6 +400,7 @@ public:
void set_wind_shaderpart( const FutariShaderPart& part );
void set_attractor_shaderpart( const FutariShaderPart& part );
void set_vortex_shaderpart( const FutariShaderPart& part );
void set_floor_shaderpart( const FutariShaderPart& part );
static void init_shaders( );
static void finish_shaders( );
......
......@@ -77,7 +77,8 @@ public:
FMT_WIND = 0,
FMT_ATTRACTOR = 1,
FMT_VORTEX = 2,
FMT_MAX = 3
FMT_FLOOR = 3,
FMT_MAX = 4
};
// set in modifier constructor
......
......@@ -202,6 +202,16 @@ void FutariParticles::_internal_process() {
}
//std::cout << "\tFMT_ATTRACTOR!" << std::endl;
break;
case FutariModifierData::FMT_FLOOR:
{
if (_floors.empty()) {
_procmat_refresh = true;
} else if (_floors.find((FutariFloorData*) fmd) == -1) {
_procmat_refresh = true;
}
}
//std::cout << "\tFMT_ATTRACTOR!" << std::endl;
break;
case FutariModifierData::FMT_WIND:
{
if (_winds.empty()) {
......@@ -248,6 +258,7 @@ void FutariParticles::_internal_process() {
bool force_wind_update = false;
bool force_attractor_update = false;
bool force_vortex_update = false;
bool force_floor_update = false;
int mnum = 0;
// updating shader if required
......@@ -276,6 +287,7 @@ void FutariParticles::_internal_process() {
FutariShaderPart wpart;
FutariShaderPart apart;
FutariShaderPart vpart;
FutariShaderPart fpart;
wpart.ss_declaration << "\n//////// FUTARI WIND -- start\n";
wpart.ss_vertex_normal << "\n//////// FUTARI WIND -- start\n";
......@@ -283,6 +295,8 @@ void FutariParticles::_internal_process() {
apart.ss_vertex_normal << "\n//////// FUTARI ATTRACTOR -- start\n";
vpart.ss_declaration << "\n//////// FUTARI VORTEX -- start\n";
vpart.ss_vertex_normal << "\n//////// FUTARI VORTEX -- start\n";
fpart.ss_declaration << "\n//////// FUTARI FLOOR -- start\n";
fpart.ss_vertex_normal << "\n//////// FUTARI FLOOR -- start\n";
int id;
......@@ -361,6 +375,46 @@ void FutariParticles::_internal_process() {
++wpart.modifier_count;
force_wind_update = true;
} else if (fmd->futari_type == FutariModifierData::FMT_FLOOR) {
id = fpart.modifier_count;
fpart.ss_declaration << "uniform vec3 floor_position_" << id << ";\n";
fpart.ss_declaration << "uniform vec3 floor_orientation_" << id << ";\n";
fpart.ss_declaration << "uniform float floor_strength_" << id << ";\n";
fpart.ss_declaration << "uniform float floor_width_" << id << ";\n";
fpart.ss_declaration << "uniform float floor_height_" << id << ";\n";
fpart.ss_declaration << "uniform float floor_range_" << id << ";\n";
fpart.ss_declaration << "uniform float floor_vmult_" << id << ";\n";
fpart.ss_declaration << "uniform float floor_pmult_" << id << ";\n";
if (fmd->strength_decay.is_valid()) {
fpart.ss_declaration << "uniform sampler2D floor_strength_decay_" << id << " : hint_white;\n";
}
if (fmd->lifetime.is_valid()) {
fpart.ss_declaration << "uniform sampler2D floor_lifetime_" << id << " : hint_white;\n";
}
fpart.ss_vertex_normal << "fut_v3 = pos - floor_position_" << id << ";\n";
fpart.ss_vertex_normal << "fut_v3_norm = normalize(fut_v3);";
fpart.ss_vertex_normal << "if ( dot( fut_v3_norm, floor_orientation_" << id << " ) < 0.0 ) {";
fpart.ss_vertex_normal << " futari_push += fut_v3 * -1.0;";
fpart.ss_vertex_normal << "}";
// fpart.ss_vertex_normal << "fut_d = 1.0 - min( 1.0, (fut_v3.x*fut_v3.x + fut_v3.y*fut_v3.y + fut_v3.z*fut_v3.z) / wind_range_" << id << " );\n";
// if (fmd->strength_decay.is_valid()) {
// fpart.ss_vertex_normal << "fut_d = textureLod(wind_strength_decay_" << id << ", vec2( fut_d, 0.0 ), 0.0).r;\n";
// }
// fpart.ss_vertex_normal << "fut_v3 = wind_orientation_" << id << " * wind_strength_" << id << " * fut_d;\n";
// if (fmd->lifetime.is_valid()) {
// fpart.ss_vertex_normal << "fut_v3 = fut_v3 * textureLod(wind_lifetime_" << id << ", vec2( CUSTOM.y, 0.0 ), 0.0).r;\n";
// }
// fpart.ss_vertex_normal << "futari_force += fut_v3 * wind_vmult_" << id << ";\n";
// fpart.ss_vertex_normal << "futari_push += fut_v3 * wind_pmult_" << id << ";\n";
_floors.push_back((FutariFloorData*) fmd);
++fpart.modifier_count;
force_floor_update = true;
} else if (fmd->futari_type == FutariModifierData::FMT_VORTEX) {
FutariVortexData* fvd = (FutariVortexData*) fmd;
......@@ -484,16 +538,20 @@ void FutariParticles::_internal_process() {
apart.ss_vertex_normal << "//////// FUTARI ATTRACTOR -- end\n\n";
vpart.ss_declaration << "//////// FUTARI VORTEX -- end\n\n";
vpart.ss_vertex_normal << "//////// FUTARI VORTEX -- end\n\n";
fpart.ss_declaration << "//////// FUTARI FLOOR -- end\n\n";
fpart.ss_vertex_normal << "//////// FUTARI FLOOR-- end\n\n";
common_part.pack();
wpart.pack();
apart.pack();
vpart.pack();
fpart.pack();
procmat->set_common_shaderpart(common_part);
procmat->set_wind_shaderpart(wpart);
procmat->set_attractor_shaderpart(apart);
procmat->set_vortex_shaderpart(vpart);
procmat->set_floor_shaderpart(fpart);
_procmat_refresh = false;
......@@ -551,6 +609,65 @@ void FutariParticles::_internal_process() {
}
}
mnum = _floors.size();
for (int i = 0; i < mnum; ++i) {
FutariFloorData* ffd = _floors[i];
if (!force_floor_update && !ffd->changed) {
continue;
}
String suffix = String::num(i);
if (force_floor_update) {
procmat->set_futari_param_v3("floor_position_" + suffix, ffd->position);
procmat->set_futari_param_v3("floor_orientation_" + suffix, ffd->orientation);
procmat->set_futari_param_real("floor_width_" + suffix, ffd->width);
procmat->set_futari_param_real("floor_height_" + suffix, ffd->height);
procmat->set_futari_param_real("floor_strength_" + suffix, ffd->strength);
procmat->set_futari_param_real("floor_range_" + suffix, ffd->range * ffd->range);
procmat->set_futari_param_real("floor_vmult_" + suffix, ffd->velocity_mult);
procmat->set_futari_param_real("floor_pmult_" + suffix, ffd->position_mult);
if (ffd->strength_decay.is_valid()) {
procmat->set_futari_param_tex("floor_strength_decay_" + suffix, ffd->strength_decay);
}
if (ffd->lifetime.is_valid()) {
procmat->set_futari_param_tex("floor_lifetime_" + suffix, ffd->lifetime);
}
} else if (ffd->changed) {
if (ffd->changed_position) {
procmat->set_futari_param_v3("floor_position_" + suffix, ffd->position);
}
if (ffd->changed_orientation) {
procmat->set_futari_param_v3("floor_orientation_" + suffix, ffd->orientation);
}
if (ffd->changed_strength) {
procmat->set_futari_param_real("floor_width_" + suffix, ffd->width);
}
if (ffd->changed_strength) {
procmat->set_futari_param_real("floor_height_" + suffix, ffd->height);
}
if (ffd->changed_strength) {
procmat->set_futari_param_real("floor_strength_" + suffix, ffd->strength);
}
if (ffd->changed_range) {
procmat->set_futari_param_real("floor_range_" + suffix, ffd->range * ffd->range);
}
if (ffd->changed_velocity_mult) {
procmat->set_futari_param_real("floor_vmult_" + suffix, ffd->velocity_mult);
}
if (ffd->changed_position_mult) {
procmat->set_futari_param_real("floor_pmult_" + suffix, ffd->position_mult);
}
}
}
mnum = _attractors.size();
for (int i = 0; i < mnum; ++i) {
......
......@@ -66,6 +66,7 @@
#include "futari_wind.h"
#include "futari_attractor.h"
#include "futari_vortex.h"
#include "futari_floor.h"
#include "futari_material.h"
#include "futari_server.h"
......@@ -153,6 +154,7 @@ protected:
Vector<FutariAttractorData*> _attractors;
Vector<FutariWindData*> _winds;
Vector<FutariVortexData*> _vortices;
Vector<FutariFloorData*> _floors;
bool _procmat_refresh;
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16"
height="16"
version="1.1"
viewBox="0 0 16 16"
id="svg5969"
inkscape:version="0.91 r13725"
sodipodi:docname="icon_futari_floor.svg">
<metadata
id="metadata5979">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs5977" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1053"
id="namedview5975"
showgrid="false"
inkscape:zoom="29.5"
inkscape:cx="3.3226868"
inkscape:cy="7.0349768"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg5969" />
<path
style="display:inline;fill:#91f7ff;fill-opacity:0.99607843;stroke:none"
d="m 6.8,2.0000004 0,4.8 -4.8,0 0,2.4 12,0 0,-2.4 -4.8,0 0,-4.8 z M 2,11.6 2,14 l 12,0 0,-2.4 z"
id="rect5086-3-4-3"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccccccccc" />
</svg>
......@@ -49,6 +49,7 @@
#include "futari_attractor.h"
#include "futari_vortex.h"
#include "futari_material.h"
#include "futari_floor.h"
#include "futari_editor_plugin.h"
void register_futari_types() {
......@@ -59,6 +60,7 @@ void register_futari_types() {
ClassDB::register_class<FutariWind>();
ClassDB::register_class<FutariAttractor>();
ClassDB::register_class<FutariVortex>();
ClassDB::register_class<FutariFloor>();
ClassDB::register_class<FutariMaterial>();
SceneTree::add_idle_callback(FutariMaterial::flush_changes);
......