/* QGLView Copyright (C) 2019 Ivan Pelipenko peri4ko@yandex.ru This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef GLCAMERA_H #define GLCAMERA_H #include "globject.h" //extern QMatrix4x4 globCameraMatrix; //extern Camera * currentCamera; class Camera: public AimedObject { friend class QGLView; friend class GLParticlesSystem; friend QDataStream & operator <<(QDataStream & s, const ObjectBase * p); friend QDataStream & operator >>(QDataStream & s, ObjectBase *& p); public: Camera(); void moveForward(const float & x, bool withZ = true); void moveBackward(const float & x, bool withZ = true) {moveForward(-x, withZ);} void moveLeft(const float & x, bool withZ = true); void moveRight(const float & x, bool withZ = true) {moveLeft(-x, withZ);} void moveUp(const float & x, bool onlyZ = false); void moveDown(const float & x, bool onlyZ = false) {moveUp(-x, onlyZ);} void rotateZ(const float & a); void rotateXY(const float & a); void rotateRoll(const float & a) {rotateX(a);} void orbitZ(const float & a); void orbitXY(const float & a); void panZ(const float & a); void panXY(const float & a); void setFOV(const float & f) {fov_ = f;} void setAngles(const QVector3D & a) {setRotation(a);} void setAngleZ(const float & a); void setAngleXY(const float & a); void setAngleRoll(const float & a) {setRotationX(a);} void setAngleLowerLimitXY(const float & a) {angle_limit_lower_xy = a; buildTransform();} void setAngleUpperLimitXY(const float & a) {angle_limit_upper_xy = a; buildTransform();} void setAngleLimitsXY(const float & lower, const float & upper) {angle_limit_lower_xy = lower; angle_limit_upper_xy = upper; buildTransform();} void setDepthStart(const float & d) {depth_start = d;} void setDepthEnd(const float & d) {depth_end = d;} void setMirrorX(bool yes) {mirror_x = yes;} void setMirrorY(bool yes) {mirror_y = yes;} float FOV() const {return fov_;} float angleZ() const {return rotationZ();} float angleXY() const {return rotationY();} float angleRoll() const {return rotationZ();} float angleLowerLimitXY() const {return angle_limit_lower_xy;} float angleUpperLimitXY() const {return angle_limit_upper_xy;} float depthStart() const {return depth_start;} float depthEnd() const {return depth_end;} bool isMirrorX() const {return mirror_x;} bool isMirrorY() const {return mirror_y;} void anglesFromPoints(); void assign(const Camera & c); virtual ObjectBase * clone(bool withChildren = true); QMatrix4x4 viewMatrix() const; QMatrix4x4 projectionMatrix(double aspect) const; QMatrix4x4 offsetMatrix() const; QMatrix4x4 fullViewMatrix() const {return viewMatrix() * offsetMatrix();} private: mutable QVector3D offset_; GLfloat fov_; GLfloat depth_start; GLfloat depth_end; GLfloat angle_limit_lower_xy; GLfloat angle_limit_upper_xy; bool mirror_x; bool mirror_y; }; #endif // GLCAMERA_H