diff --git a/Assets/Scenes/Level1.shade b/Assets/Scenes/Level1.shade index c64dde4e..2a70a118 100644 --- a/Assets/Scenes/Level1.shade +++ b/Assets/Scenes/Level1.shade @@ -7125,7 +7125,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 @@ -8204,4 +8204,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 b/Assets/Scenes/Scene2.shade new file mode 100644 index 00000000..d284d4ea --- /dev/null +++ b/Assets/Scenes/Scene2.shade @@ -0,0 +1,177 @@ +- EID: 0 + Name: Default + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0.304069757, z: 1.73034382} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Camera Component: + Position: {x: 0, y: 0.304069757, z: 1.73034382} + Pitch: 0 + Yaw: 0 + Roll: 0 + Width: 1200 + Near: 0.00999999978 + Far: 10000 + Perspective: true + FOV: 90 + IsActive: true + Scripts: ~ +- EID: 1 + Name: Raccoon + IsActive: false + NumberOfChildren: 1 + Components: + Transform Component: + Translate: {x: 0, y: 0.201105013, z: 0} + Rotate: {x: 0.00523597933, y: -2.96353412, z: -6.40293041e-10} + Scale: {x: 1.00000191, y: 1, z: 1.00000191} + IsActive: false + Renderable Component: + Mesh: 149697411 + Material: 126974645 + IsActive: false + Scripts: ~ +- EID: 3 + Name: Bag + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0.00623797067, y: -0.000395311916, z: -2.03726813e-08} + Rotate: {x: 1.35041773e-08, y: 2.79945588, z: -9.6043955e-09} + Scale: {x: 1.00008798, y: 1, z: 1.0000881} + IsActive: true + Renderable Component: + Mesh: 144838771 + Material: 123745521 + IsActive: true + Scripts: ~ +- EID: 2 + Name: DirectionalLight + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 1.82978272, z: -3.28967047} + Rotate: {x: -0, y: 0, z: -0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Light Component: + Position: {x: 3, y: 4.5, z: 7} + Type: Directional + Direction: {x: 0, y: 0, z: 1} + Color: {x: 1, y: 1, z: 1, w: 1} + Layer: 4294967295 + Strength: 0 + Casting Shadows: false + IsActive: true + Scripts: ~ +- EID: 4 + Name: AmbientLight + IsActive: true + NumberOfChildren: 0 + Components: + Light Component: + Position: {x: 0, y: 0, z: 0} + Type: Ambient + Direction: {x: 0, y: 0, z: 1} + Color: {x: 1, y: 1, z: 1, w: 1} + Layer: 4294967295 + Strength: 0.600000024 + Casting Shadows: false + IsActive: true + Scripts: ~ +- EID: 5 + Name: Floor + IsActive: false + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0.0810000002, z: 0} + Rotate: {x: -1.57079625, y: 0, z: -0} + Scale: {x: 50, y: 49.9999924, z: 49.9999924} + IsActive: false + Renderable Component: + Mesh: 141771688 + Material: 124370424 + IsActive: false + Scripts: ~ +- EID: 6 + Name: TrajectoryTest + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -3.39616156, y: 3.66783714, z: -0.722039163} + Rotate: {x: -0, y: 0, z: -0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + RigidBody Component: + Type: Dynamic + Drag: 0.00999999978 + Angular Drag: 0.100000001 + Gravity Scale: 1 + Use Gravity: true + Interpolate: true + Sleeping Enabled: false + 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: 0 + Type: Sphere + Radius: 1 + 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 + Trajectory Renderer Component: + Mesh: 134305891 + Start Color: {x: 1, y: 0.951541781, z: 0} + Start Alpha: 1 + End Color: {x: 0, y: 1, z: 0.748898745} + End Alpha: 1 + "Color Eval Rate ": 0.192000002 + IsActive: true + Scripts: ~ +- EID: 7 + Name: ParticleTest + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0.823412895, z: -4.31447983} + Rotate: {x: -0, y: 0, z: -0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + classSHADE::SHParticleEmitterComponent: + Emission Count: 15 + Is Passive: true + Emission Interval: 0.0939999968 + Min Life: 2 + Max Life: 3 + Minimum Speed: 3 + Maximum Speed: 6 + Minimum Size: 0 + Maximum Size: 0.5 + Size Decay: 0.990999997 + Angular Ranges And Offset: {x: 6.19999981, y: 1.10000002, z: 0, w: 0.100000001} + Rotation Speed: 0.0309999995 + Rotation Decay: 0.0199999996 + Texture Asset ID: 63456868 + Custom Update Shader Asset ID: 0 + Color Tint: {x: 1, y: 0, z: 0, w: 1} + IsActive: true + Scripts: ~ \ 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 45cea313..b2f81a05 100644 --- a/Assets/Shaders/ParticleEmit_CS.glsl +++ b/Assets/Shaders/ParticleEmit_CS.glsl @@ -7,11 +7,13 @@ layout(local_size_x = 128) in; struct EmitterParameters { vec4 angularRangesAndOffsets; + vec4 acceleration; float minSpeed; float maxSpeed; float rotationSpeed; float rotationDecay; vec4 lifeAndSizeRange; // min life, max life, min size, max size + vec4 colorTint; float sizeDecay; uint textureIndex; float padding[2]; @@ -24,6 +26,7 @@ struct ParticleData vec4 velocity; vec4 acceleration; vec4 scaleAndDecay; + vec4 colorTint; float life; uint textureIndex; }; @@ -166,11 +169,14 @@ void main() float particleSize = map (rand(seed), 0.0f, 1.0f, emitterParams.data.lifeAndSizeRange.z, emitterParams.data.lifeAndSizeRange.w); - // Set size of particle + // Set size of and size decay of particle particle.scaleAndDecay.x = particleSize; particle.scaleAndDecay.y = particleSize; particle.scaleAndDecay.z = emitterParams.data.sizeDecay; particle.scaleAndDecay.w = emitterParams.data.sizeDecay; + + // Set particle color tint + particle.colorTint = emitterParams.data.colorTint; // Set the texture for the particle particle.textureIndex = emitterParams.data.textureIndex; @@ -182,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 b003ba77..08972d9d 100644 Binary files a/Assets/Shaders/ParticleEmit_CS.shshaderb and b/Assets/Shaders/ParticleEmit_CS.shshaderb differ diff --git a/Assets/Shaders/ParticleUpdate_CS.glsl b/Assets/Shaders/ParticleUpdate_CS.glsl index 43d4893d..1f5384ec 100644 --- a/Assets/Shaders/ParticleUpdate_CS.glsl +++ b/Assets/Shaders/ParticleUpdate_CS.glsl @@ -17,6 +17,7 @@ struct ParticleData vec4 velocity; vec4 acceleration; vec4 scaleAndDecay; + vec4 colorTint; float life; uint textureIndex; }; diff --git a/Assets/Shaders/ParticleUpdate_CS.shshaderb b/Assets/Shaders/ParticleUpdate_CS.shshaderb index 63a79d5a..e7a3ec64 100644 Binary files a/Assets/Shaders/ParticleUpdate_CS.shshaderb and b/Assets/Shaders/ParticleUpdate_CS.shshaderb differ diff --git a/Assets/Shaders/Particle_FS.glsl b/Assets/Shaders/Particle_FS.glsl index 243baa2e..69bc224b 100644 --- a/Assets/Shaders/Particle_FS.glsl +++ b/Assets/Shaders/Particle_FS.glsl @@ -15,12 +15,13 @@ layout(location = 0) in struct layout(location = 1) flat in struct { uint textureIndex; + vec4 color; } InFlat; void main () { - fragColor = vec4 (texture(textures [nonuniformEXT(InFlat.textureIndex)], In.uv)); + fragColor = vec4 (texture(textures [nonuniformEXT(InFlat.textureIndex)], In.uv)) * InFlat.color; if (fragColor.a < 0.01f) discard; } diff --git a/Assets/Shaders/Particle_FS.shshaderb b/Assets/Shaders/Particle_FS.shshaderb index edd2dd6b..59049d0c 100644 Binary files a/Assets/Shaders/Particle_FS.shshaderb and b/Assets/Shaders/Particle_FS.shshaderb differ diff --git a/Assets/Shaders/Particle_VS.glsl b/Assets/Shaders/Particle_VS.glsl index 5004cea1..b5b6f13e 100644 --- a/Assets/Shaders/Particle_VS.glsl +++ b/Assets/Shaders/Particle_VS.glsl @@ -23,6 +23,7 @@ struct ParticleData vec4 velocity; vec4 acceleration; vec4 scaleAndDecay; + vec4 colorTint; float life; uint textureIndex; }; @@ -62,6 +63,7 @@ layout(location = 0) out struct layout(location = 1) out struct { uint textureIndex; // location = 1 + vec4 color; // location = 2 } OutFlat; vec2 CreateQuad (in uint vertexID) @@ -96,6 +98,7 @@ void main() particlePos = particle.position.xyz + (viewRight * particlePos.x * particleScaleData.x) + (viewUp * particlePos.y * particleScaleData.y); OutFlat.textureIndex = particle.textureIndex; + OutFlat.color = particle.colorTint; gl_Position = cameraData.vpMat * vec4(particlePos, 1.0f); } \ No newline at end of file diff --git a/Assets/Shaders/Particle_VS.shshaderb b/Assets/Shaders/Particle_VS.shshaderb index 0a9be96d..2ba7a729 100644 Binary files a/Assets/Shaders/Particle_VS.shshaderb and b/Assets/Shaders/Particle_VS.shshaderb differ diff --git a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp index 2edadbbc..208134bf 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp +++ b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp @@ -883,6 +883,27 @@ 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]() + { + return comp->GetColorTint(); + }, + [comp = component](SHVec4 const& val) + { + comp->SetColorTint(val); + }); + + SHEditorWidgets::DragInt("Texture Index", [comp = component]() { @@ -892,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 5454cf31..d6f1e115 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Particles/SHParticleEmitterComponent.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Particles/SHParticleEmitterComponent.cpp @@ -52,6 +52,25 @@ 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; + cpuEmitterData.angularRangesAndOffsets.y = ranges.y; + } + + void SHParticleEmitterComponent::SetAngularOffsets(SHVec2 const& offsets) noexcept + { + cpuEmitterData.angularRangesAndOffsets.z = offsets.x; + cpuEmitterData.angularRangesAndOffsets.w = offsets.y; + } + void SHParticleEmitterComponent::SetMinSpeed(float speed) noexcept { cpuEmitterData.minSpeed = speed; @@ -107,6 +126,23 @@ namespace SHADE customUpdateShader = shaderModule; } + void SHParticleEmitterComponent::SetColorTint(SHVec4 tint) noexcept + { + cpuEmitterData.colorTint = tint; + } + + void SHParticleEmitterComponent::SetColorTintRGB(SHVec3 tint) noexcept + { + cpuEmitterData.colorTint.x = tint.x; + cpuEmitterData.colorTint.y = tint.y; + cpuEmitterData.colorTint.z = tint.z; + } + + void SHParticleEmitterComponent::SetColorTintAlpha(float alpha) noexcept + { + cpuEmitterData.colorTint.w = alpha; + } + uint32_t SHParticleEmitterComponent::GetEmissionCount(void) const noexcept { return emissionCount; @@ -138,6 +174,21 @@ namespace SHADE return cpuEmitterData.angularRangesAndOffsets; } + SHVec2 SHParticleEmitterComponent::GetAngularRanges(void) const noexcept + { + return SHVec2{cpuEmitterData.angularRangesAndOffsets.x, cpuEmitterData.angularRangesAndOffsets.y}; + } + + SHVec2 SHParticleEmitterComponent::GetAngularOffsets(void) const noexcept + { + 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; @@ -194,4 +245,19 @@ namespace SHADE return customUpdateShader; } + SHVec4 const& SHParticleEmitterComponent::GetColorTint(void) const noexcept + { + return cpuEmitterData.colorTint; + } + + SHVec3 SHParticleEmitterComponent::GetColorTintRGB(void) const noexcept + { + return SHVec3 (cpuEmitterData.colorTint.x, cpuEmitterData.colorTint.y, cpuEmitterData.colorTint.z); + } + + float SHParticleEmitterComponent::GetColorTintAlpha(void) const noexcept + { + return cpuEmitterData.colorTint.w; + } + } \ No newline at end of file diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Particles/SHParticleEmitterComponent.h b/SHADE_Engine/src/Graphics/MiddleEnd/Particles/SHParticleEmitterComponent.h index d9c26666..47791c44 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Particles/SHParticleEmitterComponent.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Particles/SHParticleEmitterComponent.h @@ -1,5 +1,6 @@ #pragma once +#include "SH_API.h" #include "Resource/SHHandle.h" #include "Math/Vector/SHVec2.h" #include "Math/Vector/SHVec4.h" @@ -15,7 +16,7 @@ namespace SHADE class SHVkShaderModule; class SHVkPipeline; - class SHParticleEmitterComponent : public SHComponent + class SH_API SHParticleEmitterComponent : public SHComponent { private: @@ -24,7 +25,10 @@ namespace SHADE //! Angular ranges of emission SHVec4 angularRangesAndOffsets; - //! minimum starting velocity + //! Acceleration + SHVec4 accleration; + + //! minimum starting velocity float minSpeed; //! Maximum starting velocity @@ -39,6 +43,9 @@ namespace SHADE //! Spawn lifetime and size range (min and max) SHVec4 lifeAndSizeRange; + //! Color tint to assign to particles + SHVec4 colorTint; + //! Size decay for particles float sizeDecayMult; @@ -67,6 +74,9 @@ namespace SHADE //! x scale, x scale decay, y scale and y scale decay SHVec4 scaleAndDecay; + //! Color tinting for particle + SHVec4 colorTint; + //! Life of the particle float life; @@ -147,6 +157,9 @@ 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; void SetMaxSpeed (float speed) noexcept; void SetRotationSpeed (float speed) noexcept; @@ -156,6 +169,9 @@ namespace SHADE void SetMaxSize (float size) noexcept; void SetSizeDecayMult (float decay) noexcept; void SetCustomUpdateShader (Handle shaderModule) noexcept; + void SetColorTint (SHVec4 tint) noexcept; + void SetColorTintRGB (SHVec3 tint) noexcept; + void SetColorTintAlpha (float alpha) noexcept; uint32_t GetEmissionCount (void) const noexcept; bool GetPassive (void) const noexcept; @@ -163,6 +179,9 @@ namespace SHADE float GetMinLife (void) const noexcept; float GetMaxLife (void) const noexcept; 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; @@ -172,6 +191,9 @@ namespace SHADE float GetMaxSize (void) const noexcept; float GetSizeDecayMult (void) const noexcept; Handle GetCustomUpdateShader (void) const noexcept; + SHVec4 const& GetColorTint (void) const noexcept; + SHVec3 GetColorTintRGB (void) const noexcept; + float GetColorTintAlpha (void) const noexcept; /*-----------------------------------------------------------------------*/ /* NON-INTERFACE FUNCTIONS */ diff --git a/SHADE_Engine/src/Serialization/SHYAMLConverters.h b/SHADE_Engine/src/Serialization/SHYAMLConverters.h index 2550388e..8805ed41 100644 --- a/SHADE_Engine/src/Serialization/SHYAMLConverters.h +++ b/SHADE_Engine/src/Serialization/SHYAMLConverters.h @@ -519,6 +519,8 @@ namespace YAML static constexpr std::string_view ROTATION_DECAY_TAG = "Rotation Decay"; 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) { @@ -538,6 +540,8 @@ namespace YAML node[ROTATION_DECAY_TAG.data()] = rhs.GetRotationDecay(); 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; } @@ -581,6 +585,11 @@ namespace YAML if (node[ROTATION_DECAY_TAG.data()].IsDefined()) rhs.SetRotationDecay(node[ROTATION_DECAY_TAG.data()].as()); + 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()) { diff --git a/SHADE_Managed/src/Components/ParticleEmitter.cxx b/SHADE_Managed/src/Components/ParticleEmitter.cxx new file mode 100644 index 00000000..a5bbf350 --- /dev/null +++ b/SHADE_Managed/src/Components/ParticleEmitter.cxx @@ -0,0 +1,170 @@ +#include "SHpch.h" + +#include "ParticleEmitter.hxx" + + +namespace SHADE +{ + ParticleEmitter::ParticleEmitter(Entity entity) + :Component(entity) + { + + } + + void ParticleEmitter::Emit() + { + GetNativeComponent()->Emit(); + } + + + float ParticleEmitter::EmissionInterval::get() + { + return (GetNativeComponent()->GetEmissionInterval()); + } + + void ParticleEmitter::EmissionInterval::set(float val) + { + GetNativeComponent()->SetEmissionInterval(val); + } + + bool ParticleEmitter::IsPassive::get() + { + return (GetNativeComponent()->GetPassive()); + } + + void ParticleEmitter::IsPassive::set(bool val) + { + GetNativeComponent()->SetPassive(val); + } + + float ParticleEmitter::MinLife::get() + { + return (GetNativeComponent()->GetMinLife()); + } + + void ParticleEmitter::MinLife::set(float val) + { + GetNativeComponent()->SetMinLife(val); + } + + float ParticleEmitter::MaxLife::get() + { + return (GetNativeComponent()->GetMaxLife()); + } + + void ParticleEmitter::MaxLife::set(float val) + { + GetNativeComponent()->SetMaxLife(val); + } + + Vector2 ParticleEmitter::AngularRanges::get() + { + return Convert::ToCLI(GetNativeComponent()->GetAngularRanges()); + } + + void ParticleEmitter::AngularRanges::set(Vector2 val) + { + GetNativeComponent()->SetAngularRanges(Convert::ToNative(val)); + } + + Vector2 ParticleEmitter::AngularOffsets::get() + { + return Convert::ToCLI(GetNativeComponent()->GetAngularOffsets()); + } + + void ParticleEmitter::AngularOffsets::set(Vector2 val) + { + GetNativeComponent()->SetAngularOffsets(Convert::ToNative(val)); + } + + float ParticleEmitter::MinSpeed::get() + { + return GetNativeComponent()->GetMinSpeed(); + } + + void ParticleEmitter::MinSpeed::set(float val) + { + GetNativeComponent()->SetMinSpeed(val); + } + + float ParticleEmitter::MaxSpeed::get() + { + return GetNativeComponent()->GetMinSpeed(); + } + + void ParticleEmitter::MaxSpeed::set(float val) + { + GetNativeComponent()->SetMaxSpeed(val); + } + + float ParticleEmitter::RotationSpeed::get() + { + return GetNativeComponent()->GetRotationSpeed(); + } + + void ParticleEmitter::RotationSpeed::set(float val) + { + GetNativeComponent()->SetRotationSpeed(val); + } + + float ParticleEmitter::RotationDecay::get() + { + return GetNativeComponent()->GetRotationDecay(); + } + + void ParticleEmitter::RotationDecay::set(float val) + { + GetNativeComponent()->SetRotationDecay(val); + } + + float ParticleEmitter::MinSize::get() + { + return GetNativeComponent()->GetMinSize(); + } + + void ParticleEmitter::MinSize::set(float val) + { + GetNativeComponent()->SetMinSize(val); + } + + float ParticleEmitter::MaxSize::get() + { + return GetNativeComponent()->GetMaxSize(); + } + + void ParticleEmitter::MaxSize::set(float val) + { + GetNativeComponent()->SetMaxSize(val); + } + + float ParticleEmitter::SizeDecayMult::get() + { + return GetNativeComponent()->GetSizeDecayMult(); + } + + void ParticleEmitter::SizeDecayMult::set(float val) + { + GetNativeComponent()->SetSizeDecayMult(val); + } + + Vector3 ParticleEmitter::ColorTintRGB::get() + { + return Convert::ToCLI(GetNativeComponent()->GetColorTintRGB()); + } + + void ParticleEmitter::ColorTintRGB::set(Vector3 val) + { + GetNativeComponent()->SetColorTintRGB (Convert::ToNative (val)); + } + + float ParticleEmitter::ColorTintAlpha::get() + { + return GetNativeComponent()->GetColorTintAlpha(); + } + + void ParticleEmitter::ColorTintAlpha::set(float val) + { + GetNativeComponent()->SetColorTintAlpha(val); + } + +} \ No newline at end of file diff --git a/SHADE_Managed/src/Components/ParticleEmitter.hxx b/SHADE_Managed/src/Components/ParticleEmitter.hxx new file mode 100644 index 00000000..686d0a83 --- /dev/null +++ b/SHADE_Managed/src/Components/ParticleEmitter.hxx @@ -0,0 +1,115 @@ +#pragma once + +// Project Includes +#include "Components/Component.hxx" +#include "Math/Vector2.hxx" +#include "Math/Vector3.hxx" +#include "Math/Quaternion.hxx" +// External Dependencies +#include "Camera/SHCameraComponent.h" +#include "Graphics/MiddleEnd/Particles/SHParticleEmitterComponent.h" + +namespace SHADE +{ + public ref class ParticleEmitter : public Component + { + internal: + ParticleEmitter(Entity entity); + + public: + + property bool IsPassive + { + bool get(); + void set(bool val); + } + + property float EmissionInterval + { + float get(); + void set(float val); + } + + property float MinLife + { + float get(); + void set(float val); + } + + property float MaxLife + { + float get(); + void set(float val); + } + + property Vector2 AngularRanges + { + Vector2 get(); + void set(Vector2 val); + } + + property Vector2 AngularOffsets + { + Vector2 get(); + void set(Vector2 val); + } + + property float MinSpeed + { + float get(); + void set(float val); + } + + property float MaxSpeed + { + float get(); + void set(float val); + } + + property float RotationSpeed + { + float get(); + void set(float val); + } + + property float RotationDecay + { + float get(); + void set(float val); + } + + property float MinSize + { + float get(); + void set(float val); + } + + property float MaxSize + { + float get(); + void set(float val); + } + + property float SizeDecayMult + { + float get(); + void set(float val); + } + + property Vector3 ColorTintRGB + { + Vector3 get(); + void set(Vector3 val); + } + + property float ColorTintAlpha + { + float get(); + void set (float val); + } + + void Emit(); + + + }; +} \ No newline at end of file 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()); } /*---------------------------------------------------------------------------------*/