git-svn-id: svn://db.shs.com.ru/libs@45 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -175,93 +175,8 @@ inline QImage rotateQImage180(const QImage & im) {return im.mirrored(true, true)
|
||||
//const double rad2deg = 45. / atan(1.);
|
||||
|
||||
extern QGLWidget * currentQGLView;
|
||||
extern QMatrix4x4 globCameraMatrix;
|
||||
extern QMutex globMutex;
|
||||
|
||||
class Camera
|
||||
{
|
||||
friend class QGLView;
|
||||
friend class GLParticlesSystem;
|
||||
public:
|
||||
Camera() {fov_ = 60.; angle_xy = angle_z = angle_roll = 0.; angle_limit_lower_xy = 180.; angle_limit_upper_xy = 360.; depth_start = 0.1; depth_end = 1000.; mirror_x = mirror_y = false;}
|
||||
|
||||
void setPos(const QVector3D & p) {pos_ = p; anglesFromPoints();}
|
||||
/*void setPosX(const double & o) {QVector3D dv = aim_ - pos_; pos_.setX(o); aim_ = pos_ + dv;}
|
||||
void setPosY(const double & o) {QVector3D dv = aim_ - pos_; pos_.setY(o); aim_ = pos_ + dv;}
|
||||
void setPosZ(const double & o) {QVector3D dv = aim_ - pos_; pos_.setZ(o); aim_ = pos_ + dv;}*/
|
||||
void setAim(const QVector3D & p) {aim_ = p; anglesFromPoints();}
|
||||
void move(const QVector3D & p) {pos_ += p; aim_ += p;}
|
||||
void move(const double & x, const double & y = 0., const double & z = 0.) {pos_ += QVector3D(x, y, z); aim_ += QVector3D(x, y, z);}
|
||||
void moveForward(const double & x, bool withZ = true);
|
||||
void moveBackward(const double & x, bool withZ = true) {moveForward(-x, withZ);}
|
||||
void moveLeft(const double & x, bool withZ = true);
|
||||
void moveRight(const double & x, bool withZ = true) {moveLeft(-x, withZ);}
|
||||
void moveUp(const double & x, bool onlyZ = false);
|
||||
void moveDown(const double & x, bool onlyZ = false) {moveUp(-x, onlyZ);}
|
||||
void rotateZ(const double & a);
|
||||
void rotateXY(const double & a);
|
||||
void rotateRoll(const double & a) {angle_roll += a;}
|
||||
void orbitZ(const double & a);
|
||||
void orbitXY(const double & a);
|
||||
void panZ(const double & a);
|
||||
void panXY(const double & a);
|
||||
void setFOV(const double & f) {fov_ = f;}
|
||||
void setAngles(const QVector3D & a) {angle_xy = a.x(); angle_roll = a.y(); angle_z = a.z();}
|
||||
void setAngleZ(const double & a);
|
||||
void setAngleXY(const double & a);
|
||||
void setAngleRoll(const double & a) {angle_roll = a;}
|
||||
void setAngleLowerLimitXY(const double & a) {angle_limit_lower_xy = a;}
|
||||
void setAngleUpperLimitXY(const double & a) {angle_limit_upper_xy = a;}
|
||||
void setAngleLimitsXY(const double & lower, const double & upper) {angle_limit_lower_xy = lower; angle_limit_upper_xy = upper;}
|
||||
void setDepthStart(const double & d) {depth_start = d;}
|
||||
void setDepthEnd(const double & d) {depth_end = d;}
|
||||
void setMirrorX(bool yes) {mirror_x = yes;}
|
||||
void setMirrorY(bool yes) {mirror_y = yes;}
|
||||
void flyCloser(const double & s);
|
||||
void flyFarer(const double & s);
|
||||
void flyToDistance(const double & d);
|
||||
|
||||
QVector3D pos() const {return pos_;}
|
||||
QVector3D aim() const {return aim_;}
|
||||
QVector3D angles() const {return QVector3D(angle_xy, angle_roll, angle_z);}
|
||||
QVector3D direction() const {return (aim_ - pos_).normalized();}
|
||||
QVector3D directionXY() const {QVector3D tv = aim_ - pos_; return QVector3D(tv.x(), tv.y(), 0.).normalized();}
|
||||
double FOV() const {return fov_;}
|
||||
double distance() const {return (pos_ - aim_).length();}
|
||||
double angleZ() const {return angle_z;}
|
||||
double angleXY() const {return angle_xy;}
|
||||
double angleRoll() const {return angle_roll;}
|
||||
double angleLowerLimitXY() const {return angle_limit_lower_xy;}
|
||||
double angleUpperLimitXY() const {return angle_limit_upper_xy;}
|
||||
double depthStart() const {return depth_start;}
|
||||
double depthEnd() const {return depth_end;}
|
||||
bool isMirrorX() const {return mirror_x;}
|
||||
bool isMirrorY() const {return mirror_y;}
|
||||
void anglesFromPoints();
|
||||
void apply(const GLdouble & aspect = 1.);
|
||||
void assign(const Camera & c) {pos_ = c.pos_; aim_ = c.aim_; fov_ = c.fov_; angle_z = c.angle_z; angle_xy = c.angle_xy; angle_roll = c.angle_roll; angle_limit_lower_xy = c.angle_limit_lower_xy; angle_limit_upper_xy = c.angle_limit_upper_xy;}
|
||||
QVector3D pointFromViewport(int x_, int y_, double z_);
|
||||
private:
|
||||
|
||||
QVector3D pos_;
|
||||
QVector3D aim_;
|
||||
GLdouble fov_;
|
||||
GLdouble depth_start;
|
||||
GLdouble depth_end;
|
||||
GLdouble angle_z;
|
||||
GLdouble angle_xy;
|
||||
GLdouble angle_roll;
|
||||
GLdouble angle_limit_lower_xy;
|
||||
GLdouble angle_limit_upper_xy;
|
||||
GLdouble modelview[16], projection[16];
|
||||
GLint viewport[4];
|
||||
bool mirror_x;
|
||||
bool mirror_y;
|
||||
|
||||
};
|
||||
|
||||
extern Camera * currentCamera;
|
||||
|
||||
struct Box3D {
|
||||
GLfloat x;
|
||||
GLfloat y;
|
||||
@@ -345,6 +260,8 @@ struct Vector2d {
|
||||
Vector2d operator -(const GLfloat v) {return Vector2d(x-v, y-v);}
|
||||
Vector2d operator +(const Vector3d & v) {return Vector3d(x + v.x, y + v.y);}
|
||||
Vector2d operator -(const Vector3d & v) {return Vector3d(x - v.x, y - v.y);}
|
||||
Vector2d operator +(const Vector2d & v) {return Vector2d(x + v.x, y + v.y);}
|
||||
Vector2d operator -(const Vector2d & v) {return Vector2d(x - v.x, y - v.y);}
|
||||
Vector2d & operator *=(const GLfloat & v) {x *= v; y *= v; return *this;}
|
||||
Vector2d & operator /=(const GLfloat & v) {x /= v; y /= v; return *this;}
|
||||
Vector2d & operator +=(const GLfloat & v) {x += v; y += v; return *this;}
|
||||
@@ -398,17 +315,19 @@ inline double frac(const double & x, const double & b) {return x - int(x / b) *
|
||||
class GLObjectBase;
|
||||
class QGLView;
|
||||
class Light;
|
||||
class Camera;
|
||||
|
||||
class QGLViewBase
|
||||
{
|
||||
friend class GLObjectBase;
|
||||
public:
|
||||
QGLViewBase() {}
|
||||
Camera & camera() {return camera_;}
|
||||
void setCamera(const Camera & camera) {camera_ = camera;}
|
||||
QGLViewBase();
|
||||
Camera & camera();
|
||||
const Camera & camera() const;
|
||||
void setCamera(const Camera & camera);
|
||||
protected:
|
||||
virtual void collectLights() = 0;
|
||||
Camera camera_;
|
||||
Camera * camera_;
|
||||
};
|
||||
|
||||
#endif // GLTYPES_H
|
||||
|
||||
Reference in New Issue
Block a user