22 #ifndef PGL_CONTROLLER_H_ 23 #define PGL_CONTROLLER_H_ 34 double azimuth, elevation, distance;
38 double old_azimuth_, old_elevation_, old_distance_, old_xpos_, old_ypos_;
40 enum {modeNone, modeAngle, modeDistance, modeCenter} mode_;
48 void view(
double _azimuth,
double _elevation,
double _distance)
51 elevation = _elevation;
57 void click(
int button,
int action,
int ,
double xpos,
double ypos)
59 if (action == PGL_PRESS)
64 old_azimuth_ = azimuth;
65 old_elevation_ = elevation;
66 old_distance_ = distance;
68 if (button == PGL_MOUSE_BUTTON_LEFT) mode_ = modeAngle;
69 if (button == PGL_MOUSE_BUTTON_MIDDLE) mode_ = modeDistance;
70 if (button == PGL_MOUSE_BUTTON_RIGHT) mode_ = modeCenter;
78 distance *= pow(sqrt(2), -yoffset);
82 void motion(
double xpos,
double ypos)
87 azimuth = old_azimuth_ - 0.005*(xpos-old_xpos_);
88 elevation = old_elevation_ + 0.005*(ypos-old_ypos_);
91 distance = old_distance_ + 0.02*(ypos-old_ypos_);
94 center = old_center_ +
Rotation({0, 0, -azimuth})*(
Vector3({old_xpos_-xpos, ypos-old_ypos_, 0})*0.02);
111 #endif // PGL_CONTROLLER_H_ Camera * camera
Camera to move.
Definition: pgl.h:277
Camera Controller which orbits around a center.
Definition: controller.h:30
Definition: controller.h:27
Transform with zero translation.
Definition: math.h:282
Transform transform
Camera position.
Definition: pgl.h:227
Camera controller.
Definition: pgl.h:274
void scroll(double, double yoffset)
Scroll wheel handler.
Definition: controller.h:76
3-component vector.
Definition: math.h:43
void click(int button, int action, int, double xpos, double ypos)
Click handler.
Definition: controller.h:57
void motion(double xpos, double ypos)
Mouse motion handler.
Definition: controller.h:82
Transform with identity rotation.
Definition: math.h:289
Defines camera position and frustum.
Definition: pgl.h:224