fire from spaceship

This commit is contained in:
Pawel Felcyn 2024-01-30 21:13:23 +01:00
parent cf07257222
commit 69d7db83fa
24 changed files with 257 additions and 181 deletions

7
.gitignore vendored
View File

@ -1,5 +1,6 @@
################################################################################
# Ten plik .gitignore został utworzony automatycznie przez Microsoft(R) Visual Studio.
################################################################################

/grk/project/shaders
/grk/.vs/grk-cw
/grk/project/Debug

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ProjectOutputs>
<ProjectOutput>
<FullPath>C:\Users\KOMP\Documents\projekt_grafika_komputerowa\grafika_komputerowa\grk\Debug\grk-project.exe</FullPath>
</ProjectOutput>
</ProjectOutputs>
<ContentFiles />
<SatelliteDlls />
<NonRecipeFileRefs />
</Project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,6 +2,7 @@
#include "Sun.h"
#include "Bullet.h"
#include "src/Shader_Loader.h"
#include "ParticleSystem.h"
#pragma once
class GameUtils
@ -12,9 +13,11 @@ private:
{
this->suns = new std::list<Sun*>();
this->shaderLoader = new Core::Shader_Loader();
this->particleSystems = new std::list<ParticleSystem*>();
}
std::list<Sun*>* suns;
std::list<Bullet*> bullets;
std::list<ParticleSystem*>* particleSystems;
float aspectRatio;
@ -35,6 +38,10 @@ public:
return suns;
}
std::list<ParticleSystem*>* getParticleSystems() {
return particleSystems;
}
static GameUtils* getInstance()
{
static GameUtils instance; // Jedna i jedyna instancja

View File

@ -0,0 +1,142 @@
#pragma once
#include "glew.h"
#include <GLFW/glfw3.h>
#include "glm.hpp"
#include <list>
#include "ext.hpp"
struct Particle
{
public:
float birthTime;
glm::vec3 startPosition;
glm::vec3 direction;
glm::vec3 randomPointOnCircle;
float getAge(float time) {
return time - birthTime;
}
};
class ParticleSystem
{
private:
std::list<Particle> particles;
GLuint VBO;
GLuint VAO;
GLfloat vertices[9];
float lastGenerated = -1.f;
bool shouldGenerateNewParticle(float time) {
return lastGenerated == -1.f || time - lastGenerated > generationInterval;
}
glm::vec3 generateRandomPointOnCircle() {
float distanceFromCenter = static_cast <float> (rand()) / static_cast <float> (RAND_MAX/sourceRadius);
float radians = static_cast <float> (rand()) / static_cast <float> (RAND_MAX / 6.28f);
glm::vec3 referenceVector(0.0f, 1.0f, 0.0f);
glm::vec3 output = glm::normalize(glm::cross(sourceDirection, referenceVector)) * distanceFromCenter;
glm::mat4 rotationMatrix = glm::rotate(glm::mat4(1.0f), radians, sourceDirection);
output = glm::vec3(rotationMatrix * glm::vec4(output, 1.0f));
return output;
}
void generateNewParticle(float time) {
Particle newParticle;
newParticle.birthTime = time;
newParticle.startPosition = sourcePosition;
newParticle.randomPointOnCircle = generateRandomPointOnCircle();
newParticle.direction = sourceDirection;
particles.push_back(newParticle);
lastGenerated = time;
}
void deleteOld(float time) {
auto it = particles.begin();
while (it != particles.end()) {
if ((*it).getAge(time) > lifetime) {
it = particles.erase(it);
}
else {
++it;
}
}
}
glm::vec3 calculateParticleColor(float age) {
float rate = glm::clamp(age / lifetime, 0.f, 1.f);
glm::vec3 mixedColor = (1.0f - rate) * startColor + rate * endColor;
return mixedColor;
}
public:
glm::vec3 sourcePosition;
float sourceRadius = 0.02f;
glm::vec3 sourceDirection = glm::vec3(1.f, 0.f, 0.f);
float generationInterval = 0.0025f;
float lifetime = 0.5f;
float speed = 100.f;
glm::vec3 startColor = glm::vec3(1.f, 0.f, 0.f);
glm::vec3 endColor = glm::vec3(1.f, 1.f, 0.f);
ParticleSystem() {
// Inicjalizacja wierzcho³ków trójk¹ta w 3D
vertices[0] = -0.5f; vertices[1] = -0.5f; vertices[2] = 0.0f;
vertices[3] = 0.5f; vertices[4] = -0.5f; vertices[5] = 0.0f;
vertices[6] = 0.0f; vertices[7] = 0.5f; vertices[8] = 0.0f;
glGenBuffers(1, &VBO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glGenVertexArrays(1, &VAO);
glBindVertexArray(VAO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (void*)0);
glEnableVertexAttribArray(0);
glBindVertexArray(0);
}
void drawParticles(GLuint program, glm::mat4 view, glm::mat4 projection, float time) {
if (shouldGenerateNewParticle(time)) {
generateNewParticle(time);
}
deleteOld(time);
glUseProgram(program);
GLuint modelLoc = glGetUniformLocation(program, "model");
GLuint viewLoc = glGetUniformLocation(program, "view");
GLuint projectionLoc = glGetUniformLocation(program, "projection");
GLuint colorLoc = glGetUniformLocation(program, "color");
int i = 0;
for (auto particle : particles) {
glm::vec3 color = calculateParticleColor(particle.getAge(time));
glUniform3f(colorLoc, color.x, color.y, color.z);
glUniformMatrix4fv(viewLoc, 1, GL_FALSE, glm::value_ptr(view));
glUniformMatrix4fv(projectionLoc, 1, GL_FALSE, glm::value_ptr(projection));
glm::mat4 model = glm::translate(glm::mat4(1.0f), sourcePosition + particle.randomPointOnCircle);
model = glm::scale(model, glm::vec3(0.005f, 0.005f, 0.005f));
model = glm::translate(model, particle.direction * speed * (time - particle.birthTime));
glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model));
glBindVertexArray(VAO);
glDrawArrays(GL_TRIANGLES, 0, 3);
i++;
}
glBindVertexArray(0);
}
};

0
grk/project/Source.cpp Normal file
View File

View File

@ -3,6 +3,7 @@
#include <GLFW/glfw3.h>
#include <list>
#include "Bullet.h"
#include "ParticleSystem.h"
#pragma once
@ -12,10 +13,12 @@ private:
std::list<Bullet*> bullets;
float lastShootTime = 0.f;
float shootInterval = 0.3f;
ParticleSystem* leftParticle;
ParticleSystem* rightParticle;
// Prywatny konstruktor, aby zapobiec zewnêtrznemu tworzeniu instancji
Spaceship() {
}
// Prywatny destruktor, aby zapobiec przypadkowemu usuwaniu instancji
@ -33,7 +36,7 @@ public:
float roughness = 0.2;
float metallic = 1.0;
glm::vec3 spaceshipPos = glm::vec3(0.065808f, 1.250000f, -2.189549f);
glm::vec3 spaceshipPos /*= glm::vec3(0.065808f, 1.250000f, -2.189549f)*/;
glm::vec3 spaceshipDir = glm::vec3(-0.490263f, 0.000000f, 0.871578f);
glm::vec3 spotlightPos = glm::vec3(0, 0, 0);
@ -57,6 +60,13 @@ public:
return glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()) * glm::scale(glm::vec3(0.03f));
}
void setPerticlesParameters(float speed, float generationInterval) {
leftParticle->speed = speed;
leftParticle->generationInterval = generationInterval;
rightParticle->speed = speed;
rightParticle->generationInterval = generationInterval;
}
void processInput(GLFWwindow* window, float deltaTime, float time) {
static bool mouseButtonCallbackSet = false;
if (!mouseButtonCallbackSet) {
@ -67,12 +77,30 @@ public:
float angleSpeed = 0.05f * deltaTime * 60;
float moveSpeed = 0.05f * deltaTime * 60;
int w = glfwGetKey(window, GLFW_KEY_W);
int s = glfwGetKey(window, GLFW_KEY_S);
if (w == GLFW_PRESS) {
if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS) {
moveSpeed *= 2;
setPerticlesParameters(200.f, 0.00005f);
}
else {
setPerticlesParameters(100.f, 0.0001f);
}
}
else {
setPerticlesParameters(50.f, 0.0002f);
}
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) {
glfwSetWindowShouldClose(window, true);
}
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
if (w == GLFW_PRESS)
spaceshipPos += spaceshipDir * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
if (s == GLFW_PRESS)
spaceshipPos -= spaceshipDir * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS)
spaceshipPos += spaceshipSide * moveSpeed;
@ -89,13 +117,37 @@ public:
if (glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS)
requestShoot(time);
cameraPos = spaceshipPos - 0.5 * spaceshipDir + glm::vec3(0, 1, 0) * 0.2f;
cameraPos = spaceshipPos - 1.f * spaceshipDir + glm::vec3(0, 1, 0) * 0.2f;
cameraDir = spaceshipDir;
glm::vec3 perpendicularVector = 0.04f * glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.0f, 1.0f, 0.0f)));
if (leftParticle != nullptr && rightParticle != nullptr) {
leftParticle->sourcePosition = spaceshipPos + perpendicularVector - (0.25f * spaceshipDir);
rightParticle->sourcePosition = spaceshipPos - perpendicularVector - (0.25f * spaceshipDir);
leftParticle->sourceDirection = -spaceshipDir;
rightParticle->sourceDirection = -spaceshipDir;
}
spotlightPos = spaceshipPos + 0.2 * spaceshipDir;
spotlightConeDir = spaceshipDir;
}
void renderParticles(GLuint program, glm::mat4 view, glm::mat4 projection, float time) {
if (leftParticle != nullptr && rightParticle != nullptr) {
leftParticle->drawParticles(program, view, projection, time);
rightParticle->drawParticles(program, view, projection, time);
}
}
void createParticles() {
if (leftParticle != nullptr && rightParticle != nullptr) {
delete leftParticle;
delete rightParticle;
}
leftParticle = new ParticleSystem();
rightParticle = new ParticleSystem();
}
glm::mat4 createCameraMatrix()
{
glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir, glm::vec3(0.f, 1.f, 0.f)));

View File

@ -14,6 +14,7 @@
<ClCompile Include="GameObject.cpp" />
<ClCompile Include="Planet.cpp" />
<ClCompile Include="SpriteRenderer.cpp" />
<ClCompile Include="Source.cpp" />
<ClCompile Include="src\Box.cpp" />
<ClCompile Include="src\Camera.cpp" />
<ClCompile Include="src\main.cpp" />
@ -30,6 +31,7 @@
<ClInclude Include="Enemy.h" />
<ClInclude Include="GameObject.h" />
<ClInclude Include="GameUtils.h" />
<ClInclude Include="ParticleSystem.h" />
<ClInclude Include="Planet.h" />
<ClInclude Include="Spaceship.h" />
<ClInclude Include="SpriteRenderer.h" />
@ -50,6 +52,8 @@
<ItemGroup>
<None Include="fireball.frag" />
<None Include="fireball.vert" />
<None Include="particle.frag" />
<None Include="particle.vert" />
<None Include="shaders\shader_9_1.frag" />
<None Include="shaders\shader_9_1.vert" />
<None Include="shaders\shader_8_sun.frag" />

View File

@ -59,6 +59,8 @@
</ClCompile>
<ClCompile Include="SpriteRenderer.cpp">
<Filter>Source Files</Filter>
<ClCompile Include="Source.cpp">
<Filter>Shader Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
@ -120,6 +122,7 @@
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SpriteRenderer.h">
<ClInclude Include="ParticleSystem.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
@ -154,6 +157,10 @@
<Filter>Shader Files</Filter>
</None>
<None Include="shaders\shader_sprite.vert">
<None Include="particle.frag">
<Filter>Shader Files</Filter>
</None>
<None Include="particle.vert">
<Filter>Shader Files</Filter>
</None>
</ItemGroup>

View File

@ -1,150 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Shader Files">
<UniqueIdentifier>{0a247bb8-2e8e-4a90-b0ef-17415b0941ba}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\SOIL">
<UniqueIdentifier>{0af44075-33f4-4953-b1d6-1d28d61d758f}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\Render_Utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Shader_Loader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Box.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Camera.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Texture.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\SOIL\SOIL.c">
<Filter>Source Files\SOIL</Filter>
</ClCompile>
<ClCompile Include="src\SOIL\stb_image_aug.c">
<Filter>Source Files\SOIL</Filter>
</ClCompile>
<ClCompile Include="src\SOIL\image_DXT.c">
<Filter>Source Files\SOIL</Filter>
</ClCompile>
<ClCompile Include="src\SOIL\image_helper.c">
<Filter>Source Files\SOIL</Filter>
</ClCompile>
<ClCompile Include="GameObject.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Planet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\objload.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="src\Render_Utils.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="src\Shader_Loader.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="src\Camera.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="src\Texture.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="src\SOIL\image_helper.h">
<Filter>Source Files\SOIL</Filter>
</ClInclude>
<ClInclude Include="src\SOIL\SOIL.h">
<Filter>Source Files\SOIL</Filter>
</ClInclude>
<ClInclude Include="src\SOIL\stb_image_aug.h">
<Filter>Source Files\SOIL</Filter>
</ClInclude>
<ClInclude Include="src\SOIL\stbi_DDS_aug.h">
<Filter>Source Files\SOIL</Filter>
</ClInclude>
<ClInclude Include="src\SOIL\stbi_DDS_aug_c.h">
<Filter>Source Files\SOIL</Filter>
</ClInclude>
<ClInclude Include="src\SOIL\image_DXT.h">
<Filter>Source Files\SOIL</Filter>
</ClInclude>
<ClInclude Include="src\ex_9_1.hpp">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="Sun.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Spaceship.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GameUtils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GameObject.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Planet.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Bullet.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="shaders\shader_8_sun.vert">
<Filter>Shader Files</Filter>
</None>
<None Include="shaders\shader_8_sun.frag">
<Filter>Shader Files</Filter>
</None>
<None Include="shaders\shader_9_1.frag">
<Filter>Shader Files</Filter>
</None>
<None Include="shaders\shader_9_1.vert">
<Filter>Shader Files</Filter>
</None>
<None Include="shaders\test.frag">
<Filter>Shader Files</Filter>
</None>
<None Include="shaders\test.vert">
<Filter>Shader Files</Filter>
</None>
<<<<<<< HEAD
<None Include="shaders\shader_skybox.frag">
<Filter>Shader Files</Filter>
</None>
<None Include="shaders\shader_skybox.vert">
=======
<None Include="fireball.vert">
<Filter>Shader Files</Filter>
</None>
<None Include="fireball.frag">
>>>>>>> 62afe67 (add shooting)
<Filter>Shader Files</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -4,7 +4,7 @@
namespace Core
{
glm::mat4 createPerspectiveMatrix(float zNear = 0.1f, float zFar = 100.0f, float frustumScale = 1.f);
glm::mat4 createPerspectiveMatrix(float zNear, float zFar, float frustumScale);
// position - pozycja kamery
// forward - wektor "do przodu" kamery (jednostkowy)

View File

@ -24,6 +24,8 @@
#include "../SpriteRenderer.h"
#include "../Enemy.h"
#include "../ParticleSystem.h"
#include "Camera.h"
const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
@ -50,6 +52,7 @@ GLuint programSun;
GLuint programTest;
GLuint programSprite;
GLuint programCubemap;
GLuint programParticle;
std::list<Planet*> planets;
Sun* sun;
@ -142,10 +145,10 @@ void renderScene(GLFWwindow* window)
}
//drawObjectPBR(sphereContext, glm::translate(pointlightPos) * glm::scale(glm::vec3(1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(10.f, 0, 0)) * glm::scale(glm::vec3(0.3f)), glm::vec3(0.2, 0.7, 0.3), 0.3, 0.0, program);
glm::vec3 cameraSide = glm::normalize(glm::cross(spaceship->cameraDir, glm::vec3(0.f, 1.f, 0.f)));
glm::vec3 cameraUp = glm::normalize(glm::cross(cameraSide, spaceship->cameraDir));
glm::mat4 viewMatrix = Core::createViewMatrix(spaceship->cameraPos, spaceship->cameraDir, cameraUp);
spaceship->renderParticles(programParticle, viewMatrix, Core::createPerspectiveMatrix(), time);
glUseProgram(0);
glfwSwapBuffers(window);
@ -207,7 +210,8 @@ void init(GLFWwindow* window)
programSun = gameUtils->shaderLoader->CreateProgram("shaders/shader_8_sun.vert", "shaders/shader_8_sun.frag");
programCubemap = gameUtils->shaderLoader->CreateProgram("shaders/shader_skybox.vert", "shaders/shader_skybox.frag");
programSprite = gameUtils->shaderLoader->CreateProgram("shaders/shader_sprite.vert", "shaders/shader_sprite.frag");
programParticle = gameUtils->shaderLoader->CreateProgram("shaders/particle.vert", "shaders/particle.frag");
loadModelToContext("./models/marbleBust.obj", models::marbleBustContext);
loadModelToContext("./models/spaceship.obj", models::spaceshipContext);
loadModelToContext("./models/sphere.obj", models::sphereContext);
@ -227,6 +231,7 @@ void init(GLFWwindow* window)
texture::cubemapTexture = Core::LoadCubemap(cubeFaces);
spaceship->createParticles();
createSuns();
createEnemies();
}

View File

@ -21,9 +21,14 @@
#include "../Planet.h"
#include "../GameObject.h"
#include "../GameUtils.h"
<<<<<<< HEAD
#include "../SpriteRenderer.h"
#include "../Enemy.h"
=======
#include "../ParticleSystem.h"
#include "Camera.h"
>>>>>>> 2162820 (fire from ship)
const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
@ -50,6 +55,7 @@ GLuint programSun;
GLuint programTest;
GLuint programSprite;
GLuint programCubemap;
GLuint programParticle;
std::list<Planet*> planets;
Sun* sun;
@ -67,12 +73,9 @@ float lastTime = -1.f;
float deltaTime = 0.f;
Spaceship* spaceship = Spaceship::getInstance();
<<<<<<< HEAD
void createSolarSystem(glm::vec3 sunPos, float sunScale, float* planetSizes, int numberOfPlanets, float planetsDistance, float planetSpeedCoef);
=======
Core::SpriteRenderer* spriteRenderer;
>>>>>>> c0971c9 (Add enemy class)
void updateDeltaTime(float time) {
if (lastTime < 0) {
lastTime = time;
@ -128,6 +131,8 @@ void renderScene(GLFWwindow* window)
spaceship->color,
spaceship->roughness, spaceship->metallic, program
);
<<<<<<< HEAD
glUseProgram(programSprite);
for (const auto& enemy : enemies) {
if (enemy->isAlive()) {
@ -148,6 +153,16 @@ void renderScene(GLFWwindow* window)
//drawObjectPBR(sphereContext, glm::translate(pointlightPos) * glm::scale(glm::vec3(1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(10.f, 0, 0)) * glm::scale(glm::vec3(0.3f)), glm::vec3(0.2, 0.7, 0.3), 0.3, 0.0, program);
=======
std::list<ParticleSystem*>* particleSystems = GameUtils::getInstance()->getParticleSystems();
glm::vec3 cameraSide = glm::normalize(glm::cross(spaceship->cameraDir, glm::vec3(0.f, 1.f, 0.f)));
glm::vec3 cameraUp = glm::normalize(glm::cross(cameraSide, spaceship->cameraDir));
glm::mat4 viewMatrix = Core::createViewMatrix(spaceship->cameraPos, spaceship->cameraDir, cameraUp);
spaceship->renderParticles(programParticle, viewMatrix, Core::createPerspectiveMatrix(), time);
/*for (auto particleSystem : *particleSystems) {
particleSystem->drawParticles(programParticle, viewMatrix, Core::createPerspectiveMatrix(), time);
}*/
>>>>>>> 2162820 (fire from ship)
glUseProgram(0);
glfwSwapBuffers(window);
@ -187,9 +202,7 @@ void createSolarSystem(glm::vec3 sunPos, float sunScale, float* planetSizes, int
planets.push_back(planet);
}
}
<<<<<<< HEAD
=======
void createEnemies() {
enemies.push_back(new Enemy(100, glm::mat4(1.0f), 20, 5.0f));
@ -197,7 +210,7 @@ void createEnemies() {
enemies.push_back(new Enemy(100, glm::translate(glm::mat4(1.0f), glm::vec3(-1.f, 2.f, -0.9f)), 25, 5.0f));
}
>>>>>>> c0971c9 (Add enemy class)
void init(GLFWwindow* window)
{
GameUtils* gameUtils = GameUtils::getInstance();
@ -210,8 +223,13 @@ void init(GLFWwindow* window)
programTest = gameUtils->shaderLoader->CreateProgram("shaders/test.vert", "shaders/test.frag");
programSun = gameUtils->shaderLoader->CreateProgram("shaders/shader_8_sun.vert", "shaders/shader_8_sun.frag");
programCubemap = gameUtils->shaderLoader->CreateProgram("shaders/shader_skybox.vert", "shaders/shader_skybox.frag");
<<<<<<< HEAD
programSprite = gameUtils->shaderLoader->CreateProgram("shaders/shader_sprite.vert", "shaders/shader_sprite.frag");
=======
programParticle = gameUtils->shaderLoader->CreateProgram("shaders/particle.vert", "shaders/particle.frag");
>>>>>>> 2162820 (fire from ship)
loadModelToContext("./models/marbleBust.obj", models::marbleBustContext);
loadModelToContext("./models/spaceship.obj", models::spaceshipContext);
loadModelToContext("./models/sphere.obj", models::sphereContext);
@ -231,6 +249,7 @@ void init(GLFWwindow* window)
texture::cubemapTexture = Core::LoadCubemap(cubeFaces);
spaceship->createParticles();
createSuns();
createEnemies();
}