parent matrix works,
texture works, next fix multimodel problem
This commit is contained in:
parent
3758a2601c
commit
dca6e61c4b
|
@ -25,8 +25,8 @@ private:
|
|||
QVector<QOpenGLTexture*> m_textures;
|
||||
QVector<DrawInformation> m_drawList;
|
||||
|
||||
void initCubeGeometry();
|
||||
void initTexture();
|
||||
void loadFile(const char* filePath);
|
||||
void loadTexture(const char* filePath);
|
||||
|
||||
public:
|
||||
void drawGeometry(QOpenGLShaderProgram *program);
|
||||
|
|
|
@ -15,7 +15,7 @@ GeometryEngine::GeometryEngine()
|
|||
m_indexBuf.create();
|
||||
|
||||
// Initializes cube geometry and transfers it to VBOs
|
||||
initCubeGeometry();
|
||||
loadFile("..\\Release\\Msh\\triClothMan.msh");
|
||||
}
|
||||
|
||||
GeometryEngine::~GeometryEngine()
|
||||
|
@ -33,18 +33,21 @@ GeometryEngine::~GeometryEngine()
|
|||
/////////////////////////////////////////////////////////////////////////
|
||||
// private functions
|
||||
|
||||
void GeometryEngine::initCubeGeometry()
|
||||
void GeometryEngine::loadFile(const char* filePath)
|
||||
{
|
||||
QVector<Model*>* models;
|
||||
QVector<VertexData> vertexData;
|
||||
QVector<GLuint> indexData;
|
||||
|
||||
try
|
||||
{
|
||||
MshFile file("..\\Release\\Msh\\triClothMan.msh");
|
||||
models = file.getModels();
|
||||
//TODO normalize
|
||||
//TODO: handle the textures
|
||||
|
||||
QVector<Model*>* models;
|
||||
QVector<std::string>* textureNames;
|
||||
QVector<VertexData> vertexData;
|
||||
QVector<GLuint> indexData;
|
||||
|
||||
// open file and get the information
|
||||
MshFile file(filePath);
|
||||
models = file.getModels();
|
||||
textureNames = file.getTextureNames();
|
||||
|
||||
// collect data
|
||||
unsigned int offsetCount(0);
|
||||
|
@ -73,6 +76,8 @@ void GeometryEngine::initCubeGeometry()
|
|||
}
|
||||
}
|
||||
|
||||
//TODO: cleanup old stuff
|
||||
|
||||
// Transfer vertex data to VBO 0
|
||||
m_arrayBuf.bind();
|
||||
m_arrayBuf.allocate(vertexData.data(), vertexData.size() * sizeof(VertexData));
|
||||
|
@ -81,8 +86,15 @@ void GeometryEngine::initCubeGeometry()
|
|||
m_indexBuf.bind();
|
||||
m_indexBuf.allocate(indexData.data(), indexData.size() * sizeof(GLuint));
|
||||
|
||||
// load the texture
|
||||
initTexture();
|
||||
// get textures path
|
||||
std::string path = filePath;
|
||||
|
||||
while (path.back() != '/' && path.back() != '\\')
|
||||
path.pop_back();
|
||||
|
||||
// load the textures
|
||||
for(auto& it : *textureNames)
|
||||
loadTexture(std::string(path + it).c_str());
|
||||
|
||||
}
|
||||
catch (std::invalid_argument e)
|
||||
|
@ -94,10 +106,18 @@ void GeometryEngine::initCubeGeometry()
|
|||
|
||||
}
|
||||
|
||||
void GeometryEngine::initTexture()
|
||||
void GeometryEngine::loadTexture(const char* filePath)
|
||||
{
|
||||
// Load cube.png image
|
||||
QOpenGLTexture* new_texture = new QOpenGLTexture(QImage(":images/cube.png").mirrored());
|
||||
|
||||
QImage img;
|
||||
if (!img.load(filePath))
|
||||
{
|
||||
img = QImage(1, 1, QImage::Format_RGB32);
|
||||
img.fill(Qt::red);
|
||||
}
|
||||
|
||||
// Load image to OglTexture
|
||||
QOpenGLTexture* new_texture = new QOpenGLTexture(img.mirrored());
|
||||
|
||||
// Set nearest filtering mode for texture minification
|
||||
new_texture->setMinificationFilter(QOpenGLTexture::Nearest);
|
||||
|
|
|
@ -17,7 +17,6 @@ MshFile::MshFile(const char * path)
|
|||
|
||||
MshFile::~MshFile()
|
||||
{
|
||||
//TODO: clean up
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue