/* * \brief Constructor of the model class. Import the model and the three textures and prepare the buffers. * \param[in] name a string containing the name of the model * \param[in] fModele a const character array containing the path of the file of the model * \param[in] fTex a const character array containing the path of the file of the diffuse color texture * \param[in] fNormalmap a const character array containing the path of the file of the normalmap texture * \param[in] fSpecularmap a const character array containing the path of the file of the specular color texture * \return A well initialized model respecting the parameters */ Model::Model(std::string name, const GLchar * fModele, const GLchar * fTex, const GLchar * fNormalmap, const char * fSpecularmap) : Object() { m_name = name; m_texture_id.push_back(0); m_texture_id.push_back(0); m_texture_id.push_back(0); glGenTextures(3, &m_texture_id[0]); if (!importModel(fModele)) { throw ModelImportException(); } if (!importTexture(fTex, 0)) { throw TextureImportException(); } if (!importTexture(fNormalmap, 1)) { throw NormalmapImportException(); } if (!importTexture(fSpecularmap, 2)) { throw SpecularmapImportException(); } computeTangentSpace(); indexBuffers(); glBindBuffer(GL_ARRAY_BUFFER, m_buffer_id[0]); glBufferData(GL_ARRAY_BUFFER, m_vertices.size() * sizeof(glm::vec3), &m_vertices[0], GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, m_buffer_id[1]); glBufferData(GL_ARRAY_BUFFER, m_uvs.size() * sizeof(glm::vec2), &m_uvs[0], GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, m_buffer_id[2]); glBufferData(GL_ARRAY_BUFFER, m_normals.size() * sizeof(glm::vec3), &m_normals[0], GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, m_buffer_id[3]); glBufferData(GL_ARRAY_BUFFER, m_tangents.size() * sizeof(glm::vec3), &m_tangents[0], GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, m_buffer_id[4]); glBufferData(GL_ARRAY_BUFFER, m_bitangents.size() * sizeof(glm::vec3), &m_bitangents[0], GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_buffer_id[5]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_indexes.size() * sizeof(GLushort), &m_indexes[0], GL_STATIC_DRAW); }
void TexturesSubFolder::mousePressEvent(QMouseEvent *e) { if(e->button() == Qt::RightButton) { auto action = contextMenu_->show(e->globalPos()); if(!action) return; if(action->text().toStdString().compare("New Folder") == 0) newFolder(); if(action->text().toStdString().compare("Import Texture") == 0) importTexture(); if(action->text().toStdString().compare("Rename") == 0) rename(); if(action->text().toStdString().compare("Delete") == 0) remove(); } }
void importSkybox() { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); // Make skybox textures global so only imported once north = importTexture("skybox\\north.bmp"); south = importTexture("skybox\\south.bmp"); east = importTexture("skybox\\east.bmp"); west = importTexture("skybox\\west.bmp"); top = importTexture("skybox\\top.bmp"); bottom = importTexture("skybox\\bottom.bmp"); }
void AELoadedResourcesTreeView::createActions() { _importModelAct = new QAction(tr("Import &model"), _contextMenu); _importModelAct->setStatusTip(tr("Import a new model into the resources")); connect(_importModelAct, SIGNAL(triggered()), this, SLOT(importModel())); _importTextureAct = new QAction(tr("Import &texture"), _contextMenu); _importTextureAct->setStatusTip(tr("Import a new texture into the resources")); connect(_importTextureAct, SIGNAL(triggered()), this, SLOT(importTexture())); _addNewMaterialAct = new QAction(tr("Add new m&aterial"), _contextMenu); _addNewMaterialAct->setStatusTip(tr("Add a new material to the resources")); connect(_addNewMaterialAct, SIGNAL(triggered()), this, SLOT(addNewMaterial())); _createModelInstanceAct = new QAction(tr("Create instance"), _contextMenu); _createModelInstanceAct->setStatusTip(tr("Creates a new instance of the selected model")); connect(_createModelInstanceAct, SIGNAL(triggered()), this, SLOT(createModelInstance())); }