git-svn-id: svn://db.shs.com.ru/libs@45 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2015-11-23 17:07:25 +00:00
parent 104a7f99ad
commit 48addec20f
32 changed files with 738 additions and 541 deletions

View File

@@ -63,10 +63,10 @@ QGLView::QGLView(QWidget * parent): QGraphicsView(parent), fbo_selection(3) {
sel_mode = QGLView::SingleSelection;
sel_pen = QPen(Qt::black, 1, Qt::DashLine);
sel_brush = QBrush(QColor(170, 100, 255, 120));
camera_.setAim(QVector3D(0,0,5.5));
camera_.setPos(QVector3D(10, 5, 5.5));
emit cameraPosChanged(camera_.pos());
//camera_.aim_ = camera_.pos_;
camera().setAim(QVector3D(0,0,5.5));
camera().setPos(QVector3D(10, 5, 5.5));
emit cameraPosChanged(camera().pos());
//camera().aim_ = camera().pos_;
ktm_.restart();
sh_lm_diff << "Phong_diffuse" << "Cook_Torrance_diffuse" << "Minnaert_diffuse" << "Strauss_diffuse" << "Oren_Nayar_diffuse";
sh_lm_spec << "Phong_specular" << "Cook_Torrance_specular" << "Minnaert_specular" << "Strauss_specular" << "Oren_Nayar_specular";
@@ -127,7 +127,7 @@ void QGLView::initializeGL() {
makeCurrent();
currentQGLView = (QGLWidget * )viewport();
currentGLTextureManager = &textures_manager;
currentCamera = &camera_;
currentCamera = &camera();
//glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_TEXTURE_MAX_ANISOTROPY_EXT);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
@@ -195,7 +195,7 @@ void QGLView::paintGL() {
//QMutexLocker ml_v(&v_mutex);
glEnable(GL_CULL_FACE);
//glDisable(GL_CULL_FACE);
camera_.apply(aspect);
camera().apply(aspect);
start_rp.proj_matrix = getGLMatrix(GL_PROJECTION_MATRIX);
start_rp.view_matrix = getGLMatrix(GL_MODELVIEW_MATRIX);
//objects_.buildTransform();
@@ -257,7 +257,7 @@ void QGLView::paintGL() {
glEnableClientState(GL_COLOR_ARRAY);
}
camera_.apply(aspect);
camera().apply(aspect);
static GLRendererBase * prev_rend = 0;
if (prev_rend != renderer_) {
@@ -551,24 +551,25 @@ void QGLView::mouseMoveEvent(QMouseEvent * e) {
double dx = e->x() - lastPos.x();
double dy = e->y() - lastPos.y();
if (e->buttons() & Qt::LeftButton) {
//camera_.angle_z += dx / 4.;
//camera_.angle_xy += dy / 4.;
//camera().angle_z += dx / 4.;
//camera().angle_xy += dy / 4.;
if (cameraOrbit_) {
camera_.orbitZ(dx / 4.);
camera_.orbitXY(dy / 4.);
camera().orbitZ(dx / 4.);
camera().orbitXY(dy / 4.);
} else {
camera_.rotateZ(dx / 4.);
camera_.rotateXY(dy / 4.);
camera().rotateZ(dx / 4.);
camera().rotateXY(dy / 4.);
}
emit cameraPosChanged(camera_.pos());
emit cameraPosChanged(camera().pos());
} else if (e->buttons() & Qt::RightButton) {
camera_.moveLeft(dx / 100.);
camera_.moveUp(dy / 100.);
//camera_.pos.setX(camera_.pos.x() + camera_.pos.z() * dx / 500.);
//camera_.pos.setY(camera_.pos.y() - camera_.pos.z() * dy / 500.);
emit cameraPosChanged(camera_.pos());
double ad = camera().distance();
camera().moveLeft(dx / 1000. * ad);
camera().moveUp(dy / 1000. * ad);
//camera().pos.setX(camera().pos.x() + camera().pos.z() * dx / 500.);
//camera().pos.setY(camera().pos.y() - camera().pos.z() * dy / 500.);
emit cameraPosChanged(camera().pos());
}
//lights[0]->pos_ = camera_.pos();
//lights[0]->pos_ = camera().pos();
}
if (customMouseMove_) emit customMouseMoveEvent(e->pos(), lastPos, e->buttons());
lastPos = e->pos();
@@ -600,9 +601,9 @@ void QGLView::wheelEvent(QWheelEvent * e) {
QGraphicsView::wheelEvent(e);
if (scene()->itemAt(mapToScene(e->pos())) != 0) return;
if (mouseRotate_) {
if (e->delta() > 0) camera_.flyCloser(0.1); //camera_.pos.setZ(camera_.pos.z() - 0.1 * camera_.pos.z());
if (e->delta() < 0) camera_.flyFarer(0.1); //camera_.pos.setZ(camera_.pos.z() + 0.1 * camera_.pos.z());
emit cameraPosChanged(camera_.pos());
if (e->delta() > 0) camera().flyCloser(0.1); //camera().pos.setZ(camera().pos.z() - 0.1 * camera().pos.z());
if (e->delta() < 0) camera().flyFarer(0.1); //camera().pos.setZ(camera().pos.z() + 0.1 * camera().pos.z());
emit cameraPosChanged(camera().pos());
}
emit glWheelEvent(e);
}