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
|
|
|
|
2021-10-12 20:18:56 +03:00
|
|
|
class World final {
|
2021-09-13 15:53:43 +03:00
|
|
|
private:
|
2021-10-17 10:21:10 +03:00
|
|
|
std::map<ObjectNameTag, std::shared_ptr<RigidBody>> _objects;
|
2021-09-13 15:53:43 +03:00
|
|
|
public:
|
|
|
|
World() = default;
|
|
|
|
|
2021-10-17 10:21:10 +03:00
|
|
|
void checkCollision(const ObjectNameTag& tag);
|
2021-09-19 11:25:10 +03:00
|
|
|
void update();
|
|
|
|
void projectObjectsInCamera(std::shared_ptr<Camera> camera);
|
2021-09-13 15:53:43 +03:00
|
|
|
|
2021-10-17 10:21:10 +03:00
|
|
|
void addBody(std::shared_ptr<RigidBody> mesh, const ObjectNameTag& tag);
|
|
|
|
std::shared_ptr<RigidBody> body(const ObjectNameTag& tag);
|
|
|
|
void removeBody(const ObjectNameTag& tag);
|
|
|
|
void loadBody(const ObjectNameTag& tag, const std::string &filename, const std::string &materials = "", const Vec3D& scale = Vec3D{1, 1, 1});
|
2021-09-13 15:53:43 +03:00
|
|
|
|
|
|
|
// rayCast returns pair of Point4D and std::string:
|
2021-10-12 17:12:47 +03:00
|
|
|
// 1) Point4D is point of collision
|
2021-09-19 15:44:31 +03:00
|
|
|
// 2) std::string - title of the object
|
2021-10-17 10:21:10 +03:00
|
|
|
std::pair<Vec3D, ObjectNameTag> rayCast(const Vec3D& from, const Vec3D& to, const std::string& tag = "");
|
2021-09-13 15:53:43 +03:00
|
|
|
|
2021-10-12 17:12:47 +03:00
|
|
|
void loadMap(const std::string& filename, const std::string& materials, const std::string& name = "map", const Vec3D & scale = Vec3D{1, 1, 1});
|
2021-09-13 15:53:43 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //INC_3DZAVR_WORLD_H
|