├── FoxelEngine
├── .gitignore
├── Shader.cpp
├── resource1.h
├── FoxelEngine.rc
├── FoxelManager.cpp
├── GI_Light.h
├── Shader
│ ├── Basic.frag
│ ├── Post.vert
│ ├── Basic.vert
│ ├── Model.frag
│ ├── Foxel.frag
│ ├── Model.vert
│ ├── Foxel.vert
│ └── Post.frag
├── GI_Light.cpp
├── FoxelEngine.vcxproj.user
├── GameComponent.cpp
├── Explosion.h
├── Explosion.cpp
├── GameComponent.h
├── BitCube.h
├── BitCube.cpp
├── Convert.h
├── Main_Menu.h
├── Light.h
├── Camera.h
├── TextButton.h
├── DirectLight.h
├── Foxel_Interaction.cpp
├── ToolBox.h
├── Convert.cpp
├── Material.h
├── Foxel_Interaction.h
├── Vec2d.h
├── BitmapText.h
├── Foxel.h
├── PropDynamic.h
├── Material.cpp
├── GameMenu.h
├── GL_Screen.h
├── main.cpp
├── GlobalLight.h
├── Axes.cpp
├── Entity_2D.h
├── SlideControl.h
├── Controler.h
├── ColorPanel.h
├── World.h
├── DrawableGameComponent.h
├── Pistol.h
├── PlayerControler.h
├── Bullet.h
├── Core_events.cpp
├── Event.h
├── BitmapText.cpp
├── Shader.h
├── Axes.h
├── Vec3d.h
├── TextButton.cpp
├── Vec2.h
├── Vec3.h
├── GameGUI.h
├── TextField.h
├── Matrix4.h
├── Model.h
├── Color.h
├── PostProcessor.h
├── ShaderProgram.h
├── View.h
├── Camera.cpp
├── Config.h
├── PropDynamic.cpp
├── Foxel.cpp
├── DirectLight.cpp
├── Editor.h
├── Event.cpp
├── DrawableGameComponent.cpp
├── Bullet.cpp
├── Vec2d.cpp
├── Player.h
├── CollisionDetector.h
├── Core.h
├── Map.h
├── CollisionDetector.cpp
├── GameMenu.cpp
├── World.cpp
├── BrushBox.h
├── Entity_2D.cpp
├── GlobalLight.cpp
├── Screen.h
├── ToolBox.cpp
├── Color.cpp
├── Controler.cpp
├── SlideControl.cpp
├── Main_Menu.cpp
├── Config.cpp
├── PlayerControler.cpp
├── Maps
│ ├── Test_Map2.foxel
│ ├── Test_Map3.foxel
│ ├── Test_Map4.foxel
│ ├── Test_Map5.foxel
│ └── Test_Map.foxel
├── Models
│ └── pistol.mtl
├── TextField.cpp
├── Vec3d.cpp
├── GameGUI.cpp
├── Vec2.cpp
├── GL_Screen.cpp
├── Vec3.cpp
├── ShaderProgram.cpp
├── ColorPanel.cpp
├── Core.cpp
├── Pistol.cpp
├── BrushBox.cpp
├── Core_inputs.cpp
├── Player.cpp
├── Model.cpp
├── Matrix4.cpp
├── View.cpp
├── Map.cpp
├── Editor.cpp
├── Screen.cpp
├── FoxelManager.h
├── PostProcessor.cpp
└── FoxelEngine.vcxproj
├── FoxelEngine.suo
├── FoxelEngine.sln.docstates.suo
├── README.md
├── LICENSE
└── FoxelEngine.sln
/FoxelEngine/.gitignore:
--------------------------------------------------------------------------------
1 | # Stupid files
2 | *.aps
3 | *.cd
4 | *.cfg
5 | *.log
--------------------------------------------------------------------------------
/FoxelEngine.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FoxelFox/FoxelEngine/HEAD/FoxelEngine.suo
--------------------------------------------------------------------------------
/FoxelEngine/Shader.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FoxelFox/FoxelEngine/HEAD/FoxelEngine/Shader.cpp
--------------------------------------------------------------------------------
/FoxelEngine/resource1.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FoxelFox/FoxelEngine/HEAD/FoxelEngine/resource1.h
--------------------------------------------------------------------------------
/FoxelEngine/FoxelEngine.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FoxelFox/FoxelEngine/HEAD/FoxelEngine/FoxelEngine.rc
--------------------------------------------------------------------------------
/FoxelEngine/FoxelManager.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FoxelFox/FoxelEngine/HEAD/FoxelEngine/FoxelManager.cpp
--------------------------------------------------------------------------------
/FoxelEngine.sln.docstates.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FoxelFox/FoxelEngine/HEAD/FoxelEngine.sln.docstates.suo
--------------------------------------------------------------------------------
/FoxelEngine/GI_Light.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | class GI_Light
3 | {
4 | public:
5 | GI_Light(void);
6 | ~GI_Light(void);
7 | };
8 |
9 |
--------------------------------------------------------------------------------
/FoxelEngine/Shader/Basic.frag:
--------------------------------------------------------------------------------
1 | #version 330
2 |
3 | in vec4 ex_Color;
4 | out vec4 frag_Output;
5 |
6 | void main(void){
7 | frag_Output = ex_Color;
8 | }
--------------------------------------------------------------------------------
/FoxelEngine/GI_Light.cpp:
--------------------------------------------------------------------------------
1 | #include "GI_Light.h"
2 |
3 |
4 | GI_Light::GI_Light(void)
5 | {
6 | }
7 |
8 |
9 | GI_Light::~GI_Light(void)
10 | {
11 | }
12 |
--------------------------------------------------------------------------------
/FoxelEngine/FoxelEngine.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/FoxelEngine/GameComponent.cpp:
--------------------------------------------------------------------------------
1 | #include "GameComponent.h"
2 |
3 | GameComponent::GameComponent(){}
4 |
5 | void GameComponent::update(){}
6 |
7 | GameComponent::~GameComponent(){}
--------------------------------------------------------------------------------
/FoxelEngine/Explosion.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | class Explosion{
3 | private:
4 | short strength;
5 | public:
6 | Explosion(short strength);
7 | ~Explosion(void);
8 | };
9 |
10 |
--------------------------------------------------------------------------------
/FoxelEngine/Explosion.cpp:
--------------------------------------------------------------------------------
1 | #include "Explosion.h"
2 |
3 |
4 | Explosion::Explosion(short strength)
5 | {
6 | this->strength = strength;
7 | }
8 |
9 |
10 | Explosion::~Explosion(void)
11 | {
12 | }
13 |
--------------------------------------------------------------------------------
/FoxelEngine/GameComponent.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "Vec3d.h"
3 | class GameComponent{
4 | protected:
5 | Vec3d position;
6 | public:
7 | GameComponent(void);
8 | virtual void update();
9 | ~GameComponent(void);
10 | };
--------------------------------------------------------------------------------
/FoxelEngine/BitCube.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | class BitCube
4 | {
5 | public:
6 | std::bitset<128> bitGrid[128][128];
7 | void set(unsigned char x,unsigned char y,unsigned char z,bool state);
8 | bool get(unsigned char x,unsigned char y,unsigned char z);
9 | };
10 |
--------------------------------------------------------------------------------
/FoxelEngine/Shader/Post.vert:
--------------------------------------------------------------------------------
1 | #version 330
2 |
3 | layout(location = 0) in vec3 vertexPosition_modelspace;
4 |
5 | out vec2 uv;
6 |
7 | void main(){
8 | gl_Position = vec4(vertexPosition_modelspace,1);
9 | uv = (vertexPosition_modelspace.xy+vec2(1,1))/2.0;
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/FoxelEngine/BitCube.cpp:
--------------------------------------------------------------------------------
1 | #include "BitCube.h"
2 |
3 |
4 | void BitCube::set(unsigned char x,unsigned char y,unsigned char z,bool state){
5 | bitGrid[x][y][z] = state;
6 | }
7 |
8 | bool BitCube::get(unsigned char x,unsigned char y,unsigned char z){
9 | return bitGrid[x][y][z];
10 | }
--------------------------------------------------------------------------------
/FoxelEngine/Convert.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | const double PI = 3.14159265f;
4 | class Convert{
5 | public:
6 | static float degToRad(float* deg);
7 | static double degToRad(double* deg);
8 | static float degToRad(float deg);
9 | static double degToRad(double deg);
10 | };
11 |
12 |
--------------------------------------------------------------------------------
/FoxelEngine/Main_Menu.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "Screen.h"
3 | #include "gamemenu.h"
4 | #include "Event.h"
5 | class Main_Menu : public GameMenu{
6 | private:
7 | void createEvents();
8 | public:
9 | void draw();
10 | Main_Menu(void);
11 | ~Main_Menu(void);
12 | };
13 |
14 |
--------------------------------------------------------------------------------
/FoxelEngine/Light.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "Color.h"
3 | #include "Vec3.h"
4 | struct Light{
5 | Color color;
6 | Vec3 normal,position;
7 |
8 | Light(Vec3 position, Vec3 normal, Color color){
9 | this->position = position;
10 | this->color = color;
11 | this->normal = normal;
12 | }
13 |
14 | };
15 |
16 |
--------------------------------------------------------------------------------
/FoxelEngine/Shader/Basic.vert:
--------------------------------------------------------------------------------
1 | #version 150
2 |
3 | uniform mat4 viewMatrix, projMatrix;
4 |
5 | in vec3 in_Position;
6 | in vec4 in_Color;
7 | in vec3 in_Normal;
8 |
9 | out vec4 ex_Color;
10 |
11 | void main(void)
12 | {
13 | ex_Color = vec4(in_Color);
14 | gl_Position = projMatrix * viewMatrix * vec4(in_Position, 1.0);
15 | }
16 |
--------------------------------------------------------------------------------
/FoxelEngine/Camera.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include "PropDynamic.h"
4 | #include "Vec3d.h"
5 | #include "Matrix4.h"
6 | #include "World.h"
7 |
8 | class Camera : public PropDynamic{
9 | Matrix4 viewMatrix;
10 | public:
11 | Camera(void);
12 | Camera(Vec3d position);
13 | void setupView();
14 | ~Camera(void);
15 | };
16 |
17 |
--------------------------------------------------------------------------------
/FoxelEngine/TextButton.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "TextField.h"
3 |
4 |
5 |
6 | class TextButton : public TextField{
7 | bool pressed;
8 | public:
9 | TextButton(Vec2 position, Vec2 size, std::string content);
10 | void press();
11 | void release();
12 | bool isPressed();
13 | bool intersect(Vec2 point);
14 | ~TextButton(void);
15 | };
16 |
17 |
--------------------------------------------------------------------------------
/FoxelEngine/DirectLight.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include "Light.h"
5 | class DirectLight{
6 | private:
7 | std::vector lights;
8 | std::vector id;
9 | public:
10 | DirectLight(std::vector id);
11 |
12 |
13 | float* generateDirectLightArray();
14 |
15 | std::vector getLight();
16 | };
17 |
18 |
--------------------------------------------------------------------------------
/FoxelEngine/Foxel_Interaction.cpp:
--------------------------------------------------------------------------------
1 | #include "Foxel_Interaction.h"
2 |
3 | using namespace Event;
4 |
5 | setFoxel::setFoxel(Vec3d* pos, char id) : BasicEvent(){
6 | eventID = Event::SET_FOXEL;
7 | newFoxelID = id;
8 | position = pos;
9 |
10 | }
11 |
12 | Vec3d* setFoxel::getPosition(){
13 | return position;
14 | }
15 |
16 | setFoxel::~setFoxel(void){
17 | }
18 |
--------------------------------------------------------------------------------
/FoxelEngine/ToolBox.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "GameMenu.h"
3 | namespace MapEditor{
4 |
5 | enum ActiveTool {Brush , Entity};
6 |
7 | class ToolBox : public GameMenu{
8 | public:
9 | ToolBox(Vec2 position, Vec2 size);
10 | ~ToolBox(void);
11 | ActiveTool activeTool;
12 | void update();
13 | void draw();
14 | void resize();
15 | };
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/FoxelEngine/Convert.cpp:
--------------------------------------------------------------------------------
1 | #include "Convert.h"
2 |
3 | float Convert::degToRad(float* deg){
4 | return (float) PI**deg/180;
5 | }
6 |
7 | double Convert::degToRad(double* deg){
8 | return PI**deg/180;
9 | }
10 |
11 | float Convert::degToRad(float deg){
12 | return (float) PI*deg/180;
13 | }
14 |
15 | double Convert::degToRad(double deg){
16 | return PI*deg/180;
17 | }
18 |
--------------------------------------------------------------------------------
/FoxelEngine/Material.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "Color.h"
3 | #include "ShaderProgram.h"
4 | namespace GLSL{
5 | class Material{
6 | Color defuse,specular;
7 | ProgramTyp materialTyp;
8 | public:
9 | Material(ProgramTyp materialTyp);
10 | Material(ProgramTyp materialTyp, Color defuse, Color specular);
11 | ~Material(void);
12 | void use();
13 | };
14 | };
15 |
16 |
--------------------------------------------------------------------------------
/FoxelEngine/Foxel_Interaction.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "Event.h"
3 | #include "Vec3d.h"
4 | namespace Event{
5 | class setFoxel : public Event::BasicEvent{
6 | private:
7 | Vec3d* position;
8 | char newFoxelID;
9 |
10 | public:
11 | setFoxel(Vec3d* pos, char id);
12 | Vec3d* getPosition();
13 | char getNewFoxelID();
14 | ~setFoxel(void);
15 | };
16 |
17 |
18 | }
--------------------------------------------------------------------------------
/FoxelEngine/Shader/Model.frag:
--------------------------------------------------------------------------------
1 | #version 150
2 |
3 | in vec4 ex_Color;
4 | out vec4 frag_Output;
5 |
6 | in vec3 ex_Normal;
7 | in vec3 ex_Light;
8 |
9 | void main(void){
10 | frag_Output = ex_Color;
11 | //frag_Output.r = clamp((dot(ex_Normal,ex_Light)),0.1,1);
12 | //frag_Output.g = clamp((dot(ex_Normal,ex_Light)),0.1,1);
13 | //frag_Output.b = clamp((dot(ex_Normal,ex_Light)),0.1,1);
14 | }
--------------------------------------------------------------------------------
/FoxelEngine/Vec2d.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | class Vec2d{
3 |
4 | public:
5 | double x,y;
6 |
7 | Vec2d(void);
8 | Vec2d(double x, double y);
9 | // Operatoren
10 | void operator+=(double skalar);
11 | void operator+=(Vec2d vector);
12 | void operator-=(double skalar);
13 | void operator-=(Vec2d vector);
14 | Vec2d operator*(double skalar);
15 | Vec2d operator*(Vec2d vector);
16 | Vec2d operator-();
17 | ~Vec2d(void);
18 | };
--------------------------------------------------------------------------------
/FoxelEngine/BitmapText.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include
5 | #include "Vec3.h"
6 | #include "Screen.h"
7 |
8 | class BitmapText{
9 |
10 | private:
11 | std::string text;
12 | bool bigText;
13 | public:
14 | BitmapText(std::string);
15 | ~BitmapText(void);
16 |
17 | void setBigText(bool boolean);
18 | void setText(std::string);
19 | void draw();
20 | };
21 |
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # FoxelEngine
2 |
3 | [](https://www.youtube.com/watch?v=nXAUnrXhaOU)
4 | [](https://www.youtube.com/watch?v=BAQEjXU-blc)
5 | [](https://www.youtube.com/watch?v=kse0AOaynpQ)
6 | [](https://www.youtube.com/watch?v=fsjk-l-oyAc)
7 |
8 |
--------------------------------------------------------------------------------
/FoxelEngine/Foxel.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | class Foxel {
6 |
7 | private:
8 | GLushort color[3];
9 | char id;
10 | char visiblity;
11 | bool test;
12 |
13 | public:
14 | Foxel();
15 | Foxel(char idFoxel, char vis);
16 | ~Foxel();
17 | void setColor(GLushort r, GLushort g, GLushort b);
18 | void setVisiblity(char setBit);
19 | char getVisiblity();
20 | void setId(char);
21 | char getId();
22 | GLushort* getColor();
23 | };
24 |
--------------------------------------------------------------------------------
/FoxelEngine/PropDynamic.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "GameComponent.h"
3 | #include "Vec3d.h"
4 |
5 | class PropDynamic : public GameComponent{
6 | protected:
7 | float friction;
8 | Vec3d velocity;
9 | Vec3d rotation;
10 |
11 | public:
12 | PropDynamic(void);
13 | PropDynamic(Vec3d position);
14 | void update(float* time);
15 | ~PropDynamic(void);
16 |
17 | void setFriction(float friction);
18 | void setRotation(Vec3d rotation);
19 | void setPosition(Vec3d position);
20 | };
21 |
22 |
--------------------------------------------------------------------------------
/FoxelEngine/Material.cpp:
--------------------------------------------------------------------------------
1 | #include "Material.h"
2 | using namespace GLSL;
3 |
4 | Material::Material(ProgramTyp materialTyp){
5 | this->materialTyp = materialTyp;
6 | }
7 |
8 | Material::Material(ProgramTyp materialTyp, Color defuse, Color specular){
9 | this->materialTyp = materialTyp;
10 | this->defuse = defuse;
11 | this->specular = specular;
12 | }
13 |
14 | Material::~Material(void)
15 | {
16 | }
17 |
18 | void Material::use(){
19 | PM::useProg(materialTyp);
20 | }
21 |
--------------------------------------------------------------------------------
/FoxelEngine/GameMenu.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include "Screen.h"
4 | #include "TextButton.h"
5 | #include "Entity_2D.h"
6 | class GameMenu : public Entity_2D{
7 | protected:
8 | std::vector selectOptions;
9 | public:
10 | GameMenu(Vec2 position, Vec2 size);
11 | GameMenu(void);
12 | ~GameMenu(void);
13 | virtual void createEvents();
14 | void catchMousePosition(Vec2 pos);
15 | void catchMouseClick(Vec2 pos);
16 | void update();
17 | void draw();
18 | };
--------------------------------------------------------------------------------
/FoxelEngine/GL_Screen.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | static int screenWidth, screenHeight;
7 | class GL_Screen
8 | {
9 | private:
10 | SDL_Surface* screen;
11 | float ar;
12 |
13 | public:
14 | GL_Screen(int w, int h, bool isFullscreen);
15 | void load3DView();
16 | void resize(int w, int h);
17 | static int getWidth();
18 | static int getHeight();
19 | static void load2DView();
20 | SDL_Surface* getSurface();
21 | ~GL_Screen(void);
22 | };
--------------------------------------------------------------------------------
/FoxelEngine/main.cpp:
--------------------------------------------------------------------------------
1 | #include "Core.h"
2 | #include
3 | Core game;
4 | #undef main
5 | int main(int argc, char *argv[]){
6 | if(game.init(argc,argv)){
7 | float startTime, endTime, renderTime = 0;
8 | while(game.running){
9 | startTime = (float) SDL_GetTicks();
10 | game.inputs();
11 | game.events();
12 | game.update(&renderTime);
13 | game.render();
14 | endTime = (float) SDL_GetTicks();
15 | renderTime = (endTime - startTime);
16 |
17 | }
18 | }
19 | return 0;
20 | }
--------------------------------------------------------------------------------
/FoxelEngine/GlobalLight.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include "Vec3.h"
4 |
5 | static GLfloat* ambientLight;
6 | static GLfloat* diffuseLight;
7 | static GLfloat* specularLight;
8 | static GLfloat* mat_specular;
9 | static GLfloat* mat_shininess;
10 |
11 | class GlobalLight{
12 | private:
13 |
14 | public:
15 | static void load();
16 | static void lightAt(Vec3 position);
17 | static void turnOff();
18 | static void turnOn();
19 | GlobalLight(void);
20 | ~GlobalLight(void);
21 | };
22 |
23 |
--------------------------------------------------------------------------------
/FoxelEngine/Axes.cpp:
--------------------------------------------------------------------------------
1 | #include "Axes.h"
2 |
3 |
4 | Axes::Axes(void){
5 | anzVertex = 4;
6 | anzIndex = 6;
7 | indices = AxeIndices;
8 | vertices = AxeVertices;
9 | colors = AxeColor;
10 | }
11 |
12 | void Axes::render(){
13 | glBindVertexArray(vao);
14 | glEnableVertexAttribArray(0);
15 | glEnableVertexAttribArray(1);
16 | glDrawElements(GL_LINES,6,GL_UNSIGNED_INT,indices);
17 | glDisableVertexAttribArray(0);
18 | glDisableVertexAttribArray(1);
19 | glBindVertexArray(0);
20 | }
21 |
22 | Axes::~Axes(void){
23 | }
24 |
--------------------------------------------------------------------------------
/FoxelEngine/Entity_2D.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "Vec2.h"
3 | #include "Color.h"
4 | class Entity_2D{
5 | protected:
6 | Vec2 size;
7 | Vec2 position;
8 | Color backColor;
9 | public:
10 | Entity_2D(Vec2 position, Vec2 size);
11 | Entity_2D(void);
12 | ~Entity_2D(void);
13 | Vec2 getPosition();
14 | Vec2 getSize();
15 | void setBackColor(Color color);
16 | void setPosition(Vec2 position);
17 | void setSize(Vec2 size);
18 | void move(Vec2 value);
19 | void drawBackground();
20 | bool mouseIntersect();
21 | };
22 |
23 |
--------------------------------------------------------------------------------
/FoxelEngine/SlideControl.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include "Entity_2D.h"
4 | #include "TextField.h"
5 | class SlideControl : public Entity_2D{
6 | private:
7 | double value;
8 | double buffValue;
9 | TextField* text;
10 | void setText();
11 | std::string prefix;
12 | public:
13 | SlideControl(Vec2 position, Vec2 size, std::string prefix);
14 |
15 | void changeValue(float value);
16 | void setValue(float value);
17 | void draw();
18 | void setPosition(Vec2 position);
19 | float getValue();
20 | };
21 |
22 |
--------------------------------------------------------------------------------
/FoxelEngine/Controler.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | namespace MapEditor{
5 | class Controler{
6 | friend class Editor;
7 | private:
8 | bool rightMouseButton, leftMouseButton, midleMouseButton;
9 | bool A,S,D,W,Shift,Tab;
10 | bool Grab;
11 | int wheelState;
12 |
13 | public:
14 | Controler(void);
15 | ~Controler(void);
16 | void catchKeyDown(SDLKey sym);
17 | void catchKeyUp(SDLKey sym);
18 | void catchMouseClick(Uint8 button);
19 | void catchMouseRelease(Uint8 button);
20 | };
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/FoxelEngine/ColorPanel.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "Entity_2D.h"
3 | #include "Color.h"
4 | #include "SlideControl.h"
5 | class ColorPanel : public Entity_2D{
6 | private:
7 | Color color;
8 | SlideControl* slider_red;
9 | SlideControl* slider_green;
10 | SlideControl* slider_blue;
11 | SlideControl* slider_emit;
12 |
13 | void drawColorCircle();
14 | public:
15 | ColorPanel(Vec2 position, Vec2 size);
16 | ~ColorPanel(void);
17 |
18 | Color getColor();
19 | void draw();
20 | void resize(Vec2 position);
21 | void mouseInteraction();
22 | };
23 |
24 |
--------------------------------------------------------------------------------
/FoxelEngine/World.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //#include
3 | #include
4 | #include "Event.h"
5 | #include "FoxelManager.h"
6 | #include "Screen.h"
7 | #include "Axes.h"
8 | #include "Bullet.h"
9 | #include "GameGUI.h"
10 | #include "Config.h"
11 |
12 | class World{
13 | private:
14 | Axes* center;
15 | GameGUI* gui;
16 | BulletManager* bulletManager;
17 |
18 | public:
19 | World(void);
20 | void render();
21 | void drawGui();
22 | void update();
23 | bool load();
24 | void setDebugMode(bool boolean);
25 | ~World(void);
26 | };
27 |
28 |
--------------------------------------------------------------------------------
/FoxelEngine/DrawableGameComponent.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include "gamecomponent.h"
4 |
5 | #define BUFFER_OFFSET(i) (reinterpret_cast(i)) // for VBO
6 |
7 | class DrawableGameComponent :
8 | public GameComponent
9 | {
10 | protected:
11 | GLfloat *vertices, *colors, *normals;
12 | GLuint vao, *indices, vbos[3];
13 | unsigned int anzVertex;
14 | unsigned int anzIndex;
15 | unsigned int anzPolygon;
16 | public:
17 | DrawableGameComponent(void);
18 | ~DrawableGameComponent(void);
19 | void load();
20 | virtual void draw(){}
21 | };
22 |
23 |
--------------------------------------------------------------------------------
/FoxelEngine/Pistol.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "Model.h"
3 | #include "PropDynamic.h"
4 | #include "Screen.h"
5 | #include "Matrix4.h"
6 | #include "Bullet.h"
7 | class Pistol : public PropDynamic{
8 | private:
9 | Model* model;
10 | Matrix4 objMatrix;
11 | Vec3d rVelocity;
12 | BulletType bulletType;
13 | int cooldown;
14 | public:
15 | Pistol(void);
16 | ~Pistol(void);
17 | void load();
18 | void draw();
19 | void forceR(Vec3d rForce);
20 | void update(float* time);
21 | void shoot(Vec3 position, Vec3 direction);
22 | void shoot2(Vec3 position, Vec3 direction);
23 | };
24 |
25 |
--------------------------------------------------------------------------------
/FoxelEngine/PlayerControler.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | class PlayerControler{
4 | friend class Player;
5 | private:
6 | unsigned char nlod; //DEBUG! level of detail for chunks
7 | int controleMode;
8 | int wheelState;
9 | bool left, right;
10 | bool forward, backward;
11 | bool sprint;
12 | bool setFoxel,shoot,zoom,midleMouseButton;
13 |
14 | public:
15 | PlayerControler(int controleMode);
16 | void getKeyDown(SDLKey sym);
17 | void getKeyUp(SDLKey sym);
18 | void catchMouseClick(Uint8 button);
19 | void catchMouseRelease(Uint8 button);
20 | ~PlayerControler(void);
21 | };
22 |
23 |
--------------------------------------------------------------------------------
/FoxelEngine/Bullet.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "Vec3.h"
3 | #include
4 |
5 | enum BulletType {NORMAL, ROCKET};
6 |
7 | class Bullet{
8 | friend class BulletManager;
9 |
10 | private:
11 | BulletType bulletType;
12 |
13 | public:
14 | Vec3 position, velocity;
15 |
16 | Bullet(Vec3 start, Vec3 velocity, BulletType bulletType);
17 | BulletType getBulletType();
18 | void update();
19 | ~Bullet(void);
20 | };
21 |
22 | class BulletManager{
23 | private:
24 | static std::vector bullets;
25 |
26 | public:
27 | static void addBullet(Bullet* b);
28 | void detectHits();
29 |
30 |
31 | };
32 |
--------------------------------------------------------------------------------
/FoxelEngine/Core_events.cpp:
--------------------------------------------------------------------------------
1 | #include "Core.h"
2 | #include
3 |
4 | using namespace Event;
5 |
6 | BasicEvent* curentEvent;
7 | setFoxel* p;
8 |
9 | void Core::events(){
10 |
11 | while(BasicEvent::isWaiting()){
12 | curentEvent = BasicEvent::getNext();
13 | p = (setFoxel*)curentEvent;
14 | switch(curentEvent->getID()){
15 | case SET_FOXEL: FoxelManager::settingFoxel((setFoxel*)curentEvent);break;
16 | case PLAYMODE: startGame(); break;
17 | case EDITMODE: startEditor(); break;
18 | case EXIT: running = false;
19 | break;
20 |
21 |
22 | default: break;
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/FoxelEngine/Event.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | namespace Event{
5 |
6 | enum EventID{ SET_FOXEL, EXIT, PLAYMODE, EDITMODE };
7 |
8 | static int nextEvent;
9 | static int waitingEvents;
10 |
11 | class BasicEvent{
12 | private:
13 | static void deleteEvents();
14 |
15 |
16 | protected:
17 | short eventID;
18 |
19 | public:
20 | BasicEvent(void);
21 | BasicEvent(short id);
22 | static void initEventSystem();
23 | static BasicEvent* getNext();
24 | static bool isWaiting();
25 | short getID();
26 | ~BasicEvent(void);
27 | };
28 | static std::vector eventList;
29 | }
30 |
31 |
32 |
--------------------------------------------------------------------------------
/FoxelEngine/BitmapText.cpp:
--------------------------------------------------------------------------------
1 | #include "BitMapText.h"
2 |
3 |
4 | BitmapText::BitmapText(std::string newText){
5 | text = newText;
6 | bigText = true;
7 | }
8 |
9 | void BitmapText::setText(std::string newText){
10 | text = newText;
11 | bigText = true;
12 | }
13 |
14 |
15 | void BitmapText::draw(){
16 | for(int i = 0; i < text.length(); i++){
17 | if(bigText){
18 | glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,text[i]);
19 | }else{
20 | glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12,text[i]);
21 | }
22 |
23 | }
24 | }
25 |
26 | void BitmapText::setBigText(bool boolean){
27 | bigText = boolean;
28 | }
29 |
30 | BitmapText::~BitmapText(void){
31 |
32 | }
--------------------------------------------------------------------------------
/FoxelEngine/Shader.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | namespace GLSL{
8 | enum ShaderTyp { VERTEX_SHADER = 0, FRAGMENT_SHADER = 1 };
9 |
10 | class Shader{
11 | private:
12 | bool imFine;
13 | std::string fileName;
14 | ShaderTyp shaderTyp;
15 | GLuint shaderObject;
16 | GLint fileSize;
17 | char* fileSource;
18 |
19 | void compile();
20 | void loadFile(std::string fileName);
21 |
22 | public:
23 | Shader(std::string fileName);
24 | ~Shader(void);
25 | bool allRight();
26 | GLuint getShaderObject();
27 |
28 | static void printShaderLog(GLint object);
29 | };
30 | };
--------------------------------------------------------------------------------
/FoxelEngine/Axes.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include "drawablegamecomponent.h"
4 |
5 | static GLfloat AxeVertices[] = {0,0,0,
6 | 8,0,0,
7 | 0,8,0,
8 | 0,0,8};
9 |
10 | static GLfloat AxeColor[] = {0,0,0,
11 | 1,0,0,
12 | 0,1,0,
13 | 0,0,1};
14 |
15 | static GLuint AxeIndices[] = {0,1,0,2,0,3};
16 |
17 | class Axes : public DrawableGameComponent{
18 | private:
19 | //VertexPositionColor* vertices;
20 | public:
21 | Axes(void);
22 | ~Axes(void);
23 | void render();
24 | };
25 |
26 |
--------------------------------------------------------------------------------
/FoxelEngine/Shader/Foxel.frag:
--------------------------------------------------------------------------------
1 | #version 330
2 |
3 | in vec4 ex_Color;
4 | layout(location = 0) out vec4 frag_Output;
5 | layout(location = 1) out vec3 frag_Normal;
6 | layout(location = 2) out vec3 frag_Position;
7 |
8 | in vec3 ex_Position;
9 | in vec3 ex_Normal;
10 | in vec3 ex_Light;
11 | in vec3 ex_Light_global;
12 |
13 | void main(void){
14 | frag_Output = vec4(ex_Color.rgb,1.0) + ex_Color.a;
15 | frag_Normal = ex_Normal*0.5+0.5;
16 | frag_Position = ex_Position;
17 | //frag_Output.r += clamp(dot(ex_Normal,ex_Light),0.25,0.75)* 0.25;
18 | //frag_Output.g += clamp(dot(ex_Normal,ex_Light),0.25,0.75)* 0.25;
19 | //frag_Output.b += clamp(dot(ex_Normal,ex_Light),0.25,0.75)* 0.25;
20 | }
--------------------------------------------------------------------------------
/FoxelEngine/Vec3d.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "Vec2d.h"
3 | class Vec3d : public Vec2d{
4 |
5 | public:
6 | double z;
7 |
8 | Vec3d(void);
9 | Vec3d(double x, double y, double z);
10 | void normalize();
11 | double length();
12 | static double dot(Vec3d left, Vec3d right);
13 | // Operatoren
14 | void operator+=(double skalar);
15 | void operator+=(Vec3d vector);
16 | void operator-=(double skalar);
17 | void operator-=(Vec3d vector);
18 | Vec3d operator*(double skalar);
19 | Vec3d operator*(Vec3d vector);
20 | Vec3d operator-();
21 | Vec3d operator-(Vec3d vector);
22 | Vec3d operator+(Vec3d vector);
23 | bool operator!=(Vec3d vector);
24 | ~Vec3d(void);
25 | };
26 |
27 |
--------------------------------------------------------------------------------
/FoxelEngine/TextButton.cpp:
--------------------------------------------------------------------------------
1 | #include "TextButton.h"
2 |
3 |
4 | TextButton::TextButton(Vec2 position, Vec2 size, std::string content)
5 | : TextField(position, size, content){
6 | pressed = false;
7 | }
8 |
9 | void TextButton::press(){
10 | pressed = true;
11 | }
12 |
13 | void TextButton::release(){
14 | pressed = false;
15 | }
16 |
17 | bool TextButton::isPressed(){
18 | return pressed;
19 | }
20 |
21 | bool TextButton::intersect(Vec2 point){
22 | if(point.x > position.x && point.x < position.x + size.x
23 | && point.y > position.y && point.y < position.y + size.y){
24 | return true;
25 | }else{
26 | return false;
27 | }
28 | }
29 |
30 | TextButton::~TextButton(void)
31 | {
32 | }
33 |
--------------------------------------------------------------------------------
/FoxelEngine/Vec2.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | class Vec2{
3 |
4 | public:
5 | float x,y;
6 |
7 | Vec2(void);
8 | Vec2(float x, float y);
9 |
10 | void rotate(Vec2 center, double phi);
11 | void normalize();
12 | float length();
13 | static float dot(Vec2 left, Vec2 right);
14 | // Operatoren
15 | void operator+=(float skalar);
16 | void operator+=(Vec2 vector);
17 | void operator-=(float skalar);
18 | void operator-=(Vec2 vector);
19 | Vec2 operator*(float skalar);
20 | Vec2 operator*(Vec2 vector);
21 | Vec2 operator+(float skalar);
22 | Vec2 operator+(Vec2 vector);
23 | Vec2 operator-(float skalar);
24 | Vec2 operator-(Vec2 vector);
25 | Vec2 operator-();
26 | Vec2 operator+();
27 | ~Vec2(void);
28 | };
--------------------------------------------------------------------------------
/FoxelEngine/Vec3.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "Vec2.h"
3 | #include "Vec3d.h"
4 | class Vec3 : public Vec2{
5 |
6 | public:
7 | float z;
8 |
9 | Vec3(void);
10 | Vec3(Vec3d vector);
11 | Vec3(float x, float y, float z);
12 | void normalize();
13 | float length();
14 | static float dot(Vec3 left, Vec3 right);
15 | // Operatoren
16 | void operator+=(float skalar);
17 | void operator+=(Vec3 vector);
18 | void operator-=(float skalar);
19 | void operator-=(Vec3 vector);
20 | Vec3 operator*(float skalar);
21 | Vec3 operator*(Vec3 vector);
22 | Vec3 operator-();
23 | Vec3 operator-(Vec3 vector);
24 | Vec3 operator+(Vec3 vector);
25 | bool operator!=(Vec3 vector);
26 |
27 | bool isAxisOriented();
28 | ~Vec3(void);
29 | };
30 |
31 |
--------------------------------------------------------------------------------
/FoxelEngine/GameGUI.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include "TextField.h"
4 | #include "Screen.h"
5 | #include "Vec2.h"
6 |
7 | class GameGUI{
8 | private:
9 | bool debug;
10 | TextField* debugInformations;
11 | std::string debug_ChunkInformations;
12 | std::string debug_GPU_Uploads;
13 | std::string debug_PolycountInformation;
14 | std::string debug_DirectLights;
15 | std::string debug_BounceLights;
16 |
17 | public:
18 | GameGUI(void);
19 | ~GameGUI(void);
20 | void draw();
21 | void update();
22 | void setDebugGpuUploads(int value);
23 | void setDebugChunkInformation(int value);
24 | void setDebugPolycountInformation(long value);
25 | void setDebugDirectLightsCount(int value);
26 | void setDebugBounceLightsCount(int value);
27 | };
28 |
29 |
--------------------------------------------------------------------------------
/FoxelEngine/TextField.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include "Entity_2D.h"
5 | #include "BitMapText.h"
6 | //#include
7 |
8 |
9 | class TextField : public Entity_2D{
10 |
11 | protected:
12 | std::vector linesOfContent;
13 | int* displayWidth;
14 | int* displayHeight;
15 | bool withBox, bigText;
16 | int boxPadding;
17 | GLfloat textColor[3];
18 |
19 | public:
20 | TextField(Vec2 position, Vec2 size, std::string);
21 | TextField(Vec2 position, Vec2 size);
22 | ~TextField(void);
23 |
24 | Vec2 getPosition();
25 | void setContent(int,std::string);
26 | void setTextColor(float r, float g, float b);
27 | void draw();
28 | void setBigText(bool boolean);
29 | void newLine(std::string);
30 | void setWithBox(bool boolean);
31 | };
--------------------------------------------------------------------------------
/FoxelEngine/Matrix4.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include "Vec3.h"
5 | static const int M_SIZE = 4;
6 | class Matrix4{
7 |
8 | public:
9 | Matrix4(void);
10 | ~Matrix4(void);
11 | float matrix[M_SIZE*M_SIZE];
12 |
13 | static Matrix4 Identity();
14 |
15 | static Matrix4 RotateX(float angle);
16 | static Matrix4 RotateY(float angle);
17 | static Matrix4 RotateZ(float angle);
18 | static Matrix4 CreateFromAxisAngle(Vec3 axis, float angle);
19 |
20 | Matrix4 operator*(Matrix4 B);
21 |
22 | void scale(float x, float y, float z);
23 | void translate(float x,float y,float z);
24 | void translate(Vec3 vector);
25 | void rotate(float angle, float x, float y, float z);
26 |
27 |
28 |
29 | float* getMatrix();
30 | void printMatrix();
31 | };
32 |
33 |
--------------------------------------------------------------------------------
/FoxelEngine/Model.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 |
9 | #define BUFFER_OFFSET(i) (reinterpret_cast(i)) // for VBO
10 |
11 | struct GLVertex{
12 | GLfloat x,y,z;
13 | GLfloat a,b,c;
14 | GLfloat u,v;
15 | };
16 |
17 | struct Vertex{
18 | float x,y,z;
19 | };
20 |
21 | struct Normal{
22 | float a,b,c;
23 | };
24 |
25 | struct Textur{
26 | float u,v;
27 | };
28 |
29 | class Model{
30 | private:
31 | static GLuint anzVertex, anzIndex;
32 | static GLVertex* vertices;
33 | static GLuint vao, *indices, vbos[2];
34 | static bool loaded;
35 |
36 |
37 | public:
38 | Model();
39 | ~Model();
40 | bool load(char* objfile);
41 | void draw();
42 | };
43 |
44 |
--------------------------------------------------------------------------------
/FoxelEngine/Color.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | class Color{
4 | unsigned char RGBA[4];
5 | public:
6 | Color(void);
7 | Color(unsigned char R, unsigned char G, unsigned char B);
8 | Color(unsigned char R, unsigned char G, unsigned char B, unsigned char A);
9 |
10 | unsigned char* getColorArray();
11 | unsigned char getRed();
12 | unsigned char getGreen();
13 | unsigned char getBlue();
14 | unsigned char getAlpha();
15 |
16 | void setColor(unsigned char r, unsigned char g, unsigned char b);
17 | void setColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
18 |
19 | void setRed(unsigned char r);
20 | void setGreen(unsigned char g);
21 | void setBlue(unsigned char b);
22 | void setAlpha(unsigned char a);
23 | unsigned char getMaximum();
24 | short getLuminate();
25 | };
26 |
27 |
--------------------------------------------------------------------------------
/FoxelEngine/PostProcessor.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | static const GLfloat g_quad_vertex_buffer_data[] = {
5 | -1.0f, -1.0f, 0.0f,
6 | 1.0f, -1.0f, 0.0f,
7 | -1.0f, 1.0f, 0.0f,
8 | -1.0f, 1.0f, 0.0f,
9 | 1.0f, -1.0f, 0.0f,
10 | 1.0f, 1.0f, 0.0f,
11 | };
12 |
13 |
14 | class PostProcessor{
15 | private:
16 | GLuint framebuffer;
17 | GLuint renderedTexture;
18 | GLuint positionTexture;
19 | GLuint normalTexture;
20 | GLuint depthTexture;
21 | GLuint depthrenderbuffer;
22 |
23 | GLuint quad_VertexArrayID;
24 | GLuint quad_vertexbuffer;
25 |
26 | GLuint bounceLightTexture;
27 | void generateBounceLightTexture();
28 |
29 | public:
30 | PostProcessor(void);
31 | ~PostProcessor(void);
32 | void setupToDraw();
33 | void draw();
34 | bool load();
35 | };
36 |
37 |
--------------------------------------------------------------------------------
/FoxelEngine/ShaderProgram.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include