diff --git a/bin/Debug/main.exe b/bin/Debug/main.exe index 9e6fe88..c61ded3 100644 Binary files a/bin/Debug/main.exe and b/bin/Debug/main.exe differ diff --git a/build/.cmake/api/v1/reply/index-2024-07-15T02-44-22-0966.json b/build/.cmake/api/v1/reply/index-2024-07-17T23-41-15-0674.json similarity index 100% rename from build/.cmake/api/v1/reply/index-2024-07-15T02-44-22-0966.json rename to build/.cmake/api/v1/reply/index-2024-07-17T23-41-15-0674.json diff --git a/build/CMakeFiles/main.dir/compiler_depend.internal b/build/CMakeFiles/main.dir/compiler_depend.internal index 3b43d84..e12afbb 100644 --- a/build/CMakeFiles/main.dir/compiler_depend.internal +++ b/build/CMakeFiles/main.dir/compiler_depend.internal @@ -1575,7 +1575,6 @@ CMakeFiles/main.dir/src/main.cpp.obj C:/msys64/mingw64/include/c++/14.1.0/cassert C:/msys64/mingw64/include/c++/14.1.0/cctype C:/msys64/mingw64/include/c++/14.1.0/cerrno - C:/msys64/mingw64/include/c++/14.1.0/cfloat C:/msys64/mingw64/include/c++/14.1.0/clocale C:/msys64/mingw64/include/c++/14.1.0/cmath C:/msys64/mingw64/include/c++/14.1.0/cstddef @@ -1643,7 +1642,6 @@ CMakeFiles/main.dir/src/main.cpp.obj C:/msys64/mingw64/include/excpt.h C:/msys64/mingw64/include/fibersapi.h C:/msys64/mingw64/include/fileapi.h - C:/msys64/mingw64/include/float.h C:/msys64/mingw64/include/fltwinerror.h C:/msys64/mingw64/include/guiddef.h C:/msys64/mingw64/include/handleapi.h @@ -1789,7 +1787,6 @@ CMakeFiles/main.dir/src/main.cpp.obj C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/14.1.0/include/emmintrin.h C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/14.1.0/include/enqcmdintrin.h C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/14.1.0/include/f16cintrin.h - C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/14.1.0/include/float.h C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/14.1.0/include/fma4intrin.h C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/14.1.0/include/fmaintrin.h C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/14.1.0/include/fxsrintrin.h diff --git a/build/CMakeFiles/main.dir/compiler_depend.make b/build/CMakeFiles/main.dir/compiler_depend.make index 836ee9a..c94b7b4 100644 --- a/build/CMakeFiles/main.dir/compiler_depend.make +++ b/build/CMakeFiles/main.dir/compiler_depend.make @@ -1570,7 +1570,6 @@ CMakeFiles/main.dir/src/main.cpp.obj: C:/Users/biaso/Desktop/UFRGS/semestre5/fcg C:/msys64/mingw64/include/c++/14.1.0/cassert \ C:/msys64/mingw64/include/c++/14.1.0/cctype \ C:/msys64/mingw64/include/c++/14.1.0/cerrno \ - C:/msys64/mingw64/include/c++/14.1.0/cfloat \ C:/msys64/mingw64/include/c++/14.1.0/clocale \ C:/msys64/mingw64/include/c++/14.1.0/cmath \ C:/msys64/mingw64/include/c++/14.1.0/cstddef \ @@ -1638,7 +1637,6 @@ CMakeFiles/main.dir/src/main.cpp.obj: C:/Users/biaso/Desktop/UFRGS/semestre5/fcg C:/msys64/mingw64/include/excpt.h \ C:/msys64/mingw64/include/fibersapi.h \ C:/msys64/mingw64/include/fileapi.h \ - C:/msys64/mingw64/include/float.h \ C:/msys64/mingw64/include/fltwinerror.h \ C:/msys64/mingw64/include/guiddef.h \ C:/msys64/mingw64/include/handleapi.h \ @@ -1784,7 +1782,6 @@ CMakeFiles/main.dir/src/main.cpp.obj: C:/Users/biaso/Desktop/UFRGS/semestre5/fcg C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/14.1.0/include/emmintrin.h \ C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/14.1.0/include/enqcmdintrin.h \ C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/14.1.0/include/f16cintrin.h \ - C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/14.1.0/include/float.h \ C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/14.1.0/include/fma4intrin.h \ C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/14.1.0/include/fmaintrin.h \ C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/14.1.0/include/fxsrintrin.h \ @@ -4412,8 +4409,6 @@ C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/14.1.0/include/xsaveoptintrin.h: C:/Users/biaso/Desktop/UFRGS/semestre5/fcg/fcg-opengl/include/glm/ext/matrix_clip_space.hpp: -C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/14.1.0/include/float.h: - C:/msys64/mingw64/include/stringapiset.h: C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/14.1.0/include/prfchiintrin.h: @@ -5484,10 +5479,6 @@ C:/msys64/mingw64/include/c++/14.1.0/bits/stl_tempbuf.h: C:/msys64/mingw64/include/c++/14.1.0/bits/uniform_int_dist.h: -C:/msys64/mingw64/include/c++/14.1.0/cfloat: - -C:/msys64/mingw64/include/float.h: - C:/Users/biaso/Desktop/UFRGS/semestre5/fcg/fcg-opengl/src/matrices.cpp: C:/Users/biaso/Desktop/UFRGS/semestre5/fcg/fcg-opengl/src/objects.cpp: diff --git a/build/CMakeFiles/main.dir/objects.a b/build/CMakeFiles/main.dir/objects.a index b13033e..b37c5cd 100644 Binary files a/build/CMakeFiles/main.dir/objects.a and b/build/CMakeFiles/main.dir/objects.a differ diff --git a/build/CMakeFiles/main.dir/src/main.cpp.obj b/build/CMakeFiles/main.dir/src/main.cpp.obj index 3a915cf..ec1898c 100644 Binary files a/build/CMakeFiles/main.dir/src/main.cpp.obj and b/build/CMakeFiles/main.dir/src/main.cpp.obj differ diff --git a/build/CMakeFiles/main.dir/src/main.cpp.obj.d b/build/CMakeFiles/main.dir/src/main.cpp.obj.d index 4c82f9e..04805fb 100644 --- a/build/CMakeFiles/main.dir/src/main.cpp.obj.d +++ b/build/CMakeFiles/main.dir/src/main.cpp.obj.d @@ -25,9 +25,6 @@ CMakeFiles/main.dir/src/main.cpp.obj: \ C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/14.1.0/include/mm_malloc.h \ C:/msys64/mingw64/include/errno.h \ C:/msys64/mingw64/include/c++/14.1.0/bits/version.h \ - C:/msys64/mingw64/include/c++/14.1.0/cfloat \ - C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/14.1.0/include/float.h \ - C:/msys64/mingw64/include/float.h \ C:/msys64/mingw64/include/c++/14.1.0/map \ C:/msys64/mingw64/include/c++/14.1.0/bits/stl_tree.h \ C:/msys64/mingw64/include/c++/14.1.0/bits/stl_algobase.h \ diff --git a/build/CMakeFiles/main.dir/src/objects.cpp.obj b/build/CMakeFiles/main.dir/src/objects.cpp.obj index 7002fee..cafb5b0 100644 Binary files a/build/CMakeFiles/main.dir/src/objects.cpp.obj and b/build/CMakeFiles/main.dir/src/objects.cpp.obj differ diff --git a/data/circuits/leather_red_03_coll1_4k.png b/data/circuits/leather_red_03_coll1_4k.png new file mode 100644 index 0000000..63d11ba Binary files /dev/null and b/data/circuits/leather_red_03_coll1_4k.png differ diff --git a/data/circuits/metal_grate_rusty_diff_4k.jpg b/data/circuits/metal_grate_rusty_diff_4k.jpg new file mode 100644 index 0000000..91f5a52 Binary files /dev/null and b/data/circuits/metal_grate_rusty_diff_4k.jpg differ diff --git a/src/main.cpp b/src/main.cpp index 0c69103..5724383 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,7 +18,6 @@ #include // #include // #include -#include // Headers abaixo são específicos de C++ #include @@ -70,6 +69,10 @@ int main(int argc, char* argv[]) LoadTextureImage("../../data/display/textures/digit0.jpg"); // TextureDigit0 LoadTextureImage("../../data/display/textures/digit1.jpg"); // TextureDigit1 LoadTextureImage("../../data/circuits/wire.jpg"); // TexturePlaneWire + LoadTextureImage("../../data/circuits/not.jpg"); // TexturePlaneNot + LoadTextureImage("../../data/circuits/metal_grate_rusty_diff_4k.jpg"); // TextureBlocks + LoadTextureImage("../../data/circuits/leather_red_03_coll1_4k.png"); // TextureSphere + LoadTextureImage("../../data/circuits/and.jpg"); // TexturePlaneAnd // Construímos a representação de objetos geométricos através de malhas de triângulos buildModel("../../data/sphere.obj"); @@ -79,6 +82,8 @@ int main(int argc, char* argv[]) buildModel("../../data/display/cube.obj"); buildModel("../../data/plane.obj"); buildModel("../../data/table/chinese_console_table_4k.obj"); + buildModel("../../data/not/not.obj"); + buildModel("../../data/and/and.obj"); if ( argc > 1 ) { @@ -185,6 +190,10 @@ int main(int argc, char* argv[]) #define INPUT1_DIGIT 7 #define INPUT2_DIGIT 8 #define PLANE_WIRE 9 + #define LIGHTBULB_NOT 10 + #define PLANE_NOT 11 + #define LIGHTBULB_AND 12 + #define PLANE_AND 13 #define PLANE_WIDTH 0.2f #define PLANE_HEIGHT 0.145f @@ -265,6 +274,76 @@ int main(int argc, char* argv[]) DrawVirtualObject("Cylinder"); PopMatrix(model); + PushMatrix(model); + // posição do display + model *= Matrix_Translate(-CIRCUIT_WIDTH, 0.0f, 0.0f); + + PushMatrix(model); + // Desenhamos o modelo do cubo do display + model *= Matrix_Scale(DISPLAY_WIDTH, DISPLAY_WIDTH, DISPLAY_HEIGHT); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, DISPLAY); + DrawVirtualObject("Cube"); + PopMatrix(model); + + PushMatrix(model); + // // Desenhamos o modelo do display do dígito + model *= Matrix_Translate(0.0f, DISPLAY_WIDTH + 0.0005, 0.0f) + * Matrix_Scale(DISPLAY_WIDTH, DISPLAY_WIDTH, DISPLAY_HEIGHT); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, INPUT1_DIGIT); + DrawVirtualObject("the_plane"); + PopMatrix(model); + + PopMatrix(model); + + PopMatrix(model); + + // 2 - NOT + + // Desenhamos o circuito NOT + PushMatrix(model); + + model *= Matrix_Translate(- (3 / NUM_CIRCUITS) * tableWidth - 0.15f, 0.0f, 0.0f); + + // Plano com o circuito NOT + PushMatrix(model); + model *= Matrix_Scale(PLANE_WIDTH, 0.0f, PLANE_HEIGHT); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, PLANE_NOT); + DrawVirtualObject("the_plane"); + PopMatrix(model); + + PushMatrix(model); + // desenhamos a lâmpada + model *= Matrix_Translate(CIRCUIT_WIDTH, 0.01f, 0.0f); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, LIGHTBULB_NOT); + DrawVirtualObject("lightbulb_01"); + PopMatrix(model); + + PushMatrix(model); + // Desenhamos a primeira metade do modelo do fio + model *= Matrix_Translate(-(CIRCUIT_WIDTH - 0.05f), 0.01f,0.0f) + * Matrix_Rotate_X(M_PI/2.0f) + * Matrix_Rotate_Z(M_PI/2.0f) + * Matrix_Scale(0.01f, CIRCUIT_WIDTH / 4.0, 0.01f); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, WIRE); + DrawVirtualObject("Cylinder"); + PopMatrix(model); + + PushMatrix(model); + // Desenhamos a segunda metade do modelo do fio + model *= Matrix_Translate(CIRCUIT_WIDTH - 0.05f,0.01f,0.0f) + * Matrix_Rotate_X(M_PI/2.0f) + * Matrix_Rotate_Z(M_PI/2.0f) + * Matrix_Scale(0.01f, CIRCUIT_WIDTH / 4.0f, 0.01f); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, WIRE); + DrawVirtualObject("Cylinder"); + PopMatrix(model); + PushMatrix(model); // posição do display model *= Matrix_Translate(-CIRCUIT_WIDTH, 0.0f, 0.0f); @@ -286,8 +365,183 @@ int main(int argc, char* argv[]) DrawVirtualObject("the_plane"); PopMatrix(model); + PushMatrix(model); + // Desenhamos o modelo do bloco NOT + model *= Matrix_Translate(CIRCUIT_WIDTH / 2.0f + 0.01f, 0.0f, 0.0f) + * Matrix_Scale(CIRCUIT_WIDTH / 4.0f + 0.025f, CIRCUIT_WIDTH / 4.0f, CIRCUIT_WIDTH / 4.0f) + * Matrix_Rotate_Y(-M_PI/4.0f); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, NOT); + DrawVirtualObject("Not"); + PopMatrix(model); + + PushMatrix(model); + // Desenhamos o modelo da esfera do bloco NOT + model *= Matrix_Translate(CIRCUIT_WIDTH / 2.0f + 0.01f + CIRCUIT_WIDTH / 4.0f + 0.025f + CIRCUIT_WIDTH / 6.0f + 0.02f, 0.025f, 0.0f) + * Matrix_Scale(CIRCUIT_WIDTH / 6.0f, CIRCUIT_WIDTH / 6.0f,CIRCUIT_WIDTH / 6.0f) + * Matrix_Rotate_Y(-M_PI/4.0f); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, SPHERE); + DrawVirtualObject("the_sphere"); + PopMatrix(model); + PopMatrix(model); PopMatrix(model); + + // 3 - AND + + // Desenhamos o circuito AND + PushMatrix(model); + + model *= Matrix_Translate( tableWidth / NUM_CIRCUITS - 0.15f, 0.0f, 0.0f); + + // Plano com o circuito AND + PushMatrix(model); + model *= Matrix_Scale(PLANE_WIDTH, 50.0f, PLANE_HEIGHT); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, PLANE_AND); + DrawVirtualObject("the_plane"); + PopMatrix(model); + + PushMatrix(model); + // desenhamos a lâmpada + model *= Matrix_Translate(CIRCUIT_WIDTH, 0.01f, 0.0f); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, LIGHTBULB_AND); + DrawVirtualObject("lightbulb_01"); + PopMatrix(model); + + PushMatrix(model); + // Desenhamos a primeira metade do modelo do fio + model *= Matrix_Translate(-(CIRCUIT_WIDTH - 0.05f), 0.01f,0.0f) + * Matrix_Rotate_X(M_PI/2.0f) + * Matrix_Rotate_Z(M_PI/2.0f) + * Matrix_Scale(0.01f, CIRCUIT_WIDTH / 4.0 + 0.005f, 0.01f); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, WIRE); + DrawVirtualObject("Cylinder"); + PopMatrix(model); + + PushMatrix(model); + // Desenhamos a segunda metade do modelo do fio + model *= Matrix_Translate(CIRCUIT_WIDTH - 0.05f,0.01f,0.0f) + * Matrix_Rotate_X(M_PI/2.0f) + * Matrix_Rotate_Z(M_PI/2.0f) + * Matrix_Scale(0.01f, CIRCUIT_WIDTH / 4.0f, 0.01f); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, WIRE); + DrawVirtualObject("Cylinder"); + PopMatrix(model); + + PushMatrix(model); + // Desenhamos a o fio vertical que liga os dos displays ao circuito + model *= Matrix_Translate(-CIRCUIT_WIDTH, 0.01f, 0.0f) + * Matrix_Rotate_Y(M_PI/2.0f) + * Matrix_Rotate_Z(M_PI/2.0f) + * Matrix_Scale(0.01f, PLANE_HEIGHT - (2 * DISPLAY_HEIGHT), 0.01f); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, WIRE); + DrawVirtualObject("Cylinder"); + PopMatrix(model); + + PushMatrix(model); + // posição do display + model *= Matrix_Translate(-CIRCUIT_WIDTH, 0.0f, 0.0f); + + PushMatrix(model); + // Posição do display 1 + model *= Matrix_Translate(0.0f, 0.0f, - (PLANE_HEIGHT / 2.0f)); + + PushMatrix(model); + // Desenhamos o modelo do cubo do display + model *= Matrix_Scale(DISPLAY_WIDTH, DISPLAY_WIDTH, DISPLAY_HEIGHT); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, DISPLAY); + DrawVirtualObject("Cube"); + PopMatrix(model); + + PushMatrix(model); + // // Desenhamos o modelo do display do dígito + model *= Matrix_Translate(0.0f, DISPLAY_WIDTH + 0.0005, 0.0f) + * Matrix_Scale(DISPLAY_WIDTH, DISPLAY_WIDTH, DISPLAY_HEIGHT); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, INPUT1_DIGIT); + DrawVirtualObject("the_plane"); + PopMatrix(model); + + PushMatrix(model); + // Desenhamos o modelo do cubo do display + model *= Matrix_Scale(DISPLAY_WIDTH, DISPLAY_WIDTH, DISPLAY_HEIGHT); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, DISPLAY); + DrawVirtualObject("Cube"); + PopMatrix(model); + + PushMatrix(model); + // // Desenhamos o modelo do display do dígito + model *= Matrix_Translate(0.0f, DISPLAY_WIDTH + 0.0005, 0.0f) + * Matrix_Scale(DISPLAY_WIDTH, DISPLAY_WIDTH, DISPLAY_HEIGHT); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, INPUT1_DIGIT); + DrawVirtualObject("the_plane"); + PopMatrix(model); + + PopMatrix(model); + + PushMatrix(model); + // Posição do display 2 + model *= Matrix_Translate(0.0f, 0.0f, PLANE_HEIGHT / 2.0f); + + PushMatrix(model); + // Desenhamos o modelo do cubo do display + model *= Matrix_Scale(DISPLAY_WIDTH, DISPLAY_WIDTH, DISPLAY_HEIGHT); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, DISPLAY); + DrawVirtualObject("Cube"); + PopMatrix(model); + + PushMatrix(model); + // // Desenhamos o modelo do display do dígito + model *= Matrix_Translate(0.0f, DISPLAY_WIDTH + 0.0005, 0.0f) + * Matrix_Scale(DISPLAY_WIDTH, DISPLAY_WIDTH, DISPLAY_HEIGHT); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, INPUT2_DIGIT); + DrawVirtualObject("the_plane"); + PopMatrix(model); + + PushMatrix(model); + // Desenhamos o modelo do cubo do display + model *= Matrix_Scale(DISPLAY_WIDTH, DISPLAY_WIDTH, DISPLAY_HEIGHT); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, DISPLAY); + DrawVirtualObject("Cube"); + PopMatrix(model); + + PushMatrix(model); + // // Desenhamos o modelo do display do dígito + model *= Matrix_Translate(0.0f, DISPLAY_WIDTH + 0.0005, 0.0f) + * Matrix_Scale(DISPLAY_WIDTH, DISPLAY_WIDTH, DISPLAY_HEIGHT); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, INPUT1_DIGIT); + DrawVirtualObject("the_plane"); + PopMatrix(model); + + PopMatrix(model); + + PopMatrix(model); + + PushMatrix(model); + // Desenhamos o modelo do bloco AND + model *= Matrix_Translate(0.0f, 0.0f, 0.0f) + * Matrix_Scale(CIRCUIT_WIDTH / 4.0f + 0.01f, CIRCUIT_WIDTH / 4.0f + 0.01f, CIRCUIT_WIDTH / 4.0f + 0.01f) + * Matrix_Rotate_Y(-M_PI/2.0f); + glUniformMatrix4fv(g_model_uniform, 1 , GL_FALSE , glm::value_ptr(model)); + glUniform1i(g_object_id_uniform, AND); + DrawVirtualObject("and"); + PopMatrix(model); + + PopMatrix(model); + PopMatrix(model); diff --git a/src/objects.cpp b/src/objects.cpp index 4c99712..fc5fb89 100644 --- a/src/objects.cpp +++ b/src/objects.cpp @@ -262,7 +262,12 @@ void LoadShadersFromFiles() glUniform1i(glGetUniformLocation(g_GpuProgramID, "TextureDigit0"), 6); glUniform1i(glGetUniformLocation(g_GpuProgramID, "TextureDigit1"), 7); glUniform1i(glGetUniformLocation(g_GpuProgramID, "TexturePlaneWire"), 8); - + glUniform1i(glGetUniformLocation(g_GpuProgramID, "TexturePlaneNot"), 9); + glUniform1i(glGetUniformLocation(g_GpuProgramID, "TextureBlocks"), 10); + glUniform1i(glGetUniformLocation(g_GpuProgramID, "TextureSphere"), 11); + glUniform1i(glGetUniformLocation(g_GpuProgramID, "TexturePlaneAnd"), 12); + + // Variáveis em "shader_fragment.glsl" para controle de texturas dos dígitos glUniform1i(glGetUniformLocation(g_GpuProgramID, "u_isInput1Digit0"), isInput1Digit0); glUniform1i(glGetUniformLocation(g_GpuProgramID, "u_isInput2Digit0"), isInput2Digit0); diff --git a/src/shader_fragment.glsl b/src/shader_fragment.glsl index f9ee69c..a6769dc 100644 --- a/src/shader_fragment.glsl +++ b/src/shader_fragment.glsl @@ -29,6 +29,10 @@ uniform mat4 projection; #define INPUT1_DIGIT 7 #define INPUT2_DIGIT 8 #define PLANE_WIRE 9 +#define LIGHTBULB_NOT 10 +#define PLANE_NOT 11 +#define LIGHTBULB_AND 12 +#define PLANE_AND 13 uniform int object_id; // Parâmetros da axis-aligned bounding box (AABB) do modelo @@ -45,6 +49,10 @@ uniform sampler2D TextureDisplay; uniform sampler2D TextureDigit0; uniform sampler2D TextureDigit1; uniform sampler2D TexturePlaneWire; +uniform sampler2D TexturePlaneNot; +uniform sampler2D TextureBlocks; +uniform sampler2D TextureSphere; +uniform sampler2D TexturePlaneAnd; uniform bool u_isInput1Digit0; uniform bool u_isInput2Digit0; @@ -117,7 +125,7 @@ void main() V = (phi + M_PI / 2) / M_PI; // Obtemos a refletância difusa a partir da leitura da imagem TextureImage0 - Kd = texture(TextureImage0, vec2(U,V)).rgb; + Kd = texture(TextureSphere, vec2(U,V)).rgb; color.rgb = Kd; color.a = 1; } @@ -131,6 +139,26 @@ void main() color.rgb = Kd; color.a = 1; } + else if ( object_id == LIGHTBULB_NOT ) + { + if (u_isInput1Digit0) + Kd = texture(TextureLightbulbON, texcoords).rgb; + else + Kd = texture(TextureLightbulbOFF, texcoords).rgb; + + color.rgb = Kd; + color.a = 1; + } + else if ( object_id == LIGHTBULB_AND ) + { + if (!u_isInput1Digit0 && !u_isInput2Digit0) + Kd = texture(TextureLightbulbON, texcoords).rgb; + else + Kd = texture(TextureLightbulbOFF, texcoords).rgb; + + color.rgb = Kd; + color.a = 1; + } else if (object_id == TABLE) { @@ -174,6 +202,39 @@ void main() color.rgb = Kd; color.a = 1; } + else if (object_id == PLANE_NOT) + { + Kd = texture(TexturePlaneNot, texcoords).rgb; + color.rgb = Kd; + color.a = 1; + } + else if (object_id == PLANE_AND) + { + Kd = texture(TexturePlaneAnd, texcoords).rgb; + color.rgb = Kd; + color.a = 1; + } + else if (object_id == NOT || object_id == AND) + { + // Projeção cilíndrica + vec4 bbox_center = (bbox_min + bbox_max) / 2.0; + float height = bbox_max.y - bbox_min.y; + + // ponto q no eixo central com igual altura ao ponto p position_model + vec4 q = vec4(bbox_center.x, position_model.y, bbox_center.z, 1.0f); + + vec4 position_cylinder = q + normalize(position_model - q); + + float theta = atan(position_cylinder.z - bbox_center.z, position_cylinder.x - bbox_center.x); + float h = position_cylinder.y - bbox_min.y; + + U = (theta + M_PI) / (2.0 * M_PI); + V = h / height; + + Kd = texture(TextureBlocks, vec2(U,V)).rgb; + color.rgb = Kd; + color.a = 1; + } // NOTE: Se você quiser fazer o rendering de objetos transparentes, é // necessário: