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
|
|
|
|
2016-03-05 00:03:41 +00:00
|
|
|
namespace urde
|
2016-01-07 00:40:27 +00:00
|
|
|
{
|
2016-02-02 04:34:46 +00:00
|
|
|
class ModelViewer : public ViewerSpace
|
2016-01-17 05:08:46 +00:00
|
|
|
{
|
|
|
|
struct State : Space::State
|
|
|
|
{
|
2018-02-22 07:24:51 +00:00
|
|
|
AT_DECL_DNA_YAML
|
|
|
|
AT_DECL_DNAV
|
2016-01-17 05:08:46 +00:00
|
|
|
enum class Mode
|
|
|
|
{
|
|
|
|
Solid,
|
|
|
|
Material,
|
|
|
|
Wireframe
|
|
|
|
};
|
|
|
|
|
|
|
|
Value<Mode> renderMode = Mode::Material;
|
2016-03-04 23:04:53 +00:00
|
|
|
Value<zeus::CVector3f> cameraPosition;
|
|
|
|
Value<zeus::CQuaternion> cameraOrientation;
|
2016-01-17 22:41:49 +00:00
|
|
|
|
2016-01-17 05:08:46 +00:00
|
|
|
} m_state;
|
|
|
|
|
|
|
|
const Space::State& spaceState() const { return m_state; }
|
2016-03-04 23:04:53 +00:00
|
|
|
std::unique_ptr<urde::CLineRenderer> m_lineRenderer;
|
|
|
|
struct View : specter::View
|
2016-01-17 05:08:46 +00:00
|
|
|
{
|
2016-02-02 08:31:05 +00:00
|
|
|
ModelViewer& m_mv;
|
2016-02-18 08:56:11 +00:00
|
|
|
boo::SWindowRect m_scissorRect;
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
View(ModelViewer& mv, specter::ViewResources& res)
|
2016-03-30 19:16:01 +00:00
|
|
|
: specter::View(res, mv.m_vm.rootView()), m_mv(mv) {}
|
2016-02-18 08:56:11 +00:00
|
|
|
|
|
|
|
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub);
|
2016-01-17 05:08:46 +00:00
|
|
|
};
|
2016-01-17 22:41:49 +00:00
|
|
|
|
2016-02-02 08:31:05 +00:00
|
|
|
Camera m_camera;
|
|
|
|
std::unique_ptr<View> m_view;
|
2016-01-17 05:08:46 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
ModelViewer(ViewManager& vm, Space* parent)
|
2016-02-02 04:34:46 +00:00
|
|
|
: ViewerSpace(vm, Class::ModelViewer, parent)
|
2016-01-17 05:08:46 +00:00
|
|
|
{
|
|
|
|
reloadState();
|
2016-03-04 23:04:53 +00:00
|
|
|
m_lineRenderer.reset(new urde::CLineRenderer(urde::CLineRenderer::EPrimitiveMode::LineStrip, 4, nullptr, true));
|
2016-01-17 05:08:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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()
|
2016-02-02 08:31:05 +00:00
|
|
|
{
|
|
|
|
m_camera.setPosition(m_state.cameraPosition);
|
|
|
|
m_camera.setOrientation(m_state.cameraOrientation);
|
|
|
|
}
|
2016-01-17 05:08:46 +00:00
|
|
|
|
|
|
|
Space* copy(Space *parent) const
|
|
|
|
{
|
|
|
|
return new ModelViewer(m_vm, parent, *this);
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
virtual specter::View* buildContentView(specter::ViewResources& res)
|
2016-02-02 08:31:05 +00:00
|
|
|
{
|
|
|
|
m_view.reset(new View(*this, res));
|
|
|
|
return m_view.get();
|
|
|
|
}
|
|
|
|
|
2016-01-17 05:08:46 +00:00
|
|
|
bool usesToolbar() const { return true; }
|
|
|
|
};
|
|
|
|
|
2016-01-07 00:40:27 +00:00
|
|
|
}
|
|
|
|
|