metaforce/Editor/ModelViewer.hpp

65 lines
1.8 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
2016-01-07 00:40:27 +00:00
2016-01-17 05:08:46 +00:00
#include "Space.hpp"
#include "ViewManager.hpp"
2016-02-02 08:31:05 +00:00
#include "Camera.hpp"
2016-01-17 05:08:46 +00:00
2018-12-08 05:30:43 +00:00
namespace urde {
class ModelViewer : public ViewerSpace {
struct State : Space::State {
2019-08-11 00:49:41 +00:00
AT_DECL_DNA_YAMLV
2018-12-08 05:30:43 +00:00
enum class Mode { Solid, Material, Wireframe };
Value<Mode> renderMode = Mode::Material;
Value<zeus::CVector3f> cameraPosition;
Value<zeus::CQuaternion> cameraOrientation;
} m_state;
const Space::State& spaceState() const override { return m_state; }
2018-12-08 05:30:43 +00:00
std::unique_ptr<urde::CLineRenderer> m_lineRenderer;
struct View : specter::View {
ModelViewer& m_mv;
boo::SWindowRect m_scissorRect;
View(ModelViewer& mv, specter::ViewResources& res) : specter::View(res, mv.m_vm.rootView()), m_mv(mv) {}
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub) override;
2018-12-08 05:30:43 +00:00
};
Camera m_camera;
std::unique_ptr<View> m_view;
2016-01-17 05:08:46 +00:00
public:
2018-12-08 05:30:43 +00:00
ModelViewer(ViewManager& vm, Space* parent) : ViewerSpace(vm, Class::ModelViewer, parent) {
reloadState();
m_lineRenderer.reset(new urde::CLineRenderer(urde::CLineRenderer::EPrimitiveMode::LineStrip, 4, nullptr, true));
}
ModelViewer(ViewManager& vm, Space* parent, const ModelViewer& other) : ModelViewer(vm, parent) {
m_state = other.m_state;
reloadState();
}
ModelViewer(ViewManager& vm, Space* parent, ConfigReader& r) : ModelViewer(vm, parent) {
m_state.read(r);
reloadState();
}
void reloadState() override {
2018-12-08 05:30:43 +00:00
m_camera.setPosition(m_state.cameraPosition);
m_camera.setOrientation(m_state.cameraOrientation);
}
Space* copy(Space* parent) const override { return new ModelViewer(m_vm, parent, *this); }
2018-12-08 05:30:43 +00:00
specter::View* buildContentView(specter::ViewResources& res) override {
2018-12-08 05:30:43 +00:00
m_view.reset(new View(*this, res));
return m_view.get();
}
bool usesToolbar() const override { return true; }
2016-01-17 05:08:46 +00:00
};
2018-12-08 05:30:43 +00:00
} // namespace urde