From c970772cd622ebd00d90e7040c8f5434f8c37f08 Mon Sep 17 00:00:00 2001 From: swd Date: Mon, 11 Dec 2023 14:36:55 +0900 Subject: [PATCH] Implement Collisions module and rotate to velocity (#978) Implement Collisions module and rotate to velocity --- Dev/Cpp/Effekseer/CMakeLists.txt | 1 + .../Effekseer/Effekseer.EffectImplemented.h | 2 +- .../Effekseer/Effekseer.EffectNode.cpp | 1 + .../Effekseer/Effekseer.EffectNode.h | 3 + .../Effekseer/Effekseer.EffectNodeModel.cpp | 2 +- .../Effekseer/Effekseer.EffectNodeRibbon.cpp | 2 +- .../Effekseer/Effekseer.EffectNodeRing.cpp | 2 +- .../Effekseer/Effekseer.EffectNodeSprite.cpp | 2 +- .../Effekseer/Effekseer.EffectNodeTrack.cpp | 2 +- .../Effekseer/Effekseer.Instance.cpp | 137 +++++++++++++----- .../Effekseer/Effekseer/Effekseer.Instance.h | 7 +- .../Effekseer/Parameter/Collisions.cpp | 64 ++++++++ .../Effekseer/Parameter/Collisions.h | 39 +++++ .../Effekseer/Parameter/Rotation.cpp | 79 ++++++++++ .../Effekseer/Effekseer/Parameter/Rotation.h | 35 +++-- .../Effekseer/Effekseer/Utils/BinaryVersion.h | 1 + Dev/Editor/CMakeLists.txt | 2 + Dev/Editor/Effekseer/App.cs | 1 + .../Effekseer/GUI/Dock/CollisionsValues.cs | 85 +++++++++++ Dev/Editor/Effekseer/GUI/Menu/WindowMenu.cs | 1 + Dev/Editor/EffekseerCore/Binary/Exporter.cs | 12 +- .../EffekseerCore/Binary/RotationValues.cs | 9 ++ .../EffekseerCore/Data/CollisionsValues.cs | 30 ++++ .../EffekseerCore/Data/KillRulesValues.cs | 56 +++---- Dev/Editor/EffekseerCore/Data/Node.cs | 9 +- .../EffekseerCore/Data/RotationValues.cs | 11 ++ Dev/Editor/EffekseerCoreGUI/Application.cs | 1 + Dev/Editor/EffekseerCoreGUI/GUI/Viewer.cs | 97 +++++++------ Dev/release/resources/languages/en/Base.csv | 23 +-- .../languages/en/Effekseer_Collisions.csv | 4 + .../languages/en/Effekseer_Rotation.csv | 5 +- Dev/release/resources/languages/ja/Base.csv | 23 +-- .../languages/ja/Effekseer_Collisions.csv | 4 + .../languages/ja/Effekseer_Rotation.csv | 5 +- 34 files changed, 600 insertions(+), 157 deletions(-) create mode 100644 Dev/Cpp/Effekseer/Effekseer/Parameter/Collisions.cpp create mode 100644 Dev/Cpp/Effekseer/Effekseer/Parameter/Collisions.h create mode 100644 Dev/Editor/Effekseer/GUI/Dock/CollisionsValues.cs create mode 100644 Dev/Editor/EffekseerCore/Data/CollisionsValues.cs create mode 100644 Dev/release/resources/languages/en/Effekseer_Collisions.csv create mode 100644 Dev/release/resources/languages/ja/Effekseer_Collisions.csv diff --git a/Dev/Cpp/Effekseer/CMakeLists.txt b/Dev/Cpp/Effekseer/CMakeLists.txt index 399639d2f6..af0f42c4f2 100644 --- a/Dev/Cpp/Effekseer/CMakeLists.txt +++ b/Dev/Cpp/Effekseer/CMakeLists.txt @@ -136,6 +136,7 @@ set(effekseer_src Effekseer/Material/Effekseer.CompiledMaterial.cpp Effekseer/Material/Effekseer.MaterialCompiler.cpp Effekseer/IO/Effekseer.EfkEfcFactory.cpp + Effekseer/Parameter/Collisions.cpp Effekseer/Parameter/Easing.cpp Effekseer/Parameter/Effekseer.Parameters.cpp Effekseer/Parameter/KillRules.cpp diff --git a/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectImplemented.h b/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectImplemented.h index 9232fd9e06..7285ec5a55 100644 --- a/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectImplemented.h +++ b/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectImplemented.h @@ -104,7 +104,7 @@ class EffectImplemented : public Effect, public ReferenceObject friend class EffectFactory; friend class Instance; - static const int32_t SupportBinaryVersion = Version17; + static const int32_t SupportBinaryVersion = Version18Alpha1; protected: SettingRef m_setting; diff --git a/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNode.cpp b/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNode.cpp index c02c70d0f1..e979003c24 100644 --- a/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNode.cpp +++ b/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNode.cpp @@ -228,6 +228,7 @@ void EffectNodeImplemented::LoadParameter(unsigned char*& pos, EffectNode* paren GenerationLocation.load(pos, ef->GetVersion()); DepthValues.Load(pos, ef->GetVersion()); KillParam.Load(pos, ef->GetVersion()); + Collisions.Load(pos, ef->GetVersion()); if (m_effect->GetVersion() >= 3) { diff --git a/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNode.h b/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNode.h index 370473e26f..4784e2846c 100644 --- a/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNode.h +++ b/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNode.h @@ -16,6 +16,7 @@ #include "Parameter/AllTypeColor.h" #include "Parameter/AlphaCutoff.h" #include "Parameter/BasicSettings.h" +#include "Parameter/Collisions.h" #include "Parameter/CustomData.h" #include "Parameter/DepthParameter.h" #include "Parameter/DynamicParameter.h" @@ -518,6 +519,8 @@ class EffectNodeImplemented : public EffectNode, public SIMD::AlignedAllocationP DynamicFactorParameter DynamicFactor; + CollisionsParameter Collisions; + bool Traverse(const std::function& visitor); Effect* GetEffect() const override; diff --git a/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeModel.cpp b/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeModel.cpp index ea8ae95244..2a3bb7c76d 100644 --- a/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeModel.cpp +++ b/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeModel.cpp @@ -144,7 +144,7 @@ void EffectNodeModel::Rendering(const Instance& instance, const Instance* next_i if (nodeParam_.EnableViewOffset) { - instanceParameter.ViewOffsetDistance = instance.translation_values.view_offset.distance; + instanceParameter.ViewOffsetDistance = instance.translation_state_.view_offset.distance; } CalcCustomData(&instance, instanceParameter.CustomData1, instanceParameter.CustomData2); diff --git a/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeRibbon.cpp b/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeRibbon.cpp index e0507d2f1f..a50abb7570 100644 --- a/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeRibbon.cpp +++ b/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeRibbon.cpp @@ -186,7 +186,7 @@ void EffectNodeRibbon::BeginRenderingGroup(InstanceGroup* group, Manager* manage if (m_nodeParameter.EnableViewOffset) { - m_instanceParameter.ViewOffsetDistance = groupFirst->translation_values.view_offset.distance; + m_instanceParameter.ViewOffsetDistance = groupFirst->translation_state_.view_offset.distance; } CalcCustomData(group->GetFirst(), m_instanceParameter.CustomData1, m_instanceParameter.CustomData2); diff --git a/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeRing.cpp b/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeRing.cpp index 52df5a7b5c..540fa42983 100644 --- a/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeRing.cpp +++ b/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeRing.cpp @@ -312,7 +312,7 @@ void EffectNodeRing::Rendering(const Instance& instance, const Instance* next_in if (instance.m_pEffectNode->TranslationParam.TranslationType == ParameterTranslationType_ViewOffset) { - instanceParameter.ViewOffsetDistance = instance.translation_values.view_offset.distance; + instanceParameter.ViewOffsetDistance = instance.translation_state_.view_offset.distance; } CalcCustomData(&instance, instanceParameter.CustomData1, instanceParameter.CustomData2); diff --git a/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeSprite.cpp b/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeSprite.cpp index 06889d3c2e..a56c90938f 100644 --- a/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeSprite.cpp +++ b/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeSprite.cpp @@ -226,7 +226,7 @@ void EffectNodeSprite::Rendering(const Instance& instance, const Instance* next_ if (nodeParam_.EnableViewOffset) { - instanceParameter.ViewOffsetDistance = instance.translation_values.view_offset.distance; + instanceParameter.ViewOffsetDistance = instance.translation_state_.view_offset.distance; } CalcCustomData(&instance, instanceParameter.CustomData1, instanceParameter.CustomData2); diff --git a/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeTrack.cpp b/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeTrack.cpp index 7f618ee910..27a932a764 100644 --- a/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeTrack.cpp +++ b/Dev/Cpp/Effekseer/Effekseer/Effekseer.EffectNodeTrack.cpp @@ -148,7 +148,7 @@ void EffectNodeTrack::BeginRenderingGroup(InstanceGroup* group, Manager* manager if (m_nodeParameter.EnableViewOffset) { - m_instanceParameter.ViewOffsetDistance = groupFirst->translation_values.view_offset.distance; + m_instanceParameter.ViewOffsetDistance = groupFirst->translation_state_.view_offset.distance; } CalcCustomData(group->GetFirst(), m_instanceParameter.CustomData1, m_instanceParameter.CustomData2); diff --git a/Dev/Cpp/Effekseer/Effekseer/Effekseer.Instance.cpp b/Dev/Cpp/Effekseer/Effekseer/Effekseer.Instance.cpp index 21916d6599..e0137b9bf8 100644 --- a/Dev/Cpp/Effekseer/Effekseer/Effekseer.Instance.cpp +++ b/Dev/Cpp/Effekseer/Effekseer/Effekseer.Instance.cpp @@ -311,7 +311,7 @@ void Instance::FirstUpdate() ColorParent = m_pParent->ColorInheritance; } - steeringVec_ = SIMD::Vec3f(0, 0, 0); + steering_vec_ = SIMD::Vec3f(0, 0, 0); if (m_pEffectNode->CommonValues.TranslationBindType == TranslationParentBindType::NotBind_FollowParent || m_pEffectNode->CommonValues.TranslationBindType == TranslationParentBindType::WhenCreating_FollowParent) @@ -320,7 +320,7 @@ void Instance::FirstUpdate() followParentParam.steeringSpeed = m_pEffectNode->SteeringBehaviorParam.SteeringSpeed.getValue(rand) / 100.0f; } - m_pEffectNode->TranslationParam.InitializeTranslationState(translation_values, prevPosition_, steeringVec_, rand, effect, instanceGlobal, m_LivingTime, m_LivedTime, m_pParent, m_pEffectNode->DynamicFactor); + m_pEffectNode->TranslationParam.InitializeTranslationState(translation_state_, prevPosition_, steering_vec_, rand, effect, instanceGlobal, m_LivingTime, m_LivedTime, m_pParent, m_pEffectNode->DynamicFactor); RotationFunctions::InitRotation(rotation_values, m_pEffectNode->RotationParam, rand, effect, instanceGlobal, m_LivingTime, m_LivedTime, m_pParent, m_pEffectNode->DynamicFactor); ScalingFunctions::InitScaling(scaling_values, m_pEffectNode->ScalingParam, rand, effect, instanceGlobal, m_LivingTime, m_LivedTime, m_pParent, m_pEffectNode->DynamicFactor); @@ -591,65 +591,87 @@ void Instance::UpdateTransform(float deltaFrame) UpdateParentMatrix(deltaFrame); } - float accerarationDelta = deltaFrame; + float acceraration_delta = deltaFrame; if (deltaFrame > 1) { // trapezoid interporation - accerarationDelta = ((1.0f + 1.0f / deltaFrame) / 2.0f) * deltaFrame; + acceraration_delta = ((1.0f + 1.0f / deltaFrame) / 2.0f) * deltaFrame; } SIMD::Vec3f localPosition = prevPosition_; SIMD::Vec3f localVelocity = prevLocalVelocity_; - SIMD::Vec3f localAcc = SIMD::Vec3f(0, 0, 0); - - if (m_pEffectNode->CommonValues.TranslationBindType == TranslationParentBindType::NotBind_FollowParent || - m_pEffectNode->CommonValues.TranslationBindType == TranslationParentBindType::WhenCreating_FollowParent) + const auto calculate_acc = [&](SIMD::Vec3f& steeringVec, InstanceTranslationState& translation_state, RandObject& rand_obj, float living_time, float deltaFrame) { - SIMD::Vec3f worldPos = SIMD::Vec3f::Transform(localPosition, m_ParentMatrix); - SIMD::Vec3f toTarget = parentPosition_ - worldPos; + SIMD::Vec3f acc = SIMD::Vec3f(0, 0, 0); - if (toTarget.GetLength() > followParentParam.maxFollowSpeed) + if (m_pEffectNode->CommonValues.TranslationBindType == TranslationParentBindType::NotBind_FollowParent || + m_pEffectNode->CommonValues.TranslationBindType == TranslationParentBindType::WhenCreating_FollowParent) { - toTarget = toTarget.GetNormal(); - toTarget *= followParentParam.maxFollowSpeed; - } + SIMD::Vec3f worldPos = SIMD::Vec3f::Transform(localPosition, m_ParentMatrix); + SIMD::Vec3f toTarget = parentPosition_ - worldPos; - auto prevSteering = steeringVec_; - SIMD::Vec3f vSteering = toTarget - steeringVec_; - vSteering *= followParentParam.steeringSpeed; + if (toTarget.GetLength() > followParentParam.maxFollowSpeed) + { + toTarget = toTarget.GetNormal(); + toTarget *= followParentParam.maxFollowSpeed; + } - steeringVec_ += vSteering * deltaFrame; + auto prevSteering = steeringVec; + SIMD::Vec3f vSteering = toTarget - steeringVec; + vSteering *= followParentParam.steeringSpeed; - if (steeringVec_.GetLength() > followParentParam.maxFollowSpeed) - { - steeringVec_ = steeringVec_.GetNormal(); - steeringVec_ *= followParentParam.maxFollowSpeed; - } + steeringVec += vSteering * deltaFrame; - localAcc = (steeringVec_ - prevSteering) * m_pEffectNode->m_effect->GetMaginification(); - } - else - { - localAcc = m_pEffectNode->TranslationParam.CalculateTranslationState(translation_values, m_randObject, m_pEffectNode->GetEffect(), m_pContainer->GetRootInstance(), m_LivingTime, m_LivedTime, deltaFrame, m_pParent, coordinateSystem, m_pEffectNode->DynamicFactor); + if (steeringVec.GetLength() > followParentParam.maxFollowSpeed) + { + steeringVec = steeringVec.GetNormal(); + steeringVec *= followParentParam.maxFollowSpeed; + } - if (m_pEffectNode->GenerationLocation.EffectsRotation) + acc = (steeringVec - prevSteering) * m_pEffectNode->m_effect->GetMaginification(); + } + else { - // TODO : check rotation(It seems has bugs and it can optimize it) - localAcc = SIMD::Vec3f::Transform(localAcc, m_GenerationLocation.Get3x3SubMatrix()); + acc = m_pEffectNode->TranslationParam.CalculateTranslationState(translation_state, rand_obj, m_pEffectNode->GetEffect(), m_pContainer->GetRootInstance(), living_time, m_LivedTime, deltaFrame, m_pParent, coordinateSystem, m_pEffectNode->DynamicFactor); + + if (m_pEffectNode->GenerationLocation.EffectsRotation) + { + // TODO : check rotation(It seems has bugs and it can optimize it) + acc = SIMD::Vec3f::Transform(acc, m_GenerationLocation.Get3x3SubMatrix()); + } } + + return acc; + }; + + auto local_acc = calculate_acc(steering_vec_, translation_state_, m_randObject, m_LivingTime, deltaFrame); + + // accelaration for rotation of velocity to avoid that a velocity is zero + SIMD::Vec3f local_acc_rot = SIMD::Vec3f(0, 0, 0); + if (RotationFunctions::CalculateInGlobal(m_pEffectNode->RotationParam)) + { + const float delta_plus = 0.01f; + auto steering_vec_temp = steering_vec_; + auto translation_state_temp = translation_state_; + auto rand_obj_temp = m_randObject; + local_acc_rot = calculate_acc(steering_vec_temp, translation_state_temp, rand_obj_temp, m_LivingTime + delta_plus, delta_plus); } - auto matRot = RotationFunctions::CalculateRotation(rotation_values, m_pEffectNode->RotationParam, m_randObject, m_pEffectNode->GetEffect(), m_pContainer->GetRootInstance(), m_LivingTime, m_LivedTime, m_pParent, m_pEffectNode->DynamicFactor, m_pManager->GetLayerParameter(GetInstanceGlobal()->GetLayer()).ViewerPosition); + SIMD::Mat43f matRot = SIMD::Mat43f::Identity; + if (!RotationFunctions::CalculateInGlobal(m_pEffectNode->RotationParam)) + { + matRot = RotationFunctions::CalculateRotation(rotation_values, m_pEffectNode->RotationParam, m_randObject, m_pEffectNode->GetEffect(), m_pContainer->GetRootInstance(), m_LivingTime, m_LivedTime, m_pParent, m_pEffectNode->DynamicFactor, m_pManager->GetLayerParameter(GetInstanceGlobal()->GetLayer()).ViewerPosition); + } auto scaling = ScalingFunctions::UpdateScaling(scaling_values, m_pEffectNode->ScalingParam, m_randObject, m_pEffectNode->GetEffect(), m_pContainer->GetRootInstance(), m_LivingTime, m_LivedTime, m_pParent, m_pEffectNode->DynamicFactor); // update local fields if (m_pEffectNode->LocalForceField.HasValue) { // for compatibiliy - auto new_local_position = localPosition + (localVelocity * deltaFrame + localAcc * accerarationDelta); + auto new_local_position = localPosition + (localVelocity * deltaFrame + local_acc * acceraration_delta); - localAcc += forceField_.Update( + local_acc += forceField_.Update( m_pEffectNode->LocalForceField, new_local_position, localVelocity, @@ -658,8 +680,8 @@ void Instance::UpdateTransform(float deltaFrame) m_pEffectNode->GetEffect()->GetSetting()->GetCoordinateSystem()); } - localPosition += localVelocity * deltaFrame + localAcc * accerarationDelta; - localVelocity += localAcc; + localPosition += localVelocity * deltaFrame + local_acc * acceraration_delta; + localVelocity += local_acc; prevPosition_ = localPosition; prevLocalVelocity_ = localVelocity; @@ -685,12 +707,51 @@ void Instance::UpdateTransform(float deltaFrame) assert(calcMat.IsValid()); } + bool recalculate_matrix = false; + SIMD::Vec3f acc_global_sum = SIMD::Vec3f(0, 0, 0); + if (m_pEffectNode->LocalForceField.IsGlobalEnabled) { + recalculate_matrix = true; InstanceGlobal* instanceGlobal = m_pContainer->GetRootInstance(); const auto acc_global = forceField_.UpdateGlobal(m_pEffectNode->LocalForceField, prevGlobalPosition_, m_pEffectNode->GetEffect()->GetMaginification(), instanceGlobal->GetTargetLocation(), deltaFrame, m_pEffectNode->GetEffect()->GetSetting()->GetCoordinateSystem()); - location_modify_global_ += velocity_modify_global_ * deltaFrame + acc_global * accerarationDelta; - velocity_modify_global_ += acc_global; + acc_global_sum += acc_global; + } + + if (m_pEffectNode->Collisions.IsEnabled) + { + recalculate_matrix = true; + SIMD::Vec3f s; + SIMD::Mat43f r; + SIMD::Vec3f t; + calcMat.GetSRT(s, r, t); + + SIMD::Vec3f pos = calcMat.GetTranslation() + location_modify_global_ + (velocity_modify_global_ * deltaFrame + acc_global_sum * acceraration_delta); + SIMD::Vec3f vel = SIMD::Vec3f::Transform(prevLocalVelocity_, r) + (velocity_modify_global_ + acc_global_sum); + + InstanceGlobal* instanceGlobal = m_pContainer->GetRootInstance(); + const auto result = CollisionsFunctions::Update(collisionState_, m_pEffectNode->Collisions, pos, prevGlobalPosition_, vel, instanceGlobal->EffectGlobalMatrix.GetTranslation()); + location_modify_global_ -= std::get<1>(result); + acc_global_sum += std::get<0>(result); + } + + if (RotationFunctions::CalculateInGlobal(m_pEffectNode->RotationParam)) + { + SIMD::Vec3f s; + SIMD::Mat43f r; + SIMD::Vec3f t; + calcMat.GetSRT(s, r, t); + + const SIMD::Vec3f vel = SIMD::Vec3f::Transform(prevLocalVelocity_ + local_acc_rot, r) + (velocity_modify_global_ + acc_global_sum); + SIMD::Mat43f matRotGlobal = RotationFunctions::CalculateRotationGlobal(rotation_values, m_pEffectNode->RotationParam, vel); + calcMat = SIMD::Mat43f::SRT(s, matRotGlobal, t); + } + + if (recalculate_matrix) + { + location_modify_global_ += velocity_modify_global_ * deltaFrame + acc_global_sum * acceraration_delta; + velocity_modify_global_ += acc_global_sum; + SIMD::Mat43f mat_location_global = SIMD::Mat43f::Translation(location_modify_global_); calcMat *= mat_location_global; } diff --git a/Dev/Cpp/Effekseer/Effekseer/Effekseer.Instance.h b/Dev/Cpp/Effekseer/Effekseer/Effekseer.Instance.h index 484b84f541..78f3f2b658 100644 --- a/Dev/Cpp/Effekseer/Effekseer/Effekseer.Instance.h +++ b/Dev/Cpp/Effekseer/Effekseer/Effekseer.Instance.h @@ -25,6 +25,7 @@ #include "ForceField/ForceFields.h" #include "Parameter/AlphaCutoff.h" +#include "Parameter/Collisions.h" #include "Parameter/CustomData.h" #include "Parameter/Rotation.h" #include "Parameter/Scaling.h" @@ -75,7 +76,7 @@ class alignas(16) Instance : public IntrusiveList::Node SIMD::Vec3f parentPosition_; - SIMD::Vec3f steeringVec_; + SIMD::Vec3f steering_vec_; SIMD::Vec3f location_modify_global_; SIMD::Vec3f velocity_modify_global_; @@ -116,7 +117,7 @@ class alignas(16) Instance : public IntrusiveList::Node float steeringSpeed; } followParentParam; - InstanceTranslationState translation_values; + InstanceTranslationState translation_state_; RotationState rotation_values; @@ -178,6 +179,8 @@ class alignas(16) Instance : public IntrusiveList::Node float m_AlphaThreshold = 0.0f; + CollisionsState collisionState_; + Instance(ManagerImplemented* pManager, EffectNodeImplemented* pEffectNode, InstanceContainer* pContainer, InstanceGroup* pGroup); virtual ~Instance(); diff --git a/Dev/Cpp/Effekseer/Effekseer/Parameter/Collisions.cpp b/Dev/Cpp/Effekseer/Effekseer/Parameter/Collisions.cpp new file mode 100644 index 0000000000..0c6677a4ed --- /dev/null +++ b/Dev/Cpp/Effekseer/Effekseer/Parameter/Collisions.cpp @@ -0,0 +1,64 @@ +#include "Collisions.h" +#include + +namespace Effekseer +{ + +void CollisionsParameter::Load(unsigned char*& pos, int version) +{ + if (version >= Version18Alpha1) + { + int isEnabled = 0; + memcpy(&isEnabled, pos, sizeof(int)); + pos += sizeof(int); + + IsEnabled = isEnabled > 0; + + memcpy(&Bounce, pos, sizeof(float)); + pos += sizeof(float); + + memcpy(&Height, pos, sizeof(float)); + pos += sizeof(float); + + memcpy(&WorldCoordinateSyatem, pos, sizeof(int)); + pos += sizeof(int); + } +} + +std::tuple CollisionsFunctions::Update( + CollisionsState& state, + const CollisionsParameter& parameter, + const SIMD::Vec3f& next_position_global, + const SIMD::Vec3f& position_global, + const SIMD::Vec3f& velocity_global, + const SIMD::Vec3f& position_center_local) +{ + if (!parameter.IsEnabled) + { + return { + SIMD::Vec3f(0, 0, 0), SIMD::Vec3f(0, 0, 0)}; + } + + auto next_position = next_position_global; + auto current_position = position_global; + + if (parameter.WorldCoordinateSyatem == WorldCoordinateSyatemType::Local) + { + next_position -= position_center_local; + current_position -= position_center_local; + } + + if (next_position.GetY() < parameter.Height && current_position.GetY() >= parameter.Height) + { + auto diff = next_position - current_position; + auto pos_diff = diff * (current_position.GetY() - parameter.Height) / diff.GetY(); + return {SIMD::Vec3f(0, -velocity_global.GetY() * (1.0f + parameter.Bounce), 0), pos_diff}; + } + else + { + return { + SIMD::Vec3f(0, 0, 0), SIMD::Vec3f(0, 0, 0)}; + } +} + +} // namespace Effekseer diff --git a/Dev/Cpp/Effekseer/Effekseer/Parameter/Collisions.h b/Dev/Cpp/Effekseer/Effekseer/Parameter/Collisions.h new file mode 100644 index 0000000000..f40a51af36 --- /dev/null +++ b/Dev/Cpp/Effekseer/Effekseer/Parameter/Collisions.h @@ -0,0 +1,39 @@ +#pragma once + +#include "../SIMD/Vec3f.h" +#include "../Utils/BinaryVersion.h" + +namespace Effekseer +{ + +enum class WorldCoordinateSyatemType : int32_t +{ + Local, + Global, +}; + +struct CollisionsState +{ +}; + +struct CollisionsParameter +{ + bool IsEnabled = false; + float Bounce = 1.0f; + float Height = 0.0f; + WorldCoordinateSyatemType WorldCoordinateSyatem = WorldCoordinateSyatemType::Local; + void Load(unsigned char*& pos, int version); +}; + +struct CollisionsFunctions +{ + static std::tuple Update( + CollisionsState& state, + const CollisionsParameter& parameter, + const SIMD::Vec3f& next_position_global, + const SIMD::Vec3f& position_global, + const SIMD::Vec3f& velocity_global, + const SIMD::Vec3f& position_center_local); +}; + +} // namespace Effekseer diff --git a/Dev/Cpp/Effekseer/Effekseer/Parameter/Rotation.cpp b/Dev/Cpp/Effekseer/Effekseer/Parameter/Rotation.cpp index 066b7ff460..4b929d8d76 100644 --- a/Dev/Cpp/Effekseer/Effekseer/Parameter/Rotation.cpp +++ b/Dev/Cpp/Effekseer/Effekseer/Parameter/Rotation.cpp @@ -90,6 +90,14 @@ void RotationParameter::Load(unsigned char*& pos, int version) memcpy(&size, pos, sizeof(int)); pos += sizeof(int); } + else if (RotationType == ParameterRotationType::ParameterRotationType_Velocity) + { + memcpy(&size, pos, sizeof(int)); + pos += sizeof(int); + + memcpy(&RotationVelocity.axis, pos, sizeof(DirectionalAxisType)); + pos += sizeof(int); + } } void RotationParameter::MakeCoordinateSystemLH() @@ -239,6 +247,15 @@ void RotationFunctions::InitRotation(RotationState& rotation_values, const Rotat } } +bool RotationFunctions::CalculateInGlobal(const RotationParameter& rotationParam) +{ + if (rotationParam.RotationType == ParameterRotationType::ParameterRotationType_Velocity) + { + return true; + } + return false; +} + SIMD::Mat43f RotationFunctions::CalculateRotation(RotationState& rotation_values, const RotationParameter& rotationParam, RandObject& rand, const Effect* effect, const InstanceGlobal* instanceGlobal, float m_LivingTime, float m_LivedTime, const Instance* m_pParent, const DynamicFactorParameter& dynamicFactor, const Vector3D& viewpoint) { SIMD::Vec3f localAngle; @@ -332,4 +349,66 @@ SIMD::Mat43f RotationFunctions::CalculateRotation(RotationState& rotation_values return matRot; } +SIMD::Mat43f RotationFunctions::CalculateRotationGlobal(RotationState& rotation_state, const RotationParameter& rotationParam, const SIMD::Vec3f& globalVelocity) +{ + SIMD::Vec3f localAngle = SIMD::Vec3f(0, 0, 0); + + if (rotationParam.RotationType == ParameterRotationType::ParameterRotationType_Velocity) + { + if (globalVelocity.GetSquaredLength() > 0.00001) + { + const auto dir = globalVelocity.GetNormal(); + const auto dir_y = Clamp(dir.GetY(), 1.0f, -1.0f); + const auto angle_x = -asinf(dir_y); + float angle_y = 0; + if (fabsf(dir_y) < 0.999f) + { + angle_y = atan2f(dir.GetX(), dir.GetZ()); + } + localAngle.SetX(angle_x); + localAngle.SetY(angle_y); + localAngle.SetZ(0); + } + else + { + localAngle = SIMD::Vec3f{0, 0, 0}; + } + } + + SIMD::Mat43f matRot; + if (rotationParam.RotationType == ParameterRotationType::ParameterRotationType_Velocity) + { + if (rotationParam.RotationVelocity.axis == DirectionalAxisType::ZPositive) + { + matRot = SIMD::Mat43f::RotationZXY(localAngle.GetZ(), localAngle.GetX(), localAngle.GetY()); + } + else if (rotationParam.RotationVelocity.axis == DirectionalAxisType::ZNegative) + { + matRot = SIMD::Mat43f::RotationY(EFK_PI) * SIMD::Mat43f::RotationZXY(localAngle.GetZ(), localAngle.GetX(), localAngle.GetY()); + } + else if (rotationParam.RotationVelocity.axis == DirectionalAxisType::XPositive) + { + matRot = SIMD::Mat43f::RotationY(EFK_PI / 2) * SIMD::Mat43f::RotationZXY(localAngle.GetZ(), localAngle.GetX(), localAngle.GetY()); + } + else if (rotationParam.RotationVelocity.axis == DirectionalAxisType::XNegative) + { + matRot = SIMD::Mat43f::RotationY(-EFK_PI / 2) * SIMD::Mat43f::RotationZXY(localAngle.GetZ(), localAngle.GetX(), localAngle.GetY()); + } + else if (rotationParam.RotationVelocity.axis == DirectionalAxisType::YPositive) + { + matRot = SIMD::Mat43f::RotationX(EFK_PI / 2) * SIMD::Mat43f::RotationZXY(localAngle.GetZ(), localAngle.GetX(), localAngle.GetY()); + } + else if (rotationParam.RotationVelocity.axis == DirectionalAxisType::YNegative) + { + matRot = SIMD::Mat43f::RotationX(-EFK_PI / 2) * SIMD::Mat43f::RotationZXY(localAngle.GetZ(), localAngle.GetX(), localAngle.GetY()); + } + } + else + { + matRot = SIMD::Mat43f::Identity; + } + + return matRot; +} + } // namespace Effekseer \ No newline at end of file diff --git a/Dev/Cpp/Effekseer/Effekseer/Parameter/Rotation.h b/Dev/Cpp/Effekseer/Effekseer/Parameter/Rotation.h index 1533ecf266..ec809e9ed2 100644 --- a/Dev/Cpp/Effekseer/Effekseer/Parameter/Rotation.h +++ b/Dev/Cpp/Effekseer/Effekseer/Parameter/Rotation.h @@ -13,6 +13,16 @@ namespace Effekseer { +enum class DirectionalAxisType : int +{ + XPositive, + XNegative, + YPositive, + YNegative, + ZPositive, + ZNegative +}; + struct RotationState { union @@ -30,13 +40,6 @@ struct RotationState } random; InstanceEasing easing; - /* - struct - { - SIMD::Vec3f start; - SIMD::Vec3f end; - } easing; - */ struct { @@ -60,6 +63,10 @@ struct RotationState { SIMD::Vec3f offset; } fcruve; + + struct + { + } velocity; }; }; @@ -70,10 +77,9 @@ enum class ParameterRotationType : int32_t ParameterRotationType_Easing = 2, ParameterRotationType_AxisPVA = 3, ParameterRotationType_AxisEasing = 4, - ParameterRotationType_FCurve = 5, - ParameterRotationType_RotateToViewpoint = 6, + ParameterRotationType_Velocity = 7, ParameterRotationType_None = 0x7fffffff - 1, }; @@ -115,6 +121,11 @@ struct ParameterRotationAxisEasing ParameterEasingFloat easing{Version16Alpha9, Version16Alpha9}; }; +struct ParameterRotationVelocity +{ + DirectionalAxisType axis; +}; + struct RotationParameter { ParameterRotationType RotationType = ParameterRotationType::ParameterRotationType_None; @@ -127,6 +138,8 @@ struct RotationParameter ParameterRotationAxisPVA RotationAxisPVA; ParameterRotationAxisEasing RotationAxisEasing; + ParameterRotationVelocity RotationVelocity; + void Load(unsigned char*& pos, int version); void MakeCoordinateSystemLH(); @@ -144,7 +157,11 @@ struct RotationFunctions static void InitRotation(RotationState& rotation_values, const RotationParameter& rotationParam, RandObject& rand, const Effect* effect, const InstanceGlobal* instanceGlobal, float m_LivingTime, float m_LivedTime, const Instance* m_pParent, const DynamicFactorParameter& dynamicFactor); + static bool CalculateInGlobal(const RotationParameter& rotationParam); + static SIMD::Mat43f CalculateRotation(RotationState& rotation_values, const RotationParameter& rotationParam, RandObject& rand, const Effect* effect, const InstanceGlobal* instanceGlobal, float m_LivingTime, float m_LivedTime, const Instance* m_pParent, const DynamicFactorParameter& dynamicFactor, const Vector3D& viewpoint); + + static SIMD::Mat43f CalculateRotationGlobal(RotationState& rotation_state, const RotationParameter& rotationParam, const SIMD::Vec3f& globalVelocity); }; } // namespace Effekseer diff --git a/Dev/Cpp/Effekseer/Effekseer/Utils/BinaryVersion.h b/Dev/Cpp/Effekseer/Effekseer/Utils/BinaryVersion.h index fc3ebb4b39..e4628da8af 100644 --- a/Dev/Cpp/Effekseer/Effekseer/Utils/BinaryVersion.h +++ b/Dev/Cpp/Effekseer/Effekseer/Utils/BinaryVersion.h @@ -25,6 +25,7 @@ const int32_t Version17Alpha4 = 1703; const int32_t Version17Alpha5 = 1704; const int32_t Version17Alpha6 = 1705; const int32_t Version17 = 1710; +const int32_t Version18Alpha1 = 1800; const int32_t CompiledMaterialVersion15 = 1; const int32_t CompiledMaterialVersion16 = 1610; diff --git a/Dev/Editor/CMakeLists.txt b/Dev/Editor/CMakeLists.txt index 99bc4494cc..0080b197c7 100644 --- a/Dev/Editor/CMakeLists.txt +++ b/Dev/Editor/CMakeLists.txt @@ -20,6 +20,7 @@ file(GLOB files_core EffekseerCore/Script/*.cs EffekseerCore/IO/*.cs EffekseerCore/Utils/*.cs + EffekseerCore/Data/CollisionsValues.cs EffekseerCore/Data/ProceduralModelValues.cs EffekseerCore/Data/Value/Int2.cs EffekseerCore/Data/Value/ObjectCollection.cs @@ -74,6 +75,7 @@ file(GLOB files Effekseer/GUI/Menu/*.cs Effekseer/Properties/*.cs Effekseer/Utils/*.cs + Effekseer/GUI/Dock/Collisions.cs Effekseer/GUI/Dock/ProceduralModel.cs ) diff --git a/Dev/Editor/Effekseer/App.cs b/Dev/Editor/Effekseer/App.cs index 1edab74529..b30389bbf1 100644 --- a/Dev/Editor/Effekseer/App.cs +++ b/Dev/Editor/Effekseer/App.cs @@ -26,6 +26,7 @@ protected override void OnInitialize() typeof(Dock.LocationAbsValues), typeof(Dock.GenerationLocationValues), typeof(Dock.KillRules), + typeof(Dock.CollisionsValues), typeof(Dock.RotationValues), typeof(Dock.ScaleValues), typeof(Dock.DepthValues), diff --git a/Dev/Editor/Effekseer/GUI/Dock/CollisionsValues.cs b/Dev/Editor/Effekseer/GUI/Dock/CollisionsValues.cs new file mode 100644 index 0000000000..dab43ce7e7 --- /dev/null +++ b/Dev/Editor/Effekseer/GUI/Dock/CollisionsValues.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Effekseer.GUI.Dock +{ + class CollisionsValues : DockPanel + { + BindableComponent.ParameterList paramerterList = null; + + bool isFiestUpdate = true; + + public CollisionsValues() + { + Label = Icons.PanelDepth + MultiLanguageTextProvider.GetText("Collisions") + "###Collisions"; + DocPage = "collisions.html"; + + paramerterList = new BindableComponent.ParameterList(); + paramerterList.SetType(typeof(Data.CollisionsValues)); + CopyAndPaste = new BindableComponent.CopyAndPaste("Collisions", GetTargetObject, Read); + + Core.OnAfterLoad += OnAfterLoad; + Core.OnAfterNew += OnAfterLoad; + Core.OnAfterSelectNode += OnAfterSelectNode; + + Read(); + + TabToolTip = MultiLanguageTextProvider.GetText("Collisions"); + } + + public void FixValues() + { + paramerterList.FixValues(); + } + + public override void OnDisposed() + { + FixValues(); + + Core.OnAfterLoad -= OnAfterLoad; + Core.OnAfterNew -= OnAfterLoad; + Core.OnAfterSelectNode -= OnAfterSelectNode; + } + + protected override void UpdateInternal() + { + if (isFiestUpdate) + { + } + + Manager.NativeManager.Separator(); + paramerterList.Update(); + } + + object GetTargetObject() + { + if (Core.SelectedNode != null) + { + if (Core.SelectedNode is Data.Node) + { + return ((Data.Node)Core.SelectedNode).CollisionsValues; + } + } + return null; + } + + + void Read() + { + paramerterList.SetValue(GetTargetObject()); + } + + void OnAfterLoad(object sender, EventArgs e) + { + Read(); + } + + void OnAfterSelectNode(object sender, EventArgs e) + { + Read(); + } + } +} \ No newline at end of file diff --git a/Dev/Editor/Effekseer/GUI/Menu/WindowMenu.cs b/Dev/Editor/Effekseer/GUI/Menu/WindowMenu.cs index 30855c890d..d77c006bed 100644 --- a/Dev/Editor/Effekseer/GUI/Menu/WindowMenu.cs +++ b/Dev/Editor/Effekseer/GUI/Menu/WindowMenu.cs @@ -14,6 +14,7 @@ internal sealed class WindowMenu new DockSettings("Rotation", typeof(Dock.RotationValues), Icons.PanelRotation), new DockSettings("Scale", typeof(Dock.ScaleValues), Icons.PanelScale), new DockSettings("Depth", typeof(Dock.DepthValues), Icons.PanelDepth), + new DockSettings("Collisions", typeof(Dock.CollisionsValues), Icons.PanelDepth), new DockSettings("RenderSettings", typeof(Dock.RendererValues), Icons.PanelRender), new DockSettings("BasicRenderSettings", typeof(Dock.RendererCommonValues), Icons.PanelRenderCommon), new DockSettings("AdvancedRenderSettings", typeof(Dock.AdvancedRenderCommonValues), Icons.PanelAdvancedRenderCommon), diff --git a/Dev/Editor/EffekseerCore/Binary/Exporter.cs b/Dev/Editor/EffekseerCore/Binary/Exporter.cs index cc6bd32df1..f63eab023d 100644 --- a/Dev/Editor/EffekseerCore/Binary/Exporter.cs +++ b/Dev/Editor/EffekseerCore/Binary/Exporter.cs @@ -28,7 +28,8 @@ public enum ExporterVersion Ver17Alpha5 = 1704, Ver17Alpha6 = 1705, Ver17 = 1710, - Latest = Ver17, + Ver18Alpha1 = 1800, + Latest = Ver18Alpha1, } public class Exporter @@ -986,6 +987,7 @@ public byte[] Export(Data.NodeRoot rootNode, float magnification = 1.0f) float compatibility = 1.0f; node_data.Add(compatibility.GetBytes()); + // Export kill rules { node_data.Add(n.KillRulesValues.Type.GetValueAsInt().GetBytes()); node_data.Add(BitConverter.GetBytes(n.KillRulesValues.IsScaleAndRotationApplied ? 1 : 0)); @@ -1019,6 +1021,14 @@ public byte[] Export(Data.NodeRoot rootNode, float magnification = 1.0f) } } + // Export collisions + { + node_data.Add(BitConverter.GetBytes(n.CollisionsValues.IsEnabled.Value ? 1 : 0)); + node_data.Add(BitConverter.GetBytes(n.CollisionsValues.Bounce.Value)); + node_data.Add(BitConverter.GetBytes(n.CollisionsValues.Height.Value)); + node_data.Add(BitConverter.GetBytes((int)n.CollisionsValues.WorldCoordinateSyatem.Value)); + } + node_data.Add(RendererCommonValues.GetBytes(n.RendererCommonValues, n.AdvancedRendererCommonValuesValues, texture_and_index, normalTexture_and_index, distortionTexture_and_index, material_and_index, ConvertLoadingFilePath)); if (isRenderParamExported) diff --git a/Dev/Editor/EffekseerCore/Binary/RotationValues.cs b/Dev/Editor/EffekseerCore/Binary/RotationValues.cs index 17042099fa..7396c26f0c 100644 --- a/Dev/Editor/EffekseerCore/Binary/RotationValues.cs +++ b/Dev/Editor/EffekseerCore/Binary/RotationValues.cs @@ -94,6 +94,15 @@ public static byte[] GetBytes(Data.RotationValues value) data.Add(bytes.Count().GetBytes()); data.Add(bytes); } + else if (rotationType == Data.RotationValues.ParamaterType.RotateToVelocity) + { + List _data = new List(); + _data.Add(((int)value.Velocity.Axis.Value).GetBytes()); + var bytes = _data.ToArray().ToArray(); + + data.Add(bytes.Count().GetBytes()); + data.Add(bytes); + } return data.ToArray().ToArray(); } diff --git a/Dev/Editor/EffekseerCore/Data/CollisionsValues.cs b/Dev/Editor/EffekseerCore/Data/CollisionsValues.cs new file mode 100644 index 0000000000..fc77eb0e1b --- /dev/null +++ b/Dev/Editor/EffekseerCore/Data/CollisionsValues.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Effekseer.Data +{ + public enum WorldCoordinateSyatemType : int + { + [Key(key = "WorldCoordinateSyatemType_Local")] + Local, + [Key(key = "WorldCoordinateSyatemType_World")] + World, + }; + + public class CollisionsValues + { + [Key(key = "Enabled")] + public Value.Boolean IsEnabled { get; set; } = new Value.Boolean(false); + + [Key(key = "Collisions_Bounce")] + public Value.Float Bounce { get; set; } = new Value.Float(1.0f); + + [Key(key = "Collisions_Height")] + public Value.Float Height { get; set; } = new Value.Float(0.0f); + + [Key(key = "Collisions_CoordinateSystem")] + public Value.Enum WorldCoordinateSyatem { get; set; } = new Value.Enum(); + } +} \ No newline at end of file diff --git a/Dev/Editor/EffekseerCore/Data/KillRulesValues.cs b/Dev/Editor/EffekseerCore/Data/KillRulesValues.cs index 8af33bb91b..3c0adff77e 100644 --- a/Dev/Editor/EffekseerCore/Data/KillRulesValues.cs +++ b/Dev/Editor/EffekseerCore/Data/KillRulesValues.cs @@ -3,6 +3,22 @@ namespace Effekseer.Data { + public enum PlaneAxisType : int + { + [Key(key = "PlaneAxisType_XPositive")] + XPositive, + [Key(key = "PlaneAxisType_XNegative")] + XNegative, + [Key(key = "PlaneAxisType_YPositive")] + YPositive, + [Key(key = "PlaneAxisType_YNegative")] + YNegative, + [Key(key = "PlaneAxisType_ZPositive")] + ZPositive, + [Key(key = "PlaneAxisType_ZNegative")] + ZNegative + } + public class KillRulesValues { @@ -52,7 +68,7 @@ public Value.Vector3D BoxCenter get; set; } - + [Key(key = "KillRules_Box_Size")] [Selected(ID = 1, Value = 1)] public Value.Vector3D BoxSize @@ -76,7 +92,7 @@ public Value.Enum PlaneAxis get; set; } - + [Key(key = "KillRules_Plane_PlaneOffset")] [Selected(ID = 1, Value = 2)] public Value.Float PlaneOffset @@ -84,7 +100,7 @@ public Value.Float PlaneOffset get; set; } - + [Key(key = "KillRules_Sphere_Center")] [Selected(ID = 1, Value = 3)] public Value.Vector3D SphereCenter @@ -92,7 +108,7 @@ public Value.Vector3D SphereCenter get; set; } - + [Key(key = "KillRules_Sphere_Radius")] [Selected(ID = 1, Value = 3)] public Value.Float SphereRadius @@ -100,8 +116,8 @@ public Value.Float SphereRadius get; set; } - - + + [Key(key = "KillRules_Sphere_IsKillInside")] [Selected(ID = 1, Value = 3)] public Value.Boolean SphereIsKillInside @@ -109,8 +125,8 @@ public Value.Boolean SphereIsKillInside get; set; } - - + + [Key(key = "KillRules_IsScaleAndRotationApplied")] [Selected(ID = 1, Value = 1)] [Selected(ID = 1, Value = 2)] @@ -125,11 +141,11 @@ public KillRulesValues() { Type = new Enum(KillType.None); IsScaleAndRotationApplied = new Boolean(true); - + BoxCenter = new Vector3D(0F, 0F, 0F); BoxSize = new Vector3D(0.5F, 0.5F, 0.5F, - float.MaxValue, 0, - float.MaxValue, 0, + float.MaxValue, 0, + float.MaxValue, 0, float.MaxValue, 0); BoxIsKillInside = new Boolean(false); @@ -152,23 +168,7 @@ public enum KillType : int [Key(key = "KillType_Sphere")] Sphere } - - public enum PlaneAxisType : int - { - [Key(key = "PlaneAxisType_XPositive")] - XPositive, - [Key(key = "PlaneAxisType_XNegative")] - XNegative, - [Key(key = "PlaneAxisType_YPositive")] - YPositive, - [Key(key = "PlaneAxisType_YNegative")] - YNegative, - [Key(key = "PlaneAxisType_ZPositive")] - ZPositive, - [Key(key = "PlaneAxisType_ZNegative")] - ZNegative - } - + public class PlaneAxisSpace { public readonly Vector3D Normal; diff --git a/Dev/Editor/EffekseerCore/Data/Node.cs b/Dev/Editor/EffekseerCore/Data/Node.cs index cf3c668493..4bf60d6f38 100644 --- a/Dev/Editor/EffekseerCore/Data/Node.cs +++ b/Dev/Editor/EffekseerCore/Data/Node.cs @@ -85,7 +85,7 @@ public AdvancedRenderCommonValues AdvancedRendererCommonValuesValues get; private set; } - + [IO(Export = true)] public KillRulesValues KillRulesValues { @@ -93,6 +93,13 @@ public KillRulesValues KillRulesValues private set; } + [IO(Export = true)] + public CollisionsValues CollisionsValues + { + get; + private set; + } = new CollisionsValues(); + /// /// コンストラクタ /// diff --git a/Dev/Editor/EffekseerCore/Data/RotationValues.cs b/Dev/Editor/EffekseerCore/Data/RotationValues.cs index 004ed2c103..8e30a343c3 100644 --- a/Dev/Editor/EffekseerCore/Data/RotationValues.cs +++ b/Dev/Editor/EffekseerCore/Data/RotationValues.cs @@ -62,6 +62,10 @@ public RotationFCurveParamater RotationFCurve private set; } + [Selected(ID = 0, Value = 7)] + [IO(Export = true)] + public RotationVelocityParamater Velocity { get; private set; } = new RotationVelocityParamater(); + internal RotationValues() { Type = new Value.Enum(ParamaterType.Fixed); @@ -214,6 +218,11 @@ public RotationFCurveParamater() } } + public class RotationVelocityParamater + { + public Value.Enum Axis { get; private set; } = new Value.Enum(PlaneAxisType.XPositive); + } + public enum ParamaterType : int { [Key(key = "Rotation_ParamaterType_Fixed")] @@ -230,6 +239,8 @@ public enum ParamaterType : int RotationFCurve = 5, [Key(key = "Rotation_ParamaterType_RotateToViewpoint")] RotateToViewpoint = 6, + [Key(key = "Rotation_ParamaterType_RotateToVelocity")] + RotateToVelocity = 7, } } } \ No newline at end of file diff --git a/Dev/Editor/EffekseerCoreGUI/Application.cs b/Dev/Editor/EffekseerCoreGUI/Application.cs index 904e1f3054..e43bbc43b1 100644 --- a/Dev/Editor/EffekseerCoreGUI/Application.cs +++ b/Dev/Editor/EffekseerCoreGUI/Application.cs @@ -215,6 +215,7 @@ private static void ChangeLanguage() MultiLanguageTextProvider.LoadCSV("Effekseer.csv"); MultiLanguageTextProvider.LoadCSV("Effekseer_Options.csv"); MultiLanguageTextProvider.LoadCSV("Effekseer_BasicSettings.csv"); + MultiLanguageTextProvider.LoadCSV("Effekseer_Collisions.csv"); MultiLanguageTextProvider.LoadCSV("Effekseer_Position.csv"); MultiLanguageTextProvider.LoadCSV("Effekseer_Rotation.csv"); MultiLanguageTextProvider.LoadCSV("Effekseer_Scale.csv"); diff --git a/Dev/Editor/EffekseerCoreGUI/GUI/Viewer.cs b/Dev/Editor/EffekseerCoreGUI/GUI/Viewer.cs index c43eb833f7..f0b9139de4 100644 --- a/Dev/Editor/EffekseerCoreGUI/GUI/Viewer.cs +++ b/Dev/Editor/EffekseerCoreGUI/GUI/Viewer.cs @@ -9,7 +9,7 @@ namespace Effekseer.GUI { - public class Viewer: EffectRendererCallback + public class Viewer : EffectRendererCallback { HardwareDevice hardwareDevice; swig.EffectSetting effectSetting; @@ -76,7 +76,7 @@ public Viewer(HardwareDevice hardwareDevice) protected override void Dispose(bool disposing) { base.Dispose(disposing); - + if (CurrentEffect != null) { CurrentEffect.Dispose(); @@ -98,7 +98,7 @@ protected override void Dispose(bool disposing) if (EffectRenderer != null) { EffectRenderer.Callback = null; - + EffectRenderer.Dispose(); EffectRenderer = null; } @@ -260,7 +260,7 @@ public bool Initialize(swig.DeviceType deviceType) EffectRenderer = new swig.MainScreenEffectRenderer(); EffectRenderer.Initialize(hardwareDevice.GraphicsDevice, hardwareDevice.SoundDevice, effectSetting, spriteCount, hardwareDevice.GraphicsDevice.GetIsSRGBMode()); EffectRenderer.Callback = this; - + ViewPointController = new swig.ViewPointController(); ViewPointController.ProjectionStyle = deviceType == swig.DeviceType.OpenGL ? swig.ProjectionMatrixStyle.OpenGLStyle : swig.ProjectionMatrixStyle.DirectXStyle; @@ -333,7 +333,7 @@ public override void OnAfterClear() if (Core.Option.RenderingMode != OptionValues.RenderMode.Overdraw) { - RenderGrid(cameraMatrix,projectionMatrix); + RenderGrid(cameraMatrix, projectionMatrix); RenderKillRulesPreview(cameraMatrix, projectionMatrix); RenderCullingPreview(cameraMatrix, projectionMatrix); } @@ -343,7 +343,7 @@ private void RenderSphere(Matrix44F cameraMatrix, Matrix44F projectionMatrix, float sphereX, float sphereY, float sphereZ, float sphereRadius, Color color) { EffectRenderer.StartRenderingLines(); - + for (int y = -3; y <= 3; y++) { float ylen = sphereRadius * (y / 4.0f); @@ -353,7 +353,7 @@ private void RenderSphere(Matrix44F cameraMatrix, Matrix44F projectionMatrix, { float a0 = 3.1415f * 2.0f / 9.0f * r; float a1 = 3.1415f * 2.0f / 9.0f * (r + 1.0f); - + EffectRenderer.AddLine( (float)(sphereX + Math.Sin(a0) * radius), sphereY + ylen, (float)(sphereZ + Math.Cos(a0) * radius), (float)(sphereX + Math.Sin(a1) * radius), sphereY + ylen, (float)(sphereZ + Math.Cos(a1) * radius), @@ -361,14 +361,14 @@ private void RenderSphere(Matrix44F cameraMatrix, Matrix44F projectionMatrix, ); } } - + EffectRenderer.EndRenderingLines(cameraMatrix, projectionMatrix); } private void RenderGrid(Matrix44F cameraMatrix, Matrix44F projectionMatrix) { - if(!Core.Option.IsGridShown) return; - + if (!Core.Option.IsGridShown) return; + Color gridColor = new Color { R = (byte)Core.Option.GridColor.R, @@ -405,7 +405,7 @@ private void RenderGrid(Matrix44F cameraMatrix, Matrix44F projectionMatrix) gridColor); } } - + if (Core.Option.IsYZGridShown) { for (int i = -5; i <= 5; i++) @@ -418,17 +418,17 @@ private void RenderGrid(Matrix44F cameraMatrix, Matrix44F projectionMatrix) gridColor); } } - + EffectRenderer.AddLine(0, 0.001F, 0, gridLength, 0.001F, 0, new Color(255, 0, 0, 255)); EffectRenderer.AddLine(0, 0, 0, 0, gridLength, 0, new Color(0, 255, 0, 255)); EffectRenderer.AddLine(0, 0.001F, 0, 0, 0.001F, gridLength, new Color(0, 0, 255, 255)); - + EffectRenderer.EndRenderingLines(cameraMatrix, projectionMatrix); } - + private void RenderCullingPreview(Matrix44F cameraMatrix, Matrix44F projectionMatrix) { if (Core.Culling.Type.Value != Data.EffectCullingValues.ParamaterType.Sphere) return; @@ -437,11 +437,11 @@ private void RenderCullingPreview(Matrix44F cameraMatrix, Matrix44F projectionMa Core.Culling.Sphere.Location.X, Core.Culling.Sphere.Location.Y, Core.Culling.Sphere.Location.Z, Core.Culling.Sphere.Radius, new Color(255, 255, 255, 255)); } - + private void RenderKillRulesPreview(Matrix44F cameraMatrix, Matrix44F projectionMatrix) { if (Core.SelectedNode == null || !(Core.SelectedNode is Data.Node)) return; - + Data.Node node = (Data.Node)Core.SelectedNode; if (node.KillRulesValues.Type == KillRulesValues.KillType.Height) @@ -449,7 +449,7 @@ private void RenderKillRulesPreview(Matrix44F cameraMatrix, Matrix44F projection EffectRenderer.StartRenderingLines(); Color planeColor = new Color(0xFF, 0x23, 0x23, 0xff); - KillRulesValues.PlaneAxisType axisType = node.KillRulesValues.PlaneAxis; + PlaneAxisType axisType = node.KillRulesValues.PlaneAxis; KillRulesValues.PlaneAxisSpace space = KillRulesValues.PlaneAxisNormal[axisType]; Vector3D normal = space.Normal; Vector3D tangent = space.Tangent; @@ -463,15 +463,15 @@ private void RenderKillRulesPreview(Matrix44F cameraMatrix, Matrix44F projection float v1X = offsetX - tangent.X * 5F - bitangent.X * 5F; float v1Y = offsetY - tangent.Y * 5F - bitangent.Y * 5F; float v1Z = offsetZ - tangent.Z * 5F - bitangent.Z * 5F; - + float v2X = offsetX + tangent.X * 5F - bitangent.X * 5F; float v2Y = offsetY + tangent.Y * 5F - bitangent.Y * 5F; float v2Z = offsetZ + tangent.Z * 5F - bitangent.Z * 5F; - + float v3X = offsetX + tangent.X * 5F + bitangent.X * 5F; float v3Y = offsetY + tangent.Y * 5F + bitangent.Y * 5F; float v3Z = offsetZ + tangent.Z * 5F + bitangent.Z * 5F; - + float v4X = offsetX - tangent.X * 5F + bitangent.X * 5F; float v4Y = offsetY - tangent.Y * 5F + bitangent.Y * 5F; float v4Z = offsetZ - tangent.Z * 5F + bitangent.Z * 5F; @@ -485,16 +485,16 @@ void AddPointer(float x, float y, float z, float nx, float ny, float nz, Color c { EffectRenderer.AddLine(x, y, z, x + nx, y + ny, z + nz, color); } - - AddPointer((v1X + v2X) * 0.5F, (v1Y + v2Y) * 0.5F, (v1Z + v2Z) * 0.5F, + + AddPointer((v1X + v2X) * 0.5F, (v1Y + v2Y) * 0.5F, (v1Z + v2Z) * 0.5F, normal.X, normal.Y, normal.Z, planeColor); - AddPointer((v2X + v3X) * 0.5F, (v2Y + v3Y) * 0.5F, (v2Z + v3Z) * 0.5F, + AddPointer((v2X + v3X) * 0.5F, (v2Y + v3Y) * 0.5F, (v2Z + v3Z) * 0.5F, normal.X, normal.Y, normal.Z, planeColor); - AddPointer((v3X + v4X) * 0.5F, (v3Y + v4Y) * 0.5F, (v3Z + v4Z) * 0.5F, + AddPointer((v3X + v4X) * 0.5F, (v3Y + v4Y) * 0.5F, (v3Z + v4Z) * 0.5F, normal.X, normal.Y, normal.Z, planeColor); - AddPointer((v4X + v1X) * 0.5F, (v4Y + v1Y) * 0.5F, (v4Z + v1Z) * 0.5F, + AddPointer((v4X + v1X) * 0.5F, (v4Y + v1Y) * 0.5F, (v4Z + v1Z) * 0.5F, normal.X, normal.Y, normal.Z, planeColor); - + EffectRenderer.EndRenderingLines(cameraMatrix, projectionMatrix); } if (node.KillRulesValues.Type == KillRulesValues.KillType.Box) @@ -507,40 +507,40 @@ void AddPointer(float x, float y, float z, float nx, float ny, float nz, Color c float maxX = center.X + size.X; float maxY = center.Y + size.Y; float maxZ = center.Z + size.Z; - - Color boxColor = node.KillRulesValues.BoxIsKillInside ? + + Color boxColor = node.KillRulesValues.BoxIsKillInside ? new Color(0xFF, 0x23, 0x23, 0xFF) : new Color(0x23, 0xFF, 0x23, 0xFF); - + EffectRenderer.StartRenderingLines(); - + // bottom rectangle - EffectRenderer.AddLine(minX, minY, minZ, + EffectRenderer.AddLine(minX, minY, minZ, maxX, minY, minZ, boxColor); - EffectRenderer.AddLine(maxX, minY, minZ, + EffectRenderer.AddLine(maxX, minY, minZ, maxX, minY, maxZ, boxColor); - EffectRenderer.AddLine(maxX, minY, maxZ, + EffectRenderer.AddLine(maxX, minY, maxZ, minX, minY, maxZ, boxColor); - EffectRenderer.AddLine(minX, minY, maxZ, + EffectRenderer.AddLine(minX, minY, maxZ, minX, minY, minZ, boxColor); - + // top rectangle - EffectRenderer.AddLine(minX, maxY, minZ, + EffectRenderer.AddLine(minX, maxY, minZ, maxX, maxY, minZ, boxColor); - EffectRenderer.AddLine(maxX, maxY, minZ, + EffectRenderer.AddLine(maxX, maxY, minZ, maxX, maxY, maxZ, boxColor); - EffectRenderer.AddLine(maxX, maxY, maxZ, + EffectRenderer.AddLine(maxX, maxY, maxZ, minX, maxY, maxZ, boxColor); - EffectRenderer.AddLine(minX, maxY, maxZ, + EffectRenderer.AddLine(minX, maxY, maxZ, minX, maxY, minZ, boxColor); - + // sides - EffectRenderer.AddLine(minX, minY, minZ, + EffectRenderer.AddLine(minX, minY, minZ, minX, maxY, minZ, boxColor); - EffectRenderer.AddLine(maxX, minY, minZ, + EffectRenderer.AddLine(maxX, minY, minZ, maxX, maxY, minZ, boxColor); - EffectRenderer.AddLine(minX, minY, maxZ, + EffectRenderer.AddLine(minX, minY, maxZ, minX, maxY, maxZ, boxColor); - EffectRenderer.AddLine(maxX, minY, maxZ, + EffectRenderer.AddLine(maxX, minY, maxZ, maxX, maxY, maxZ, boxColor); EffectRenderer.EndRenderingLines(cameraMatrix, projectionMatrix); } @@ -549,9 +549,9 @@ void AddPointer(float x, float y, float z, float nx, float ny, float nz, Color c { Vector3D sphereCenter = node.KillRulesValues.SphereCenter; float radius = node.KillRulesValues.SphereRadius; - Color sphereColor = node.KillRulesValues.SphereIsKillInside ? + Color sphereColor = node.KillRulesValues.SphereIsKillInside ? new Color(0xFF, 0x23, 0x23, 0xFF) : new Color(0x23, 0xFF, 0x23, 0xFF); - + RenderSphere(cameraMatrix, projectionMatrix, sphereCenter.X, sphereCenter.Y, sphereCenter.Z, radius, sphereColor); @@ -591,7 +591,8 @@ public void UpdateViewer() stepFrame = Math.Min(stepFrame, 4); StepViewer(stepFrame, true); - } else if (IsPlaying && IsPaused) + } + else if (IsPlaying && IsPaused) { // need to update LOD which could have changed because of changed camera position // even if effect is paused @@ -652,7 +653,7 @@ public void UpdateViewer() Core.Option.MouseRotInvY, Core.Option.MouseSlideInvX, Core.Option.MouseSlideInvY); - + EffectRenderer.SetLODDistanceBias(LODDistanceBias); } else diff --git a/Dev/release/resources/languages/en/Base.csv b/Dev/release/resources/languages/en/Base.csv index 9bc9b8ee57..eb482f3f90 100644 --- a/Dev/release/resources/languages/en/Base.csv +++ b/Dev/release/resources/languages/en/Base.csv @@ -1,13 +1,16 @@ CharacterTable,default Language_en,English Language_ja,日本語 -"","" -"Save","Save" -"Cancel","Cancel" -"Select","Select" -"MultipleValues","Multiple values" -"Enabled_Name","Enabled" -"Disabled_Name","Disabled" -"","" -"Font_Normal","resources/GenShinGothic-Monospace-Normal.ttf" -"Font_Bold","resources/fonts/GenShinGothic-Monospace-Bold.ttf" \ No newline at end of file +, +Save,Save +Cancel,Cancel +Select,Select +MultipleValues,Multiple values +Enabled_Name,Enabled +Disabled_Name,Disabled +, +WorldCoordinateSyatemType_Local_Name,Local +WorldCoordinateSyatemType_World_Name,World +, +Font_Normal,resources/GenShinGothic-Monospace-Normal.ttf +Font_Bold,resources/fonts/GenShinGothic-Monospace-Bold.ttf diff --git a/Dev/release/resources/languages/en/Effekseer_Collisions.csv b/Dev/release/resources/languages/en/Effekseer_Collisions.csv new file mode 100644 index 0000000000..2d6b31c8a9 --- /dev/null +++ b/Dev/release/resources/languages/en/Effekseer_Collisions.csv @@ -0,0 +1,4 @@ +Collisions,Collisions +Collisions_Bounce_Name,Bounce +Collisions_Height_Name,Height +Collisions_CoordinateSystem_Name,CoordinateSystem diff --git a/Dev/release/resources/languages/en/Effekseer_Rotation.csv b/Dev/release/resources/languages/en/Effekseer_Rotation.csv index b964664fb9..d9ed116443 100644 --- a/Dev/release/resources/languages/en/Effekseer_Rotation.csv +++ b/Dev/release/resources/languages/en/Effekseer_Rotation.csv @@ -1,10 +1,11 @@ -Rotation_ParamaterType_Fixed_Name,Fixed Angle +Rotation_ParamaterType_Fixed_Name,Fixed Angle Rotation_ParamaterType_PVA_Name,PVA Rotation_ParamaterType_Easing_Name,Easing Rotation_ParamaterType_AxisPVA_Name,PVA (Arbitrary Axis) Rotation_ParamaterType_AxisEasing_Name,Easing (Arbitrary Axis) Rotation_ParamaterType_RotationFCurve_Name,Rotation (F-Curve) Rotation_ParamaterType_RotateToViewpoint_Name,Rotate in the viewpoint direction +Rotation_ParameterType_RotateToVelocity_Name,Rotate to the moving direction Rotation_FixedParamater_Rotation_Name,Angle Rotation_FixedParamater_Rotation_Desc,"Rotation of the instance, in degrees" Rotation_PVAParamater_Rotation_Name,Angle @@ -28,4 +29,4 @@ Accel" Rotation_AxisPVAParamater_Acceleration_Desc,"Acceleration of the instance's angular velocity, in degrees" Rotation_AxisEasingParamater_Axis_Name,"Axis of Rotation" -Rotation_AxisEasingParamater_Axis_Desc,Axis of rotation of the instance \ No newline at end of file +Rotation_AxisEasingParamater_Axis_Desc,Axis of rotation of the instance diff --git a/Dev/release/resources/languages/ja/Base.csv b/Dev/release/resources/languages/ja/Base.csv index 4d494acf0a..35a2a08613 100644 --- a/Dev/release/resources/languages/ja/Base.csv +++ b/Dev/release/resources/languages/ja/Base.csv @@ -1,13 +1,16 @@ CharacterTable,japanese Language_en,English Language_ja,日本語 -"","" -"Save","保存" -"Cancel","キャンセル" -"Select","選択" -"MultipleValues","複数の値" -"Enabled_Name","有効" -"Disabled_Name","無効" -"","" -"Font_Normal","resources/GenShinGothic-Monospace-Normal.ttf" -"Font_Bold","resources/fonts/GenShinGothic-Monospace-Bold.ttf" \ No newline at end of file +, +Save,保存 +Cancel,キャンセル +Select,選択 +MultipleValues,複数の値 +Enabled_Name,有効 +Disabled_Name,無効 +, +WorldCoordinateSyatemType_Local_Name,Local +WorldCoordinateSyatemType_World_Name,World +, +Font_Normal,resources/GenShinGothic-Monospace-Normal.ttf +Font_Bold,resources/fonts/GenShinGothic-Monospace-Bold.ttf diff --git a/Dev/release/resources/languages/ja/Effekseer_Collisions.csv b/Dev/release/resources/languages/ja/Effekseer_Collisions.csv new file mode 100644 index 0000000000..5f4f2a8c6a --- /dev/null +++ b/Dev/release/resources/languages/ja/Effekseer_Collisions.csv @@ -0,0 +1,4 @@ +Collisions,衝突 +Collisions_Bounce_Name,バウンス +Collisions_Height_Name,高さ +Collisions_CoordinateSystem_Name,座標系 diff --git a/Dev/release/resources/languages/ja/Effekseer_Rotation.csv b/Dev/release/resources/languages/ja/Effekseer_Rotation.csv index d4b312c935..bcf52d1f77 100644 --- a/Dev/release/resources/languages/ja/Effekseer_Rotation.csv +++ b/Dev/release/resources/languages/ja/Effekseer_Rotation.csv @@ -1,10 +1,11 @@ -Rotation_ParamaterType_Fixed_Name,角度 +Rotation_ParamaterType_Fixed_Name,角度 Rotation_ParamaterType_PVA_Name,角度・速度・加速度 Rotation_ParamaterType_Easing_Name,イージング Rotation_ParamaterType_AxisPVA_Name,任意軸 角度・速度・加速度 Rotation_ParamaterType_AxisEasing_Name,任意軸 イージング Rotation_ParamaterType_RotationFCurve_Name,角度(Fカーブ) Rotation_ParamaterType_RotateToViewpoint_Name,視点方向に回転 +Rotation_ParameterType_RotateToVelocity_Name,移動方向に回転 Rotation_FixedParamater_Rotation_Name,角度(度) Rotation_FixedParamater_Rotation_Desc,インスタンスの角度 Rotation_PVAParamater_Rotation_Name,角度(度) @@ -22,4 +23,4 @@ Rotation_AxisPVAParamater_Velocity_Desc,インスタンスの角速度 Rotation_AxisPVAParamater_Acceleration_Name,角加速度(度) Rotation_AxisPVAParamater_Acceleration_Desc,インスタンスの初期角加速度 Rotation_AxisEasingParamater_Axis_Name,回転軸 -Rotation_AxisEasingParamater_Axis_Desc,インスタンスの回転軸 \ No newline at end of file +Rotation_AxisEasingParamater_Axis_Desc,インスタンスの回転軸