scale and move to center,
performance is not very good. Takes very long to load
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "..\Header\GeometryEngine.h"
|
||||
#include "..\Header\MshFile.h"
|
||||
#include <cmath>
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
@@ -45,6 +46,7 @@ void GeometryEngine::loadFile(const char* filePath)
|
||||
MshFile file(filePath);
|
||||
models = file.getModels();
|
||||
textureNames = file.getTextureNames();
|
||||
m_boundings = file.getBoundingBox();
|
||||
|
||||
// collect data
|
||||
unsigned int indexOffset(0);
|
||||
@@ -76,8 +78,6 @@ void GeometryEngine::loadFile(const char* filePath)
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: cleanup old stuff
|
||||
|
||||
// Transfer vertex data to VBO 0
|
||||
m_arrayBuf.bind();
|
||||
m_arrayBuf.allocate(vertexData.data(), vertexData.size() * sizeof(VertexData));
|
||||
@@ -159,6 +159,13 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program)
|
||||
m_arrayBuf.bind();
|
||||
m_indexBuf.bind();
|
||||
|
||||
// Allways normalize by this
|
||||
QMatrix4x4 normMatrix;
|
||||
float maxExtent = std::max(std::max(m_boundings.extents[0], m_boundings.extents[1]), m_boundings.extents[2]);
|
||||
normMatrix.scale(1 / maxExtent);
|
||||
normMatrix.translate(-m_boundings.center[0], -m_boundings.center[1], -m_boundings.center[2]);
|
||||
program->setUniformValue("norm_matrix", normMatrix);
|
||||
|
||||
// Allways use texture unit 0
|
||||
program->setUniformValue("texture", 0);
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
#include <math.h>
|
||||
#include <iostream>
|
||||
|
||||
#define DEFAULT_Z_DISTANCE -5.0
|
||||
#define DEFAULT_Z_DISTANCE -4.0
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
Reference in New Issue
Block a user