Tidying up.
This commit is contained in:
parent
ec08b28002
commit
b97bf52214
@ -173,7 +173,6 @@ int main(int argc, char *argv[])
|
|||||||
cout << endl << "Time taken = " << time.elapsed() / 1000.0f << "s" << endl << endl;
|
cout << endl << "Time taken = " << time.elapsed() / 1000.0f << "s" << endl << endl;
|
||||||
|
|
||||||
const int32_t extractedRegionSize = 32;
|
const int32_t extractedRegionSize = 32;
|
||||||
const int32_t gapBetweenRegions = 1; // Set this to '1'
|
|
||||||
int meshCounter = 0;
|
int meshCounter = 0;
|
||||||
|
|
||||||
for (int32_t z = 0; z < volData.getDepth(); z += extractedRegionSize)
|
for (int32_t z = 0; z < volData.getDepth(); z += extractedRegionSize)
|
||||||
|
@ -135,7 +135,7 @@ void OpenGLWidget::paintGL()
|
|||||||
for (OpenGLMeshData meshData : mMeshData)
|
for (OpenGLMeshData meshData : mMeshData)
|
||||||
{
|
{
|
||||||
QMatrix4x4 modelToWorldMatrix{};
|
QMatrix4x4 modelToWorldMatrix{};
|
||||||
modelToWorldMatrix.translate(meshData.translation.getX(), meshData.translation.getY(), meshData.translation.getZ());
|
modelToWorldMatrix.translate(meshData.translation);
|
||||||
modelToWorldMatrix.scale(meshData.scale);
|
modelToWorldMatrix.scale(meshData.scale);
|
||||||
shader->setUniformValue("modelToWorldMatrix", modelToWorldMatrix);
|
shader->setUniformValue("modelToWorldMatrix", modelToWorldMatrix);
|
||||||
|
|
||||||
|
@ -31,16 +31,21 @@ distribution.
|
|||||||
#include <QGLWidget>
|
#include <QGLWidget>
|
||||||
#include <QGLShaderProgram>
|
#include <QGLShaderProgram>
|
||||||
|
|
||||||
|
// This structure holds all the data required
|
||||||
|
// to render one of our meshes through OpenGL.
|
||||||
struct OpenGLMeshData
|
struct OpenGLMeshData
|
||||||
{
|
{
|
||||||
GLuint noOfIndices;
|
GLuint noOfIndices;
|
||||||
GLuint indexBuffer;
|
GLuint indexBuffer;
|
||||||
GLuint vertexBuffer;
|
GLuint vertexBuffer;
|
||||||
GLuint vertexArrayObject;
|
GLuint vertexArrayObject;
|
||||||
PolyVox::Vector3DInt32 translation;
|
QVector3D translation;
|
||||||
float scale;
|
float scale;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Our OpenGLWidget is used by all the examples to render the extracted meshes. It is
|
||||||
|
// fairly specific to our needs (you probably won't want to use it in your own project)
|
||||||
|
// but should provide a useful illustration of how PolyVox meshes can be rendered.
|
||||||
class OpenGLWidget : public QGLWidget
|
class OpenGLWidget : public QGLWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -51,9 +56,11 @@ public:
|
|||||||
void mouseMoveEvent(QMouseEvent* event);
|
void mouseMoveEvent(QMouseEvent* event);
|
||||||
void mousePressEvent(QMouseEvent* event);
|
void mousePressEvent(QMouseEvent* event);
|
||||||
|
|
||||||
// The viewable region can be adjusted so that this example framework can be use for different volume sizes.
|
// The viewable region can be adjusted so that this example framework can be used for different volume sizes.
|
||||||
void setViewableRegion(PolyVox::Region viewableRegion);
|
void setViewableRegion(PolyVox::Region viewableRegion);
|
||||||
|
|
||||||
|
// For our purposes we use a single shader for the whole volume, and
|
||||||
|
// this example framework is only meant to show a single volume at a time
|
||||||
void setShader(QGLShaderProgram* shader)
|
void setShader(QGLShaderProgram* shader)
|
||||||
{
|
{
|
||||||
this->shader = shader;
|
this->shader = shader;
|
||||||
@ -100,14 +107,13 @@ public:
|
|||||||
|
|
||||||
meshData.noOfIndices = vecIndices.size(); //Save this for the call to glDrawElements later
|
meshData.noOfIndices = vecIndices.size(); //Save this for the call to glDrawElements later
|
||||||
|
|
||||||
meshData.translation = translation;
|
meshData.translation = QVector3D(translation.getX(), translation.getY(), translation.getZ());
|
||||||
meshData.scale = scale;
|
meshData.scale = scale;
|
||||||
|
|
||||||
mMeshData.push_back(meshData);
|
mMeshData.push_back(meshData);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
||||||
// Qt OpenGL functions
|
// Qt OpenGL functions
|
||||||
void initializeGL();
|
void initializeGL();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user