Skip to content

Commit

Permalink
technique architecture restructured
Browse files Browse the repository at this point in the history
  • Loading branch information
MeyerFabian committed Aug 10, 2018
1 parent e315168 commit 6372706
Show file tree
Hide file tree
Showing 49 changed files with 782 additions and 563 deletions.
2 changes: 1 addition & 1 deletion src/exe/snowBallDrop.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "launch.hpp"
#include "../snow/launchHelper/explicit.hpp"
using namespace std;
void scene(shared_ptr<ParticleSystem> const pPs,
shared_ptr<CollisionObjects> const pCO,
Expand Down
2 changes: 1 addition & 1 deletion src/exe/snowBallSmash.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "launch.hpp"
#include "../snow/launchHelper/explicit.hpp"
using namespace std;
void scene(shared_ptr<ParticleSystem> const pPs,
shared_ptr<CollisionObjects> const pCO,
Expand Down
2 changes: 1 addition & 1 deletion src/exe/snowBallsCrash.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "launch.hpp"
#include "../snow/launchHelper/explicit.hpp"
using namespace std;
void scene(shared_ptr<ParticleSystem> const pPs,
shared_ptr<CollisionObjects> const pCO,
Expand Down
3 changes: 2 additions & 1 deletion src/exe/snowBunnyScene.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "launch.hpp"
#include "../snow/launchHelper/explicit.hpp"
using namespace std;

void scene(shared_ptr<ParticleSystem> const pPs,
Expand Down Expand Up @@ -26,6 +26,7 @@ class SnowBunnyScene : public Scene {

int main() {
SnowBunnyScene scene;

if (!launchSnow(scene)) {
return 1;
}
Expand Down
10 changes: 5 additions & 5 deletions src/exe/snowPlowField.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#include "launch.hpp"
#include "../snow/launchHelper/explicit.hpp"
using namespace std;

void scene(shared_ptr<ParticleSystem> const pPs,
shared_ptr<CollisionObjects> const pCO,
shared_ptr<std::vector<shared_ptr<Mesh>>> const meshes) {
int x = 0;
float xpos = 0.8125,
float xpos = 0.8125,
ypos = GRID_POS_Y + GRID_COLLISION_PLANE_OFFSET * GRID_SPACING,
zpos = 2.4;
while (x < 2) {
float height = GRID_DIM_Z* GRID_SPACING * 0.1;
float width = GRID_DIM_X* GRID_SPACING *0.2;
float length = GRID_DIM_Y* GRID_SPACING*0.2;
float height = GRID_DIM_Z * GRID_SPACING * 0.1;
float width = GRID_DIM_X * GRID_SPACING * 0.2;
float length = GRID_DIM_Y * GRID_SPACING * 0.2;
float rand1 = (float(rand()) / 32727.0f) * width;
float rand2 = (float(rand()) / 32727.0f) * height;
float rand3 = (float(rand()) / 32727.0f) * length;
Expand Down
7 changes: 4 additions & 3 deletions src/exe/snowPlowTrack.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "launch.hpp"
#include "../snow/launchHelper/explicit.hpp"
using namespace std;
void scene(shared_ptr<ParticleSystem> const pPs,
shared_ptr<CollisionObjects> const pCO,
Expand All @@ -7,7 +7,7 @@ void scene(shared_ptr<ParticleSystem> const pPs,
float xpos = 0.8125,
ypos = GRID_POS_Y + GRID_COLLISION_PLANE_OFFSET * GRID_SPACING,
zpos = 2.4;
while (x < 32*32*64) {
while (x < 32 * 32 * 64) {
float height = 0.5;
float width = 2.0;
float length = 0.8;
Expand All @@ -30,7 +30,8 @@ void scene(shared_ptr<ParticleSystem> const pPs,
sphere->setRotation(0, 0, 0);

meshes->push_back(sphere);
//pCO->colliders->push_back(Collider(sphere, 0.3f, 1, Vector3f(5.0f, 0.0f, 0.0f), Vector3f(0.0f, 0.0f, 0.0f)));
// pCO->colliders->push_back(Collider(sphere, 0.3f, 1, Vector3f(5.0f, 0.0f,
// 0.0f), Vector3f(0.0f, 0.0f, 0.0f)));
}
class SnowPlowTrackScene : public Scene {
public:
Expand Down
2 changes: 1 addition & 1 deletion src/exe/snowSingleParticle.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "launch.hpp"
#include "../snow/launchHelper/explicit.hpp"
using namespace std;
void scene(shared_ptr<ParticleSystem> const pPs,
shared_ptr<CollisionObjects> const pCO,
Expand Down
4 changes: 2 additions & 2 deletions src/exe/snowSquare.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "launch.hpp"
#include "../snow/launchHelper/explicit.hpp"
using namespace std;
void scene(shared_ptr<ParticleSystem> const pPs,
shared_ptr<CollisionObjects> const pCO,
Expand Down Expand Up @@ -28,7 +28,7 @@ void scene(shared_ptr<ParticleSystem> const pPs,

class SnowSquareScene : public Scene {
public:
SnowSquareScene () = default;
SnowSquareScene() = default;
virtual void init(shared_ptr<ParticleSystem> const pPs,
shared_ptr<CollisionObjects> const pCO,
shared_ptr<std::vector<shared_ptr<Mesh>>> const meshes) {
Expand Down
2 changes: 1 addition & 1 deletion src/snow/defines/defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define GRID_SPACING 0.05
#define PARTICLE_TO_GRID_SIZE 64
#define GRID_COLLISION_PLANE_OFFSET 4
#define PHYSIC_DT 1e-4
#define PHYSIC_DT 1e-3
#define STEP_DT 0.0333

#define NUMOFPARTICLES 32 * 64 * 64
Expand Down
44 changes: 12 additions & 32 deletions src/exe/launch.hpp → src/snow/launchHelper/explicit.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
#ifndef LAUNCHER_H
#define LAUNCHER_H
#include <time.h>
#include <iostream>
#include <memory>
#include <vector>
#include "../snow/defines/defines.hpp"
#include "../snow/object/collisionObjects.hpp"
#include "../snow/object/grid.hpp"
#include "../snow/object/mesh.hpp"
#include "../snow/object/particlesystem.hpp"
#include "../snow/rendering/myRenderingEngine.hpp"
#include "../snow/scene/Scene.hpp"
#include "../snow/simulation/myPhysicEngine.hpp"
#include "../snow/simulation/timeUpdate.hpp"
#include "GLFW/glfw3.h"
#include "explicit.hpp"
int launchSnow(Scene& scene) {
shared_ptr<ParticleSystem> const pPs = make_shared<ParticleSystem>();

Expand Down Expand Up @@ -91,30 +76,27 @@ int launchSnow(Scene& scene) {
Vector3f(0.0, 0.0f, -1.0f)));

/*
Mesh halfplane;
halfplane.setPosition(0.7125f,0.7125f,0.7125f);
pCo->colliders->push_back(Collider(halfplane));
Mesh halfplane;
halfplane.setPosition(0.7125f,0.7125f,0.7125f);
pCo->colliders->push_back(Collider(halfplane));
*/

/*
Mesh quad;
quad.LoadMesh("model/box.obj");
quad.setPosition(5.0f,-3.0f,5.0f);
quad.setScale(10.0f,1.0f,10.0f);
quad.setRotation(0,0,0);
meshes->push_back(std::move(quad));
Mesh quad;
quad.LoadMesh("model/box.obj");
quad.setPosition(5.0f,-3.0f,5.0f);
quad.setScale(10.0f,1.0f,10.0f);
quad.setRotation(0,0,0);
meshes->push_back(std::move(quad));
*/
shared_ptr<renderingEngine> const rE =
make_shared<myRenderingEngine>(meshes, pPs, grid);

shared_ptr<Renderer> const rE =
make_shared<ParticleRenderer>(meshes, pPs, grid);
shared_ptr<TimeUpdate> const update =
make_shared<ExplicitTimeUpdate>(pCO, pPs, grid);

shared_ptr<physicEngine> const pE = make_shared<myPhysicEngine>(update);

cout << "init renderingEngine" << endl;
std::cout << std::flush;
bool re_err = rE->init();

if (re_err) {
Expand All @@ -141,5 +123,3 @@ int launchSnow(Scene& scene) {
return 0;
}

#endif

20 changes: 20 additions & 0 deletions src/snow/launchHelper/explicit.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef LAUNCHER_H
#define LAUNCHER_H
#include <time.h>
#include <iostream>
#include <memory>
#include <vector>
#include "../defines/defines.hpp"
#include "../object/collisionObjects.hpp"
#include "../object/grid.hpp"
#include "../object/mesh.hpp"
#include "../object/particlesystem.hpp"
#include "../rendering/particleRenderer.hpp"
#include "../scene/Scene.hpp"
#include "../simulation/myPhysicEngine.hpp"
#include "../simulation/timeUpdate.hpp"
#include "GLFW/glfw3.h"

int launchSnow(Scene& scene);
#endif

87 changes: 87 additions & 0 deletions src/snow/rendering/GLFWContext.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#ifndef GLFW_CONTEXT
#define GLFW_CONTEXT
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <iostream>
#include "../defines/defines.hpp"
#include "pipeline/pipeline.hpp"

static GLFWwindow* window;
static bool debug;

static pipeline world;

static float anglesize = 0.001f;
static float stepsize = 0.05f;
static float rotation = 0.0f;

static void error_callback(int error, const char* description) {
fputs(description, stderr);
}

static void key_callback(GLFWwindow* window, int key, int scancode, int action,
int mods) {
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GL_TRUE);
else if (key == GLFW_KEY_Q) {
if (action == GLFW_PRESS) {
}
} else if (key == GLFW_KEY_E) {
if (action == GLFW_PRESS) {
}
} else if (key == GLFW_KEY_W) {
if (action == GLFW_PRESS) {
}

} else if (key == GLFW_KEY_S) {
if (action == GLFW_PRESS) {
}
} else if (key == GLFW_KEY_D) {
if (action == GLFW_PRESS) {
debug = true;
} else if (action == GLFW_RELEASE) {
debug = false;
}
} else {
world.update(key, stepsize);
}
}
static void mouse_callback(GLFWwindow* window, double xpos, double ypos) {
double mouse_x = (xpos - WINDOW_WIDTH / 2) * anglesize;
double mouse_y = (-ypos + WINDOW_HEIGHT / 2) * anglesize;

world.update(mouse_x, mouse_y);
glfwSetCursorPos(window, WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2);
}

class Window_Context {
protected:
Window_Context() {
// GLFW INIT: ORDER IS IMPORTANT
glfwSetErrorCallback(error_callback);
if (!glfwInit()) exit(EXIT_FAILURE);

window = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "OpenGL Project",
NULL, NULL);
if (!window) {
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
glfwSetKeyCallback(window, key_callback);
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
glfwSetCursorPos(window, WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2);
glfwSetCursorPosCallback(window, mouse_callback);

// GLEW INIT
GLenum err = glewInit();

if (err != GLEW_OK) {
fprintf(stderr, "Error: '%s'\n", glewGetErrorString(err));
}
}
};

#endif // GLFW_CONTEXT

22 changes: 0 additions & 22 deletions src/snow/rendering/myRenderingEngine.hpp

This file was deleted.

0 comments on commit 6372706

Please sign in to comment.