prbTexture+ammo_count #10
@ -14,15 +14,19 @@ private:
|
|||||||
float scale;
|
float scale;
|
||||||
glm::vec3 position;
|
glm::vec3 position;
|
||||||
glm::mat4 positionMatrix;
|
glm::mat4 positionMatrix;
|
||||||
|
GLuint textureID;
|
||||||
|
GLuint normalMapID;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Planet(GameObject* center, float distanceFromCenter, float rotationSpeed, float scale, Core::RenderContext sphereContext) {
|
Planet(GameObject* center, float distanceFromCenter, float rotationSpeed, float scale, Core::RenderContext sphereContext, GLuint textureID, GLuint normalMapID) {
|
||||||
this->center = center;
|
this->center = center;
|
||||||
this->distanceFromCenter = distanceFromCenter;
|
this->distanceFromCenter = distanceFromCenter;
|
||||||
this->rotationSpeed = rotationSpeed;
|
this->rotationSpeed = rotationSpeed;
|
||||||
this->sphereContext = sphereContext;
|
this->sphereContext = sphereContext;
|
||||||
this->scale = scale;
|
this->scale = scale;
|
||||||
this->position = glm::vec3(0);
|
this->position = glm::vec3(0);
|
||||||
|
this->textureID = textureID;
|
||||||
|
this->normalMapID = normalMapID;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 getPositionMatrix() override {
|
glm::mat4 getPositionMatrix() override {
|
||||||
@ -37,6 +41,6 @@ public:
|
|||||||
float rotationAngle = glm::radians(time * rotationSpeed);
|
float rotationAngle = glm::radians(time * rotationSpeed);
|
||||||
positionMatrix = center->getPositionMatrix() * glm::eulerAngleY(time * rotationSpeed) * glm::translate(glm::vec3(distanceFromCenter, 0, 0));
|
positionMatrix = center->getPositionMatrix() * glm::eulerAngleY(time * rotationSpeed) * glm::translate(glm::vec3(distanceFromCenter, 0, 0));
|
||||||
glm::mat4 modelMatrix = positionMatrix * glm::scale(glm::vec3(scale));
|
glm::mat4 modelMatrix = positionMatrix * glm::scale(glm::vec3(scale));
|
||||||
Core::drawObjectPBR(sphereContext, modelMatrix, glm::vec3(0.2, 0.7, 0.3), 0.3, 0.0, program);
|
Core::drawObjectPBRTexture(sphereContext, modelMatrix, textureID, 0.7, 0.0, program);
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -43,6 +43,14 @@ namespace texture {
|
|||||||
GLuint earthTexture;
|
GLuint earthTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct TextureTuple {
|
||||||
|
GLuint textureID;
|
||||||
|
GLuint normalMapID;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<TextureTuple> planetTextures;
|
||||||
|
|
||||||
|
|
||||||
void createGalaxy(glm::vec3 galaxyPosition);
|
void createGalaxy(glm::vec3 galaxyPosition);
|
||||||
|
|
||||||
GLuint depthMapFBO;
|
GLuint depthMapFBO;
|
||||||
@ -85,6 +93,15 @@ void updateDeltaTime(float time) {
|
|||||||
lastTime = time;
|
lastTime = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextureTuple getRandomPlanetTexture() {
|
||||||
|
int textureIndex = rand() % planetTextures.size();
|
||||||
|
TextureTuple selectedTextures = planetTextures[textureIndex];
|
||||||
|
//GLuint textureID = selectedTextures.textureID;
|
||||||
|
//GLuint normalMapID = selectedTextures.normalMapID;
|
||||||
|
|
||||||
|
return planetTextures[textureIndex];
|
||||||
|
}
|
||||||
|
|
||||||
void renderShadowapSun() {
|
void renderShadowapSun() {
|
||||||
float time = glfwGetTime();
|
float time = glfwGetTime();
|
||||||
glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
|
glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
|
||||||
@ -113,12 +130,13 @@ void renderScene(GLFWwindow* window)
|
|||||||
sun->draw();
|
sun->draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
glUseProgram(program);
|
glUseProgram(programTex);
|
||||||
|
|
||||||
for (Planet* p : planets) {
|
for (Planet* p : planets) {
|
||||||
p->draw(time, program);
|
p->draw(time, programTex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glUseProgram(program);
|
||||||
|
|
||||||
spaceship->renderBullets(glfwGetTime(), program);
|
spaceship->renderBullets(glfwGetTime(), program);
|
||||||
|
|
||||||
|
|
||||||
@ -196,8 +214,11 @@ void createSolarSystem(glm::vec3 sunPos, float sunScale, float* planetSizes, int
|
|||||||
sun = new Sun(programSun, models::sphereContext, sunPos, glm::vec3(-0.93633f, 0.351106, 0.003226f), glm::vec3(0.9f, 0.9f, 0.7f) * 5, sunScale);
|
sun = new Sun(programSun, models::sphereContext, sunPos, glm::vec3(-0.93633f, 0.351106, 0.003226f), glm::vec3(0.9f, 0.9f, 0.7f) * 5, sunScale);
|
||||||
gu->getSuns()->push_back(sun);
|
gu->getSuns()->push_back(sun);
|
||||||
for (int i = 0; i < numberOfPlanets; i++) {
|
for (int i = 0; i < numberOfPlanets; i++) {
|
||||||
|
TextureTuple textures = getRandomPlanetTexture();
|
||||||
|
GLuint texID = textures.textureID;
|
||||||
|
GLuint norMapID = textures.normalMapID;
|
||||||
float distanceFromSum = (i + 1) * planetsDistance;
|
float distanceFromSum = (i + 1) * planetsDistance;
|
||||||
Planet* planet = new Planet(sun, distanceFromSum, i * 0.1f + planetSpeedCoef, planetSizes[i], models::sphereContext);
|
Planet* planet = new Planet(sun, distanceFromSum, i * 0.1f + planetSpeedCoef, planetSizes[i], models::sphereContext, texID, norMapID);
|
||||||
planets.push_back(planet);
|
planets.push_back(planet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -210,6 +231,25 @@ void createEnemies() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void loadPlanetsTextures() {
|
||||||
|
planetTextures.clear();
|
||||||
|
|
||||||
|
std::vector<std::pair<std::string, std::string>> texturePaths = {
|
||||||
|
{"./textures/planets/planet1.png", "./textures/planets/planet1normal.png"},
|
||||||
|
{"./textures/planets/planet2.png", "./textures/planets/planet2normal.png"},
|
||||||
|
{"./textures/planets/planet3.png", "./textures/planets/planet3normal.png"},
|
||||||
|
{"./textures/planets/planet4.png", "./textures/planets/planet4normal.png"}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const auto& paths : texturePaths) {
|
||||||
|
GLuint textureID = Core::LoadTexture(paths.first.c_str());
|
||||||
|
GLuint normalMapID = Core::LoadTexture(paths.second.c_str());
|
||||||
|
planetTextures.push_back({ textureID, normalMapID });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void init(GLFWwindow* window)
|
void init(GLFWwindow* window)
|
||||||
{
|
{
|
||||||
GameUtils* gameUtils = GameUtils::getInstance();
|
GameUtils* gameUtils = GameUtils::getInstance();
|
||||||
@ -244,9 +284,10 @@ void init(GLFWwindow* window)
|
|||||||
"bkg2_back6.png"
|
"bkg2_back6.png"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
loadPlanetsTextures();
|
||||||
texture::cubemapTexture = Core::LoadCubemap(cubeFaces);
|
texture::cubemapTexture = Core::LoadCubemap(cubeFaces);
|
||||||
texture::spaceshipTexture = Core::LoadTexture("./textures/spaceship/Material.001_Base_color.jpg");
|
texture::spaceshipTexture = Core::LoadTexture("./textures/spaceship/Material.001_Base_color.jpg");
|
||||||
texture::earthTexture = Core::LoadTexture("./textures/spaceship/earth_daymap.jpg");
|
texture::earthTexture = Core::LoadTexture("./textures/planets/8k_earth_daymap.jpg");
|
||||||
|
|
||||||
spaceship->createParticles();
|
spaceship->createParticles();
|
||||||
createSuns();
|
createSuns();
|
||||||
|
BIN
grk/project/textures/planets/8k_earth_clouds.jpg
Normal file
After Width: | Height: | Size: 11 MiB |
BIN
grk/project/textures/planets/8k_earth_daymap.jpg
Normal file
After Width: | Height: | Size: 4.4 MiB |
BIN
grk/project/textures/planets/8k_earth_nightmap.jpg
Normal file
After Width: | Height: | Size: 3.0 MiB |
BIN
grk/project/textures/planets/8k_earth_normal_map.jpg
Normal file
After Width: | Height: | Size: 1.1 MiB |
BIN
grk/project/textures/planets/earth_daymap.jpg
Normal file
After Width: | Height: | Size: 452 KiB |
BIN
grk/project/textures/planets/planet1.png
Normal file
After Width: | Height: | Size: 3.1 MiB |
BIN
grk/project/textures/planets/planet1normal.png
Normal file
After Width: | Height: | Size: 1.7 MiB |
BIN
grk/project/textures/planets/planet2.png
Normal file
After Width: | Height: | Size: 2.4 MiB |
BIN
grk/project/textures/planets/planet2normal.png
Normal file
After Width: | Height: | Size: 2.1 MiB |
BIN
grk/project/textures/planets/planet3.png
Normal file
After Width: | Height: | Size: 3.7 MiB |
BIN
grk/project/textures/planets/planet3normal.png
Normal file
After Width: | Height: | Size: 2.2 MiB |
BIN
grk/project/textures/planets/planet4.png
Normal file
After Width: | Height: | Size: 3.3 MiB |
BIN
grk/project/textures/planets/planet4normal.png
Normal file
After Width: | Height: | Size: 2.3 MiB |