Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

circuitos AND e NOT #14

Merged
merged 1 commit into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bin/Debug/main.exe
Binary file not shown.
3 changes: 0 additions & 3 deletions build/CMakeFiles/main.dir/compiler_depend.internal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions build/CMakeFiles/main.dir/compiler_depend.make
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
Binary file modified build/CMakeFiles/main.dir/objects.a
Binary file not shown.
Binary file modified build/CMakeFiles/main.dir/src/main.cpp.obj
Binary file not shown.
3 changes: 0 additions & 3 deletions build/CMakeFiles/main.dir/src/main.cpp.obj.d
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
Binary file modified build/CMakeFiles/main.dir/src/objects.cpp.obj
Binary file not shown.
Binary file added data/circuits/leather_red_03_coll1_4k.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/circuits/metal_grate_rusty_diff_4k.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
256 changes: 255 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <cmath>
// #include <cstdio>
// #include <cstdlib>
#include <cfloat>

// Headers abaixo são específicos de C++
#include <map>
Expand Down Expand Up @@ -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");
Expand All @@ -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 )
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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);


Expand Down
Loading