code format
This commit is contained in:
62
glcamera.cpp
62
glcamera.cpp
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
QGL Camera
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
QGL Camera
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "gltypes.h"
|
||||
@@ -21,9 +21,9 @@
|
||||
|
||||
|
||||
Camera::Camera() {
|
||||
type_ = glCamera;
|
||||
fov_ = 60.;
|
||||
roll_ = 0.;
|
||||
type_ = glCamera;
|
||||
fov_ = 60.;
|
||||
roll_ = 0.;
|
||||
depth_start = 0.1f;
|
||||
mirror_x = mirror_y = false;
|
||||
}
|
||||
@@ -37,11 +37,11 @@ QMatrix4x4 Camera::offsetMatrix() const {
|
||||
|
||||
|
||||
void Camera::assign(const Camera & c) {
|
||||
trans = c.trans;
|
||||
aim_dist = c.aim_dist;
|
||||
fov_ = c.fov_;
|
||||
mirror_x = c.mirror_x;
|
||||
mirror_y = c.mirror_y;
|
||||
trans = c.trans;
|
||||
aim_dist = c.aim_dist;
|
||||
fov_ = c.fov_;
|
||||
mirror_x = c.mirror_x;
|
||||
mirror_y = c.mirror_y;
|
||||
depth_start = c.depth_start;
|
||||
buildTransform();
|
||||
}
|
||||
@@ -50,34 +50,34 @@ void Camera::assign(const Camera & c) {
|
||||
ObjectBase * Camera::clone(bool withChildren) {
|
||||
Camera * o = new Camera(*this);
|
||||
o->is_init = false;
|
||||
o->name_ = name_;
|
||||
o->scene_ = nullptr;
|
||||
o->name_ = name_;
|
||||
o->scene_ = nullptr;
|
||||
o->children_.clear();
|
||||
if (withChildren) {
|
||||
for (int i = 0; i < children_.size(); ++i)
|
||||
o->addChild(children_[i]->clone(withChildren));
|
||||
}
|
||||
o->trans = trans;
|
||||
o->aim_dist = aim_dist;
|
||||
o->fov_ = fov_;
|
||||
o->roll_ = roll_;
|
||||
o->mirror_x = mirror_x;
|
||||
o->mirror_y = mirror_y;
|
||||
o->trans = trans;
|
||||
o->aim_dist = aim_dist;
|
||||
o->fov_ = fov_;
|
||||
o->roll_ = roll_;
|
||||
o->mirror_x = mirror_x;
|
||||
o->mirror_y = mirror_y;
|
||||
o->depth_start = depth_start;
|
||||
o->meta = meta;
|
||||
o->meta = meta;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
QMatrix4x4 Camera::viewMatrix() const {
|
||||
QMatrix4x4 ret;
|
||||
//qDebug() << pos() << aim();
|
||||
// qDebug() << pos() << aim();
|
||||
ret.translate(0., 0., -distance());
|
||||
ret.rotate(-roll_, 0., 0., 1.);
|
||||
ret *= trans.matrixRotateScale().inverted();
|
||||
if (parent_) {
|
||||
QMatrix4x4 pmat = parent_->worldTransform();
|
||||
offset_ = pmat.column(3).toVector3D();
|
||||
offset_ = pmat.column(3).toVector3D();
|
||||
pmat(0, 3) = pmat(1, 3) = pmat(2, 3) = 0.;
|
||||
pmat.translate(aim());
|
||||
ret *= pmat.inverted();
|
||||
|
||||
Reference in New Issue
Block a user