Saxum/game/level.hh

124 lines
4.5 KiB
C++
Raw Permalink Normal View History

2014-10-20 16:38:29 +00:00
#ifndef LEVEL_HH_INCLUDED
#define LEVEL_HH_INCLUDED
#include <string>
#include "object.hh"
#include "light.hh"
2014-10-20 16:38:29 +00:00
#include "entity.hh"
2014-10-20 17:07:45 +00:00
#include "terrain.hh"
#include "material.hh"
#include "camera.hh"
#include "physics.hh"
#include "trigger.hh"
#include "skydome.hh"
2015-03-12 18:14:14 +00:00
#include "keyboardState.hh"
2015-03-16 15:58:50 +00:00
#include "chunk.hh"
2014-10-20 16:38:29 +00:00
extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}
#include "LuaBridge.h"
2015-03-21 14:05:22 +00:00
// forward declaration
class Graphics;
2014-10-20 16:38:29 +00:00
class Level {
public:
Level(std::string xmlFilePath, float farPlane);
Level();
2014-10-20 16:38:29 +00:00
~Level();
void load();
2015-03-12 18:14:14 +00:00
void update(float runTimeSinceLastUpdate, float runTime, glm::vec2 mouseDelta,
KeyboardState* keyboardState);
void render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
glm::vec3 center, int chunkRenderDistance, glm::mat4* viewProjectionMatrix,
2015-03-21 20:46:58 +00:00
std::vector<glm::mat4>* shadowVPs=0);
2014-10-30 22:59:03 +00:00
glm::vec3 getAmbientLight();
2014-11-17 16:51:15 +00:00
Light* getDirectionalLight();
std::vector<shared_ptr<Light>>* getLights();
Object* getCameraCenter();
2014-11-15 13:54:44 +00:00
Camera* getCamera();
glm::vec3 getCameraPosition();
2015-03-08 23:39:59 +00:00
glm::vec4 getFogColourDay();
glm::vec4 getFogColourRise();
glm::vec4 getFogColourNight();
2014-11-21 23:39:58 +00:00
void setSkydomeSize(float size);
float getSkydomeSize();
2015-03-09 13:28:09 +00:00
void setWaterPlane(Object* water);
Object* getWaterPlane();
Skydome* getSkydome();
2015-03-16 15:58:50 +00:00
std::vector<Object*>* getAllObjects();
std::vector<Object*>* getPhysicsObjects();
void moveObject(int objectIndex, float strength, float xPos, float yPos, float zPos);
void setStrength(float strength);
void setSkydomeObject(Skydome object);
void addObject(Object* object, bool crossesChunks);
void addPhysicsObject(Object* object);
void setAmbientLight(glm::vec3 colour);
2015-03-08 23:39:59 +00:00
void setFogColourDay(glm::vec4 colour);
void setFogColourRise(glm::vec4 colour);
void setFogColourNight(glm::vec4 colour);
void setDirectionalLight(Light light);
void setSunDirection(float x, float y, float z);
unsigned int getPhysicsObjectsVectorSize();
2015-03-16 15:58:50 +00:00
Physics* getPhysics();
void setCameraCenter(Object* object);
void addLight(Light light);
void preloadLightPosition(float xPos, float yPos, float zPos);
void addLightByParameters(float redColour, float greenColour,
float blueColour, float intensity, float flameYOffset,
float flameHeight, float flameWidth);
void deleteFourLights();
void addTrigger(Trigger trigger);
lua_State* getLuaState();
Terrain* getTerrain();
void resetPlayer();
void movePlayer(float xPosition, float yPosition, float zPosition);
void setPlayerIndex(int index);
void forceMove(float x, float y, float z, unsigned indice);
2015-03-06 15:19:57 +00:00
void activateEndgame();
void setTerrain(Terrain terrain);
void printPosition();
2015-03-16 15:58:50 +00:00
void generateChunks(int chunkSize);
std::vector<std::vector<Chunk>>* getChunks();
void addToSpecificChunk(Object* object, int xPosition, int zPosition);
2015-03-21 14:05:22 +00:00
void enqueueObjects(Graphics* graphics);
void sortObjects(int textureCount);
std::vector<shared_ptr<Light>>* getClosestLights(unsigned int maximumAmount);
int checkMaxSurroundingLights();
2014-10-20 16:38:29 +00:00
private:
std::vector<Chunk*> getSurroundingChunks(glm::vec3 center, int chunkRenderDistance);
lua_State* luaState=nullptr;
2015-03-16 15:58:50 +00:00
std::vector<Object*> crossChunkObjects;
2015-03-21 14:05:22 +00:00
std::vector<std::vector<Object*>> sortedCrossChunkObjects;
2015-03-16 15:58:50 +00:00
std::vector<Object*> allObjects;
std::vector<Object*> physicsObjects;
2015-03-17 08:39:42 +00:00
std::vector<std::vector<Chunk>> chunks;
std::vector<shared_ptr<Light>> lights;
std::vector<shared_ptr<Light>> closestLights;
std::vector<Trigger> triggers;
2015-03-24 18:09:39 +00:00
Object* waterPlane=nullptr;
glm::vec3 ambientLight;
2015-03-08 23:39:59 +00:00
glm::vec4 fogColourDay;
glm::vec4 fogColourRise;
glm::vec4 fogColourNight;
2014-11-17 16:51:15 +00:00
Light directionalLight;
2015-03-24 18:09:39 +00:00
Object* cameraCenter=nullptr;
int playerIndex;
Skydome skydome;
Physics physics;
Camera camera;
2014-10-20 17:07:45 +00:00
Terrain terrain;
2014-11-21 23:39:58 +00:00
float skydomeSize;
float strength;
std::string xmlFilePath;
glm::vec3 nextLightPosition;
int chunkSize;
float farPlane;
bool compareLightDistances(shared_ptr<Light> a, shared_ptr<Light> b);
2014-10-20 16:44:23 +00:00
};
2014-10-20 16:48:20 +00:00
#endif