Skip to content

Commit

Permalink
3d view
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Jan 20, 2019
1 parent 8d7cd1b commit 722838a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions CRITERIA3D/viewer3d.cpp
Expand Up @@ -14,7 +14,7 @@
Viewer3D::Viewer3D(QWidget *parent)
{
isCameraChanging = false;
m_zoomLevel = 6.f;
m_zoomLevel = 8.f;

m_project = nullptr;
m_geometry = nullptr;
Expand Down Expand Up @@ -64,14 +64,14 @@ void Viewer3D::initialize(Crit3DProject *project)
m_ratio = m_size / dz;
m_magnify = maxValue(1.f, minValue(10.f, m_ratio / 5.f));

// Set root object of the scene
createScene();

// Camera
m_view->camera()->lens()->setPerspectiveProjection(45.0f, 16.f/9.f, 0.01f, 1000000.f);
m_view->camera()->setPosition(QVector3D(float(m_center.x), float(m_center.y), (z + dz * m_zoomLevel) * m_magnify));
m_view->camera()->setViewCenter(QVector3D(float(m_center.x), float(m_center.y), z * m_magnify));

// Set root object of the scene
createScene();

m_view->setRootEntity(m_rootEntity);
}

Expand Down Expand Up @@ -158,8 +158,10 @@ void Viewer3D::mouseMoveEvent(QMouseEvent *ev)
float dy = delta.y() * m_zoomLevel;
m_view->camera()->setViewCenter(QVector3D(float(m_center.x), float(m_center.y), z * m_magnify));*/

float angle = m_rotationZ - delta.x() * m_zoomLevel / 10.f;
m_view->camera()->transform()->setRotationZ(angle);
float anglex = m_rotationZ - delta.x() * m_zoomLevel / 10.f;
//float angley = delta.y() * m_zoomLevel / 360.f;
m_view->camera()->transform()->setRotationZ(anglex);
//m_view->camera()->panAboutViewCenter(angley);
}
else if (m_button == Qt::RightButton)
{
Expand Down Expand Up @@ -335,8 +337,8 @@ void Viewer3D::createScene()
if (v1 != long(m_project->indexMap.header->flag) && v2 != long(m_project->indexMap.header->flag))
{
indexData[index*3] = uint(v0);
indexData[index*3+1] = uint(v1);
indexData[index*3+2] = uint(v2);
indexData[index*3+1] = uint(v2);
indexData[index*3+2] = uint(v1);
index++;
}
if (v2 != long(m_project->indexMap.header->flag) && v3 != long(m_project->indexMap.header->flag))
Expand Down

0 comments on commit 722838a

Please sign in to comment.