diff --git a/Assets/Scenes/Level1.shade b/Assets/Scenes/Level1.shade index af4c20e3..fbb6ba1c 100644 --- a/Assets/Scenes/Level1.shade +++ b/Assets/Scenes/Level1.shade @@ -7124,7 +7124,7 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: -2.50000072, y: 0.799999893, z: -4.28408909} + Translate: {x: -2.51287055, y: 0.799999893, z: -4.28408909} Rotate: {x: -5.83341553e-08, y: 7.48974247e-14, z: 1.10461471e-08} Scale: {x: 1, y: 1, z: 1} IsActive: true @@ -8178,4 +8178,75 @@ Hovered: false Clicked: false IsActive: true - Scripts: ~ \ No newline at end of file + Scripts: ~ +- EID: 523 + Name: Mesh_Apple + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -7.29431438, y: 1.17736602, z: -4.53253984} + Rotate: {x: -5.83341553e-08, y: 7.48974247e-14, z: 1.10461471e-08} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Renderable Component: + Mesh: 144128170 + Material: 122370915 + IsActive: true + RigidBody Component: + Type: Dynamic + Drag: 0.00999999978 + Angular Drag: 0.100000001 + Gravity Scale: 1 + Use Gravity: true + Interpolate: false + Sleeping Enabled: true + Freeze Position X: false + Freeze Position Y: false + Freeze Position Z: false + Freeze Rotation X: false + Freeze Rotation Y: false + Freeze Rotation Z: false + IsActive: true + Collider Component: + Colliders: + - Is Trigger: false + Collision Tag: 2 + Type: Box + Half Extents: {x: 0.200000003, y: 0.200000003, z: 0.200000003} + Friction: 0.400000006 + Bounciness: 0 + Density: 1 + Position Offset: {x: 0, y: 0, z: 0} + Rotation Offset: {x: 0, y: 0, z: 0} + IsActive: true + classSHADE::SHParticleEmitterComponent: + Emission Count: 4 + Is Passive: false + Emission Interval: 0 + Min Life: 1 + Max Life: 2 + Minimum Speed: 1 + Maximum Speed: 1.5 + Minimum Size: 0 + Maximum Size: 0.075000003 + Size Decay: 0.907999992 + Angular Ranges And Offset: {x: 6.19999981, y: 3.1400001, z: 0, w: 1.70000005} + Rotation Speed: 0.805999994 + Rotation Decay: 0 + Texture Asset ID: 0 + Custom Update Shader Asset ID: 0 + Color Tint: {x: 0.470701218, y: 0.559471369, z: 0.283432603, w: 1} + Acceleration: {x: 0, y: -0.0390000008, z: 0} + IsActive: true + Scripts: + - Type: Item + Enabled: true + Score: 10 + currCategory: 0 + density: 1 + dontReturn: false + soundDistance: 10 + highlightSpeed: 200 + highlightThickness: 60 + highlightLowerClamp: 0.25 \ No newline at end of file diff --git a/Assets/Scenes/Scene2.shade.shmeta b/Assets/Scenes/Scene2.shade.shmeta new file mode 100644 index 00000000..9ec289c8 --- /dev/null +++ b/Assets/Scenes/Scene2.shade.shmeta @@ -0,0 +1,3 @@ +Name: Scene2 +ID: 89281126 +Type: 5 diff --git a/Assets/Scripts/Gameplay/Item/SC_Item.cs b/Assets/Scripts/Gameplay/Item/SC_Item.cs index be28bb5a..3fdeee6e 100644 --- a/Assets/Scripts/Gameplay/Item/SC_Item.cs +++ b/Assets/Scripts/Gameplay/Item/SC_Item.cs @@ -33,6 +33,8 @@ public class Item : Script public float highlightThickness = 600.0f; public float highlightLowerClamp = 0.25f; + private ParticleEmitter emitter; + protected override void awake() { @@ -50,6 +52,8 @@ public class Item : Script AudioHandler.audioClipHandlers["SFXImpactElastic"] = Audio.CreateAudioClip("event:/Props/impact_elastic"); AudioHandler.audioClipHandlers["SFXImpactHard"] = Audio.CreateAudioClip("event:/Props/impact_hard"); + + emitter = GetComponent(); } protected override void start() @@ -135,6 +139,11 @@ public class Item : Script playSound = false; Audio.DetachAudioClipFromObject(AudioHandler.audioClipHandlers["SFXImpactElastic"]); Audio.DetachAudioClipFromObject(AudioHandler.audioClipHandlers["SFXImpactHard"]); + + if(emitter) + emitter.Emit(); + + Debug.Log("EMIT"); } if (info.GameObject.GetScript() && !returnBack) diff --git a/Assets/Shaders/ParticleEmit_CS.glsl b/Assets/Shaders/ParticleEmit_CS.glsl index 43ed335d..b2f81a05 100644 --- a/Assets/Shaders/ParticleEmit_CS.glsl +++ b/Assets/Shaders/ParticleEmit_CS.glsl @@ -7,6 +7,7 @@ layout(local_size_x = 128) in; struct EmitterParameters { vec4 angularRangesAndOffsets; + vec4 acceleration; float minSpeed; float maxSpeed; float rotationSpeed; @@ -187,7 +188,7 @@ void main() particle.orientationSpeedDecay = vec4 (0.0f); - particle.acceleration = vec4 (0.0f, -0.058f, 0.0f, 0.0f); + particle.acceleration = emitterParams.data.acceleration; inputParticles.data[index] = particle; diff --git a/Assets/Shaders/ParticleEmit_CS.shshaderb b/Assets/Shaders/ParticleEmit_CS.shshaderb index dea78edc..08972d9d 100644 Binary files a/Assets/Shaders/ParticleEmit_CS.shshaderb and b/Assets/Shaders/ParticleEmit_CS.shshaderb differ diff --git a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp index 421aec6d..208134bf 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp +++ b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp @@ -883,6 +883,16 @@ namespace SHADE comp->SetRotationDecay(val); }); + SHEditorWidgets::DragVec3("Acceleration", {"x", "y", "z"}, + [comp = component]() + { + return comp->GetAcceleration(); + }, + [comp = component](SHVec3 const& val) + { + comp->SetAcceleration(val); + }); + SHEditorWidgets::ColorPicker("Color Tint", [comp = component]() { @@ -903,6 +913,13 @@ namespace SHADE { comp->SetTextureAssetID(val); }); + ImGui::SameLine(); + if (ImGui::Button("Reset")) + { + component->SetTextureAssetID(0); + component->SetTextureIndex(0); + } + if (SHDragDrop::BeginTarget()) { if (AssetID* payload = SHDragDrop::AcceptPayload(SHDragDrop::DRAG_RESOURCE)) diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Particles/SHParticleEmitterComponent.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Particles/SHParticleEmitterComponent.cpp index fcdb20da..d6f1e115 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Particles/SHParticleEmitterComponent.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Particles/SHParticleEmitterComponent.cpp @@ -52,6 +52,13 @@ namespace SHADE } + void SHParticleEmitterComponent::SetAcceleration(SHVec3 const& accel) noexcept + { + cpuEmitterData.accleration.x = accel.x; + cpuEmitterData.accleration.y = accel.y; + cpuEmitterData.accleration.z = accel.z; + } + void SHParticleEmitterComponent::SetAngularRanges(SHVec2 const& ranges) noexcept { cpuEmitterData.angularRangesAndOffsets.x = ranges.x; @@ -177,6 +184,11 @@ namespace SHADE return {cpuEmitterData.angularRangesAndOffsets.z, cpuEmitterData.angularRangesAndOffsets.w }; } + SHVec3 SHParticleEmitterComponent::GetAcceleration(void) const noexcept + { + return SHVec3{cpuEmitterData.accleration.x, cpuEmitterData.accleration.y, cpuEmitterData.accleration.z }; + } + float SHParticleEmitterComponent::GetMinSpeed(void) const noexcept { return cpuEmitterData.minSpeed; diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Particles/SHParticleEmitterComponent.h b/SHADE_Engine/src/Graphics/MiddleEnd/Particles/SHParticleEmitterComponent.h index e5360e85..47791c44 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Particles/SHParticleEmitterComponent.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Particles/SHParticleEmitterComponent.h @@ -25,6 +25,9 @@ namespace SHADE //! Angular ranges of emission SHVec4 angularRangesAndOffsets; + //! Acceleration + SHVec4 accleration; + //! minimum starting velocity float minSpeed; @@ -154,6 +157,7 @@ namespace SHADE void SetMinLife (float val) noexcept; void SetMaxLife (float val) noexcept; void SetAngularRangesAndOffsets (SHVec4 const& ranges) noexcept; + void SetAcceleration (SHVec3 const& accel) noexcept; void SetAngularRanges (SHVec2 const& ranges) noexcept; void SetAngularOffsets (SHVec2 const& offsets) noexcept; void SetMinSpeed (float speed) noexcept; @@ -177,6 +181,7 @@ namespace SHADE SHVec4 const& GetAngularRangesAndOffsets (void) const noexcept; SHVec2 GetAngularRanges (void) const noexcept; SHVec2 GetAngularOffsets (void) const noexcept; + SHVec3 GetAcceleration (void) const noexcept; float GetMinSpeed (void) const noexcept; float GetMaxSpeed (void) const noexcept; float GetRotationSpeed (void) const noexcept; diff --git a/SHADE_Engine/src/Serialization/SHYAMLConverters.h b/SHADE_Engine/src/Serialization/SHYAMLConverters.h index 923037d1..8805ed41 100644 --- a/SHADE_Engine/src/Serialization/SHYAMLConverters.h +++ b/SHADE_Engine/src/Serialization/SHYAMLConverters.h @@ -520,6 +520,7 @@ namespace YAML static constexpr std::string_view TEXTURE_ASSET_ID_TAG = "Texture Asset ID"; static constexpr std::string_view CUSTOM_UPDATE_SHADER_ASSET_ID_TAG = "Custom Update Shader Asset ID"; static constexpr std::string_view COLOR_TINT_TAG = "Color Tint"; + static constexpr std::string_view ACCELERATION_TAG = "Acceleration"; static YAML::Node encode(SHParticleEmitterComponent const& rhs) { @@ -540,6 +541,7 @@ namespace YAML node[TEXTURE_ASSET_ID_TAG.data()] = rhs.GetTextureAssetID(); node[CUSTOM_UPDATE_SHADER_ASSET_ID_TAG.data()] = rhs.GetCustomUpdateShaderAssetID(); node[COLOR_TINT_TAG.data()] = rhs.GetColorTint(); + node[ACCELERATION_TAG.data()] = rhs.GetAcceleration(); return node; } @@ -586,6 +588,9 @@ namespace YAML if (node[COLOR_TINT_TAG.data()].IsDefined()) rhs.SetColorTint(node[COLOR_TINT_TAG.data()].as()); + if (node[ACCELERATION_TAG.data()].IsDefined()) + rhs.SetAcceleration(node[ACCELERATION_TAG.data()].as()); + if (node[TEXTURE_ASSET_ID_TAG.data()].IsDefined()) { AssetID id = node[TEXTURE_ASSET_ID_TAG.data()].as(); diff --git a/SHADE_Managed/src/Engine/ECS.cxx b/SHADE_Managed/src/Engine/ECS.cxx index c79175bf..38138be6 100644 --- a/SHADE_Managed/src/Engine/ECS.cxx +++ b/SHADE_Managed/src/Engine/ECS.cxx @@ -34,6 +34,7 @@ of DigiPen Institute of Technology is prohibited. #include "UI\SHCanvasComponent.h" #include "Animation\SHAnimatorComponent.h" #include "Graphics\MiddleEnd\TrajectoryRendering\SHTrajectoryRenderableComponent.h" +#include "Graphics\MiddleEnd/Particles/SHParticleEmitterComponent.h" // Project Headers #include "Utility/Convert.hxx" #include "Utility/Debug.hxx" @@ -50,6 +51,7 @@ of DigiPen Institute of Technology is prohibited. #include "Components\Slider.hxx" #include "Components\TrajectoryRenderable.hxx" #include "Components\Animator.hxx" +#include "Components\ParticleEmitter.hxx" @@ -341,6 +343,7 @@ namespace SHADE componentMap.Add(createComponentSet()); componentMap.Add(createComponentSet()); componentMap.Add(createComponentSet()); + componentMap.Add(createComponentSet()); } /*---------------------------------------------------------------------------------*/