diff --git a/qglview/glcamera.cpp b/qglview/glcamera.cpp index 84ee029..84a0fba 100644 --- a/qglview/glcamera.cpp +++ b/qglview/glcamera.cpp @@ -97,10 +97,39 @@ void Camera::assign(const Camera & c) { angles_ = c.angles_; angle_limit_lower_xy = c.angle_limit_lower_xy; angle_limit_upper_xy = c.angle_limit_upper_xy; + mirror_x = c.mirror_x; + mirror_y = c.mirror_y; + depth_start = c.depth_start; + depth_end = c.depth_end; buildTransform(); } +GLObjectBase * Camera::clone(bool withChildren) { + Camera * o = new Camera(*this); + //GLObjectBase::clone(withChildren); + o->is_init = false; + o->name_ = name_ + "_copy"; + o->view_ = nullptr; + o->children_.clear(); + if (withChildren) { + for (int i = 0; i < children_.size(); ++i) + o->addChild(children_[i]->clone(withChildren)); + } + o->pos_ = pos_; + o->aim_ = aim_; + o->fov_ = fov_; + o->angles_ = angles_; + o->angle_limit_lower_xy = angle_limit_lower_xy; + o->angle_limit_upper_xy = angle_limit_upper_xy; + o->mirror_x = mirror_x; + o->mirror_y = mirror_y; + o->depth_start = depth_start; + o->depth_end = depth_end; + return o; +} + + void Camera::panZ(const float & a) { QVector3D dv = aim_ - pos_; float tl = QVector2D(dv.x(), dv.y()).length(); diff --git a/qglview/glcamera.h b/qglview/glcamera.h index b427b16..411a66a 100644 --- a/qglview/glcamera.h +++ b/qglview/glcamera.h @@ -87,6 +87,8 @@ public: void apply(const GLfloat & aspect = 1.); void assign(const Camera & c); + + virtual GLObjectBase * clone(bool withChildren = true); QMatrix4x4 offsetMatrix() const; private: diff --git a/qglview/globject_editor.cpp b/qglview/globject_editor.cpp index af7d3c7..9504bb6 100644 --- a/qglview/globject_editor.cpp +++ b/qglview/globject_editor.cpp @@ -18,6 +18,7 @@ #include "globject_editor.h" #include "ui_globject_editor.h" +#include "glcamera.h" GLObjectEditor::GLObjectEditor(QWidget * parent): QWidget(parent) { @@ -27,6 +28,9 @@ GLObjectEditor::GLObjectEditor(QWidget * parent): QWidget(parent) { object = 0; rmodes << GLObjectBase::View << GLObjectBase::Point << GLObjectBase::Line << GLObjectBase::Fill; ui->groupLight->setEnabled(false); + ui->groupLight->setVisible(false); + ui->groupCamera->setEnabled(false); + ui->groupCamera->setVisible(false); } @@ -47,6 +51,9 @@ void GLObjectEditor::setObject(GLObjectBase * o) { object = o; if (object == 0) { ui->groupLight->setEnabled(false); + ui->groupLight->setVisible(false); + ui->groupCamera->setEnabled(false); + ui->groupCamera->setVisible(false); return; } ui->buttonDiscardRawMatrix->setEnabled(o->isRawMatrix()); @@ -68,6 +75,7 @@ void GLObjectEditor::setObject(GLObjectBase * o) { ui->checkReceiveShadows->setChecked(object->isReceiveShadows()); ui->comboRenderMode->setCurrentIndex(rmodes.indexOf(object->renderMode())); ui->groupLight->setEnabled(object->type() == GLObjectBase::glLight); + ui->groupLight->setVisible(object->type() == GLObjectBase::glLight); if (object->type() == GLObjectBase::glLight) { Light * l = globject_cast(object); //bool is_dir = l->light_type == Light::Directional, is_cone = l->light_type == Light::Cone; @@ -83,6 +91,16 @@ void GLObjectEditor::setObject(GLObjectBase * o) { ui->spinLightDirectionY->setValue(l->direction.y()); ui->spinLightDirectionZ->setValue(l->direction.z()); } + ui->groupCamera->setEnabled(object->type() == GLObjectBase::glCamera); + ui->groupCamera->setVisible(object->type() == GLObjectBase::glCamera); + if (object->type() == GLObjectBase::glCamera) { + Camera * c = globject_cast(object); + ui->checkCameraMirrorX->setChecked(c->isMirrorX()); + ui->checkCameraMirrorY->setChecked(c->isMirrorY()); + ui->spinCameraFOV->setValue(c->FOV()); + ui->spinCameraDepthStart->setValue(c->depthStart()); + ui->spinCameraDepthEnd->setValue(c->depthEnd()); + } active = true; } @@ -120,6 +138,14 @@ void GLObjectEditor::objectChanged() { l->angle_end = ui->spinLightAngleEnd->value(); l->direction = QVector3D(ui->spinLightDirectionX->value(), ui->spinLightDirectionY->value(), ui->spinLightDirectionZ->value()).normalized(); } + if (object->type() == GLObjectBase::glCamera) { + Camera * c = globject_cast(object); + c->setMirrorX(ui->checkCameraMirrorX->isChecked()); + c->setMirrorY(ui->checkCameraMirrorY->isChecked()); + c->setFOV(ui->spinCameraFOV->value()); + c->setDepthStart(ui->spinCameraDepthStart->value()); + c->setDepthEnd(ui->spinCameraDepthEnd->value()); + } emit changed(); } diff --git a/qglview/globject_editor.ui b/qglview/globject_editor.ui index de26c1d..3563659 100644 --- a/qglview/globject_editor.ui +++ b/qglview/globject_editor.ui @@ -7,7 +7,7 @@ 0 0 329 - 707 + 891 @@ -26,6 +26,16 @@ 2 + + + + false + + + Discard raw transform + + + @@ -84,20 +94,6 @@ - - - - Rotation Y - - - - - - - Rotation Z - - - @@ -106,6 +102,16 @@ 180.000000000000000 + + ° + + + + + + + Rotation Y + @@ -116,6 +122,16 @@ 180.000000000000000 + + ° + + + + + + + Rotation Z + @@ -126,6 +142,9 @@ 180.000000000000000 + + ° + @@ -135,20 +154,6 @@ - - - - Scale Y - - - - - - - Scale Z - - - @@ -168,6 +173,13 @@ + + + + Scale Y + + + @@ -187,6 +199,13 @@ + + + + Scale Z + + + @@ -258,6 +277,20 @@ + + + + Cast shadows + + + + + + + Receive shadows + + + @@ -281,20 +314,6 @@ - - - - Cast shadows - - - - - - - Receive shadows - - - @@ -504,6 +523,9 @@ 30.000000000000000 + + ° + @@ -530,6 +552,9 @@ 30.000000000000000 + + ° + @@ -622,14 +647,116 @@ - - - - false - - - Discard raw transform + + + + Camera + + + + + Depth + + + + + + + 0 + + + + + 5 + + + 999999999.000000000000000 + + + 0.100000000000000 + + + + + + + + 0 + 0 + + + + - + + + + + + + 5 + + + 999999999.000000000000000 + + + 1000.000000000000000 + + + + + + + + + FOV + + + + + + + 1.000000000000000 + + + 179.000000000000000 + + + 60.000000000000000 + + + 2 + + + 5.000000000000000 + + + 30.000000000000000 + + + ° + + + + + + + + + Mirror Y + + + + + + + Mirror X + + + + + + @@ -655,8 +782,8 @@ objectChanged() - 312 - 9 + 319 + 43 321 @@ -671,8 +798,8 @@ objectChanged() - 307 - 40 + 319 + 75 320 @@ -687,8 +814,8 @@ objectChanged() - 317 - 73 + 319 + 97 321 @@ -703,8 +830,8 @@ objectChanged() - 97 - 78 + 172 + 121 82 @@ -719,8 +846,8 @@ objectChanged() - 317 - 123 + 319 + 145 320 @@ -735,8 +862,8 @@ objectChanged() - 292 - 128 + 319 + 169 321 @@ -751,8 +878,8 @@ objectChanged() - 295 - 156 + 319 + 191 321 @@ -767,8 +894,8 @@ objectChanged() - 273 - 177 + 319 + 213 321 @@ -783,8 +910,8 @@ objectChanged() - 297 - 202 + 319 + 235 321 @@ -815,8 +942,8 @@ objectChanged() - 104 - 277 + 179 + 295 61 @@ -847,8 +974,8 @@ objectChanged() - 208 - 337 + 283 + 333 55 @@ -863,8 +990,8 @@ objectChanged() - 212 - 360 + 287 + 352 78 @@ -895,8 +1022,8 @@ objectChanged() - 299 - 228 + 319 + 257 321 @@ -911,8 +1038,8 @@ objectChanged() - 270 - 423 + 309 + 422 320 @@ -927,8 +1054,8 @@ objectChanged() - 292 - 447 + 309 + 442 320 @@ -943,8 +1070,8 @@ objectChanged() - 255 - 469 + 309 + 464 318 @@ -959,8 +1086,8 @@ objectChanged() - 303 - 492 + 309 + 486 320 @@ -975,8 +1102,8 @@ objectChanged() - 289 - 511 + 309 + 508 318 @@ -991,8 +1118,8 @@ objectChanged() - 299 - 535 + 309 + 530 325 @@ -1007,8 +1134,8 @@ objectChanged() - 295 - 559 + 309 + 552 321 @@ -1023,8 +1150,8 @@ objectChanged() - 301 - 585 + 309 + 574 320 @@ -1039,8 +1166,8 @@ objectChanged() - 302 - 612 + 309 + 596 332 @@ -1055,8 +1182,8 @@ objectChanged() - 313 - 636 + 309 + 618 330 @@ -1071,8 +1198,8 @@ objectChanged() - 313 - 654 + 309 + 640 326 @@ -1080,6 +1207,86 @@ + + spinCameraDepthStart + valueChanged(double) + GLObjectEditor + objectChanged() + + + 85 + 691 + + + 171 + 652 + + + + + spinCameraDepthEnd + valueChanged(double) + GLObjectEditor + objectChanged() + + + 259 + 693 + + + 277 + 652 + + + + + spinCameraFOV + valueChanged(double) + GLObjectEditor + objectChanged() + + + 145 + 719 + + + 324 + 696 + + + + + checkCameraMirrorX + clicked(bool) + GLObjectEditor + objectChanged() + + + 129 + 753 + + + 323 + 758 + + + + + checkCameraMirrorY + clicked(bool) + GLObjectEditor + objectChanged() + + + 194 + 782 + + + 328 + 785 + + + objectChanged()