#ifndef slic3r_CameraUtils_hpp_
#define slic3r_CameraUtils_hpp_
#include "Camera.hpp"
#include "libslic3r/Point.hpp"
namespace Slic3r {
class GLVolume;
}
namespace Slic3r::GUI {
///
/// Help divide camera data and camera functions
/// This utility work with camera data by static funtions
///
class CameraUtils
{
public:
CameraUtils() = delete; // only static functions
///
/// Project point throw camera to 2d coordinate into imgui window
///
/// Projection params
/// Point to project.
/// projected points by camera into coordinate of camera.
/// x(from left to right), y(from top to bottom)
static Points project(const Camera& camera, const std::vector &points);
static Point project(const Camera& camera, const Vec3d &point);
///
/// Create hull around GLVolume in 2d space of camera
///
/// Projection params
/// Outline by 3d object
/// Polygon around object
static Polygon create_hull2d(const Camera &camera, const GLVolume &volume);
///
/// Create ray(point and direction) for screen coordinate
///
/// Definition of camera
/// Position on screen(aka mouse position)
/// OUT start of ray
/// OUT direction of ray
static void ray_from_screen_pos(const Camera &camera, const Vec2d &position, Vec3d &point, Vec3d &direction);
static void ray_from_ortho_screen_pos(const Camera &camera, const Vec2d &position, Vec3d &point, Vec3d &direction);
static void ray_from_persp_screen_pos(const Camera &camera, const Vec2d &position, Vec3d &point, Vec3d &direction);
///
/// Unproject mouse coordinate to get position in space where z coor is zero
/// Platter surface should be in z == 0
///
/// Projection params
/// Mouse position
/// Position on platter under mouse
static Vec2d get_z0_position(const Camera &camera, const Vec2d &coor);
///
/// Create 3d screen point from 2d position
///
/// Define camera viewport
/// Position on screen(aka mouse position)
/// Point represented screen coor in 3d
static Vec3d screen_point(const Camera &camera, const Vec2d &position);
};
} // Slic3r::GUI
#endif /* slic3r_CameraUtils_hpp_ */