Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParticleSystem #415

Merged
merged 91 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
613b047
particleSystem and nodeTest
OVOAOVO Sep 14, 2023
08da43d
change init
OVOAOVO Sep 15, 2023
d710339
shader forgeted
OVOAOVO Sep 16, 2023
640c22a
conflict
OVOAOVO Sep 16, 2023
f228d98
texture
OVOAOVO Sep 20, 2023
3c4d799
texturec.exe change?
OVOAOVO Sep 20, 2023
7dfbd94
untrack
OVOAOVO Sep 20, 2023
c7c0244
conflict
OVOAOVO Sep 20, 2023
6cbb342
back AABB sor...
OVOAOVO Sep 20, 2023
3ab4b93
cancle link
OVOAOVO Sep 21, 2023
8517b7a
emit pos
OVOAOVO Sep 21, 2023
05d8e99
precision quadrilateral
OVOAOVO Sep 21, 2023
78eff11
bufferupdate judge and rotate
OVOAOVO Sep 25, 2023
6158453
Merge branch 'main' of https://github.com/CatDogEngine/CatDogEngine
OVOAOVO Sep 25, 2023
96b5fd4
Merge branch 'main' into particle_and_nodeTest
OVOAOVO Sep 25, 2023
a5ecd92
merge main
OVOAOVO Sep 25, 2023
0f9cd99
conflict
OVOAOVO Sep 25, 2023
a280fef
chunk
OVOAOVO Oct 13, 2023
c64a299
Merge branch 'main' of https://github.com/CatDogEngine/CatDogEngine
OVOAOVO Oct 13, 2023
edf2fef
remove chunk
OVOAOVO Oct 14, 2023
8a00b0c
remove! chunk
OVOAOVO Oct 14, 2023
fce058e
no actually value
OVOAOVO Oct 25, 2023
72a4c84
Merge branch 'main' of https://github.com/CatDogEngine/CatDogEngine
OVOAOVO Oct 25, 2023
2677d33
conflict
OVOAOVO Oct 25, 2023
43de71b
test new lazy shader
OVOAOVO Oct 25, 2023
b8854c4
instancing
OVOAOVO Nov 1, 2023
f7cac2d
add color
OVOAOVO Nov 3, 2023
a08d819
Merge branch 'main' into particle_and_nodeTest
OVOAOVO Nov 3, 2023
c8e5d6a
fix branch
OVOAOVO Nov 3, 2023
5df948c
num(bug) scale(bug) rotate
OVOAOVO Nov 27, 2023
bce5782
reset branch
OVOAOVO Nov 27, 2023
b0cfccf
conflict fix
OVOAOVO Nov 27, 2023
6f2b2a8
rerun sdl2.dll test
OVOAOVO Nov 27, 2023
682f53c
emitter fixed(without speed fix)
OVOAOVO Nov 29, 2023
00498f1
merge shader
OVOAOVO Nov 29, 2023
c09a157
coding style fix
OVOAOVO Dec 7, 2023
c9c74a7
ParticlePool Rebuild
OVOAOVO Dec 11, 2023
f21e667
Merge branch 'main' into particle_and_nodeTest
OVOAOVO Dec 11, 2023
869730b
assetPipline Reback
OVOAOVO Dec 11, 2023
e7696f6
Assetpipline Reback
OVOAOVO Dec 11, 2023
3f35fa8
Runtime Verison
OVOAOVO Dec 12, 2023
912e264
Creating multiple particles fixed
OVOAOVO Dec 12, 2023
5683dc0
branch test
OVOAOVO Dec 12, 2023
4b765da
add num option
OVOAOVO Dec 13, 2023
4fbcc30
conflict
OVOAOVO Dec 13, 2023
671db31
color picker reAdd
OVOAOVO Dec 13, 2023
c7867f5
assetpipline update
OVOAOVO Dec 18, 2023
a84d286
Merge branch 'main' into particle_and_nodeTest
OVOAOVO Dec 18, 2023
2390e16
follow macros
OVOAOVO Dec 18, 2023
575279e
Merge branch 'main' into particle_and_nodeTest
OVOAOVO Dec 20, 2023
015962a
add mesh
OVOAOVO Dec 26, 2023
38b9989
AssetPipeline index fixed
OVOAOVO Dec 26, 2023
1aa7063
fixed ECworld particle id
OVOAOVO Dec 26, 2023
81b0277
add scale
OVOAOVO Dec 27, 2023
f57041e
transform component fixd
OVOAOVO Dec 27, 2023
6892173
format fix
OVOAOVO Dec 27, 2023
be3e8a5
Type Fixed
OVOAOVO Jan 2, 2024
c5e8226
Ribbon first
OVOAOVO Jan 2, 2024
bc2ee8f
billboard
OVOAOVO Jan 3, 2024
88046c5
billboard fixed
OVOAOVO Jan 5, 2024
4909296
shader billboard(bug)
OVOAOVO Jan 9, 2024
49f2825
Box Emitter Shape
OVOAOVO Jan 9, 2024
1209206
base ForceField (need fix and update)
OVOAOVO Jan 11, 2024
3805e61
confict fix
OVOAOVO Jan 11, 2024
bcfdb25
assetpipline follow
OVOAOVO Jan 15, 2024
a202866
Merge branch 'main' into particle_and_nodeTest
OVOAOVO Jan 15, 2024
c36e9e1
asset pipline follow
OVOAOVO Jan 15, 2024
f4e46f4
assetpipline update
OVOAOVO Jan 15, 2024
5d7cc9a
DeleteEmitterShapeRenderer
OVOAOVO Jan 16, 2024
728a4b8
remove EmitterShapeRenderer.h
OVOAOVO Jan 16, 2024
86e75e4
dynamic vertex to vertex
OVOAOVO Jan 18, 2024
d9e790f
texture reback
OVOAOVO Jan 22, 2024
22005b8
ImGuiUtil.hpp follow main
OVOAOVO Jan 22, 2024
ca005ee
Fixes #448 (#455)
t0xxxic Jan 23, 2024
b130697
new billboard(bug)
OVOAOVO Feb 20, 2024
0c6c90e
Billboard fixed
OVOAOVO Feb 21, 2024
d02d4a4
update AssetPipeline
OVOAOVO Feb 21, 2024
c953111
merged main
OVOAOVO Feb 21, 2024
6399646
conflict fix
OVOAOVO Feb 21, 2024
6696528
force field range
OVOAOVO Feb 21, 2024
65e43e4
add uber shader(.vs not support)
OVOAOVO Feb 29, 2024
9cf0121
update Assetpipline
OVOAOVO Feb 29, 2024
5b501e6
merge main
OVOAOVO Feb 29, 2024
2f1fc90
conflict fixed
OVOAOVO Feb 29, 2024
8651b1d
add random control
OVOAOVO Mar 1, 2024
88e3e9c
EC World fixed
OVOAOVO Mar 1, 2024
bf8fffa
fixed style
OVOAOVO Mar 1, 2024
0c79af7
Merge https://github.com/CatDogEngine/CatDogEngine into particle_and_…
T-rvw Mar 3, 2024
77a546c
refine
T-rvw Mar 3, 2024
8d88402
revert texturec
T-rvw Mar 3, 2024
ef9e901
Use MeshUtils.hpp to vb ib
OVOAOVO Mar 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Engine/BuiltInShaders/shaders/fs_particle.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$input v_color0, v_texcoord0
#include "../common/common.sh"

SAMPLER2D(s_texColor, 0);

void main()
{
vec4 rgba = texture2D(s_texColor, v_texcoord0.xy);

rgba.xyz = rgba.xyz * v_color0.xyz;
rgba.w = rgba.w * v_color0.w;
gl_FragColor = rgba;
}
6 changes: 6 additions & 0 deletions Engine/BuiltInShaders/shaders/fs_particleEmitterShape.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "../common/common.sh"

void main()
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
6 changes: 6 additions & 0 deletions Engine/BuiltInShaders/shaders/fs_particleforcefield.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "../common/common.sh"

void main()
{
gl_FragColor = vec4(0.0, 1.0, 1.0, 1.0);
}
13 changes: 13 additions & 0 deletions Engine/BuiltInShaders/shaders/fs_wo_billboardparticle.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$input v_color0, v_texcoord0
#include "../common/common.sh"

SAMPLER2D(s_texColor, 0);

void main()
{
vec4 rgba = texture2D(s_texColor, v_texcoord0.xy);

rgba.xyz = rgba.xyz * v_color0.xyz;
rgba.w = rgba.w * v_color0.w;
gl_FragColor = rgba;
}
8 changes: 7 additions & 1 deletion Engine/BuiltInShaders/shaders/varying.def.sc
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@ vec2 a_texcoord0 : TEXCOORD0;
vec4 a_color0 : COLOR0;
vec4 a_color1 : COLOR1;
ivec4 a_indices : BLENDINDICES;
vec4 a_weight : BLENDWEIGHT;
vec4 a_weight : BLENDWEIGHT;

vec4 i_data0 : TEXCOORD7;
vec4 i_data1 : TEXCOORD6;
vec4 i_data2 : TEXCOORD5;
vec4 i_data3 : TEXCOORD4;
vec4 i_data4 : TEXCOORD3;
14 changes: 14 additions & 0 deletions Engine/BuiltInShaders/shaders/vs_particle.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
$input a_position, a_color0, a_texcoord0, i_data0, i_data1 ,i_data2 ,i_data3 ,i_data4
$output v_color0, v_texcoord0

#include "../common/common.sh"

void main()
{
mat4 model = mtxFromCols(i_data0, i_data1, i_data2, i_data3);

vec4 worldPos = mul(model,vec4(a_position,1.0));
gl_Position = mul(u_viewProj, worldPos);
v_color0 = a_color0*i_data4;
v_texcoord0 = a_texcoord0;
}
10 changes: 10 additions & 0 deletions Engine/BuiltInShaders/shaders/vs_particleEmitterShape.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
$input a_position//, a_color1

#include "../common/common.sh"

uniform vec4 u_shapeRange;

void main()
{
gl_Position = mul(u_modelViewProj, vec4(a_position*u_shapeRange.xyz, 1.0));
}
8 changes: 8 additions & 0 deletions Engine/BuiltInShaders/shaders/vs_particleforcefield.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$input a_position//, a_color1

#include "../common/common.sh"

void main()
{
gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0));
}
54 changes: 54 additions & 0 deletions Engine/BuiltInShaders/shaders/vs_wo_billboardparticle.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
$input a_position, a_color0, a_texcoord0, i_data0, i_data1 ,i_data2 ,i_data3 ,i_data4
$output v_color0, v_texcoord0

#include "../common/common.sh"

uniform vec4 u_cameraPos;
uniform vec4 u_particleUp;

void main()
{
mat4 model = mtxFromCols(i_data0, i_data1, i_data2, i_data3);

vec4 forward = u_cameraPos - model[3];
T-rvw marked this conversation as resolved.
Show resolved Hide resolved
forward = mul(model,forward);

vec4 right = vec4(
u_particleUp.y * forward.z - u_particleUp.z * forward.y,
u_particleUp.z * forward.x - u_particleUp.x * forward.z,
u_particleUp.x * forward.y - u_particleUp.y * forward.x,
1.0
);

float pitch = -atan2(forward.y, sqrt(forward.x * forward.x + forward.z * forward.z));
float yaw = -atan2(right.z, right.x);
float roll = atan2(right.x, -right.y);

mat4 pitchMatrix = mat4(
1.0, 0.0, 0.0, 0.0,
0.0, cos(pitch), -sin(pitch), 0.0,
0.0, sin(pitch), cos(pitch), 0.0,
0.0, 0.0, 0.0, 1.0
);

mat4 yawMatrix = mat4(
cos(yaw), 0.0, sin(yaw), 0.0,
0.0, 1.0, 0.0, 0.0,
-sin(yaw), 0.0, cos(yaw), 0.0,
0.0, 0.0, 0.0, 1.0
);

mat4 rollMatrix = mat4(
cos(roll), -sin(roll), 0.0, 0.0,
sin(roll), cos(roll), 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
);
mat4 rotationMatrix = mul(pitchMatrix,mul(yawMatrix,rollMatrix));
model = mul(model,rotationMatrix);

vec4 worldPos = mul(model,vec4(a_position,1.0));
gl_Position = mul(u_viewProj, worldPos);
v_color0 = a_color0*i_data4;
v_texcoord0 = a_texcoord0;
}
Binary file modified Engine/EditorTools/Win64/texturec.exe
Binary file not shown.
55 changes: 55 additions & 0 deletions Engine/Source/Editor/ECWorld/ECWorldConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,23 @@ void ECWorldConsumer::Execute(const cd::SceneDatabase* pSceneDatabase)
}
};

auto ParseMeshWithParticles= [&](cd::MeshID meshID, const cd::ParticleEmitter& emitter)
{
engine::Entity meshEntity = m_pSceneWorld->GetWorld()->CreateEntity();

engine::MaterialType* pMaterialType = m_pSceneWorld->GetParticleMaterialType();

const auto& mesh = pSceneDatabase->GetMesh(meshID.Data());
AddParticleEmitter(meshEntity, mesh, pMaterialType->GetRequiredVertexFormat(),emitter);
};

// There are multiple kinds of cases in the SceneDatabase:
// 1. No nodes but have meshes in the SceneDatabase.
// 2. Only a root node with multiple meshes.
// 3. Node hierarchy.
// Another case is that we want to skip Node/Mesh which alreay parsed previously.
std::set<uint32_t> parsedMeshIDs;
m_particleMinID = 0;
for (const auto& mesh : pSceneDatabase->GetMeshes())
{
if (m_meshMinID > mesh.GetID().Data())
Expand All @@ -107,6 +118,14 @@ void ECWorldConsumer::Execute(const cd::SceneDatabase* pSceneDatabase)
ParseMeshWithMorphs(mesh.GetID(), cd::Transform::Identity(), pSceneDatabase->GetMorphs());
parsedMeshIDs.insert(mesh.GetID().Data());
}
//TODO: Change to " have a generic function to judge what is the purpose of mesh usage."
// The first case is your particle mesh. But in the future, there maybe lod meshes, imposter meshes, collision meshes... So pre-sort meshes by purpose is better.
else if (pSceneDatabase->GetParticleEmitterCount())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of writing a if branch, we should have a generic function to judge what is the purpose of mesh usage.
The first case is your particle mesh. But in the future, there maybe lod meshes, imposter meshes, collision meshes... So pre-sort meshes by purpose is better.
Or you can keep current code. I will refact these logics.

{
ParseMeshWithParticles(mesh.GetID(), pSceneDatabase->GetParticleEmitter(m_particleMinID));
parsedMeshIDs.insert(mesh.GetID().Data());
++m_particleMinID;
}
else
{
ParseMesh(mesh.GetID(), cd::Transform::Identity());
Expand Down Expand Up @@ -345,4 +364,40 @@ void ECWorldConsumer::AddMorphs(engine::Entity entity, const std::vector<cd::Mor
blendShapeComponent.Build();
}

void ECWorldConsumer::AddParticleEmitter(engine::Entity entity, const cd::Mesh& mesh, const cd::VertexFormat& vertexFormat, const cd::ParticleEmitter& emitter)
{
engine::World* pWorld = m_pSceneWorld->GetWorld();
engine::NameComponent& nameComponent = pWorld->CreateComponent<engine::NameComponent>(entity);
nameComponent.SetName(emitter.GetName());
auto& particleEmitterComponent = pWorld->CreateComponent<engine::ParticleEmitterComponent>(entity);
// TODO : Some initialization here.
auto& transformComponent = pWorld->CreateComponent<engine::TransformComponent>(entity);
cd::Vec3f pos = emitter.GetPosition();
cd::Vec3f rotation = emitter.GetFixedRotation();
cd::Vec3f scale = emitter.GetFixedScale();
auto fixedrotation = cd::Math::RadianToDegree(rotation);
OVOAOVO marked this conversation as resolved.
Show resolved Hide resolved
cd::Quaternion rotationQuat = cd::Quaternion::FromPitchYawRoll(fixedrotation.x(), fixedrotation.y(), fixedrotation.z());
transformComponent.GetTransform().SetTranslation(pos);
transformComponent.GetTransform().SetRotation(rotationQuat);
transformComponent.GetTransform().SetScale(scale);
transformComponent.Build();

particleEmitterComponent.SetRequiredVertexFormat(&vertexFormat);
////const cd::VertexFormat *requriredVertexFormat = emitter.GetVertexFormat();
////particleEmitterComponent.SetRequiredVertexFormat(requriredVertexFormat);
////particleEmitterComponent.GetParticleSystem().Init();
if (nameof::nameof_enum(emitter.GetType()) == "Sprite") { particleEmitterComponent.SetEmitterParticleType(engine::ParticleType::Sprite); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use cd::ParticleType is better because they are all same:
particleEmitterComponent.SetEmitterParticleType(emitter.GetType());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it's not.
cd::ParticleEmitterTypeTraits::Type not suit engine::particleType

else if (nameof::nameof_enum(emitter.GetType()) == "Ribbon") { particleEmitterComponent.SetEmitterParticleType(engine::ParticleType::Ribbon); }
else if (nameof::nameof_enum(emitter.GetType()) == "Ring") { particleEmitterComponent.SetEmitterParticleType(engine::ParticleType::Ring); }
else if (nameof::nameof_enum(emitter.GetType()) == "Model") { particleEmitterComponent.SetEmitterParticleType(engine::ParticleType::Model); }
else if (nameof::nameof_enum(emitter.GetType()) == "Track") { particleEmitterComponent.SetEmitterParticleType(engine::ParticleType::Track); }

particleEmitterComponent.SetSpawnCount(emitter.GetMaxCount());
particleEmitterComponent.SetEmitterColor(emitter.GetColor()/255.0f);
particleEmitterComponent.SetEmitterVelocity(emitter.GetVelocity());
particleEmitterComponent.SetEmitterAcceleration(emitter.GetAccelerate());
particleEmitterComponent.SetMeshData(&mesh);
particleEmitterComponent.Build();
}

}
3 changes: 3 additions & 0 deletions Engine/Source/Editor/ECWorld/ECWorldConsumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Material;
class Mesh;
class Morph;
class Node;
class ParticleEmitter;
class SceneDatabase;
class Texture;
class VertexFormat;
Expand Down Expand Up @@ -67,6 +68,7 @@ class ECWorldConsumer final : public cdtools::IConsumer
void AddAnimation(engine::Entity entity, const cd::Animation& animation, const cd::SceneDatabase* pSceneDatabase);
void AddMaterial(engine::Entity entity, const cd::Material* pMaterial, engine::MaterialType* pMaterialType, const cd::SceneDatabase* pSceneDatabase);
void AddMorphs(engine::Entity entity, const std::vector<cd::Morph>& morphs, const cd::Mesh* pMesh);
void AddParticleEmitter(engine::Entity entity, const cd::Mesh& mesh, const cd::VertexFormat& vertexFormat, const cd::ParticleEmitter& emitter);

private:
engine::MaterialType* m_pDefaultMaterialType = nullptr;
Expand All @@ -75,6 +77,7 @@ class ECWorldConsumer final : public cdtools::IConsumer

uint32_t m_nodeMinID;
uint32_t m_meshMinID;
uint32_t m_particleMinID = 0;
};

}
13 changes: 13 additions & 0 deletions Engine/Source/Editor/EditorApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "Rendering/TerrainRenderer.h"
#include "Rendering/WorldRenderer.h"
#include "Rendering/ParticleRenderer.h"
#include "Rendering/ParticleForceFieldRenderer.h"
#include "Resources/FileWatcher.h"
#include "Resources/ResourceBuilder.h"
#include "Resources/ShaderBuilder.h"
Expand Down Expand Up @@ -257,19 +258,23 @@ void EditorApp::InitMaterialType()
constexpr const char* WorldProgram = "WorldProgram";
constexpr const char* AnimationProgram = "AnimationProgram";
constexpr const char* TerrainProgram = "TerrainProgram";
constexpr const char* ParticleProgram = "ParticleProgram";

constexpr engine::StringCrc WorldProgramCrc{ WorldProgram };
constexpr engine::StringCrc AnimationProgramCrc{ AnimationProgram };
constexpr engine::StringCrc TerrainProgramCrc{ TerrainProgram };
constexpr engine::StringCrc ParticleProgramCrc{ ParticleProgram};

m_pRenderContext->RegisterShaderProgram(WorldProgramCrc, { "vs_PBR", "fs_PBR" });
m_pRenderContext->RegisterShaderProgram(AnimationProgramCrc, { "vs_animation", "fs_animation" });
m_pRenderContext->RegisterShaderProgram(TerrainProgramCrc, { "vs_terrain", "fs_terrain" });
m_pRenderContext->RegisterShaderProgram(ParticleProgramCrc, { "vs_particle","fs_particle" });
OVOAOVO marked this conversation as resolved.
Show resolved Hide resolved

m_pSceneWorld = std::make_unique<engine::SceneWorld>();
m_pSceneWorld->CreatePBRMaterialType(WorldProgram, IsAtmosphericScatteringEnable());
m_pSceneWorld->CreateAnimationMaterialType(AnimationProgram);
m_pSceneWorld->CreateTerrainMaterialType(TerrainProgram);
m_pSceneWorld->CreateParticleMaterialType(ParticleProgram);
}

void EditorApp::InitEditorCameraEntity()
Expand Down Expand Up @@ -541,6 +546,14 @@ void EditorApp::InitEngineRenderers()
pParticlerenderer->SetSceneWorld(m_pSceneWorld.get());
AddEngineRenderer(cd::MoveTemp(pParticlerenderer));

//auto pParticleShapeRenderer = std::make_unique<engine::ParticleEmitterShapeRenderer>(m_pRenderContext->CreateView(), pSceneRenderTarget);
//pParticleShapeRenderer->SetSceneWorld(m_pSceneWorld.get());
//AddEngineRenderer(cd::MoveTemp(pParticleShapeRenderer));

auto pParticleForceFieldRenderer = std::make_unique<engine::ParticleForceFieldRenderer>(m_pRenderContext->CreateView(), pSceneRenderTarget);
pParticleForceFieldRenderer->SetSceneWorld(m_pSceneWorld.get());
AddEngineRenderer(cd::MoveTemp(pParticleForceFieldRenderer));

#ifdef ENABLE_DDGI
auto pDDGIRenderer = std::make_unique<engine::DDGIRenderer>(m_pRenderContext->CreateView(), pSceneRenderTarget);
pDDGIRenderer->SetSceneWorld(m_pSceneWorld.get());
Expand Down
54 changes: 54 additions & 0 deletions Engine/Source/Editor/UILayers/AssetBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "Log/Log.h"
#include "Material/MaterialType.h"
#include "Producers/CDProducer/CDProducer.h"
#include "Producers/EffekseerProducer/EffekseerProducer.h"
#include "Rendering/WorldRenderer.h"
#include "Rendering/RenderContext.h"
#include "Resources/ResourceBuilder.h"
Expand Down Expand Up @@ -98,6 +99,21 @@ bool IsLightInputFile(const char* pFileExtension)
return false;
}

bool IsParticleInputFile(const char* pFileExtension)
{
constexpr const char* pFileExtensions[] = { ".efkefc"};
OVOAOVO marked this conversation as resolved.
Show resolved Hide resolved
constexpr const int fileExtensionsSize = sizeof(pFileExtensions) / sizeof(pFileExtensions[0]);
for (int extensionIndex = 0; extensionIndex < fileExtensionsSize; ++extensionIndex)
{
if (0 == strcmp(pFileExtensions[extensionIndex], pFileExtension))
{
return true;
}
}

return false;
}

std::string GetFilePathExtension(const std::string& FileName)
{
auto pos = FileName.find_last_of('.');
Expand Down Expand Up @@ -780,6 +796,10 @@ void AssetBrowser::ImportAssetFile(const char* pFilePath)
{
m_importOptions.AssetType = IOAssetType::Light;
}
else if (IsParticleInputFile(pFileExtension.c_str()))
{
m_importOptions.AssetType = IOAssetType::Particle;
}
else
{
// Still unknown, exit.
Expand Down Expand Up @@ -852,6 +872,10 @@ void AssetBrowser::ImportAssetFile(const char* pFilePath)
{
ImportJson(pFilePath);
}
else if (IOAssetType::Particle == m_importOptions.AssetType)
{
ImportParticleEffect(pFilePath);
}
}

void AssetBrowser::ProcessSceneDatabase(cd::SceneDatabase* pSceneDatabase, bool keepMesh, bool keepMaterial, bool keepTexture, bool keepCamera, bool keepLight)
Expand Down Expand Up @@ -1085,6 +1109,36 @@ void AssetBrowser::ImportJson(const char* pFilePath)
}
}

void AssetBrowser::ImportParticleEffect(const char* pFilePath)
{
////engine::RenderContext* pCurrentRenderContext = GetRenderContext();
//engine::SceneWorld* pSceneWorld = GetImGuiContextInstance()->GetSceneWorld();

//cd::SceneDatabase* pSceneDatabase = pSceneWorld->GetSceneDatabase();
////uint32_t oldNodeCount = pSceneDatabase->GetNodeCount();
////uint32_t oldMeshCount = pSceneDatabase->GetMeshCount();
//uint32_t oldParticleEmitterCount = pSceneDatabase->GetParticleEmitterCount();

//// Step 1 : Convert model file to cd::SceneDatabase
//std::filesystem::path inputFilePath(pFilePath);
//std::filesystem::path inputFileExtension = inputFilePath.extension();
//if (0 == inputFileExtension.compare(".efkefc"))
//{
///* cdtools::CDProducer cdProducer(pFilePath);
// cd::SceneDatabase newSceneDatabase;
// cdtools::Processor processor(&cdProducer, nullptr, &newSceneDatabase);
// proce qssor.Run();
// pSceneDatabase->Merge(cd::MoveTemp(newSceneDatabase));*/
// std::string filePath = pFilePath;
// int size = MultiByteToWideChar(CP_UTF8, 0, filePath.c_str(), -1, nullptr, 0);
// std::wstring wstr(size, 0);
// MultiByteToWideChar(CP_UTF8, 0, filePath.c_str(), -1, &wstr[0], size);
// std::wstring wFilePath = wstr;
// const char16_t* u16_cstr = reinterpret_cast<const char16_t*>(wFilePath.c_str());
// cdtools::EffekseerProducer efkProducer(u16_cstr);
//}
}

void AssetBrowser::ExportAssetFile(const char* pFilePath)
{
engine::SceneWorld* pSceneWorld = GetImGuiContextInstance()->GetSceneWorld();
Expand Down
Loading