merge with headless_mode

This commit is contained in:
2025-02-04 23:54:08 +01:00
17 changed files with 585 additions and 188 deletions

55
includes/RT/Arguments.hpp Normal file
View File

@ -0,0 +1,55 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Arguments.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/04 01:07:08 by tomoron #+# #+# */
/* Updated: 2025/02/04 22:04:04 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ARGUMENTS_HPP
# define ARGUMENTS_HPP
#include "RT.hpp"
typedef struct s_arg
{
char shortName;
std::string longName;
int isFlag;
} t_arg;
class Arguments
{
public :
Arguments(int argc, char **argv);
bool getHeadless(void) const;
bool error(void) const;
void show(void);
std::string &getSceneName(void);
std::string *getRenderPath(void);
bool getHeadless(void);
private:
void printUsage();
int handleArg(char **argv, int argc, int *i);
void initArguments(void);
void addArgument(char shortName, std::string longName, int isFlag);
int setArg(t_arg arg, char **argv, int argc, int *i);
void parseRenderPathName(char * path);
bool _headless;
bool _err;
std::vector<t_arg> _args;
std::map<std::string, std::string> _values;
};
#endif

View File

@ -6,7 +6,7 @@
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/22 16:29:26 by tomoron #+# #+# */
/* Updated: 2025/01/30 22:15:55 by tomoron ### ########.fr */
/* Updated: 2025/02/04 23:19:37 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -36,22 +36,28 @@ typedef struct s_pathPoint
class Renderer
{
public:
Renderer(Scene *scene, Window *win);
Renderer(Scene *scene, Window *win, Arguments &args);
void renderImgui(void);
void update(Shader &shader);
int rendering(void) const;
bool shouldClose(void) const;
private:
void addPoint(float time);
void init(Scene *scene, Window *win);
void savePath(void);
void rawRead(std::ifstream &file, void *buf, size_t len);
void loadPath(std::string filename);
void makeMovement(float timeFromStart, float curSplitTimeReset);
void initRender();
void addImageToRender(Shader &shader);
void endRender(void);
void imguiPathCreation(void);
void imguiRenderInfo(void);
std::string floatToTime(float timef);
void showRenderInfo(int isImgui);
void imguiRenderSettings(void);
std::string floatToTime(double timef);
glm::vec2 bezierSphereInterpolate(glm::vec4 control, glm::vec2 from, glm::vec2 to, float time);
void updateAvailableCodecs(void);
void updateAvailableCodecs(int mode, AVCodecID id);
void fillGoodCodecList(std::vector<AVCodecID> &lst);
glm::vec3 hermiteInterpolate(glm::vec3 points[4], double alpha);
@ -69,6 +75,11 @@ class Renderer
std::vector<const AVCodec *> _codecList;
std::vector<const char *> _codecListStr;
int _codecIndex;
bool _renderSettings;
bool _ignoreUnavailableCodec;
bool _headless;
bool _tp;
bool _shouldClose;
int _curPathIndex;
int _destPathIndex;

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/23 18:30:18 by ycontre #+# #+# */
/* Updated: 2025/01/28 19:05:16 by ycontre ### ########.fr */
/* Updated: 2025/02/04 03:11:36 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -105,11 +105,9 @@ class Camera;
class Scene
{
public:
Scene();
Scene(std::string &name);
~Scene();
bool parseScene(char *name);
void addObject(Object *object);
void addMaterial(Material *material);
void addTexture(std::string path);
@ -141,7 +139,11 @@ class Scene
Camera *getCamera(void) const;
GPUMaterial getMaterial(int material_index);
bool fail(void) const;
private:
bool _fail;
std::vector<GPUBvhData> _gpu_bvh_data;
std::vector<GPUBvh> _gpu_bvh;

View File

@ -6,7 +6,7 @@
/* By: TheRed <TheRed@students.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/26 21:37:37 by TheRed #+# #+# */
/* Updated: 2025/01/21 15:15:13 by tomoron ### ########.fr */
/* Updated: 2025/02/04 01:21:28 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,7 +18,7 @@
class SceneParser
{
public:
SceneParser(Scene *scene, char *filename);
SceneParser(Scene *scene, std::string filename);
bool parseLine(const std::string &line);

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/13 16:15:41 by TheRed #+# #+# */
/* Updated: 2025/01/25 03:09:23 by tomoron ### ########.fr */
/* Updated: 2025/02/04 16:46:37 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,7 +20,7 @@ class Scene;
class Window
{
public:
Window(Scene *scene, int width, int height, const char *title, int sleep);
Window(Scene *scene, int width, int height, const char *title, int sleep, Arguments &args);
~Window(void);
void display();