vectozavr-shooter/engine/World.h

47 lines
1.4 KiB
C
Raw Normal View History

2021-09-13 15:53:43 +03:00
//
// Created by Иван Ильин on 13.01.2021.
//
#ifndef ENGINE_WORLD_H
#define ENGINE_WORLD_H
#include <map>
#include "Camera.h"
2021-10-22 19:42:32 +03:00
#include "Screen.h"
#include "physics/RigidBody.h"
2021-09-13 15:53:43 +03:00
2021-10-22 19:42:32 +03:00
struct IntersectionInformation final {
const Vec3D pointOfIntersection;
const double distanceToObject;
const Triangle intersectedTriangle;
const ObjectNameTag objectName;
const std::shared_ptr<RigidBody> obj;
const bool intersected;
};
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);
void update();
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);
2021-10-17 20:52:21 +03:00
void loadBody(const ObjectNameTag& tag, const std::string &filename, const Vec3D& scale = Vec3D{1, 1, 1});
2021-09-13 15:53:43 +03:00
2021-10-22 19:42:32 +03:00
// std::string skipTags is a string that consist of all objects we want to skip in ray casting
IntersectionInformation rayCast(const Vec3D& from, const Vec3D& to, const std::string& skipTags = "");
2021-09-13 15:53:43 +03:00
2021-10-17 20:52:21 +03:00
void loadMap(const std::string& filename, const Vec3D & scale = Vec3D{1, 1, 1});
2021-10-22 19:42:32 +03:00
std::map<ObjectNameTag, std::shared_ptr<RigidBody>>::iterator begin() { return _objects.begin(); }
std::map<ObjectNameTag, std::shared_ptr<RigidBody>>::iterator end() { return _objects.end(); }
2021-09-13 15:53:43 +03:00
};
#endif //INC_3DZAVR_WORLD_H