przenieś fabułę i teksturowane obiekty do osobnych plików
This commit is contained in:
232
fabula.cpp
Normal file
232
fabula.cpp
Normal file
@@ -0,0 +1,232 @@
|
|||||||
|
#include "fabula.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<std::vector<bool>> wzory = {
|
||||||
|
|
||||||
|
// GK
|
||||||
|
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 1, 1, 1, 0, 1, 0, 0, 1, 0,
|
||||||
|
0, 1, 0, 0, 0, 1, 0, 1, 1, 0,
|
||||||
|
1, 1, 0, 0, 0, 1, 1, 1, 0, 0,
|
||||||
|
1, 0, 0, 0, 0, 1, 1, 0, 0, 0,
|
||||||
|
1, 0, 1, 1, 0, 1, 1, 0, 0, 0,
|
||||||
|
1, 0, 0, 1, 1, 1, 1, 1, 0, 0,
|
||||||
|
1, 1, 0, 0, 1, 1, 0, 1, 1, 0,
|
||||||
|
0, 1, 1, 1, 1, 1, 0, 0, 1, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 1, 1},
|
||||||
|
|
||||||
|
// Ślimak
|
||||||
|
{0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
|
||||||
|
1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
|
||||||
|
1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
1, 0, 0, 1, 1, 1, 1, 1, 1, 0,
|
||||||
|
1, 0, 1, 1, 0, 0, 0, 0, 1, 0,
|
||||||
|
1, 0, 1, 0, 1, 0, 0, 0, 1, 0,
|
||||||
|
1, 0, 1, 1, 1, 0, 0, 0, 1, 0,
|
||||||
|
1, 0, 0, 0, 0, 1, 1, 1, 1, 0,
|
||||||
|
1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
|
||||||
|
// Sygnał TTL
|
||||||
|
{0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
|
||||||
|
1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
|
||||||
|
1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 1, 1, 1, 1, 1, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
|
||||||
|
0, 0, 0, 0, 1, 1, 1, 1, 1, 0,
|
||||||
|
1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
|
||||||
|
1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
|
||||||
|
|
||||||
|
// Okrąg
|
||||||
|
{0, 0, 1, 1, 1, 1, 1, 0, 0, 0,
|
||||||
|
0, 1, 1, 0, 0, 0, 1, 1, 1, 0,
|
||||||
|
0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
|
||||||
|
1, 1, 0, 0, 0, 0, 0, 0, 1, 1,
|
||||||
|
1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
|
||||||
|
1, 1, 0, 0, 0, 0, 0, 0, 1, 1,
|
||||||
|
0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
|
||||||
|
0, 1, 1, 0, 0, 0, 0, 1, 1, 0,
|
||||||
|
0, 0, 1, 1, 1, 0, 0, 1, 0, 0,
|
||||||
|
0, 0, 0, 0, 1, 1, 1, 1, 1, 1},
|
||||||
|
|
||||||
|
// Kwadrat
|
||||||
|
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
|
||||||
|
1, 0, 0, 0, 0, 0, 0, 1, 0, 0,
|
||||||
|
1, 0, 0, 0, 0, 0, 0, 1, 0, 0,
|
||||||
|
1, 0, 0, 0, 0, 0, 0, 1, 1, 1,
|
||||||
|
1, 0, 0, 0, 0, 0, 0, 1, 1, 1,
|
||||||
|
1, 0, 0, 0, 0, 0, 0, 1, 0, 0,
|
||||||
|
1, 0, 0, 0, 0, 0, 0, 1, 0, 0,
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
|
||||||
|
// ABACABA
|
||||||
|
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
|
||||||
|
0, 0, 0, 1, 0, 0, 0, 1, 0, 0,
|
||||||
|
0, 0, 0, 1, 0, 0, 0, 1, 0, 0,
|
||||||
|
0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
|
||||||
|
0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
|
||||||
|
|
||||||
|
// Paski
|
||||||
|
{1, 1, 1, 0, 1, 0, 1, 0, 1, 0,
|
||||||
|
1, 0, 1, 1, 1, 0, 1, 0, 1, 0,
|
||||||
|
1, 0, 1, 0, 1, 1, 1, 0, 1, 0,
|
||||||
|
1, 0, 1, 0, 1, 0, 1, 1, 1, 0,
|
||||||
|
1, 0, 1, 0, 1, 0, 1, 0, 1, 1,
|
||||||
|
1, 0, 1, 0, 1, 0, 1, 0, 1, 1,
|
||||||
|
1, 0, 1, 0, 1, 0, 1, 1, 1, 0,
|
||||||
|
1, 0, 1, 0, 1, 1, 1, 0, 1, 0,
|
||||||
|
1, 0, 1, 1, 1, 0, 1, 0, 1, 0,
|
||||||
|
1, 1, 1, 0, 1, 0, 1, 0, 1, 0},
|
||||||
|
|
||||||
|
// Puste pole
|
||||||
|
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<unsigned short> siatka = {
|
||||||
|
|
||||||
|
// Możliwe stany pól siatki:
|
||||||
|
// - 0 - niezamalowana, nie do zamalowania (zielony)
|
||||||
|
// - 1 - niezamalowana, do zamalowania (złoty)
|
||||||
|
// - 2 - zamalowana, nie do zamalowania (czerwony)
|
||||||
|
// - 3 - zamalowana, do zamalowania (jasnozielony)
|
||||||
|
|
||||||
|
// 1. bit mówi o tym, czy jest do zamalowania
|
||||||
|
// 2. bit mówi o tym, czy jest zamalowana
|
||||||
|
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
void sprawdzPostepGry() {
|
||||||
|
unsigned short zgodne_pola = 0;
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
for (int j = 0; j < 10; j++) {
|
||||||
|
// std::cout << "zgp: " << zgodne_pola << "\n";
|
||||||
|
unsigned short pole_w_siatce = siatka[10*i + (9 - j)];
|
||||||
|
bool pole_we_wzorach = wzory[biezacy_wzor][10*i + (9 - j)];
|
||||||
|
if (pole_w_siatce == 0 && pole_we_wzorach == 0) zgodne_pola++;
|
||||||
|
else if (pole_w_siatce == 3 && pole_we_wzorach == 1) zgodne_pola++;
|
||||||
|
else {
|
||||||
|
// std::cout << "dla i=" << i << " j=" << j << " otrzymano p_w_s " << pole_w_siatce << " a spodziewano sie p_w_w: " << pole_we_wzorach << "\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (zgodne_pola == 100) {
|
||||||
|
biezacy_wzor = (biezacy_wzor + 1) % (wzory.size() + 1);
|
||||||
|
Foward = 45.0f;
|
||||||
|
Sides = -45.0f;
|
||||||
|
Rotation = 270.0f;
|
||||||
|
nadpiszNowaSiatke(biezacy_wzor);
|
||||||
|
} else {
|
||||||
|
// std::cout << "zgodne_pola: " << zgodne_pola << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ustalPozycjeGracza(GLfloat gracz_x, GLfloat gracz_z, short &grid_x, short &grid_z) {
|
||||||
|
grid_x = static_cast<int>(gracz_x) / 90;
|
||||||
|
grid_z = static_cast<int>(gracz_z) / 90;
|
||||||
|
|
||||||
|
// zapobiega rysowaniu ze "spawna"
|
||||||
|
if (gracz_x < 0 && gracz_x > -90) grid_x = -1; // ten przypadek dotyczy tylko noclipa
|
||||||
|
if (gracz_z < 0 && gracz_z > -90) grid_z = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ustawSiatkeNaWzorNieNadpisujacPostepu() {
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
for (int j = 0; j < 10; j++) {
|
||||||
|
bool ma_byc_zamalowana = wzory[biezacy_wzor][10*i + (10 - j)];
|
||||||
|
if (ma_byc_zamalowana) siatka[10*i + (10 - j)] |= 1;
|
||||||
|
else siatka[10*i + (10 - j)] = siatka[10*i + (10 - j)] - siatka[10*i + (10 - j)] % 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void nadpiszNowaSiatke(short nowy_wzor) {
|
||||||
|
std::cout << "Przepisz zawartosc siatki!\n";
|
||||||
|
biezacy_wzor = nowy_wzor;
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
for (int j = 0; j < 10; j++) {
|
||||||
|
siatka[10*i + (10 - j)] = static_cast<unsigned short>(wzory[biezacy_wzor][10*i + (10 - j)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void tworzKratke(unsigned int grid_x, unsigned int grid_z, unsigned short grid_value) {
|
||||||
|
|
||||||
|
// https://rgbcolorpicker.com/0-1
|
||||||
|
switch (grid_value) {
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
// niezamalowana, nie do zamalowania (zielony)
|
||||||
|
glColor3d(0.031, 0.51, 0.094);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
// niezamalowana, do zamalowania (złoty)
|
||||||
|
glColor3d(0.7, 0.5, 0.259);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
// zamalowana, nie do zamalowania (czerwony)
|
||||||
|
glColor3d(1, 0.122, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
// zamalowana, do zamalowania (biały)
|
||||||
|
glColor3d(1, 1, 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
platforma(45.0f + grid_x * 90.0f, 0.0f, 45.0f + grid_z * 90.0f, 45.0f, 45.0f);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void tworzKratkiZSiatki() {
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
// Aby nie musieć rysować wzorów w odbiciu
|
||||||
|
// lustrzanym, musimy tutaj przyjąć inną sekwencję
|
||||||
|
for (int j = 0; j < 10; j++) {
|
||||||
|
tworzKratke(i, j, siatka[10*i + (9 - j)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void aktualizujBiezacaKratke(short grid_x, short grid_z) {
|
||||||
|
if (grid_x < 0 || grid_z < 0) return;
|
||||||
|
unsigned short a = siatka[10*grid_x + (9 - grid_z)];
|
||||||
|
siatka[10*grid_x + (9 - grid_z)] |= 2;
|
||||||
|
// jeżeli coś się zmieniło
|
||||||
|
if (siatka[10*grid_x + (9 - grid_z)] != a) {
|
||||||
|
sprawdzPostepGry();
|
||||||
|
}
|
||||||
|
}
|
||||||
18
fabula.hpp
Normal file
18
fabula.hpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <iostream>
|
||||||
|
#include "GL/glew.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
extern short biezacy_wzor;
|
||||||
|
extern float Foward;
|
||||||
|
extern float Sides;
|
||||||
|
extern float Rotation;
|
||||||
|
extern void platforma(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat xlen, GLfloat zlen);
|
||||||
|
|
||||||
|
void sprawdzPostepGry();
|
||||||
|
void ustalPozycjeGracza(GLfloat gracz_x, GLfloat gracz_z, short &grid_x, short &grid_z);
|
||||||
|
void ustawSiatkeNaWzorNieNadpisujacPostepu();
|
||||||
|
void nadpiszNowaSiatke(short nowy_wzor);
|
||||||
|
void tworzKratke(unsigned int grid_x, unsigned int grid_z, unsigned short grid_value);
|
||||||
|
void tworzKratkiZSiatki();
|
||||||
|
void aktualizujBiezacaKratke(short grid_x, short grid_z);
|
||||||
601
main.cpp
601
main.cpp
@@ -35,6 +35,8 @@
|
|||||||
#include "shader.hpp"
|
#include "shader.hpp"
|
||||||
#include "FPSCounter.cpp"
|
#include "FPSCounter.cpp"
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include "teksturowane.hpp"
|
||||||
|
#include "fabula.hpp"
|
||||||
|
|
||||||
using namespace glm;
|
using namespace glm;
|
||||||
|
|
||||||
@@ -73,7 +75,6 @@ BOOL APIENTRY AboutDlgProc(HWND hDlg, UINT message, UINT wParam, LONG lParam);
|
|||||||
|
|
||||||
void SetDCPixelFormat(HDC hDC);
|
void SetDCPixelFormat(HDC hDC);
|
||||||
|
|
||||||
static void platforma(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat xlen, GLfloat zlen);
|
|
||||||
void sprawdzPostepGry();
|
void sprawdzPostepGry();
|
||||||
void ustalPozycjeGracza(GLfloat gracz_x, GLfloat gracz_z, short &grid_x, short &grid_z);
|
void ustalPozycjeGracza(GLfloat gracz_x, GLfloat gracz_z, short &grid_x, short &grid_z);
|
||||||
void ustawSiatkeNaWzorNieNadpisujacPostepu();
|
void ustawSiatkeNaWzorNieNadpisujacPostepu();
|
||||||
@@ -93,7 +94,7 @@ bool panoramic_view = 0;
|
|||||||
//Zmienne do ruchu ##############################################^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
//Zmienne do ruchu ##############################################^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
FPSCounter fpsCounter;
|
FPSCounter fpsCounter;
|
||||||
|
|
||||||
static const int targetFPS = 144; // Celowany FPS
|
static const int targetFPS = 250; // Celowany FPS
|
||||||
//Fps counter
|
//Fps counter
|
||||||
static void LimitFPS(int targetFPS) {
|
static void LimitFPS(int targetFPS) {
|
||||||
static auto lastTime = std::chrono::high_resolution_clock::now();
|
static auto lastTime = std::chrono::high_resolution_clock::now();
|
||||||
@@ -130,7 +131,7 @@ float velocity = 0.0f; // Aktualna prędkość łazika
|
|||||||
float rotationVelocity = 0.0f; // Prędkość obrotu łazika
|
float rotationVelocity = 0.0f; // Prędkość obrotu łazika
|
||||||
|
|
||||||
|
|
||||||
const float friction = 0.1f; // Współczynnik tarcia (μ)
|
const float friction = 0.05f; // Współczynnik tarcia (μ)
|
||||||
const float maxSpeed = 2.0f; // Maksymalna prędkość łazika
|
const float maxSpeed = 2.0f; // Maksymalna prędkość łazika
|
||||||
const float acceleration = 0.2f;
|
const float acceleration = 0.2f;
|
||||||
|
|
||||||
@@ -330,233 +331,6 @@ std::vector<Plot> fences = {
|
|||||||
{10*90.0f, 3.0f, 405.0f, 990.0f, 4.0f, 0} // 0 - pionowo
|
{10*90.0f, 3.0f, 405.0f, 990.0f, 4.0f, 0} // 0 - pionowo
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<std::vector<bool>> wzory = {
|
|
||||||
|
|
||||||
// GK
|
|
||||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 1, 1, 1, 0, 1, 0, 0, 1, 0,
|
|
||||||
0, 1, 0, 0, 0, 1, 0, 1, 1, 0,
|
|
||||||
1, 1, 0, 0, 0, 1, 1, 1, 0, 0,
|
|
||||||
1, 0, 0, 0, 0, 1, 1, 0, 0, 0,
|
|
||||||
1, 0, 1, 1, 0, 1, 1, 0, 0, 0,
|
|
||||||
1, 0, 0, 1, 1, 1, 1, 1, 0, 0,
|
|
||||||
1, 1, 0, 0, 1, 1, 0, 1, 1, 0,
|
|
||||||
0, 1, 1, 1, 1, 1, 0, 0, 1, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1},
|
|
||||||
|
|
||||||
// Ślimak
|
|
||||||
{0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
|
|
||||||
1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 0, 0, 1, 1, 1, 1, 1, 1, 0,
|
|
||||||
1, 0, 1, 1, 0, 0, 0, 0, 1, 0,
|
|
||||||
1, 0, 1, 0, 1, 0, 0, 0, 1, 0,
|
|
||||||
1, 0, 1, 1, 1, 0, 0, 0, 1, 0,
|
|
||||||
1, 0, 0, 0, 0, 1, 1, 1, 1, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
|
||||||
|
|
||||||
// Sygnał TTL
|
|
||||||
{0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
|
|
||||||
1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 1, 1, 1, 1, 1, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
|
|
||||||
0, 0, 0, 0, 1, 1, 1, 1, 1, 0,
|
|
||||||
1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
|
|
||||||
1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
|
|
||||||
|
|
||||||
// Okrąg
|
|
||||||
{0, 0, 1, 1, 1, 1, 1, 0, 0, 0,
|
|
||||||
0, 1, 1, 0, 0, 0, 1, 1, 1, 0,
|
|
||||||
0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
|
|
||||||
1, 1, 0, 0, 0, 0, 0, 0, 1, 1,
|
|
||||||
1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
|
|
||||||
1, 1, 0, 0, 0, 0, 0, 0, 1, 1,
|
|
||||||
0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
|
|
||||||
0, 1, 1, 0, 0, 0, 0, 1, 1, 0,
|
|
||||||
0, 0, 1, 1, 1, 0, 0, 1, 0, 0,
|
|
||||||
0, 0, 0, 0, 1, 1, 1, 1, 1, 1},
|
|
||||||
|
|
||||||
// Kwadrat
|
|
||||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
|
|
||||||
1, 0, 0, 0, 0, 0, 0, 1, 0, 0,
|
|
||||||
1, 0, 0, 0, 0, 0, 0, 1, 0, 0,
|
|
||||||
1, 0, 0, 0, 0, 0, 0, 1, 1, 1,
|
|
||||||
1, 0, 0, 0, 0, 0, 0, 1, 1, 1,
|
|
||||||
1, 0, 0, 0, 0, 0, 0, 1, 0, 0,
|
|
||||||
1, 0, 0, 0, 0, 0, 0, 1, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
|
||||||
|
|
||||||
// ABACABA
|
|
||||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
|
|
||||||
0, 0, 0, 1, 0, 0, 0, 1, 0, 0,
|
|
||||||
0, 0, 0, 1, 0, 0, 0, 1, 0, 0,
|
|
||||||
0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
|
|
||||||
0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
|
|
||||||
|
|
||||||
// Paski
|
|
||||||
{1, 1, 1, 0, 1, 0, 1, 0, 1, 0,
|
|
||||||
1, 0, 1, 1, 1, 0, 1, 0, 1, 0,
|
|
||||||
1, 0, 1, 0, 1, 1, 1, 0, 1, 0,
|
|
||||||
1, 0, 1, 0, 1, 0, 1, 1, 1, 0,
|
|
||||||
1, 0, 1, 0, 1, 0, 1, 0, 1, 1,
|
|
||||||
1, 0, 1, 0, 1, 0, 1, 0, 1, 1,
|
|
||||||
1, 0, 1, 0, 1, 0, 1, 1, 1, 0,
|
|
||||||
1, 0, 1, 0, 1, 1, 1, 0, 1, 0,
|
|
||||||
1, 0, 1, 1, 1, 0, 1, 0, 1, 0,
|
|
||||||
1, 1, 1, 0, 1, 0, 1, 0, 1, 0},
|
|
||||||
|
|
||||||
// Puste pole
|
|
||||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<unsigned short> siatka = {
|
|
||||||
|
|
||||||
// Możliwe stany pól siatki:
|
|
||||||
// - 0 - niezamalowana, nie do zamalowania (zielony)
|
|
||||||
// - 1 - niezamalowana, do zamalowania (złoty)
|
|
||||||
// - 2 - zamalowana, nie do zamalowania (czerwony)
|
|
||||||
// - 3 - zamalowana, do zamalowania (jasnozielony)
|
|
||||||
|
|
||||||
// 1. bit mówi o tym, czy jest do zamalowania
|
|
||||||
// 2. bit mówi o tym, czy jest zamalowana
|
|
||||||
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
void sprawdzPostepGry() {
|
|
||||||
unsigned short zgodne_pola = 0;
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
for (int j = 0; j < 10; j++) {
|
|
||||||
std::cout << "zgp: " << zgodne_pola << "\n";
|
|
||||||
unsigned short pole_w_siatce = siatka[10*i + (9 - j)];
|
|
||||||
bool pole_we_wzorach = wzory[biezacy_wzor][10*i + (9 - j)];
|
|
||||||
if (pole_w_siatce == 0 && pole_we_wzorach == 0) zgodne_pola++;
|
|
||||||
else if (pole_w_siatce == 3 && pole_we_wzorach == 1) zgodne_pola++;
|
|
||||||
else {
|
|
||||||
std::cout << "dla i=" << i << " j=" << j << " otrzymano p_w_s " << pole_w_siatce << " a spodziewano sie p_w_w: " << pole_we_wzorach << "\n";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (zgodne_pola == 100) {
|
|
||||||
biezacy_wzor = (biezacy_wzor + 1) % (wzory.size() + 1);
|
|
||||||
nadpiszNowaSiatke(biezacy_wzor);
|
|
||||||
} else {
|
|
||||||
std::cout << "zgodne_pola: " << zgodne_pola << "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ustalPozycjeGracza(GLfloat gracz_x, GLfloat gracz_z, short &grid_x, short &grid_z) {
|
|
||||||
grid_x = static_cast<int>(gracz_x) / 90;
|
|
||||||
grid_z = static_cast<int>(gracz_z) / 90;
|
|
||||||
|
|
||||||
// zapobiega rysowaniu ze "spawna"
|
|
||||||
if (gracz_x < 0 && gracz_x > -90) grid_x = -1; // ten przypadek dotyczy tylko noclipa
|
|
||||||
if (gracz_z < 0 && gracz_z > -90) grid_z = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ustawSiatkeNaWzorNieNadpisujacPostepu() {
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
for (int j = 0; j < 10; j++) {
|
|
||||||
bool ma_byc_zamalowana = wzory[biezacy_wzor][10*i + (10 - j)];
|
|
||||||
if (ma_byc_zamalowana) siatka[10*i + (10 - j)] |= 1;
|
|
||||||
else siatka[10*i + (10 - j)] = siatka[10*i + (10 - j)] - siatka[10*i + (10 - j)] % 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void nadpiszNowaSiatke(short nowy_wzor) {
|
|
||||||
std::cout << "Przepisz zawartosc siatki!\n";
|
|
||||||
biezacy_wzor = nowy_wzor;
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
for (int j = 0; j < 10; j++) {
|
|
||||||
siatka[10*i + (10 - j)] = static_cast<unsigned short>(wzory[biezacy_wzor][10*i + (10 - j)]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void tworzKratke(unsigned int grid_x, unsigned int grid_z, unsigned short grid_value) {
|
|
||||||
|
|
||||||
// https://rgbcolorpicker.com/0-1
|
|
||||||
switch (grid_value) {
|
|
||||||
|
|
||||||
case 0:
|
|
||||||
// niezamalowana, nie do zamalowania (zielony)
|
|
||||||
glColor3d(0.031, 0.51, 0.094);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
// niezamalowana, do zamalowania (złoty)
|
|
||||||
glColor3d(0.7, 0.5, 0.259);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
// zamalowana, nie do zamalowania (czerwony)
|
|
||||||
glColor3d(1, 0.122, 0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
// zamalowana, do zamalowania (biały)
|
|
||||||
glColor3d(1, 1, 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
platforma(45.0f + grid_x * 90.0f, 0.0f, 45.0f + grid_z * 90.0f, 45.0f, 45.0f);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void tworzKratkiZSiatki() {
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
// Aby nie musieć rysować wzorów w odbiciu
|
|
||||||
// lustrzanym, musimy tutaj przyjąć inną sekwencję
|
|
||||||
for (int j = 0; j < 10; j++) {
|
|
||||||
tworzKratke(i, j, siatka[10*i + (9 - j)]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void aktualizujBiezacaKratke(short grid_x, short grid_z) {
|
|
||||||
if (grid_x < 0 || grid_z < 0) return;
|
|
||||||
unsigned short a = siatka[10*grid_x + (9 - grid_z)];
|
|
||||||
siatka[10*grid_x + (9 - grid_z)] |= 2;
|
|
||||||
// jeżeli coś się zmieniło
|
|
||||||
if (siatka[10*grid_x + (9 - grid_z)] != a) {
|
|
||||||
sprawdzPostepGry();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Change viewing volume and viewport. Called when window is resized
|
// Change viewing volume and viewport. Called when window is resized
|
||||||
void static ChangeSize(GLsizei w, GLsizei h) {
|
void static ChangeSize(GLsizei w, GLsizei h) {
|
||||||
GLfloat nRange = 100.0f;
|
GLfloat nRange = 100.0f;
|
||||||
@@ -681,363 +455,6 @@ void SetDCPixelFormat(HDC hDC) {
|
|||||||
SetPixelFormat(hDC, nPixelFormat, &pfd);
|
SetPixelFormat(hDC, nPixelFormat, &pfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void skrzynka(GLfloat k) {
|
|
||||||
glColor3d(0.8, 0.7, 0.3);
|
|
||||||
|
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D); // Włącz teksturowanie
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture[0]);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glNormal3d(0, 0, 1);
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d( k, k, k);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(-k, k, k);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(-k, -k, k);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d( k, -k, k);
|
|
||||||
glEnd();
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture[1]);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glNormal3d(1, 0, 0);
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(k, k, k);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(k, -k, k);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(k, -k, -k);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(k, k, -k);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D); // Wyłącz teksturowanie
|
|
||||||
|
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glNormal3d(0, 0, -1);
|
|
||||||
glVertex3d( k, k, -k);
|
|
||||||
glVertex3d( k, -k, -k);
|
|
||||||
glVertex3d(-k, -k, -k);
|
|
||||||
glVertex3d(-k, k, -k);
|
|
||||||
|
|
||||||
glNormal3d(-1, 0, 0);
|
|
||||||
glVertex3d(-k, k, -k);
|
|
||||||
glVertex3d(-k, -k, -k);
|
|
||||||
glVertex3d(-k, -k, k);
|
|
||||||
glVertex3d(-k, k, k);
|
|
||||||
|
|
||||||
glNormal3d(0, 1, 0);
|
|
||||||
glVertex3d( k, k, k);
|
|
||||||
glVertex3d( k, k, -k);
|
|
||||||
glVertex3d(-k, k, -k);
|
|
||||||
glVertex3d(-k, k, k);
|
|
||||||
|
|
||||||
glNormal3d(0, -1, 0);
|
|
||||||
glVertex3d( k, -k, k);
|
|
||||||
glVertex3d(-k, -k, k);
|
|
||||||
glVertex3d(-k, -k, -k);
|
|
||||||
glVertex3d( k, -k, -k);
|
|
||||||
glEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void platforma(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat xlen, GLfloat zlen) {
|
|
||||||
// glColor3d(0.729, 0.91, 0.51); // jasnozielony, dla grass02.bmp
|
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture[1]); // Wybieramy teksturę
|
|
||||||
|
|
||||||
// Ustawienie powtarzania tekstury
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); // Powtarzanie w kierunku S
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); // Powtarzanie w kierunku T
|
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
// Powtarzające się współrzędne tekstury (np. *5, aby powtórzyła się 5 razy)
|
|
||||||
glTexCoord2d(5.0, 5.0); glVertex3d(xc - xlen, yc, zc - zlen); // Lewy dolny
|
|
||||||
glTexCoord2d(5.0, 0.0); glVertex3d(xc + xlen, yc, zc - zlen); // Prawy dolny
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(xc + xlen, yc, zc + zlen); // Prawy górny
|
|
||||||
glTexCoord2d(0.0, 5.0); glVertex3d(xc - xlen, yc, zc + zlen); // Lewy górny
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void stodola(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat krawedz) {
|
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
|
|
||||||
// ściany stodoły z bruku (brickwall)
|
|
||||||
glColor3d(0.612f, 0.573f, 0.478f); // ciemny szary popadający w brąz (https://rgbcolorpicker.com/0-1)
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture[3]);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(xc - krawedz/2, yc, zc - krawedz/2);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(xc - krawedz/2, yc + krawedz, zc - krawedz/2);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(xc + krawedz/2, yc + krawedz, zc - krawedz/2);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(xc + krawedz/2, yc, zc - krawedz/2);
|
|
||||||
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(xc - krawedz/2, yc, zc - krawedz/2);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(xc - krawedz/2, yc + krawedz, zc - krawedz/2);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(xc - krawedz/2, yc + krawedz, zc + krawedz/2);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(xc - krawedz/2, yc, zc + krawedz/2);
|
|
||||||
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(xc - krawedz/2, yc, zc + krawedz/2);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(xc - krawedz/2, yc + krawedz, zc + krawedz/2);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(xc + krawedz/2, yc + krawedz, zc + krawedz/2);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(xc + krawedz/2, yc, zc + krawedz/2);
|
|
||||||
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
// przód i tył dachu
|
|
||||||
glColor3d(0.612f, 0.573f, 0.478f);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture[3]);
|
|
||||||
glBegin(GL_TRIANGLES);
|
|
||||||
|
|
||||||
glTexCoord2f(1.0, 1.0); glVertex3f(xc - krawedz/2, yc + krawedz, zc - krawedz/2);
|
|
||||||
glTexCoord2f(1.0, 0.0); glVertex3f(xc - krawedz/2, yc + 1.5 * krawedz, zc);
|
|
||||||
glTexCoord2f(0.0, 0.0); glVertex3f(xc - krawedz/2, yc + krawedz, zc + krawedz/2);
|
|
||||||
|
|
||||||
glTexCoord2f(1.0, 1.0); glVertex3f(xc + krawedz/2, yc + krawedz, zc - krawedz/2);
|
|
||||||
glTexCoord2f(1.0, 0.0); glVertex3f(xc + krawedz/2, yc + 1.5 * krawedz, zc);
|
|
||||||
glTexCoord2f(0.0, 0.0); glVertex3f(xc + krawedz/2, yc + krawedz, zc + krawedz/2);
|
|
||||||
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
|
|
||||||
// dach stodoły (barnroof)
|
|
||||||
glColor3d(0.639, 0.553, 0.322); // wyblakły brązowy
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture[2]);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(xc - krawedz/2, yc + krawedz, zc + krawedz/2);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(xc - krawedz/2, yc + 1.5 * krawedz, zc);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(xc + krawedz/2, yc + 1.5 * krawedz, zc);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(xc + krawedz/2, yc + krawedz, zc + krawedz/2);
|
|
||||||
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(xc - krawedz/2, yc + krawedz, zc - krawedz/2);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(xc - krawedz/2, yc + 1.5 * krawedz, zc);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(xc + krawedz/2, yc + 1.5 * krawedz, zc);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(xc + krawedz/2, yc + krawedz, zc - krawedz/2);
|
|
||||||
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void plot(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat length, GLfloat gruboscY, bool mod_x)
|
|
||||||
{
|
|
||||||
|
|
||||||
GLfloat grubosc = 1.0f;
|
|
||||||
|
|
||||||
// timestampedCout("main.cpp (plot): otrzymano xc=" << xc << " yc=" << yc << " zc=" << zc << " length=" << length << " mod_x=" << mod_x);
|
|
||||||
|
|
||||||
GLfloat gruboscX = grubosc + mod_x * length;
|
|
||||||
GLfloat gruboscZ = grubosc + !mod_x * length;
|
|
||||||
|
|
||||||
// timestampedCout("main.cpp (plot): gruboscX=" << gruboscX << " gruboscY=" << gruboscY << " gruboscZ=" << gruboscZ);
|
|
||||||
|
|
||||||
// d-----------c Y
|
|
||||||
// / /| ^
|
|
||||||
// a-----------b | \
|
|
||||||
// | h | g C->X
|
|
||||||
// | |/ |
|
|
||||||
// e-----------f v
|
|
||||||
// Z (płaszczyzna XZ, Y to trzeci wymiar)
|
|
||||||
|
|
||||||
GLfloat a1_x = xc - gruboscX / 2, a1_y = yc + 1 + gruboscY, a1_z = zc + gruboscZ / 2; // 3
|
|
||||||
GLfloat b1_x = xc + gruboscX / 2, b1_y = yc + 1 + gruboscY, b1_z = zc + gruboscZ / 2;
|
|
||||||
GLfloat c1_x = xc + gruboscX / 2, c1_y = yc + 1 + gruboscY, c1_z = zc - gruboscZ / 2;
|
|
||||||
GLfloat d1_x = xc - gruboscX / 2, d1_y = yc + 1 + gruboscY, d1_z = zc - gruboscZ / 2;
|
|
||||||
GLfloat e1_x = xc - gruboscX / 2, e1_y = yc + 1 , e1_z = zc + gruboscZ / 2; // 1
|
|
||||||
GLfloat f1_x = xc + gruboscX / 2, f1_y = yc + 1 , f1_z = zc + gruboscZ / 2;
|
|
||||||
GLfloat g1_x = xc + gruboscX / 2, g1_y = yc + 1 , g1_z = zc - gruboscZ / 2;
|
|
||||||
GLfloat h1_x = xc - gruboscX / 2, h1_y = yc + 1 , h1_z = zc - gruboscZ / 2;
|
|
||||||
|
|
||||||
GLfloat a2_x = a1_x, a2_y = a1_y - 1 - gruboscY, a2_z = a1_z; //zc - 1; // -4
|
|
||||||
GLfloat b2_x = b1_x, b2_y = b1_y - 1 - gruboscY, b2_z = b1_z; //zc - 1;
|
|
||||||
GLfloat c2_x = c1_x, c2_y = c1_y - 1 - gruboscY, c2_z = c1_z; //zc - 1;
|
|
||||||
GLfloat d2_x = d1_x, d2_y = d1_y - 1 - gruboscY, d2_z = d1_z; //zc - 1;
|
|
||||||
GLfloat e2_x = e1_x, e2_y = e1_y - 1 - gruboscY, e2_z = e1_z; //zc - 2;
|
|
||||||
GLfloat f2_x = f1_x, f2_y = f1_y - 1 - gruboscY, f2_z = f1_z; //zc - 2;
|
|
||||||
GLfloat g2_x = g1_x, g2_y = g1_y - 1 - gruboscY, g2_z = g1_z; //zc - 2;
|
|
||||||
GLfloat h2_x = h1_x, h2_y = h1_y - 1 - gruboscY, h2_z = h1_z; //zc - 2;
|
|
||||||
|
|
||||||
glColor3d(0.71, 0.522, 0.067);
|
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture[0]);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
|
|
||||||
// Góra (1_x, 1_y, 1_z):
|
|
||||||
// ABCD
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(a1_x, a1_y, a1_z);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(b1_x, b1_y, b1_z);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(c1_x, c1_y, c1_z);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(d1_x, d1_y, d1_z);
|
|
||||||
|
|
||||||
// EFGH
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(e1_x, e1_y, e1_z);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(f1_x, f1_y, f1_z);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(g1_x, g1_y, g1_z);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(h1_x, h1_y, h1_z);
|
|
||||||
|
|
||||||
// BCGF
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(b1_x, b1_y, b1_z);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(c1_x, c1_y, c1_z);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(g1_x, g1_y, g1_z);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(f1_x, f1_y, f1_z);
|
|
||||||
|
|
||||||
// ADHE
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(a1_x, a1_y, a1_z);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(b1_x, b1_y, b1_z);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(c1_x, c1_y, c1_z);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(d1_x, d1_y, d1_z);
|
|
||||||
|
|
||||||
// ABFE
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(a1_x, a1_y, a1_z);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(b1_x, b1_y, b1_z);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(f1_x, f1_y, f1_z);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(e1_x, e1_y, e1_z);
|
|
||||||
|
|
||||||
// DCGH
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(d1_x, d1_y, d1_z);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(c1_x, c1_y, c1_z);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(g1_x, g1_y, g1_z);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(h1_x, h1_y, h1_z);
|
|
||||||
|
|
||||||
// Dół (2_x, 2_y, 2_z):
|
|
||||||
// ABCD
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(a2_x, a2_y, a2_z);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(b2_x, b2_y, b2_z);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(c2_x, c2_y, c2_z);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(d2_x, d2_y, d2_z);
|
|
||||||
|
|
||||||
// EFGH
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(e2_x, e2_y, e2_z);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(f2_x, f2_y, f2_z);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(g2_x, g2_y, g2_z);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(h2_x, h2_y, h2_z);
|
|
||||||
|
|
||||||
// BCGF
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(b2_x, b2_y, b2_z);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(c2_x, c2_y, c2_z);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(g2_x, g2_y, g2_z);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(f2_x, f2_y, f2_z);
|
|
||||||
|
|
||||||
// ADHE
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(a2_x, a2_y, a2_z);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(b2_x, b2_y, b2_z);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(c2_x, c2_y, c2_z);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(d2_x, d2_y, d2_z);
|
|
||||||
|
|
||||||
// ABFE
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(a2_x, a2_y, a2_z);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(b2_x, b2_y, b2_z);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(f2_x, f2_y, f2_z);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(e2_x, e2_y, e2_z);
|
|
||||||
|
|
||||||
// DCGH
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(d2_x, d2_y, d2_z);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(c2_x, c2_y, c2_z);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(g2_x, g2_y, g2_z);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(h2_x, h2_y, h2_z);
|
|
||||||
|
|
||||||
// Pachołki
|
|
||||||
|
|
||||||
// d-----------c Y
|
|
||||||
// / /| ^
|
|
||||||
// a-----------b | \
|
|
||||||
// | h | g C->X
|
|
||||||
// | |/ |
|
|
||||||
// e-----------f v
|
|
||||||
// Z (płaszczyzna XZ, Y to trzeci wymiar)
|
|
||||||
|
|
||||||
|
|
||||||
GLfloat p_a_x, p_a_y, p_a_z;
|
|
||||||
GLfloat p_b_x, p_b_y, p_b_z;
|
|
||||||
GLfloat p_c_x, p_c_y, p_c_z;
|
|
||||||
GLfloat p_d_x, p_d_y, p_d_z;
|
|
||||||
GLfloat p_e_x, p_e_y, p_e_z;
|
|
||||||
GLfloat p_f_x, p_f_y, p_f_z;
|
|
||||||
GLfloat p_g_x, p_g_y, p_g_z;
|
|
||||||
GLfloat p_h_x, p_h_y, p_h_z;
|
|
||||||
|
|
||||||
if (!mod_x) {
|
|
||||||
|
|
||||||
p_a_x = xc + gruboscX / 2, p_a_y = yc + 1.5f * gruboscY, p_a_z = zc; // +3 dla y
|
|
||||||
p_b_x = xc - gruboscX / 2, p_b_y = yc + 1.5f * gruboscY, p_b_z = zc; // +3 dla y
|
|
||||||
p_c_x = xc + gruboscX / 2, p_c_y = yc + 1.5f * gruboscY, p_c_z = zc; // +3 dla y
|
|
||||||
p_d_x = xc - gruboscX / 2, p_d_y = yc + 1.5f * gruboscY, p_d_z = zc; // +3 dla y
|
|
||||||
p_e_x = xc + gruboscX / 2, p_e_y = yc - 6 , p_e_z = zc;
|
|
||||||
p_f_x = xc - gruboscX / 2, p_f_y = yc - 6 , p_f_z = zc;
|
|
||||||
p_g_x = xc + gruboscX / 2, p_g_y = yc - 6 , p_g_z = zc;
|
|
||||||
p_h_x = xc - gruboscX / 2, p_h_y = yc - 6 , p_h_z = zc;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
p_a_x = xc, p_a_y = yc + 1.5f * gruboscY, p_a_z = zc - gruboscZ / 2; // +3 dla y
|
|
||||||
p_b_x = xc, p_b_y = yc + 1.5f * gruboscY, p_b_z = zc - gruboscZ / 2; // +3 dla y
|
|
||||||
p_c_x = xc, p_c_y = yc + 1.5f * gruboscY, p_c_z = zc + gruboscZ / 2; // +3 dla y
|
|
||||||
p_d_x = xc, p_d_y = yc + 1.5f * gruboscY, p_d_z = zc + gruboscZ / 2; // +3 dla y
|
|
||||||
p_e_x = xc, p_e_y = yc - 6 , p_e_z = zc - gruboscZ / 2;
|
|
||||||
p_f_x = xc, p_f_y = yc - 6 , p_f_z = zc - gruboscZ / 2;
|
|
||||||
p_g_x = xc, p_g_y = yc - 6 , p_g_z = zc + gruboscZ / 2;
|
|
||||||
p_h_x = xc, p_h_y = yc - 6 , p_h_z = zc + gruboscZ / 2;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
|
||||||
|
|
||||||
// d-----------c Y
|
|
||||||
// / /| ^
|
|
||||||
// a-----------b | \
|
|
||||||
// | h | g C->X
|
|
||||||
// | |/ |
|
|
||||||
// e-----------f v
|
|
||||||
// Z (płaszczyzna XZ, Y to trzeci wymiar)
|
|
||||||
|
|
||||||
// timestampedCout("main.cpp (plot): p_a_x=" << p_a_x << " p_b_x=" << p_b_x << " p_c_x=" << p_c_x << " p_d_x=" << p_d_x);
|
|
||||||
|
|
||||||
// ABCD
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(p_a_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_a_y, p_a_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(p_b_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_b_y, p_b_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(p_c_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_c_y, p_c_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(p_d_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_d_y, p_d_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
|
||||||
|
|
||||||
// EFGH
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(p_e_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_e_y, p_e_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(p_f_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_f_y, p_f_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(p_g_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_g_y, p_g_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(p_h_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_h_y, p_h_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
|
||||||
|
|
||||||
// BCGF
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(p_b_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_b_y, p_b_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(p_c_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_c_y, p_c_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(p_g_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_g_y, p_g_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(p_f_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_f_y, p_f_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
|
||||||
|
|
||||||
// ADHE
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(p_a_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_a_y, p_a_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(p_d_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_d_y, p_d_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(p_h_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_h_y, p_h_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(p_e_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_e_y, p_e_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
|
||||||
|
|
||||||
// ABFE
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(p_a_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_a_y, p_a_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(p_b_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_b_y, p_b_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(p_f_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_f_y, p_f_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(p_e_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_e_y, p_e_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
|
||||||
|
|
||||||
// DCGH
|
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(p_d_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_d_y, p_d_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(p_c_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_c_y, p_c_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(p_g_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_g_y, p_g_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(p_h_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_h_y, p_h_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//GLuint programID, VertexArrayID, MatrixID;
|
//GLuint programID, VertexArrayID, MatrixID;
|
||||||
lazik user(10.0f, 0.0f, 0.0f, "res/models/lazik4.obj"); // obiekty eksportujemy z Forward Axis Z, Up Axis Y.
|
lazik user(10.0f, 0.0f, 0.0f, "res/models/lazik4.obj"); // obiekty eksportujemy z Forward Axis Z, Up Axis Y.
|
||||||
plane mapa( 0.0f, 0.0f, 0.0f, "res/models/mapka3_nofence_noplatform.obj");
|
plane mapa( 0.0f, 0.0f, 0.0f, "res/models/mapka3_nofence_noplatform.obj");
|
||||||
@@ -1084,11 +501,11 @@ static void SetupRC() {
|
|||||||
glEnable(GL_LIGHT2);
|
glEnable(GL_LIGHT2);
|
||||||
|
|
||||||
// Setup and enable light 3
|
// Setup and enable light 3
|
||||||
glLightfv(GL_LIGHT3, GL_AMBIENT, ambientLight);
|
// glLightfv(GL_LIGHT3, GL_AMBIENT, ambientLight);
|
||||||
glLightfv(GL_LIGHT3, GL_DIFFUSE, diffuseLight);
|
// glLightfv(GL_LIGHT3, GL_DIFFUSE, diffuseLight);
|
||||||
glLightfv(GL_LIGHT3, GL_SPECULAR, specular);
|
// glLightfv(GL_LIGHT3, GL_SPECULAR, specular);
|
||||||
glLightfv(GL_LIGHT3, GL_POSITION, lightPos4);
|
// glLightfv(GL_LIGHT3, GL_POSITION, lightPos4);
|
||||||
glEnable(GL_LIGHT3);
|
// glEnable(GL_LIGHT3);
|
||||||
|
|
||||||
// Enable color tracking
|
// Enable color tracking
|
||||||
glEnable(GL_COLOR_MATERIAL);
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
|
|||||||
357
teksturowane.cpp
Normal file
357
teksturowane.cpp
Normal file
@@ -0,0 +1,357 @@
|
|||||||
|
#include "teksturowane.hpp"
|
||||||
|
|
||||||
|
void skrzynka(GLfloat k) {
|
||||||
|
glColor3d(0.8, 0.7, 0.3);
|
||||||
|
|
||||||
|
|
||||||
|
glEnable(GL_TEXTURE_2D); // Włącz teksturowanie
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture[0]);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glNormal3d(0, 0, 1);
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d( k, k, k);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(-k, k, k);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(-k, -k, k);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d( k, -k, k);
|
||||||
|
glEnd();
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture[1]);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glNormal3d(1, 0, 0);
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(k, k, k);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(k, -k, k);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(k, -k, -k);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(k, k, -k);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glDisable(GL_TEXTURE_2D); // Wyłącz teksturowanie
|
||||||
|
|
||||||
|
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glNormal3d(0, 0, -1);
|
||||||
|
glVertex3d( k, k, -k);
|
||||||
|
glVertex3d( k, -k, -k);
|
||||||
|
glVertex3d(-k, -k, -k);
|
||||||
|
glVertex3d(-k, k, -k);
|
||||||
|
|
||||||
|
glNormal3d(-1, 0, 0);
|
||||||
|
glVertex3d(-k, k, -k);
|
||||||
|
glVertex3d(-k, -k, -k);
|
||||||
|
glVertex3d(-k, -k, k);
|
||||||
|
glVertex3d(-k, k, k);
|
||||||
|
|
||||||
|
glNormal3d(0, 1, 0);
|
||||||
|
glVertex3d( k, k, k);
|
||||||
|
glVertex3d( k, k, -k);
|
||||||
|
glVertex3d(-k, k, -k);
|
||||||
|
glVertex3d(-k, k, k);
|
||||||
|
|
||||||
|
glNormal3d(0, -1, 0);
|
||||||
|
glVertex3d( k, -k, k);
|
||||||
|
glVertex3d(-k, -k, k);
|
||||||
|
glVertex3d(-k, -k, -k);
|
||||||
|
glVertex3d( k, -k, -k);
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
void platforma(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat xlen, GLfloat zlen) {
|
||||||
|
// glColor3d(0.729, 0.91, 0.51); // jasnozielony, dla grass02.bmp
|
||||||
|
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture[1]); // Wybieramy teksturę
|
||||||
|
|
||||||
|
// Ustawienie powtarzania tekstury
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); // Powtarzanie w kierunku S
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); // Powtarzanie w kierunku T
|
||||||
|
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
// Powtarzające się współrzędne tekstury (np. *5, aby powtórzyła się 5 razy)
|
||||||
|
glTexCoord2d(5.0, 5.0); glVertex3d(xc - xlen, yc, zc - zlen); // Lewy dolny
|
||||||
|
glTexCoord2d(5.0, 0.0); glVertex3d(xc + xlen, yc, zc - zlen); // Prawy dolny
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(xc + xlen, yc, zc + zlen); // Prawy górny
|
||||||
|
glTexCoord2d(0.0, 5.0); glVertex3d(xc - xlen, yc, zc + zlen); // Lewy górny
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void stodola(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat krawedz) {
|
||||||
|
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
// ściany stodoły z bruku (brickwall)
|
||||||
|
glColor3d(0.612f, 0.573f, 0.478f); // ciemny szary popadający w brąz (https://rgbcolorpicker.com/0-1)
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture[3]);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(xc - krawedz/2, yc, zc - krawedz/2);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(xc - krawedz/2, yc + krawedz, zc - krawedz/2);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(xc + krawedz/2, yc + krawedz, zc - krawedz/2);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(xc + krawedz/2, yc, zc - krawedz/2);
|
||||||
|
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(xc - krawedz/2, yc, zc - krawedz/2);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(xc - krawedz/2, yc + krawedz, zc - krawedz/2);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(xc - krawedz/2, yc + krawedz, zc + krawedz/2);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(xc - krawedz/2, yc, zc + krawedz/2);
|
||||||
|
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(xc - krawedz/2, yc, zc + krawedz/2);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(xc - krawedz/2, yc + krawedz, zc + krawedz/2);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(xc + krawedz/2, yc + krawedz, zc + krawedz/2);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(xc + krawedz/2, yc, zc + krawedz/2);
|
||||||
|
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
// przód i tył dachu
|
||||||
|
glColor3d(0.612f, 0.573f, 0.478f);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture[3]);
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
|
||||||
|
glTexCoord2f(1.0, 1.0); glVertex3f(xc - krawedz/2, yc + krawedz, zc - krawedz/2);
|
||||||
|
glTexCoord2f(1.0, 0.0); glVertex3f(xc - krawedz/2, yc + 1.5 * krawedz, zc);
|
||||||
|
glTexCoord2f(0.0, 0.0); glVertex3f(xc - krawedz/2, yc + krawedz, zc + krawedz/2);
|
||||||
|
|
||||||
|
glTexCoord2f(1.0, 1.0); glVertex3f(xc + krawedz/2, yc + krawedz, zc - krawedz/2);
|
||||||
|
glTexCoord2f(1.0, 0.0); glVertex3f(xc + krawedz/2, yc + 1.5 * krawedz, zc);
|
||||||
|
glTexCoord2f(0.0, 0.0); glVertex3f(xc + krawedz/2, yc + krawedz, zc + krawedz/2);
|
||||||
|
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
|
||||||
|
// dach stodoły (barnroof)
|
||||||
|
glColor3d(0.639, 0.553, 0.322); // wyblakły brązowy
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture[2]);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(xc - krawedz/2, yc + krawedz, zc + krawedz/2);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(xc - krawedz/2, yc + 1.5 * krawedz, zc);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(xc + krawedz/2, yc + 1.5 * krawedz, zc);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(xc + krawedz/2, yc + krawedz, zc + krawedz/2);
|
||||||
|
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(xc - krawedz/2, yc + krawedz, zc - krawedz/2);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(xc - krawedz/2, yc + 1.5 * krawedz, zc);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(xc + krawedz/2, yc + 1.5 * krawedz, zc);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(xc + krawedz/2, yc + krawedz, zc - krawedz/2);
|
||||||
|
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void plot(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat length, GLfloat gruboscY, bool mod_x) {
|
||||||
|
|
||||||
|
GLfloat grubosc = 1.0f;
|
||||||
|
|
||||||
|
// timestampedCout("main.cpp (plot): otrzymano xc=" << xc << " yc=" << yc << " zc=" << zc << " length=" << length << " mod_x=" << mod_x);
|
||||||
|
|
||||||
|
GLfloat gruboscX = grubosc + mod_x * length;
|
||||||
|
GLfloat gruboscZ = grubosc + !mod_x * length;
|
||||||
|
|
||||||
|
// timestampedCout("main.cpp (plot): gruboscX=" << gruboscX << " gruboscY=" << gruboscY << " gruboscZ=" << gruboscZ);
|
||||||
|
|
||||||
|
// d-----------c Y
|
||||||
|
// / /| ^
|
||||||
|
// a-----------b | \
|
||||||
|
// | h | g C->X
|
||||||
|
// | |/ |
|
||||||
|
// e-----------f v
|
||||||
|
// Z (płaszczyzna XZ, Y to trzeci wymiar)
|
||||||
|
|
||||||
|
GLfloat a1_x = xc - gruboscX / 2, a1_y = yc + 1 + gruboscY, a1_z = zc + gruboscZ / 2; // 3
|
||||||
|
GLfloat b1_x = xc + gruboscX / 2, b1_y = yc + 1 + gruboscY, b1_z = zc + gruboscZ / 2;
|
||||||
|
GLfloat c1_x = xc + gruboscX / 2, c1_y = yc + 1 + gruboscY, c1_z = zc - gruboscZ / 2;
|
||||||
|
GLfloat d1_x = xc - gruboscX / 2, d1_y = yc + 1 + gruboscY, d1_z = zc - gruboscZ / 2;
|
||||||
|
GLfloat e1_x = xc - gruboscX / 2, e1_y = yc + 1 , e1_z = zc + gruboscZ / 2; // 1
|
||||||
|
GLfloat f1_x = xc + gruboscX / 2, f1_y = yc + 1 , f1_z = zc + gruboscZ / 2;
|
||||||
|
GLfloat g1_x = xc + gruboscX / 2, g1_y = yc + 1 , g1_z = zc - gruboscZ / 2;
|
||||||
|
GLfloat h1_x = xc - gruboscX / 2, h1_y = yc + 1 , h1_z = zc - gruboscZ / 2;
|
||||||
|
|
||||||
|
GLfloat a2_x = a1_x, a2_y = a1_y - 1 - gruboscY, a2_z = a1_z; //zc - 1; // -4
|
||||||
|
GLfloat b2_x = b1_x, b2_y = b1_y - 1 - gruboscY, b2_z = b1_z; //zc - 1;
|
||||||
|
GLfloat c2_x = c1_x, c2_y = c1_y - 1 - gruboscY, c2_z = c1_z; //zc - 1;
|
||||||
|
GLfloat d2_x = d1_x, d2_y = d1_y - 1 - gruboscY, d2_z = d1_z; //zc - 1;
|
||||||
|
GLfloat e2_x = e1_x, e2_y = e1_y - 1 - gruboscY, e2_z = e1_z; //zc - 2;
|
||||||
|
GLfloat f2_x = f1_x, f2_y = f1_y - 1 - gruboscY, f2_z = f1_z; //zc - 2;
|
||||||
|
GLfloat g2_x = g1_x, g2_y = g1_y - 1 - gruboscY, g2_z = g1_z; //zc - 2;
|
||||||
|
GLfloat h2_x = h1_x, h2_y = h1_y - 1 - gruboscY, h2_z = h1_z; //zc - 2;
|
||||||
|
|
||||||
|
glColor3d(0.71, 0.522, 0.067);
|
||||||
|
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture[0]);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
|
// Góra (1_x, 1_y, 1_z):
|
||||||
|
// ABCD
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(a1_x, a1_y, a1_z);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(b1_x, b1_y, b1_z);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(c1_x, c1_y, c1_z);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(d1_x, d1_y, d1_z);
|
||||||
|
|
||||||
|
// EFGH
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(e1_x, e1_y, e1_z);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(f1_x, f1_y, f1_z);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(g1_x, g1_y, g1_z);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(h1_x, h1_y, h1_z);
|
||||||
|
|
||||||
|
// BCGF
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(b1_x, b1_y, b1_z);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(c1_x, c1_y, c1_z);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(g1_x, g1_y, g1_z);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(f1_x, f1_y, f1_z);
|
||||||
|
|
||||||
|
// ADHE
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(a1_x, a1_y, a1_z);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(b1_x, b1_y, b1_z);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(c1_x, c1_y, c1_z);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(d1_x, d1_y, d1_z);
|
||||||
|
|
||||||
|
// ABFE
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(a1_x, a1_y, a1_z);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(b1_x, b1_y, b1_z);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(f1_x, f1_y, f1_z);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(e1_x, e1_y, e1_z);
|
||||||
|
|
||||||
|
// DCGH
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(d1_x, d1_y, d1_z);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(c1_x, c1_y, c1_z);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(g1_x, g1_y, g1_z);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(h1_x, h1_y, h1_z);
|
||||||
|
|
||||||
|
// Dół (2_x, 2_y, 2_z):
|
||||||
|
// ABCD
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(a2_x, a2_y, a2_z);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(b2_x, b2_y, b2_z);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(c2_x, c2_y, c2_z);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(d2_x, d2_y, d2_z);
|
||||||
|
|
||||||
|
// EFGH
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(e2_x, e2_y, e2_z);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(f2_x, f2_y, f2_z);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(g2_x, g2_y, g2_z);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(h2_x, h2_y, h2_z);
|
||||||
|
|
||||||
|
// BCGF
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(b2_x, b2_y, b2_z);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(c2_x, c2_y, c2_z);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(g2_x, g2_y, g2_z);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(f2_x, f2_y, f2_z);
|
||||||
|
|
||||||
|
// ADHE
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(a2_x, a2_y, a2_z);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(b2_x, b2_y, b2_z);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(c2_x, c2_y, c2_z);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(d2_x, d2_y, d2_z);
|
||||||
|
|
||||||
|
// ABFE
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(a2_x, a2_y, a2_z);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(b2_x, b2_y, b2_z);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(f2_x, f2_y, f2_z);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(e2_x, e2_y, e2_z);
|
||||||
|
|
||||||
|
// DCGH
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(d2_x, d2_y, d2_z);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(c2_x, c2_y, c2_z);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(g2_x, g2_y, g2_z);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(h2_x, h2_y, h2_z);
|
||||||
|
|
||||||
|
// Pachołki
|
||||||
|
|
||||||
|
// d-----------c Y
|
||||||
|
// / /| ^
|
||||||
|
// a-----------b | \
|
||||||
|
// | h | g C->X
|
||||||
|
// | |/ |
|
||||||
|
// e-----------f v
|
||||||
|
// Z (płaszczyzna XZ, Y to trzeci wymiar)
|
||||||
|
|
||||||
|
|
||||||
|
GLfloat p_a_x, p_a_y, p_a_z;
|
||||||
|
GLfloat p_b_x, p_b_y, p_b_z;
|
||||||
|
GLfloat p_c_x, p_c_y, p_c_z;
|
||||||
|
GLfloat p_d_x, p_d_y, p_d_z;
|
||||||
|
GLfloat p_e_x, p_e_y, p_e_z;
|
||||||
|
GLfloat p_f_x, p_f_y, p_f_z;
|
||||||
|
GLfloat p_g_x, p_g_y, p_g_z;
|
||||||
|
GLfloat p_h_x, p_h_y, p_h_z;
|
||||||
|
|
||||||
|
if (!mod_x) {
|
||||||
|
|
||||||
|
p_a_x = xc + gruboscX / 2, p_a_y = yc + 1.5f * gruboscY, p_a_z = zc; // +3 dla y
|
||||||
|
p_b_x = xc - gruboscX / 2, p_b_y = yc + 1.5f * gruboscY, p_b_z = zc; // +3 dla y
|
||||||
|
p_c_x = xc + gruboscX / 2, p_c_y = yc + 1.5f * gruboscY, p_c_z = zc; // +3 dla y
|
||||||
|
p_d_x = xc - gruboscX / 2, p_d_y = yc + 1.5f * gruboscY, p_d_z = zc; // +3 dla y
|
||||||
|
p_e_x = xc + gruboscX / 2, p_e_y = yc - 6 , p_e_z = zc;
|
||||||
|
p_f_x = xc - gruboscX / 2, p_f_y = yc - 6 , p_f_z = zc;
|
||||||
|
p_g_x = xc + gruboscX / 2, p_g_y = yc - 6 , p_g_z = zc;
|
||||||
|
p_h_x = xc - gruboscX / 2, p_h_y = yc - 6 , p_h_z = zc;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
p_a_x = xc, p_a_y = yc + 1.5f * gruboscY, p_a_z = zc - gruboscZ / 2; // +3 dla y
|
||||||
|
p_b_x = xc, p_b_y = yc + 1.5f * gruboscY, p_b_z = zc - gruboscZ / 2; // +3 dla y
|
||||||
|
p_c_x = xc, p_c_y = yc + 1.5f * gruboscY, p_c_z = zc + gruboscZ / 2; // +3 dla y
|
||||||
|
p_d_x = xc, p_d_y = yc + 1.5f * gruboscY, p_d_z = zc + gruboscZ / 2; // +3 dla y
|
||||||
|
p_e_x = xc, p_e_y = yc - 6 , p_e_z = zc - gruboscZ / 2;
|
||||||
|
p_f_x = xc, p_f_y = yc - 6 , p_f_z = zc - gruboscZ / 2;
|
||||||
|
p_g_x = xc, p_g_y = yc - 6 , p_g_z = zc + gruboscZ / 2;
|
||||||
|
p_h_x = xc, p_h_y = yc - 6 , p_h_z = zc + gruboscZ / 2;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
|
||||||
|
// d-----------c Y
|
||||||
|
// / /| ^
|
||||||
|
// a-----------b | \
|
||||||
|
// | h | g C->X
|
||||||
|
// | |/ |
|
||||||
|
// e-----------f v
|
||||||
|
// Z (płaszczyzna XZ, Y to trzeci wymiar)
|
||||||
|
|
||||||
|
// timestampedCout("main.cpp (plot): p_a_x=" << p_a_x << " p_b_x=" << p_b_x << " p_c_x=" << p_c_x << " p_d_x=" << p_d_x);
|
||||||
|
|
||||||
|
// ABCD
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(p_a_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_a_y, p_a_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(p_b_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_b_y, p_b_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(p_c_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_c_y, p_c_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(p_d_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_d_y, p_d_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
||||||
|
|
||||||
|
// EFGH
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(p_e_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_e_y, p_e_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(p_f_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_f_y, p_f_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(p_g_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_g_y, p_g_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(p_h_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_h_y, p_h_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
||||||
|
|
||||||
|
// BCGF
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(p_b_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_b_y, p_b_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(p_c_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_c_y, p_c_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(p_g_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_g_y, p_g_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(p_f_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_f_y, p_f_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
||||||
|
|
||||||
|
// ADHE
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(p_a_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_a_y, p_a_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(p_d_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_d_y, p_d_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(p_h_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_h_y, p_h_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(p_e_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_e_y, p_e_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
||||||
|
|
||||||
|
// ABFE
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(p_a_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_a_y, p_a_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(p_b_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_b_y, p_b_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(p_f_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_f_y, p_f_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(p_e_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_e_y, p_e_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
|
||||||
|
|
||||||
|
// DCGH
|
||||||
|
glTexCoord2d(1.0, 1.0); glVertex3d(p_d_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_d_y, p_d_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
||||||
|
glTexCoord2d(1.0, 0.0); glVertex3d(p_c_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_c_y, p_c_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
||||||
|
glTexCoord2d(0.0, 0.0); glVertex3d(p_g_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_g_y, p_g_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
||||||
|
glTexCoord2d(0.0, 1.0); glVertex3d(p_h_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_h_y, p_h_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
}
|
||||||
9
teksturowane.hpp
Normal file
9
teksturowane.hpp
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "GL/glew.h"
|
||||||
|
|
||||||
|
extern unsigned int texture[4];
|
||||||
|
|
||||||
|
void skrzynka(GLfloat k);
|
||||||
|
void platforma(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat xlen, GLfloat zlen);
|
||||||
|
void stodola(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat krawedz);
|
||||||
|
void plot(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat length, GLfloat gruboscY, bool mod_x);
|
||||||
Reference in New Issue
Block a user