Files
vr-poser/include/Application.h
2026-03-16 00:22:49 -04:00

71 lines
2.0 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"
#include "PoseManager.h"
class MorphManager;
class ImGuiLayer;
class SkeletonLoader;
class BoneSelector;
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
void applyPoseUpdate(); // called by update callback
private:
void setupLighting();
void setupGrid();
void requestShader(const std::string& mode);
void setModelScale(float scale);
void setPoseMode(bool enabled);
void handleViewportClick(float x, float y);
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;
osg::ref_ptr<osg::Group> m_skeletonRoot;
AppConfig m_config;
std::unique_ptr<ShaderManager> m_shaderMgr;
std::unique_ptr<MorphManager> m_morphMgr;
std::unique_ptr<PoseManager> m_poseMgr;
std::unique_ptr<BoneSelector> m_boneSel;
std::unique_ptr<ImGuiLayer> m_imguiLayer;
bool m_poseMode = false;
std::mutex m_shaderMutex;
std::string m_pendingShader;
std::string m_currentShader = "toon";
bool m_shaderDirty = false;
bool m_reloadShaders = false;
};