git-svn-id: svn://db.shs.com.ru/libs@707 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
Camera::Camera() {
|
||||
type_ = glCamera;
|
||||
fov_ = 60.;
|
||||
roll_ = 0.;
|
||||
//setRotationX(90.f);
|
||||
depth_start = 0.1f;
|
||||
mirror_x = mirror_y = false;
|
||||
@@ -75,6 +76,7 @@ ObjectBase * Camera::clone(bool 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->depth_start = depth_start;
|
||||
@@ -87,10 +89,10 @@ QMatrix4x4 Camera::viewMatrix() const {
|
||||
QMatrix4x4 ret;
|
||||
//qDebug() << pos() << aim();
|
||||
ret.translate(0., 0., -distance());
|
||||
ret.rotate(-roll_, 0., 0., 1.);
|
||||
ret *= trans.matrixRotateScale().inverted();
|
||||
//ret.rotate(angles_.y(), 1., 0., 0.);
|
||||
//ret.rotate(angles_.x(), 0., 1., 0.);
|
||||
//ret.rotate(angles_.z(), 0., 0., 1.);
|
||||
//pm.translate(-aim_);
|
||||
if (parent_) {
|
||||
QMatrix4x4 pmat = parent_->worldTransform();
|
||||
|
||||
@@ -37,15 +37,15 @@ public:
|
||||
void setAngles(const QVector3D & a) {setRotation(a);}
|
||||
void setAngleZ(const float & a) {setRotationZ(a);}
|
||||
void setAngleXY(const float & a) {setRotationX(a);}
|
||||
void setAngleRoll(const float & a) {setRotationY(a);}
|
||||
void setAngleRoll(const float & a) {roll_ = a;}
|
||||
void setDepthStart(const float & d) {depth_start = d;}
|
||||
void setMirrorX(bool yes) {mirror_x = yes;}
|
||||
void setMirrorY(bool yes) {mirror_y = yes;}
|
||||
|
||||
float FOV() const {return fov_;}
|
||||
float angleZ() const {return rotationZ();}
|
||||
float angleXY() const {return rotationY();}
|
||||
float angleRoll() const {return rotationZ();}
|
||||
float angleXY() const {return rotationX();}
|
||||
float angleRoll() const {return roll_;}
|
||||
float depthStart() const {return depth_start;}
|
||||
bool isMirrorX() const {return mirror_x;}
|
||||
bool isMirrorY() const {return mirror_y;}
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
|
||||
private:
|
||||
mutable QVector3D offset_;
|
||||
GLfloat fov_;
|
||||
GLfloat fov_, roll_;
|
||||
GLfloat depth_start;
|
||||
bool mirror_x;
|
||||
bool mirror_y;
|
||||
|
||||
@@ -642,7 +642,8 @@ QDataStream & operator <<(QDataStream & s, const ObjectBase * p) {
|
||||
//qDebug() << "place camera ...";
|
||||
const Camera * c = (const Camera*)p;
|
||||
cs.add(200, c->aim()).add(201, c->fov_).add(202, c->depth_start)
|
||||
.add(206, c->mirror_x).add(207, c->mirror_y).add(208, c->distance());
|
||||
.add(206, c->mirror_x).add(207, c->mirror_y).add(208, c->distance())
|
||||
.add(209, c->roll_);
|
||||
}
|
||||
//qDebug() << "place" << p->name() << cs.data().size() << s.device()->size();
|
||||
s << cs.data();
|
||||
@@ -700,6 +701,7 @@ QDataStream & operator >>(QDataStream & s, ObjectBase *& p) {
|
||||
case 206: if (c) c->mirror_x = cs.getData<bool>(); break;
|
||||
case 207: if (c) c->mirror_y = cs.getData<bool>(); break;
|
||||
case 208: if (c) c->setDistance(cs.getData<double>()); break;
|
||||
case 209: if (c) c->roll_ = cs.getData<GLfloat>(); break;
|
||||
}
|
||||
}
|
||||
//qDebug() << p->name() << ccnt;
|
||||
|
||||
@@ -88,7 +88,8 @@ RendererService::RendererService(Renderer * r_): r(r_) {
|
||||
m->transformPoints(mat);
|
||||
camera_mesh_f->append(m);
|
||||
|
||||
line_mesh_f = Primitive::lineFrame(QVector3D(), QVector3D(0, 0, -1));
|
||||
line_spot_f = Primitive::lineFrame(QVector3D(), QVector3D(0, 0, -1));
|
||||
line_camera_f = Primitive::lineFrame(QVector3D(), QVector3D(0, 0, -1));
|
||||
|
||||
handle_move_mesh = Primitive::arrow(12, 0.06);
|
||||
handle_ms_2_mesh = Primitive::torus(8, 12, 0.5, 0.02, 90);
|
||||
@@ -128,7 +129,8 @@ RendererService::~RendererService() {
|
||||
delete cone_mesh_f;
|
||||
delete camera_mesh;
|
||||
delete camera_mesh_f;
|
||||
delete line_mesh_f;
|
||||
delete line_spot_f;
|
||||
delete line_camera_f;
|
||||
delete axis_camera;
|
||||
delete axis_mesh;
|
||||
delete handle_move_mesh;
|
||||
@@ -202,14 +204,14 @@ void RendererService::fillOmniObjects() {
|
||||
}
|
||||
|
||||
|
||||
void RendererService::fillAimedObjects(const ObjectBaseList & objects) {
|
||||
void RendererService::fillAimedObjects(const ObjectBaseList & objects, Mesh * line_mesh) {
|
||||
Object o;
|
||||
cur_objects.clear();
|
||||
cur_aims.clear();
|
||||
QVector<QVector3D> & lv (line_mesh_f->vertices ());
|
||||
QVector<QVector3D> & ln (line_mesh_f->normals ());
|
||||
QVector<QVector2D> & lt (line_mesh_f->texcoords ());
|
||||
QVector< Vector2i> & lind(line_mesh_f->indicesLines());
|
||||
QVector<QVector3D> & lv (line_mesh->vertices ());
|
||||
QVector<QVector3D> & ln (line_mesh->normals ());
|
||||
QVector<QVector2D> & lt (line_mesh->texcoords ());
|
||||
QVector< Vector2i> & lind(line_mesh->indicesLines());
|
||||
lv.clear();
|
||||
foreach (ObjectBase * go, objects) {
|
||||
AimedObject * ao = (AimedObject *)go;
|
||||
@@ -333,7 +335,7 @@ void RendererService::drawLights() {
|
||||
omni_mesh->draw(v, cur_objects.size());
|
||||
|
||||
ObjectBaseList ll = lights2objectList(r->view->scene()->lights_used.value(Light::Cone));
|
||||
fillAimedObjects(ll);
|
||||
fillAimedObjects(ll, line_spot_f);
|
||||
cone_mesh->loadObjects(v, cur_objects);
|
||||
r->fillSelectionsBuffer(rs.cur_selections_, ll);
|
||||
cone_mesh->loadSelections(v, rs.cur_selections_);
|
||||
@@ -357,7 +359,7 @@ void RendererService::drawLightsFrame(QColor color) {
|
||||
omni_mesh_f->draw(v, cur_objects.size());
|
||||
|
||||
ObjectBaseList ll = lights2objectList(r->view->scene()->lights_used.value(Light::Cone));
|
||||
fillAimedObjects(ll);
|
||||
fillAimedObjects(ll, line_spot_f);
|
||||
setObjectsColor(cur_objects, color);
|
||||
cone_mesh_f->loadObjects(v, cur_objects);
|
||||
r->fillSelectionsBuffer(rs.cur_selections_, ll);
|
||||
@@ -378,7 +380,7 @@ void RendererService::drawCameras() {
|
||||
|
||||
ObjectBaseList cl = cameras2objectList(r->view->scene()->cameras_used);
|
||||
cl.removeOne(r->view->camera());
|
||||
fillAimedObjects(cl);
|
||||
fillAimedObjects(cl, line_camera_f);
|
||||
camera_mesh->loadObjects(v, cur_objects);
|
||||
r->fillSelectionsBuffer(rs.cur_selections_, cl);
|
||||
camera_mesh->loadSelections(v, rs.cur_selections_);
|
||||
@@ -396,7 +398,7 @@ void RendererService::drawCamerasFrame(QColor color) {
|
||||
|
||||
ObjectBaseList cl = cameras2objectList(r->view->scene()->cameras_used);
|
||||
cl.removeOne(r->view->camera());
|
||||
fillAimedObjects(cl);
|
||||
fillAimedObjects(cl, line_camera_f);
|
||||
setObjectsColor(cur_objects, color);
|
||||
camera_mesh_f->loadObjects(v, cur_objects);
|
||||
r->fillSelectionsBuffer(rs.cur_selections_, cl);
|
||||
@@ -447,8 +449,10 @@ void RendererService::renderService() {
|
||||
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
r->setUniformCamera(prog, r->view->camera());
|
||||
line_object.color = QColor2QVector(Qt::white);
|
||||
line_mesh_f->loadObject(f, line_object);
|
||||
line_mesh_f->draw(f, 1);
|
||||
line_spot_f ->loadObject(f, line_object);
|
||||
line_camera_f->loadObject(f, line_object);
|
||||
line_spot_f ->draw(f, 1);
|
||||
line_camera_f->draw(f, 1);
|
||||
//glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
}
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
QMatrix4x4 parentRotationMatrix(ObjectBase * o, bool self_rotation = true);
|
||||
void fillXYZObjects();
|
||||
void fillOmniObjects();
|
||||
void fillAimedObjects(const ObjectBaseList & objects);
|
||||
void fillAimedObjects(const ObjectBaseList & objects, Mesh * line_mesh);
|
||||
void fillHandleObjects(QVector3D center, HandleMesh ids[], const QVector<QMatrix4x4> & mats, const QVector<QVector4D> & colors, QMatrix4x4 add_mat, int count = 3);
|
||||
bool calculateCenter();
|
||||
void drawCurrentHandleObjects();
|
||||
@@ -89,7 +89,7 @@ private:
|
||||
Mesh * handle_ms_2_mesh, * handle_scale_3_mesh;
|
||||
Mesh * box_mesh_f, * omni_mesh_f, * cone_mesh_f, * camera_mesh_f;
|
||||
Mesh * box_mesh, * omni_mesh, * cone_mesh, * camera_mesh;
|
||||
Mesh * line_mesh_f;
|
||||
Mesh * line_spot_f, * line_camera_f;
|
||||
QMatrix4x4 v_mat, axis_mat;
|
||||
QVector3D selection_center;
|
||||
QVector<QMatrix4x4> mat_xyz, mat_ms2;
|
||||
|
||||
@@ -49,7 +49,7 @@ ObjectEditor::ObjectEditor(QWidget * parent): QWidget(parent) {
|
||||
connect(o, SIGNAL(valueChanged(double)), this, SLOT(spinLightChanged(double)));
|
||||
|
||||
ol.clear();
|
||||
ol << ui->spinCameraFOV << ui->spinCameraDepthStart << ui->spinAimDist;
|
||||
ol << ui->spinCameraFOV << ui->spinCameraDepthStart << ui->spinCameraRoll << ui->spinAimDist;
|
||||
foreach (QObject * o, ol)
|
||||
connect(o, SIGNAL(valueChanged(double)), this, SLOT(spinCameraChanged(double)));
|
||||
|
||||
@@ -152,6 +152,7 @@ void ObjectEditor::setObject(ObjectBase * o) {
|
||||
ui->checkCameraMirrorX->setChecked(c->isMirrorX());
|
||||
ui->checkCameraMirrorY->setChecked(c->isMirrorY());
|
||||
ui->spinCameraFOV->setValue(c->FOV());
|
||||
ui->spinCameraRoll->setValue(c->angleRoll());
|
||||
ui->spinCameraDepthStart->setValue(c->depthStart());
|
||||
ui->spinAimDist->setValue(c->distance());
|
||||
}
|
||||
@@ -240,6 +241,7 @@ void ObjectEditor::spinCameraChanged(double v) {
|
||||
QObject * s = sender();
|
||||
foreach (Camera * o, scl) {
|
||||
if (s == ui->spinCameraFOV ) o->setFOV (v);
|
||||
if (s == ui->spinCameraRoll ) o->setAngleRoll (v);
|
||||
if (s == ui->spinCameraDepthStart) o->setDepthStart(v);
|
||||
if (s == ui->spinAimDist ) o->setDistance (v);
|
||||
}
|
||||
|
||||
@@ -650,14 +650,14 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_46">
|
||||
<property name="text">
|
||||
<string>Depth start</string>
|
||||
<string>Depth start:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_45">
|
||||
<property name="text">
|
||||
<string>FOV</string>
|
||||
<string>FOV:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -686,7 +686,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="3" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkCameraMirrorY">
|
||||
@@ -717,6 +717,38 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="SpinSlider" name="spinCameraRoll">
|
||||
<property name="minimum">
|
||||
<double>-180.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>180.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</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="0">
|
||||
<widget class="QLabel" name="label_47">
|
||||
<property name="text">
|
||||
<string>Roll:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user