58 lines
1.0 KiB
C
58 lines
1.0 KiB
C
#ifndef OBJ_H
|
|
#define OBJ_H
|
|
|
|
#include "aliases.h"
|
|
#include "img.h"
|
|
#include "mem_arena.h"
|
|
#include "typed_list.h"
|
|
#include "vec.h"
|
|
|
|
#define INVALID_MODEL ((Model){0})
|
|
#define IS_INVALID_MODEL(m) (m.vertices == NULL || m.triangles == NULL)
|
|
|
|
typedef struct triangle Triangle;
|
|
struct triangle {
|
|
u64 p0;
|
|
u64 p1;
|
|
u64 p2;
|
|
u64 n0;
|
|
u64 n1;
|
|
u64 n2;
|
|
u64 tx0;
|
|
u64 tx1;
|
|
u64 tx2;
|
|
};
|
|
|
|
MAKE_LIST_TYPE(Triangle);
|
|
|
|
typedef struct phong_material PhongMaterial;
|
|
struct phong_material {
|
|
f32 specular;
|
|
f32 diffuse;
|
|
f32 ambient;
|
|
f32 shininess;
|
|
};
|
|
|
|
typedef struct point_light PointLight;
|
|
struct point_light {
|
|
V3f diffuse_intensity;
|
|
V3f specular_intensity;
|
|
V3f position;
|
|
};
|
|
|
|
typedef struct model Model;
|
|
struct model {
|
|
LIST_TYPE(V3f) * vertices;
|
|
LIST_TYPE(V3f) * normals;
|
|
LIST_TYPE(V2f) * texture_coordinates;
|
|
LIST_TYPE(Triangle) * triangles;
|
|
Image *texture;
|
|
Image *normal;
|
|
PhongMaterial material;
|
|
};
|
|
|
|
Model load_obj_file(Arena *arena, const char *filename, const char *texture,
|
|
const char *normal_map);
|
|
|
|
#endif // OBJ_H
|