QList<GLC_Point2d> GLC_Viewport::project(const QList<GLC_Point3d> &points, bool useCameraMatrix) const { QList<GLC_Point2d> subject; GLC_Matrix4x4 modelView; GLC_Matrix4x4 projectionMatrix; GLint viewport[4]= {0, 0, m_Width, m_Height}; if (useCameraMatrix) { modelView= m_pViewCam->modelViewMatrix(); projectionMatrix= m_ProjectionMatrix; } else { modelView= GLC_Context::current()->modelViewMatrix(); glGetIntegerv(GL_VIEWPORT, viewport); projectionMatrix= GLC_Context::current()->projectionMatrix(); } double x; double y; double z; const int count= points.count(); for (int i= 0; i < count; ++i) { const GLC_Point3d point= points.at(i); glc::gluProject(point.x(), point.y(), point.z(), modelView.getData(), projectionMatrix.getData(), viewport, &x, &y, &z); subject.append(GLC_Point2d(x, y)); } return subject; }
GLC_Point2d GLC_Viewport::project(const GLC_Point3d &point, bool useCameraMatrix) const { GLC_Matrix4x4 modelView; GLC_Matrix4x4 projectionMatrix; GLint viewport[4]= {0, 0, m_Width, m_Height}; if (useCameraMatrix) { modelView= m_pViewCam->modelViewMatrix(); projectionMatrix= m_ProjectionMatrix; } else { modelView= GLC_Context::current()->modelViewMatrix(); glGetIntegerv(GL_VIEWPORT, viewport); projectionMatrix= GLC_Context::current()->projectionMatrix(); } double x; double y; double z; glc::gluProject(point.x(), point.y(), point.z(), modelView.getData(), projectionMatrix.getData(), viewport, &x, &y, &z); GLC_Vector2d subject; subject.setX(x); subject.setY(y); return subject; }
GLC_uint GLC_PointCloud::addPoint(const QList<GLC_Point3d>& pointsList) { const int pointCount= pointsList.size(); const int size= pointCount * 3; GLfloatVector data(size); for (int i= 0; i < pointCount; ++i) { const GLC_Point3d currentPoint(pointsList.at(i)); data[i * 3]= static_cast<float>(currentPoint.x()); data[i * 3 + 1]= static_cast<float>(currentPoint.y()); data[i * 3 + 2]= static_cast<float>(currentPoint.z()); } return GLC_Geometry::m_WireData.addVerticeGroup(data); }