Subversion Repositories gelsvn

Rev

Rev 178 | Rev 447 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#include <fstream>
#include "QuatTrackBall.h"

namespace GLGraphics
{

        class GLViewController
        {
                float FOV_DEG;
                float FOV_RAD;
                int WINX, WINY;
                float znear, zfar;
                float aspect;
                bool button_down;
                TrackBallAction last_action;
                bool spin;

                QuatTrackBall ball;
        public:

                GLViewController(int _WINX, int _WINY,
                                                                                 const CGLA::Vec3f& _centre, float _rad);
                void grab_ball(TrackBallAction action, const CGLA::Vec2i& pos);
                void roll_ball(const CGLA::Vec2i& pos);
                void release_ball();
                bool try_spin();
                void reset_projection();
                void set_gl_modelview();
                void reshape(int W, int H);
                void set_near_and_far();
                
                void set_centre(const CGLA::Vec3f& c)
                {
                        ball.set_centre(c);
                }
                
                void set_eye_dist(float rad)
                {
                        ball.set_eye_dist(rad);
                        set_near_and_far();
                }

                float get_fovy_rad() const {return FOV_RAD;}

                float get_eye_dist() const
                {
                        return ball.get_eye_dist();
                }

                void get_view_param(CGLA::Vec3f& e, CGLA::Vec3f& c, CGLA::Vec3f& u) const
                {
                        ball.get_view_param(e,c,u);
                }

                bool load(std::ifstream&);
                bool save(std::ofstream&) const;
        };
        
}