// sceneGraph.h

#ifndef SCENE_GRAPH_H
#define SCENE_GRAPH_H

#include <GL/glew.h>
#include "matrixMath.h"
#include "wavefrontobj.h"
#include "objectHandler.h"


typedef struct SceneNode SceneNode;

typedef struct {
    ObjectData* objectData;
    GLuint texture;
    GLuint secondaryTexture;
    GLuint normalMap;
} Model;

struct SceneNode {
    int id;
    mat4 transformation; // Local transformation matrix
    mat4 worldTransformation; // World transformation matrix
    SceneNode** children; // Array of pointers to child nodes
    int numChildren; // Number of child nodes
    Model* model;
    char* name;
};

extern SceneNode* findNode(int id, SceneNode* root);
extern SceneNode* findNodeByName(char* name, SceneNode* root);
extern void setNodeRenderFunction(void (*newRenderFunction)(SceneNode*));
extern SceneNode* createSceneNode();
extern void addChild(SceneNode* parent, SceneNode* child);
extern void updateSceneNode(SceneNode* node, mat4* parentTransformation);
extern void renderSceneNode(SceneNode* node);
extern void freeSceneNode(SceneNode* node);
extern void printSceneGraph(SceneNode* root, int level);
extern SceneNode* loadSceneGraphFromFile(char* path);

#endif