7 SeaView::SeaView(double distance, double azimuth, double altitude) :
14 void SeaView::onMouseEvent(int button, int state, int x, int y)
16 if (button == 3 && state == 0) {
17 m_distance += m_distance*DISTANCE_MULTIPLIER;
20 else if (button == 4 && state == 0) {
21 m_distance -= m_distance*DISTANCE_MULTIPLIER;
24 else if (button == 0 && state == 0) {
25 m_mouseDownPos[0] = x;
26 m_mouseDownPos[1] = y;
27 m_mouseDownAzimuth = m_azimuth;
28 m_mouseDownAltitude = m_altitude;
32 void SeaView::onMouseMove(int x, int y)
35 fmod(m_mouseDownAltitude +
36 (double)((y - m_mouseDownPos[1]) *
37 2*M_PI / glutGet(GLUT_WINDOW_HEIGHT)),
41 fmod(m_mouseDownAzimuth +
42 (double)((x - m_mouseDownPos[0]) *
43 2*M_PI / glutGet(GLUT_WINDOW_WIDTH)),
49 void SeaView::setupView() const
51 glMatrixMode(GL_MODELVIEW);
54 const double eyePos[3] =
55 {m_distance * cos(m_altitude) * sin(m_azimuth),
56 m_distance * cos(m_altitude) * cos(m_azimuth),
57 m_distance * sin(m_altitude)};
59 gluLookAt(eyePos[0], eyePos[1], eyePos[2],