Files
vr-poser/include/Application.h
2026-03-15 22:03:30 -04:00

59 lines
1.6 KiB
C++

#pragma once
#include <string>
#include <memory>
#include <mutex>
#include <osgViewer/Viewer>
#include <osg/ref_ptr>
#include <osg/Group>
#include <osg/Node>
#include <osg/NodeCallback>
#include <osg/MatrixTransform>
#include <osgGA/GUIEventHandler>
#include "ShaderManager.h"
#include "AppConfig.h"
class MorphManager;
class ImGuiLayer;
class Application : public osgGA::GUIEventHandler {
public:
Application();
~Application();
bool init(int width = 1280, int height = 720,
const std::string& title = "VR Model Viewer");
bool loadModel(const std::string& filepath);
int run();
bool handle(const osgGA::GUIEventAdapter& ea,
osgGA::GUIActionAdapter& aa) override;
void applyPendingShader(); // called by update callback
void applyMorphWeights(); // called by update callback
private:
void setupLighting();
void setupGrid();
void requestShader(const std::string& mode);
void setModelScale(float scale);
osg::ref_ptr<osgViewer::Viewer> m_viewer;
osg::ref_ptr<osg::Group> m_sceneRoot;
osg::ref_ptr<osg::Group> m_shaderGroup;
osg::ref_ptr<osg::Node> m_modelNode;
osg::ref_ptr<osg::MatrixTransform> m_modelXform; // scale/transform wrapper
AppConfig m_config;
std::unique_ptr<ShaderManager> m_shaderMgr;
std::unique_ptr<MorphManager> m_morphMgr;
std::unique_ptr<ImGuiLayer> m_imguiLayer;
std::mutex m_shaderMutex;
std::string m_pendingShader;
std::string m_currentShader = "toon";
bool m_shaderDirty = false;
bool m_reloadShaders = false;
};