code format
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
QGLView
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -23,66 +23,101 @@
|
||||
|
||||
class Camera;
|
||||
|
||||
//extern QMatrix4x4 globCameraMatrix;
|
||||
//extern Camera * currentCamera;
|
||||
// extern QMatrix4x4 globCameraMatrix;
|
||||
// extern Camera * currentCamera;
|
||||
|
||||
class Camera: public GLObjectBase
|
||||
{
|
||||
class Camera: public GLObjectBase {
|
||||
friend class QGLView;
|
||||
friend class GLParticlesSystem;
|
||||
friend QDataStream & operator <<(QDataStream & s, const GLObjectBase * p);
|
||||
friend QDataStream & operator >>(QDataStream & s, GLObjectBase *& p);
|
||||
friend QDataStream & operator<<(QDataStream & s, const GLObjectBase * p);
|
||||
friend QDataStream & operator>>(QDataStream & s, GLObjectBase *& p);
|
||||
|
||||
public:
|
||||
Camera();
|
||||
|
||||
void setPos(const QVector3D & p) {pos_ = p; anglesFromPoints(); buildTransform();}
|
||||
void setAim(const QVector3D & p) {aim_ = p; anglesFromPoints(); buildTransform();}
|
||||
void move(const QVector3D & p) {pos_ += p; aim_ += p; buildTransform();}
|
||||
void move(const float & x, const float & y = 0., const float & z = 0.) {pos_ += QVector3D(x, y, z); aim_ += QVector3D(x, y, z); buildTransform();}
|
||||
void setPos(const QVector3D & p) {
|
||||
pos_ = p;
|
||||
anglesFromPoints();
|
||||
buildTransform();
|
||||
}
|
||||
void setAim(const QVector3D & p) {
|
||||
aim_ = p;
|
||||
anglesFromPoints();
|
||||
buildTransform();
|
||||
}
|
||||
void move(const QVector3D & p) {
|
||||
pos_ += p;
|
||||
aim_ += p;
|
||||
buildTransform();
|
||||
}
|
||||
void move(const float & x, const float & y = 0., const float & z = 0.) {
|
||||
pos_ += QVector3D(x, y, z);
|
||||
aim_ += QVector3D(x, y, z);
|
||||
buildTransform();
|
||||
}
|
||||
void moveForward(const float & x, bool withZ = true);
|
||||
void moveBackward(const float & x, bool withZ = true) {moveForward(-x, withZ);}
|
||||
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 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 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) {angles_.setX(angles_.x() + a); buildTransform();}
|
||||
void rotateRoll(const float & a) {
|
||||
angles_.setX(angles_.x() + a);
|
||||
buildTransform();
|
||||
}
|
||||
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 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) {angles_.setX(a); buildTransform();}
|
||||
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;}
|
||||
void setAngleRoll(const float & a) {
|
||||
angles_.setX(a);
|
||||
buildTransform();
|
||||
}
|
||||
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; }
|
||||
void flyCloser(const float & s);
|
||||
void flyFarer(const float & s);
|
||||
void flyToDistance(const float & d);
|
||||
|
||||
QVector3D aim() const {return aim_;}
|
||||
QVector3D angles() const {return rotation();}
|
||||
QVector3D direction() const {return (aim_ - pos_).normalized();}
|
||||
QVector3D directionXY() const {QVector3D tv = aim_ - pos_; return QVector3D(tv.x(), tv.y(), 0.).normalized();}
|
||||
float FOV() const {return fov_;}
|
||||
float distance() const {return (pos_ - aim_).length();}
|
||||
float angleZ() const {return angles_.z();}
|
||||
float angleXY() const {return angles_.y();}
|
||||
float angleRoll() const {return angles_.x();}
|
||||
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;}
|
||||
QVector3D aim() const { return aim_; }
|
||||
QVector3D angles() const { return rotation(); }
|
||||
QVector3D direction() const { return (aim_ - pos_).normalized(); }
|
||||
QVector3D directionXY() const {
|
||||
QVector3D tv = aim_ - pos_;
|
||||
return QVector3D(tv.x(), tv.y(), 0.).normalized();
|
||||
}
|
||||
float FOV() const { return fov_; }
|
||||
float distance() const { return (pos_ - aim_).length(); }
|
||||
float angleZ() const { return angles_.z(); }
|
||||
float angleXY() const { return angles_.y(); }
|
||||
float angleRoll() const { return angles_.x(); }
|
||||
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 apply(const GLfloat & aspect = 1.);
|
||||
void assign(const Camera & c);
|
||||
@@ -100,7 +135,6 @@ private:
|
||||
GLfloat angle_limit_upper_xy;
|
||||
bool mirror_x;
|
||||
bool mirror_y;
|
||||
|
||||
};
|
||||
|
||||
#endif // GLCAMERA_H
|
||||
|
||||
Reference in New Issue
Block a user