stuff-from-scratch/apps/notes_tk/mesh_viewer/MeshViewerView.cpp

67 lines
1.3 KiB
C++
Raw Normal View History

2022-11-18 17:05:33 +00:00
#include "MeshViewerView.h"
#include "MeshNode.h"
#include "TransformNode.h"
#include "AbstractMesh.h"
#include "MeshPrimitives.h"
2023-01-17 13:01:59 +00:00
#include "ThemeManager.h"
#include "PaintEvent.h"
2022-11-18 17:05:33 +00:00
#include <iostream>
std::unique_ptr<MeshViewerView> MeshViewerView::Create()
{
return std::make_unique<MeshViewerView>();
}
MeshViewerView::~MeshViewerView()
{
}
MeshViewerView::MeshViewerView()
{
mName = "MeshViewerView";
}
void MeshViewerView::doPaint(const PaintEvent* event)
{
if (!mVisible)
{
return;
}
if (!mMeshNode)
{
2023-01-20 08:07:09 +00:00
mMeshNode = std::make_unique<MeshNode>(Transform(mLocation));
2022-11-18 17:05:33 +00:00
mMeshNode->setName(mName + "_MeshNode");
mMeshNode->setWidth(mSize.mWidth);
mMeshNode->setHeight(mSize.mHeight);
2023-01-17 13:01:59 +00:00
mMeshNode->setFillColor(event->getThemesManager()->getColor(mBackground));
2022-11-18 17:05:33 +00:00
mRootNode->addChild(mMeshNode.get());
}
if (mTransformDirty)
{
mMeshNode->setWidth(mSize.mWidth);
mMeshNode->setHeight(mSize.mHeight);
}
if (mMaterialDirty)
{
2023-01-17 13:01:59 +00:00
mMeshNode->setFillColor(event->getThemesManager()->getColor(mBackground));
2022-11-18 17:05:33 +00:00
}
if (!mMesh)
{
auto mesh = MeshPrimitives::buildRectangleAsTriMesh();
mMesh = std::move(mesh);
mMeshNode->setMesh(mMesh.get());
}
}