camera fixes

git-svn-id: svn://db.shs.com.ru/libs@603 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
2019-10-02 14:18:39 +00:00
parent 30517fa7f3
commit b7e9fd6cf9
4 changed files with 362 additions and 98 deletions

View File

@@ -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();

View File

@@ -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:

View File

@@ -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<Light * >(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<Camera * >(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<Camera * >(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();
}

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>329</width>
<height>707</height>
<height>891</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
@@ -26,6 +26,16 @@
<property name="verticalSpacing">
<number>2</number>
</property>
<item row="0" column="0" colspan="2">
<widget class="QPushButton" name="buttonDiscardRawMatrix">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Discard raw transform</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
@@ -84,20 +94,6 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Rotation Y</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Rotation Z</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="SpinSlider" name="spinRotationX">
<property name="minimum">
@@ -106,6 +102,16 @@
<property name="maximum">
<double>180.000000000000000</double>
</property>
<property name="suffix">
<string>°</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Rotation Y</string>
</property>
</widget>
</item>
<item row="5" column="1">
@@ -116,6 +122,16 @@
<property name="maximum">
<double>180.000000000000000</double>
</property>
<property name="suffix">
<string>°</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Rotation Z</string>
</property>
</widget>
</item>
<item row="6" column="1">
@@ -126,6 +142,9 @@
<property name="maximum">
<double>180.000000000000000</double>
</property>
<property name="suffix">
<string>°</string>
</property>
</widget>
</item>
<item row="7" column="0">
@@ -135,20 +154,6 @@
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Scale Y</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Scale Z</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QDoubleSpinBox" name="spinScaleX">
<property name="decimals">
@@ -168,6 +173,13 @@
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Scale Y</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QDoubleSpinBox" name="spinScaleY">
<property name="decimals">
@@ -187,6 +199,13 @@
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Scale Z</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QDoubleSpinBox" name="spinScaleZ">
<property name="decimals">
@@ -258,6 +277,20 @@
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QCheckBox" name="checkCastShadows">
<property name="text">
<string>Cast shadows</string>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QCheckBox" name="checkReceiveShadows">
<property name="text">
<string>Receive shadows</string>
</property>
</widget>
</item>
<item row="16" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
@@ -281,20 +314,6 @@
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QCheckBox" name="checkCastShadows">
<property name="text">
<string>Cast shadows</string>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QCheckBox" name="checkReceiveShadows">
<property name="text">
<string>Receive shadows</string>
</property>
</widget>
</item>
<item row="17" column="0" colspan="2">
<widget class="QGroupBox" name="groupLight">
<property name="title">
@@ -504,6 +523,9 @@
<property name="pageStep">
<double>30.000000000000000</double>
</property>
<property name="suffix">
<string>°</string>
</property>
</widget>
</item>
<item row="7" column="0">
@@ -530,6 +552,9 @@
<property name="pageStep">
<double>30.000000000000000</double>
</property>
<property name="suffix">
<string>°</string>
</property>
</widget>
</item>
<item row="8" column="0">
@@ -622,14 +647,116 @@
</layout>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QPushButton" name="buttonDiscardRawMatrix">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Discard raw transform</string>
<item row="18" column="0" colspan="2">
<widget class="QGroupBox" name="groupCamera">
<property name="title">
<string>Camera</string>
</property>
<layout class="QFormLayout" name="formLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="label_46">
<property name="text">
<string>Depth</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QDoubleSpinBox" name="spinCameraDepthStart">
<property name="decimals">
<number>5</number>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
<property name="value">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_47">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string> - </string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="spinCameraDepthEnd">
<property name="decimals">
<number>5</number>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
<property name="value">
<double>1000.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_45">
<property name="text">
<string>FOV</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="SpinSlider" name="spinCameraFOV">
<property name="minimum">
<double>1.000000000000000</double>
</property>
<property name="maximum">
<double>179.000000000000000</double>
</property>
<property name="value">
<double>60.000000000000000</double>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="singleStep">
<double>5.000000000000000</double>
</property>
<property name="pageStep">
<double>30.000000000000000</double>
</property>
<property name="suffix">
<string>°</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="checkCameraMirrorY">
<property name="text">
<string>Mirror Y</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkCameraMirrorX">
<property name="text">
<string>Mirror X</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
@@ -655,8 +782,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>312</x>
<y>9</y>
<x>319</x>
<y>43</y>
</hint>
<hint type="destinationlabel">
<x>321</x>
@@ -671,8 +798,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>307</x>
<y>40</y>
<x>319</x>
<y>75</y>
</hint>
<hint type="destinationlabel">
<x>320</x>
@@ -687,8 +814,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>317</x>
<y>73</y>
<x>319</x>
<y>97</y>
</hint>
<hint type="destinationlabel">
<x>321</x>
@@ -703,8 +830,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>97</x>
<y>78</y>
<x>172</x>
<y>121</y>
</hint>
<hint type="destinationlabel">
<x>82</x>
@@ -719,8 +846,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>317</x>
<y>123</y>
<x>319</x>
<y>145</y>
</hint>
<hint type="destinationlabel">
<x>320</x>
@@ -735,8 +862,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>292</x>
<y>128</y>
<x>319</x>
<y>169</y>
</hint>
<hint type="destinationlabel">
<x>321</x>
@@ -751,8 +878,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>295</x>
<y>156</y>
<x>319</x>
<y>191</y>
</hint>
<hint type="destinationlabel">
<x>321</x>
@@ -767,8 +894,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>273</x>
<y>177</y>
<x>319</x>
<y>213</y>
</hint>
<hint type="destinationlabel">
<x>321</x>
@@ -783,8 +910,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>297</x>
<y>202</y>
<x>319</x>
<y>235</y>
</hint>
<hint type="destinationlabel">
<x>321</x>
@@ -815,8 +942,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>104</x>
<y>277</y>
<x>179</x>
<y>295</y>
</hint>
<hint type="destinationlabel">
<x>61</x>
@@ -847,8 +974,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>208</x>
<y>337</y>
<x>283</x>
<y>333</y>
</hint>
<hint type="destinationlabel">
<x>55</x>
@@ -863,8 +990,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>212</x>
<y>360</y>
<x>287</x>
<y>352</y>
</hint>
<hint type="destinationlabel">
<x>78</x>
@@ -895,8 +1022,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>299</x>
<y>228</y>
<x>319</x>
<y>257</y>
</hint>
<hint type="destinationlabel">
<x>321</x>
@@ -911,8 +1038,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>270</x>
<y>423</y>
<x>309</x>
<y>422</y>
</hint>
<hint type="destinationlabel">
<x>320</x>
@@ -927,8 +1054,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>292</x>
<y>447</y>
<x>309</x>
<y>442</y>
</hint>
<hint type="destinationlabel">
<x>320</x>
@@ -943,8 +1070,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>255</x>
<y>469</y>
<x>309</x>
<y>464</y>
</hint>
<hint type="destinationlabel">
<x>318</x>
@@ -959,8 +1086,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>303</x>
<y>492</y>
<x>309</x>
<y>486</y>
</hint>
<hint type="destinationlabel">
<x>320</x>
@@ -975,8 +1102,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>289</x>
<y>511</y>
<x>309</x>
<y>508</y>
</hint>
<hint type="destinationlabel">
<x>318</x>
@@ -991,8 +1118,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>299</x>
<y>535</y>
<x>309</x>
<y>530</y>
</hint>
<hint type="destinationlabel">
<x>325</x>
@@ -1007,8 +1134,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>295</x>
<y>559</y>
<x>309</x>
<y>552</y>
</hint>
<hint type="destinationlabel">
<x>321</x>
@@ -1023,8 +1150,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>301</x>
<y>585</y>
<x>309</x>
<y>574</y>
</hint>
<hint type="destinationlabel">
<x>320</x>
@@ -1039,8 +1166,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>302</x>
<y>612</y>
<x>309</x>
<y>596</y>
</hint>
<hint type="destinationlabel">
<x>332</x>
@@ -1055,8 +1182,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>313</x>
<y>636</y>
<x>309</x>
<y>618</y>
</hint>
<hint type="destinationlabel">
<x>330</x>
@@ -1071,8 +1198,8 @@
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>313</x>
<y>654</y>
<x>309</x>
<y>640</y>
</hint>
<hint type="destinationlabel">
<x>326</x>
@@ -1080,6 +1207,86 @@
</hint>
</hints>
</connection>
<connection>
<sender>spinCameraDepthStart</sender>
<signal>valueChanged(double)</signal>
<receiver>GLObjectEditor</receiver>
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>85</x>
<y>691</y>
</hint>
<hint type="destinationlabel">
<x>171</x>
<y>652</y>
</hint>
</hints>
</connection>
<connection>
<sender>spinCameraDepthEnd</sender>
<signal>valueChanged(double)</signal>
<receiver>GLObjectEditor</receiver>
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>259</x>
<y>693</y>
</hint>
<hint type="destinationlabel">
<x>277</x>
<y>652</y>
</hint>
</hints>
</connection>
<connection>
<sender>spinCameraFOV</sender>
<signal>valueChanged(double)</signal>
<receiver>GLObjectEditor</receiver>
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>145</x>
<y>719</y>
</hint>
<hint type="destinationlabel">
<x>324</x>
<y>696</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkCameraMirrorX</sender>
<signal>clicked(bool)</signal>
<receiver>GLObjectEditor</receiver>
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>129</x>
<y>753</y>
</hint>
<hint type="destinationlabel">
<x>323</x>
<y>758</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkCameraMirrorY</sender>
<signal>clicked(bool)</signal>
<receiver>GLObjectEditor</receiver>
<slot>objectChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>194</x>
<y>782</y>
</hint>
<hint type="destinationlabel">
<x>328</x>
<y>785</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>objectChanged()</slot>