]> git.tdb.fi Git - libs/vr.git/blobdiff - source/openvr/openvrsystem.h
Provide objects for visualizing controllers
[libs/vr.git] / source / openvr / openvrsystem.h
index 498865992fdaa8c5a886e3f3e2bb8bdb1d3f128d..0e787eb8d465c947d8d6f53283be5c5a6bfb5f1d 100644 (file)
@@ -1,10 +1,14 @@
 #ifndef MSP_VR_OPENVRSYSTEM_H_
 #define MSP_VR_OPENVRSYSTEM_H_
 
+#include <msp/gl/material.h>
 #include <msp/gl/matrix.h>
+#include <msp/gl/object.h>
+#include <msp/gl/technique.h>
 #include <msp/vr/system.h>
 #include "openvrcamera.h"
 #include "openvrcombiner.h"
+#include "openvrcontroller.h"
 
 namespace Msp {
 namespace VR {
@@ -12,7 +16,20 @@ namespace VR {
 class OpenVRSystem: public System
 {
 private:
-       GL::Matrix hmd_matrix;
+       struct RenderModel;
+
+       unsigned n_tracked_devices;
+       std::vector<GL::Matrix> tracking_matrices;
+       std::vector<OpenVRController *> controllers;
+       std::vector<unsigned> unclaimed_controllers;
+
+       GL::Program render_shprog;
+       GL::Program render_shprog_textured;
+       GL::Material render_material;
+       std::map<std::string, RenderModel *> render_models;
+       std::map<unsigned, GL::Texture2D *> render_textures;
+       std::list<std::string> loading_render_models;
+       std::list<unsigned> loading_textures;
 
        static unsigned n_instances;
 
@@ -24,12 +41,26 @@ public:
 
        virtual void configure_window(Graphics::Window &) const { }
        virtual void configure_view(StereoView &) const;
+       virtual bool is_absolute_tracking_supported() const { return true; }
        virtual void set_absolute_tracking(bool);
+       virtual bool get_absolute_tracking() const;
        virtual OpenVRCamera *create_camera(const GL::Camera &);
        virtual OpenVRCombiner *create_combiner(GL::View &);
+       virtual OpenVRController *create_controller();
+
+       virtual void tick();
 
        void update_pose_matrices();
-       const GL::Matrix &get_hmd_matrix() const { return hmd_matrix; }
+       const GL::Matrix &get_tracking_matrix(unsigned) const;
+       const GL::Matrix &get_hmd_matrix() const;
+       void add_controller(OpenVRController &);
+       void remove_controller(OpenVRController &);
+
+       const GL::Object *get_render_model(const std::string &);
+private:
+       bool check_loading_render_model(const std::string &);
+       const GL::Texture2D *get_texture(unsigned);
+       bool check_loading_texture(unsigned);
 };
 
 } // namespace VR