AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

This commit is contained in:
Dmitri K 2016-11-10 23:26:00 -05:00
parent 36020ec131
commit d73b7f19dd
16 changed files with 94 additions and 22 deletions

View File

@ -0,0 +1,35 @@
***************************************************************
* Toutes les images fournies proviennent du domaine publique. *
***************************************************************
dry_ground.jpg
--------------
Attribution : By Lover of Freedom [Public domain]
Source : http://pdtextures.blogspot.ca/2008/03/first-set.html
granite_floor.jpg
-----------------
Attribution : By Coyau [Public domain], via Wikimedia Commons
Source : https://commons.wikimedia.org/wiki/File%3AGranite_paving_tileable_2048x2048.jpg
grass.jpg
---------
Attribution : By Moohasha at English Wikibooks [Public domain], via Wikimedia Commons
Source : https://commons.wikimedia.org/wiki/File%3ABlender3DNoobToPro-Grass.jpg
limestone_wall.jpg
------------------
Attribution : By Coyau [Public domain], via Wikimedia Commons
Source : https://commons.wikimedia.org/wiki/File%3ALimestone_wall_tileable.jpg
pierre_bouchardee.jpg
---------------------
Attribution : Original work by Pierre-Yves Beaudouin [Public domain]. Derivative work by Coyau [Public domain], via Wikimedia Commons
Source : https://commons.wikimedia.org/wiki/File%3APierre_bouchard%C3%A9e_tileable_1024x1024.jpg
wood_floor.jpg
--------------
Attribution : By Tom Havik [Public domain]
Source : http://www.pixnio.com/textures-and-patterns/wood-texture/wood-pattern-parquet-floor-tiles

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 KiB

BIN
src/data/assets/grass.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

BIN
src/data/dry_ground.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 KiB

BIN
src/data/granite_floor.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 KiB

BIN
src/data/grass.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 KiB

Binary file not shown.

BIN
src/data/limestone_wall.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 KiB

BIN
src/data/wood_floor.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

View File

@ -368,6 +368,13 @@ void Viewer::initShaders()
s_texture = new QOpenGLTexture(QImage("src/data/uvLayoutGrid.png"));//*/
s_texture->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear);
s_texture->setMagnificationFilter(QOpenGLTexture::Linear);
// load remaining textures
for(int i = 0; i<TEX_LENGTH; i++){
TexturePrograms[i] = new QOpenGLTexture(QImage(TexturePaths[i]));
TexturePrograms[i]->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear);
TexturePrograms[i]->setMagnificationFilter(QOpenGLTexture::Linear);
}//*/
}
// Creates the basic shapes in memory. We only have 3, so we just prep them all in advance.
@ -608,35 +615,37 @@ void Viewer::visit(Cube &s)
void Viewer::visit(Sphere &s)
{
return;
// std::cout << "Sphere found";
QMatrix4x4 modelViewMatrix = modelStack.top() * QMatrix4x4(s.transform);
glBindVertexArray(m_VAOs[VAO_Sphere]);
m_program->setUniformValue(m_isSkyLoc, false);
m_program->setUniformValue(m_mvMatrixLocation, modelViewMatrix);
m_program->setUniformValue(m_normalMatrixLoc, modelViewMatrix.normalMatrix());
m_program->setUniformValue(m_colorLocation, s.getColor());
m_program->setUniformValue(m_drawTextLoc, false);
m_program->setUniformValue(m_isLightLoc, true);
// This will save the current position of this light ball as the next point
// This means point lights are technically 1 frame behind
QVector3D point = QVector3D(0,0,0);
point = modelViewMatrix * point;
if(!isPickingActivated){
glBindVertexArray(m_VAOs[VAO_Sphere]);
m_program->setUniformValue(m_isSkyLoc, false);
m_program->setUniformValue(m_mvMatrixLocation, modelViewMatrix);
m_program->setUniformValue(m_normalMatrixLoc, modelViewMatrix.normalMatrix());
m_program->setUniformValue(m_colorLocation, s.getColor());
m_program->setUniformValue(m_drawTextLoc, false);
m_program->setUniformValue(m_isLightLoc, true);
int pointLocs[3] = {m_point1Loc, m_point2Loc, m_point3Loc};
int pointCLocs[3] = {m_c1Loc, m_c2Loc, m_c3Loc};
// This will save the current position of this light ball as the next point
// This means point lights are technically 1 frame behind
m_program->setUniformValue(pointLocs[currentPoint], point);
m_program->setUniformValue(pointCLocs[currentPoint], s.getColor());
QVector3D point = QVector3D(0,0,0);
currentPoint = (currentPoint + 1) % 3;
point = modelViewMatrix * point;
glDrawElements(GL_TRIANGLES, numTriSphere*3, GL_UNSIGNED_INT, 0);
int pointLocs[3] = {m_point1Loc, m_point2Loc, m_point3Loc};
int pointCLocs[3] = {m_c1Loc, m_c2Loc, m_c3Loc};
m_program->setUniformValue(pointLocs[currentPoint], point);
m_program->setUniformValue(pointCLocs[currentPoint], s.getColor());
currentPoint = (currentPoint + 1) % 3;
glDrawElements(GL_TRIANGLES, numTriSphere*3, GL_UNSIGNED_INT, 0);
}
}
void Viewer::visit(SceneGroup &s)
@ -678,6 +687,8 @@ Shape* Viewer::pickGeom(int x, int y){
m_program->bind();
m_program->setUniformValue(m_isPickingModeLoc, true);
isPickingActivated = true;
QMap<QRgb, Shape*> mapColorToShape;
QColor c;
QRgb startColor = 0xFF0001; // alpha must be 100%, glReadPixels doesn't resturn alpha
@ -739,6 +750,8 @@ Shape* Viewer::pickGeom(int x, int y){
std::cout << "Picked Color: " << pickedColor->red() << " " << pickedColor->green() << " " << pickedColor->blue() << " " << pickedColor->alpha() << endl;
std::cout << "Picked Shape: " << pickedShape << endl;
m_program->setUniformValue(m_isPickingModeLoc, true);
//m_program->setUniformValue(m_isPickingModeLoc, false);
//isPickingActivated = false;
return pickedShape;
}

View File

@ -111,6 +111,7 @@ private:
int m_c3Loc;
int m_isPickingModeLoc;
bool isPickingActivated = false;
float angle_mult;
@ -128,6 +129,29 @@ private:
Shape* generateShapeFromIndex(int);
enum Textures{
TEX_DRYGOUND,
TEX_GRANITEFLOOR,
TEX_GRASS,
TEX_LIMESTONEWALLS,
TEX_PIERREBOUCHARDEE,
TEX_WOODFLOOR,
TEX_LENGTH
};
QString TexturePaths[TEX_LENGTH] = {
"src/data/dry_gound.jpg",
"src/data/granite_floor.jpg",
"src/data/grass.jpg",
"src/data/limestone_walls.jpg",
"src/data/pierre_bouchardee.jpg",
"src/data/wood_floor.jpg"
};
QOpenGLTexture *TexturePrograms[TEX_LENGTH];
QQuaternion rot;
unsigned int frame;
};