2021-09-13 15:53:43 +03:00
|
|
|
//
|
|
|
|
// Created by Иван Ильин on 13.01.2021.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef ENGINE_WORLD_H
|
|
|
|
#define ENGINE_WORLD_H
|
|
|
|
|
|
|
|
#include <map>
|
2021-09-19 11:25:10 +03:00
|
|
|
#include "Camera.h"
|
|
|
|
#include "physics/RigidBody.h"
|
2021-09-13 15:53:43 +03:00
|
|
|
|
|
|
|
class World {
|
|
|
|
private:
|
2021-09-19 11:25:10 +03:00
|
|
|
std::map<std::string, std::shared_ptr<RigidBody>> _objects;
|
2021-09-13 15:53:43 +03:00
|
|
|
public:
|
|
|
|
World() = default;
|
|
|
|
|
2021-09-19 11:25:10 +03:00
|
|
|
void checkCollision(const std::string& body);
|
|
|
|
void update();
|
|
|
|
void projectObjectsInCamera(std::shared_ptr<Camera> camera);
|
2021-09-13 15:53:43 +03:00
|
|
|
|
2021-09-19 11:25:10 +03:00
|
|
|
void addBody(std::shared_ptr<RigidBody> mesh, const std::string& name = "");
|
|
|
|
std::shared_ptr<RigidBody> body(const std::string& name);
|
2021-10-09 13:41:12 +03:00
|
|
|
void removeBody(std::string name);
|
2021-09-19 11:25:10 +03:00
|
|
|
void loadBody(const std::string &name, const std::string &filename, const std::string &materials = "", const Point4D& scale = Point4D{1, 1, 1});
|
2021-09-13 15:53:43 +03:00
|
|
|
|
|
|
|
// rayCast returns pair of Point4D and std::string:
|
|
|
|
// 1) Point4D is point of collision (the last coordinate is -1 if there are no collisions)
|
2021-09-19 15:44:31 +03:00
|
|
|
// 2) std::string - title of the object
|
2021-09-13 15:53:43 +03:00
|
|
|
std::pair<Point4D, std::string> rayCast(const Point4D& from, const Point4D& to);
|
|
|
|
|
2021-10-09 13:41:12 +03:00
|
|
|
void loadMap(const std::string& filename, const std::string& materials, const std::string& name = "map", const Point4D & scale = Point4D{1, 1, 1});
|
2021-09-13 15:53:43 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //INC_3DZAVR_WORLD_H
|