Skip to content

Commit

Permalink
Display number of joints in skeleton asset
Browse files Browse the repository at this point in the history
  • Loading branch information
jankrassnigg committed Feb 25, 2021
1 parent 82c20d5 commit f93af19
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ void ezSkeletonContext::OnInitialize()
ezSkeletonComponent::CreateComponent(m_pGameObject, pVisSkeleton);
ezStringBuilder sSkeletonGuid;
ezConversionUtils::ToString(GetDocumentGuid(), sSkeletonGuid);
ezSkeletonResourceHandle hSkeleton = ezResourceManager::LoadResource<ezSkeletonResource>(sSkeletonGuid);
pVisSkeleton->SetSkeleton(hSkeleton);
m_hSkeleton = ezResourceManager::LoadResource<ezSkeletonResource>(sSkeletonGuid);
pVisSkeleton->SetSkeleton(m_hSkeleton);
pVisSkeleton->m_bVisualizeSkeleton = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class EZ_ENGINEPLUGINASSETS_DLL ezSkeletonContext : public ezEngineProcessDocume

virtual void HandleMessage(const ezEditorEngineDocumentMsg* pMsg) override;

ezSkeletonResourceHandle GetSkeleton() const { return m_hSkeleton; }

protected:
virtual void OnInitialize() override;

Expand All @@ -25,5 +27,5 @@ class EZ_ENGINEPLUGINASSETS_DLL ezSkeletonContext : public ezEngineProcessDocume
void QuerySelectionBBox(const ezEditorEngineDocumentMsg* pMsg);

ezGameObject* m_pGameObject = nullptr;
ezSkeletonResourceHandle m_hMesh;
ezSkeletonResourceHandle m_hSkeleton;
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <EnginePluginAssets/SkeletonAsset/SkeletonView.h>
#include <Foundation/Utilities/GraphicsUtils.h>
#include <GameEngine/GameApplication/GameApplication.h>
#include <RendererCore/Debug/DebugRenderer.h>
#include <RendererCore/Pipeline/Implementation/RenderPipelineResourceLoader.h>
#include <RendererCore/Pipeline/View.h>
#include <RendererCore/RenderContext/RenderContext.h>
Expand Down Expand Up @@ -47,3 +48,24 @@ ezViewHandle ezSkeletonViewContext::CreateView()
pView->SetCamera(&m_Camera);
return pView->GetHandle();
}

void ezSkeletonViewContext::SetCamera(const ezViewRedrawMsgToEngine* pMsg)
{
ezEngineProcessViewContext::SetCamera(pMsg);

const ezUInt32 viewHeight = pMsg->m_uiWindowHeight;

auto hSkeleton = m_pContext->GetSkeleton();
if (hSkeleton.IsValid())
{
ezResourceLock<ezSkeletonResource> pSkeleton(hSkeleton, ezResourceAcquireMode::AllowLoadingFallback);

ezUInt32 uiNumJoints = pSkeleton->GetDescriptor().m_Skeleton.GetJointCount();

ezStringBuilder sText;
sText.AppendFormat("Joints: {}\n", uiNumJoints);

ezDebugRenderer::Draw2DText(m_hView, sText, ezVec2I32(10, viewHeight - 10), ezColor::White, 16, ezDebugRenderer::HorizontalAlignment::Left,
ezDebugRenderer::VerticalAlignment::Bottom);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ezSkeletonViewContext : public ezEngineProcessViewContext

protected:
virtual ezViewHandle CreateView() override;
virtual void SetCamera(const ezViewRedrawMsgToEngine* pMsg) override;

ezSkeletonContext* m_pContext;
};

0 comments on commit f93af19

Please sign in to comment.