diff --git a/src/data/assets/README.txt b/src/data/assets/README.txt new file mode 100644 index 0000000..b81680b --- /dev/null +++ b/src/data/assets/README.txt @@ -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 + + diff --git a/src/data/assets/dry_ground.jpg b/src/data/assets/dry_ground.jpg new file mode 100644 index 0000000..aa17428 Binary files /dev/null and b/src/data/assets/dry_ground.jpg differ diff --git a/src/data/assets/granite_floor.jpg b/src/data/assets/granite_floor.jpg new file mode 100644 index 0000000..109034e Binary files /dev/null and b/src/data/assets/granite_floor.jpg differ diff --git a/src/data/assets/grass.jpg b/src/data/assets/grass.jpg new file mode 100644 index 0000000..101f905 Binary files /dev/null and b/src/data/assets/grass.jpg differ diff --git a/src/data/assets/limestone_wall.jpg b/src/data/assets/limestone_wall.jpg new file mode 100644 index 0000000..6c18211 Binary files /dev/null and b/src/data/assets/limestone_wall.jpg differ diff --git a/src/data/assets/pierre_bouchardee.jpg b/src/data/assets/pierre_bouchardee.jpg new file mode 100644 index 0000000..7e67edc Binary files /dev/null and b/src/data/assets/pierre_bouchardee.jpg differ diff --git a/src/data/assets/wood_floor.jpg b/src/data/assets/wood_floor.jpg new file mode 100644 index 0000000..281ea79 Binary files /dev/null and b/src/data/assets/wood_floor.jpg differ diff --git a/src/data/dry_ground.jpg b/src/data/dry_ground.jpg new file mode 100644 index 0000000..aa17428 Binary files /dev/null and b/src/data/dry_ground.jpg differ diff --git a/src/data/granite_floor.jpg b/src/data/granite_floor.jpg new file mode 100644 index 0000000..109034e Binary files /dev/null and b/src/data/granite_floor.jpg differ diff --git a/src/data/grass.jpg b/src/data/grass.jpg new file mode 100644 index 0000000..101f905 Binary files /dev/null and b/src/data/grass.jpg differ diff --git a/src/data/lab2_assets v2.00.zip b/src/data/lab2_assets v2.00.zip new file mode 100644 index 0000000..dc14e25 Binary files /dev/null and b/src/data/lab2_assets v2.00.zip differ diff --git a/src/data/limestone_wall.jpg b/src/data/limestone_wall.jpg new file mode 100644 index 0000000..6c18211 Binary files /dev/null and b/src/data/limestone_wall.jpg differ diff --git a/src/data/pierre_bouchardee.jpg b/src/data/pierre_bouchardee.jpg new file mode 100644 index 0000000..7e67edc Binary files /dev/null and b/src/data/pierre_bouchardee.jpg differ diff --git a/src/data/wood_floor.jpg b/src/data/wood_floor.jpg new file mode 100644 index 0000000..281ea79 Binary files /dev/null and b/src/data/wood_floor.jpg differ diff --git a/src/viewer/simpleViewer.cpp b/src/viewer/simpleViewer.cpp index ca36e71..f89297f 100644 --- a/src/viewer/simpleViewer.cpp +++ b/src/viewer/simpleViewer.cpp @@ -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; isetMinificationFilter(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 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; } diff --git a/src/viewer/simpleViewer.h b/src/viewer/simpleViewer.h index dde5cdd..f458f6d 100644 --- a/src/viewer/simpleViewer.h +++ b/src/viewer/simpleViewer.h @@ -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; };