Skip to content

Commit

Permalink
Added progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
denis-beqiraj committed May 4, 2024
1 parent 23709f3 commit c12e7d4
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Engine/include/SceneData/Animation.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ namespace Prisma {
float GetDuration() { return m_Duration; }
const AssimpNodeData& GetRootNode() { return m_RootNode; }
const std::map<std::string, Prisma::BoneInfo>& GetBoneIDMap() const;
std::string name() const;

private:
std::string m_animationPath;
void ReadMissingBones(const aiAnimation* animation, std::shared_ptr<Prisma::AnimatedMesh> model);
glm::mat4 m_inverseTransform;
void ReadHierarchyData(AssimpNodeData& dest, const aiNode* src);
Expand Down
4 changes: 4 additions & 0 deletions Engine/include/SceneData/Animator.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ namespace Prisma {

void mesh(Prisma::Node* mesh);

std::shared_ptr<Animation> animation();

float currentTime() const;

private:
std::shared_ptr<Animation> m_CurrentAnimation;

Expand Down
8 changes: 6 additions & 2 deletions Engine/src/Handlers/AnimationHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ std::vector<Prisma::AnimationHandler::SSBOAnimation>& Prisma::AnimationHandler::

Prisma::AnimationHandler::AnimationHandler()
{

m_ssboAnimation = std::make_shared<SSBO>(8);
m_ssboAnimation->resize(sizeof(SSBOAnimation)*MAX_ANIMATION_MESHES);
m_animations.resize(MAX_ANIMATION_MESHES);
for (int i = 0; i < m_animations.size(); i++) {
for (int j = 0; j < MAX_BONES; j++) {
m_animations[i].animations[j] = glm::mat4(1.0f);
}
}
}

inline void Prisma::AnimationHandler::copyMatrices(SSBOAnimation& animation, std::vector<glm::mat4>& animationsData) {
void Prisma::AnimationHandler::copyMatrices(SSBOAnimation& animation, std::vector<glm::mat4>& animationsData) {
for (int i = 0; i < animationsData.size(); i++) {
animation.animations[i] = animationsData[i];
}
Expand Down
6 changes: 5 additions & 1 deletion Engine/src/SceneData/Animation.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "../../include/SceneData/Animation.h"

Prisma::Animation::Animation(const std::string& animationPath, std::shared_ptr<Prisma::AnimatedMesh> model)
Prisma::Animation::Animation(const std::string& animationPath, std::shared_ptr<Prisma::AnimatedMesh> model):m_animationPath{animationPath}
{
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(animationPath, aiProcess_Triangulate);
Expand All @@ -27,6 +27,10 @@ const std::map<std::string, Prisma::BoneInfo>& Prisma::Animation::GetBoneIDMap()
return m_BoneInfoMap;
}

std::string Prisma::Animation::name() const {
return m_animationPath;
}

void Prisma::Animation::ReadMissingBones(const aiAnimation* animation, std::shared_ptr<Prisma::AnimatedMesh> model)
{
int size = animation->mNumChannels;
Expand Down
8 changes: 8 additions & 0 deletions Engine/src/SceneData/Animator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ void Prisma::Animator::mesh(Node* mesh) {
m_mesh = mesh;
}

std::shared_ptr<Prisma::Animation> Prisma::Animator::animation() {
return m_CurrentAnimation;
}

float Prisma::Animator::currentTime() const {
return m_CurrentTime;
}

int Prisma::Animator::findUUID()
{
auto meshes = currentGlobalScene->animateMeshes;
Expand Down
2 changes: 1 addition & 1 deletion GUI/include/ImGuiStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace Prisma {
//colors[ImGuiCol_DockingEmptyBg] = ImVec4(1.00f, 0.00f, 0.00f, 1.00f);
colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 0.00f, 0.00f, 1.00f);
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.00f, 0.00f, 1.00f);
colors[ImGuiCol_PlotHistogram] = ImVec4(1.00f, 0.00f, 0.00f, 1.00f);
colors[ImGuiCol_PlotHistogram] = ImVec4(0.4f, 1.00f, 0.4f, 1.00f);
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.00f, 0.00f, 1.00f);
colors[ImGuiCol_TableHeaderBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.52f);
colors[ImGuiCol_TableBorderStrong] = ImVec4(0.00f, 0.00f, 0.00f, 0.52f);
Expand Down
22 changes: 17 additions & 5 deletions GUI/src/MeshInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void Prisma::MeshInfo::drawGizmo(Prisma::MeshInfo::MeshData meshData) {
}

void Prisma::MeshInfo::showSelected(Prisma::MeshInfo::MeshData meshData) {
if(meshData.mesh) {
if (meshData.mesh) {

float windowWidth = meshData.translate * meshData.width / 2.0f;
auto nextRight = [&](float pos) {
Expand All @@ -64,9 +64,9 @@ void Prisma::MeshInfo::showSelected(Prisma::MeshInfo::MeshData meshData) {



ImGui::InputFloat3("Translation",glm::value_ptr(m_translation),"%.3f", ImGuiInputTextFlags_ReadOnly);
ImGui::InputFloat3("Translation", glm::value_ptr(m_translation), "%.3f", ImGuiInputTextFlags_ReadOnly);

ImGui::InputFloat3("Rotation",glm::value_ptr(m_rotation), "%.3f", ImGuiInputTextFlags_ReadOnly);
ImGui::InputFloat3("Rotation", glm::value_ptr(m_rotation), "%.3f", ImGuiInputTextFlags_ReadOnly);

ImGui::InputFloat3("Scale", glm::value_ptr(m_scale), "%.3f", ImGuiInputTextFlags_ReadOnly);

Expand All @@ -80,10 +80,22 @@ void Prisma::MeshInfo::showSelected(Prisma::MeshInfo::MeshData meshData) {
if (mass <= 0.0) {
drawGizmo(meshData);
}

auto isAnimate = dynamic_cast<AnimatedMesh*>(meshData.mesh);
if (isAnimate) {
auto animator = isAnimate->animator();
auto animation = animator->animation();
auto getLast = [](std::string s) {
size_t found = s.find_last_of('/');
return found != std::string::npos ? s.substr(found + 1) : s;
};
auto name = getLast(animation->name());
ImGui::Text("%s", name.c_str());
float current = animator->currentTime()/animation->GetDuration()*100;
//ImGui::ProgressBar(current);
ImGui::SliderFloat("Slider", &current, 0.0f, 100.0f); // Slider for float value between 0 and 1
}
ImGui::Dummy(ImVec2(0.0f, 10.0f));
showComponents(meshData);

ImGui::End();
}
}
Expand Down
3 changes: 0 additions & 3 deletions UserEngine/src/UserEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ bool UserEngine::update()
light->type(type);
}

animator->UpdateAnimation(deltaTime);
animator1->UpdateAnimation(deltaTime);


return false;
}
Expand Down

0 comments on commit c12e7d4

Please sign in to comment.