void Spline::render(unique_ptr<Shader> &shader, bool showPoints, Config conf) { if (m_points.size() <= 1) return; vector<RenderableObject::Vertex> pointData; vector<RenderableObject::Vertex> lineData; glm::vec4 pColor(1.0f, 1.0f, 0.0f, 0.5f); // Interpolated Points for (float f = 0; f <= 1.0f; f += 0.01f) { glm::vec3 v = interpolatedPoint(f, conf); RenderableObject::Vertex newPt; newPt.Position = v; newPt.Color = pColor; lineData.push_back(newPt); } // Base Points for (uint i = 0; i < m_points.size(); ++i) { glm::vec3 v = m_points[i]; RenderableObject::Vertex newPt; newPt.Position = v; newPt.Color = pColor; pointData.push_back(newPt); } // Phantom Points std::vector<RenderableObject::Vertex> phantomPoints; float phantomPtSize = 3.0f; glm::vec3 p1 = m_phantomStart; glm::vec3 p2 = m_phantomEnd; RenderableObject::Vertex newPt1, newPt2; newPt1.Position = p1; newPt1.Color = glm::vec4(1.0f, 0.0f, 1.0f, 0.5f); newPt2.Position = p2; newPt2.Color = glm::vec4(0.0f, 1.0f, 1.0f, 0.5f); pointData.push_back(newPt1); pointData.push_back(newPt2); m_vboLines->setData(lineData, GL_LINE_STRIP); m_vboPoints->setData(pointData, GL_POINTS); if(showPoints) { m_vboLines->render(); glPointSize(m_ptSize); m_vboPoints->render(); glPointSize(1.0f); } }
/** * Read mesh data from ASSIMP mesh to an internal mesh representation that can be used to generate Vulkan buffers * * @param meshEntry Pointer to the target MeshEntry strucutre for the mesh data * @param paiMesh ASSIMP mesh to get the data from * @param pScene Scene file of the ASSIMP mesh */ void InitMesh(MeshEntry *meshEntry, const aiMesh* paiMesh, const aiScene* pScene) { meshEntry->MaterialIndex = paiMesh->mMaterialIndex; aiColor3D pColor(0.f, 0.f, 0.f); pScene->mMaterials[paiMesh->mMaterialIndex]->Get(AI_MATKEY_COLOR_DIFFUSE, pColor); aiVector3D Zero3D(0.0f, 0.0f, 0.0f); for (unsigned int i = 0; i < paiMesh->mNumVertices; i++) { aiVector3D* pPos = &(paiMesh->mVertices[i]); aiVector3D* pNormal = &(paiMesh->mNormals[i]); aiVector3D* pTexCoord = (paiMesh->HasTextureCoords(0)) ? &(paiMesh->mTextureCoords[0][i]) : &Zero3D; aiVector3D* pTangent = (paiMesh->HasTangentsAndBitangents()) ? &(paiMesh->mTangents[i]) : &Zero3D; aiVector3D* pBiTangent = (paiMesh->HasTangentsAndBitangents()) ? &(paiMesh->mBitangents[i]) : &Zero3D; Vertex v( glm::vec3(pPos->x, -pPos->y, pPos->z), glm::vec2(pTexCoord->x , pTexCoord->y), glm::vec3(pNormal->x, pNormal->y, pNormal->z), glm::vec3(pTangent->x, pTangent->y, pTangent->z), glm::vec3(pBiTangent->x, pBiTangent->y, pBiTangent->z), glm::vec3(pColor.r, pColor.g, pColor.b) ); dim.max.x = fmax(pPos->x, dim.max.x); dim.max.y = fmax(pPos->y, dim.max.y); dim.max.z = fmax(pPos->z, dim.max.z); dim.min.x = fmin(pPos->x, dim.min.x); dim.min.y = fmin(pPos->y, dim.min.y); dim.min.z = fmin(pPos->z, dim.min.z); meshEntry->Vertices.push_back(v); } dim.size = dim.max - dim.min; uint32_t indexBase = static_cast<uint32_t>(meshEntry->Indices.size()); for (unsigned int i = 0; i < paiMesh->mNumFaces; i++) { const aiFace& Face = paiMesh->mFaces[i]; if (Face.mNumIndices != 3) continue; meshEntry->Indices.push_back(indexBase + Face.mIndices[0]); meshEntry->Indices.push_back(indexBase + Face.mIndices[1]); meshEntry->Indices.push_back(indexBase + Face.mIndices[2]); } }
void FLConnectDBDialog::paintEvent( QPaintEvent * pe ) { QPainter p( this ); p.fillRect( pe->rect(), QColor( logo.pixel( 1, 1 ) ) ); int dx = width() - logo.width(); int dy = height() - logo.height(); p.drawImage( QPoint( dx, dy ), logo ); if ( pbnMore->isOn() ) { QFont font7( qApp->font().family(), 7 ); QFont font8( qApp->font().family(), 8 ); font8.setBold( true ); QString copyright( "Copyright (C) 2003-2009 by InfoSiAL S.L." ); int lineWidth = QFontMetrics( font8 ).width( copyright ); int lineHeight = QFontMetrics( font8 ).height(); p.setFont( font8 ); p.drawText( QRect( 6, height() - lineHeight * 4 - 2, lineWidth + 10, lineHeight ), Qt::AlignVCenter | Qt::AlignJustify | Qt::SingleLine, copyright ); p.drawImage( lineWidth + 20 , height() - lineHeight * 4, QImage::fromMimeSource( "defFactory" ) ); lineWidth = QFontMetrics( font7 ).width( "This software is provided under the terms" ); lineHeight = QFontMetrics( font7 ).height(); p.setFont( font7 ); p.drawText( QRect( 6, height() - lineHeight * 3 - 2, lineWidth + 10, lineHeight ), Qt::AlignVCenter | Qt::AlignJustify | Qt::SingleLine, "This software is provided under the terms" ); p.drawText( QRect( 6, height() - lineHeight * 2 - 2, lineWidth + 10, lineHeight ), Qt::AlignVCenter | Qt::AlignJustify | Qt::SingleLine, "of GNU General Public License ( GPL ) and" ); p.drawText( QRect( 6, height() - lineHeight - 2, lineWidth + 10, lineHeight ), Qt::AlignVCenter | Qt::AlignJustify | Qt::SingleLine, "without warranty of any kind." ); } #if defined(Q_OS_WIN32) || defined(Q_OS_MACX) QFont font6( qApp->font().family(), 8 ); #else QFont font6( qApp->font().family(), 6 ); #endif p.setFont( font6 ); p.drawText( 54, 18, "(C) 2003-2009 InfoSiAL S.L." ); p.drawImage( QRect( 6, 5, 45, 15 ), QImage::fromMimeSource( "defFactory" ) ); QColor pColor( 0, 0, 32 ); p.setPen( pColor ); p.setBrush( pColor ); p.drawRect( dx + 32, 0, 4, dy ); p.end(); QWidget::paintEvent( pe ); }