Improved particles and tested on some objects #434

Merged
Xenosas1337 merged 3 commits from SP3-1-Rendering into main 2023-03-21 15:30:13 +08:00
10 changed files with 129 additions and 3 deletions
Showing only changes of commit 7216c1c3dd - Show all commits

View File

@ -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
@ -8179,3 +8179,74 @@
Clicked: false
IsActive: true
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

View File

@ -0,0 +1,3 @@
Name: Scene2
ID: 89281126
Type: 5

View File

@ -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<ParticleEmitter>();
}
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<Homeowner1>() && !returnBack)

View File

@ -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;

View File

@ -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<AssetID>(SHDragDrop::DRAG_RESOURCE))

View File

@ -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;

View File

@ -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;

View File

@ -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<SHVec4>());
if (node[ACCELERATION_TAG.data()].IsDefined())
rhs.SetAcceleration(node[ACCELERATION_TAG.data()].as<SHVec3>());
if (node[TEXTURE_ASSET_ID_TAG.data()].IsDefined())
{
AssetID id = node[TEXTURE_ASSET_ID_TAG.data()].as<AssetID>();

View File

@ -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<SHSliderComponent, Slider>());
componentMap.Add(createComponentSet<SHTrajectoryRenderableComponent, TrajectoryRenderable>());
componentMap.Add(createComponentSet<SHAnimatorComponent, Animator>());
componentMap.Add(createComponentSet<SHParticleEmitterComponent, ParticleEmitter>());
}
/*---------------------------------------------------------------------------------*/