lekko poprawiona mapka, dodane nowe klasy do projektu w visual studio, oddzielny kolor dla mapki i łazika

This commit is contained in:
2024-12-08 16:00:25 +01:00
parent 2b51e31307
commit 633be80ec4
6 changed files with 65 additions and 54 deletions

View File

@@ -124,14 +124,14 @@
<ClCompile Include="lazik.cpp" /> <ClCompile Include="lazik.cpp" />
<ClCompile Include="loadOBJ.cpp" /> <ClCompile Include="loadOBJ.cpp" />
<ClCompile Include="main.cpp" /> <ClCompile Include="main.cpp" />
<ClCompile Include="szescian.cpp" /> <ClCompile Include="plane.cpp" />
<ClCompile Include="timeh.cpp" /> <ClCompile Include="timeh.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="lazik.hpp" /> <ClInclude Include="lazik.hpp" />
<ClInclude Include="loadOBJ.h" /> <ClInclude Include="loadOBJ.h" />
<ClInclude Include="plane.hpp" />
<ClInclude Include="RESOURCE.H" /> <ClInclude Include="RESOURCE.H" />
<ClInclude Include="szescian.h" />
<ClInclude Include="timeh.hpp" /> <ClInclude Include="timeh.hpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -21,9 +21,6 @@
<ClCompile Include="main.cpp"> <ClCompile Include="main.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="szescian.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="glew.c"> <ClCompile Include="glew.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@@ -33,6 +30,9 @@
<ClCompile Include="timeh.cpp"> <ClCompile Include="timeh.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="plane.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="loadOBJ.h"> <ClInclude Include="loadOBJ.h">
@@ -41,14 +41,14 @@
<ClInclude Include="RESOURCE.H"> <ClInclude Include="RESOURCE.H">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="szescian.h"> <ClInclude Include="plane.hpp">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="lazik.hpp"> <ClInclude Include="lazik.hpp">
<Filter>Source Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="timeh.hpp"> <ClInclude Include="timeh.hpp">
<Filter>Source Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -65,6 +65,7 @@ void lazik::draw() {
} }
void lazik::moveX(float x){ void lazik::moveX(float x){
// TODO: dodać timer do poniższych funkcji, aby czas przejścia z punktu A do B był uniezależniony od FPSów
timestampedCout("dummy moveX"); timestampedCout("dummy moveX");
} }
@@ -75,3 +76,8 @@ void lazik::moveY(float y){
void lazik::moveZ(float z){ void lazik::moveZ(float z){
timestampedCout("dummy moveZ"); timestampedCout("dummy moveZ");
} }
void lazik::moveXYZ(float x, float y, float z){
// TODO: modyfikować wektor z koordynatami oraz c_x, c_y, c_z
timestampedCout("dummy moveXYZ");
}

View File

@@ -30,4 +30,5 @@ class lazik {
void moveX(float x); void moveX(float x);
void moveY(float y); void moveY(float y);
void moveZ(float z); void moveZ(float z);
void moveXYZ(float x, float y, float z);
}; };

View File

@@ -78,14 +78,14 @@ std::time_t monitormodehelper;
// Change viewing volume and viewport. Called when window is resized // Change viewing volume and viewport. Called when window is resized
void ChangeSize(GLsizei w, GLsizei h) { void ChangeSize(GLsizei w, GLsizei h) {
GLfloat nRange = 100.0f; GLfloat nRange = 100.0f;
GLfloat fAspect; //GLfloat fAspect;
// Prevent a divide by zero // Prevent a divide by zero
if (h == 0) h = 1; if (h == 0) h = 1;
lastWidth = w; lastWidth = w;
lastHeight = h; lastHeight = h;
fAspect = (GLfloat)w / (GLfloat)h; //fAspect = (GLfloat)w / (GLfloat)h;
// Set Viewport to window dimensions // Set Viewport to window dimensions
glViewport(0, 0, w, h); glViewport(0, 0, w, h);
@@ -93,9 +93,13 @@ void ChangeSize(GLsizei w, GLsizei h) {
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
// // Establish clipping volume (left, right, bottom, top, near, far)
// if (w <= h) glOrtho(-nRange, nRange, -nRange * h / w, nRange * h / w, -nRange, nRange);
// else glOrtho(-nRange * w / h, nRange * w / h, -nRange, nRange, -nRange, nRange);
// Establish clipping volume (left, right, bottom, top, near, far) // Establish clipping volume (left, right, bottom, top, near, far)
if (w <= h) glOrtho(-nRange, nRange, -nRange * h / w, nRange * h / w, -nRange, nRange); if (w <= h) glOrtho(-nRange, nRange, -nRange * h / w, nRange * h / w, -20 * nRange, 20 * nRange);
else glOrtho(-nRange * w / h, nRange * w / h, -nRange, nRange, -nRange, nRange); else glOrtho(-nRange * w / h, nRange * w / h, -nRange, nRange, -20 * nRange, 20 * nRange);
// Establish perspective: // Establish perspective:
/* /*
@@ -197,8 +201,8 @@ void SetDCPixelFormat(HDC hDC) {
SetPixelFormat(hDC, nPixelFormat, &pfd); SetPixelFormat(hDC, nPixelFormat, &pfd);
} }
lazik user(0.0f, 0.0f, 0.0f, "res/models/lazik4.obj"); lazik user(10.0f, 0.0f, 0.0f, "res/models/lazik4.obj");
plane mapa(0.0f, 0.0f, 0.0f, "res/models/mapka.obj"); plane mapa(0.0f, 0.0f, 0.0f, "res/models/mapka.obj");
void SetupRC() { void SetupRC() {
// Light values and coordinates // Light values and coordinates
@@ -322,8 +326,11 @@ void RenderScene(void) {
// // Set our "myTextureSampler" sampler to use Texture Unit 0 // // Set our "myTextureSampler" sampler to use Texture Unit 0
// glUniform1i(TextureID, 0); // glUniform1i(TextureID, 0);
glColor3f(1.0, 0.0, 0.0);
user.draw(); user.draw();
glColor3f(0.0, 1.0, 0.0);
mapa.draw(); mapa.draw();
glColor3f(0.0, 0.0, 0.0);
// Swap buffers // Swap buffers
//glfwSwapBuffers(window); //glfwSwapBuffers(window);
@@ -647,7 +654,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case ' ': // 32 case ' ': // 32
polygonmode = !polygonmode; polygonmode = !polygonmode;
getTime;
if (polygonmode) timestampedCout("Uwaga! Tryb wireframe jest niewydajny i powinien sluzyc tylko do debugowania!"); if (polygonmode) timestampedCout("Uwaga! Tryb wireframe jest niewydajny i powinien sluzyc tylko do debugowania!");
break; break;

View File

@@ -16,23 +16,22 @@ f 2/1/1 4/4/1 3/2/1
o Cube o Cube
v -15.000000 0.000000 15.000000 v -15.000000 0.000000 15.000000
v -15.000000 40.000000 15.000000 v -15.000000 40.000000 15.000000
v -15.000000 0.000000 -15.000000 v -15.000000 0.000000 -35.000004
v -15.000000 40.000000 -15.000000 v -15.000000 40.000000 -35.000004
v 15.000000 0.000000 15.000000 v 15.000000 0.000000 15.000000
v 15.000000 40.000000 15.000000 v 15.000000 40.000000 15.000000
v 15.000000 0.000000 -15.000000 v 15.000000 0.000000 -35.000004
v 15.000000 40.000000 -15.000000 v 15.000000 40.000000 -35.000004
v 15.000000 40.000000 15.000000
v 0.000000 52.654823 15.000000 v 0.000000 52.654823 15.000000
v 0.000000 52.654823 -15.000000 v 0.000000 52.654823 -35.000004
v -15.000000 20.000000 -15.000000 v -15.000000 20.000000 -35.000004
v 0.000000 40.000000 -15.000000 v 0.000000 40.000000 -35.000004
v 15.000000 20.000000 -15.000000 v 15.000000 20.000000 -35.000004
v 0.000000 20.000000 -15.000000 v 0.000000 20.000000 -35.000004
v -15.000000 10.000000 -15.000000 v -15.000000 10.000000 -35.000004
v -7.500000 20.000000 -15.000000 v -7.500000 20.000000 -35.000004
v 15.000000 10.000000 -15.000000 v 15.000000 10.000000 -35.000004
v 7.500000 20.000000 -15.000000 v 7.500000 20.000000 -35.000004
vn -1.0000 -0.0000 -0.0000 vn -1.0000 -0.0000 -0.0000
vn -0.0000 -0.0000 -1.0000 vn -0.0000 -0.0000 -1.0000
vn 1.0000 -0.0000 -0.0000 vn 1.0000 -0.0000 -0.0000
@@ -61,31 +60,30 @@ vt 0.375000 0.000000
vt 0.375000 0.500000 vt 0.375000 0.500000
vt 0.625000 1.000000 vt 0.625000 1.000000
s 0 s 0
f 6/5/2 16/6/2 20/7/2 f 6/5/2 15/6/2 19/7/2
f 17/8/3 18/9/3 23/10/3 f 16/8/3 17/9/3 22/10/3
f 18/9/4 10/11/4 9/12/4 f 17/9/4 10/11/4 9/12/4
f 10/11/5 5/13/5 9/12/5 f 10/11/5 5/13/5 9/12/5
f 14/14/5 6/15/5 13/11/5 f 13/14/6 8/15/6 6/15/6
f 14/14/6 8/15/6 6/15/6 f 21/16/3 22/10/3 17/9/3
f 22/16/3 23/10/3 18/9/3 f 8/17/3 18/18/3 20/19/3
f 8/17/3 19/18/3 21/19/3 f 19/7/3 20/19/3 7/20/3
f 20/7/3 21/19/3 7/20/3 f 16/8/3 14/21/3 12/22/3
f 17/8/3 15/21/3 12/22/3 f 12/22/7 13/14/7 10/11/7
f 14/14/7 12/22/7 15/21/7 f 6/15/5 10/11/5 13/14/5
f 7/20/2 5/23/2 6/5/2 f 7/20/2 5/23/2 6/5/2
f 6/5/2 8/17/2 16/6/2 f 6/5/2 8/17/2 15/6/2
f 20/7/2 7/20/2 6/5/2 f 19/7/2 7/20/2 6/5/2
f 23/10/3 19/18/3 17/8/3 f 22/10/3 18/18/3 16/8/3
f 17/8/3 12/22/3 18/9/3 f 16/8/3 12/22/3 17/9/3
f 9/12/4 11/24/4 22/16/4 f 9/12/4 11/24/4 21/16/4
f 18/9/4 12/22/4 10/11/4 f 17/9/4 12/22/4 10/11/4
f 9/12/4 22/16/4 18/9/4 f 9/12/4 21/16/4 17/9/4
f 10/11/5 6/25/5 5/13/5 f 10/11/5 6/25/5 5/13/5
f 14/14/6 15/21/6 8/15/6 f 13/14/6 14/21/6 8/15/6
f 22/16/3 11/24/3 23/10/3 f 21/16/3 11/24/3 22/10/3
f 21/19/3 16/6/3 8/17/3 f 20/19/3 15/6/3 8/17/3
f 8/17/3 17/8/3 19/18/3 f 8/17/3 16/8/3 18/18/3
f 20/7/3 16/6/3 21/19/3 f 19/7/3 15/6/3 20/19/3
f 17/8/3 8/15/3 15/21/3 f 16/8/3 8/15/3 14/21/3
f 14/14/7 13/11/7 12/22/7 f 12/22/7 14/21/7 13/14/7
l 10 13