2016-11-19 09:28:01 +00:00
|
|
|
#include "graphics/buffer.h"
|
|
|
|
#include "graphics/texture.h"
|
2017-01-18 08:51:09 +00:00
|
|
|
#include "math/mat4.h"
|
|
|
|
#include "math/vec3.h"
|
2016-11-19 09:28:01 +00:00
|
|
|
#include "glfw.h"
|
2016-11-19 07:41:23 +00:00
|
|
|
#include "util.h"
|
2016-11-26 07:15:04 +00:00
|
|
|
#include "vendor/vec/vec.h"
|
2016-07-09 05:27:34 +00:00
|
|
|
|
2016-08-10 06:28:17 +00:00
|
|
|
#ifndef LOVR_MODEL_TYPES
|
|
|
|
#define LOVR_MODEL_TYPES
|
2016-11-26 07:15:04 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float z;
|
|
|
|
} ModelVertex;
|
|
|
|
|
|
|
|
typedef vec_t(ModelVertex) vec_model_vertex_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned int indices[3];
|
|
|
|
} ModelFace;
|
|
|
|
|
|
|
|
typedef vec_t(ModelFace) vec_model_face_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
vec_model_face_t faces;
|
|
|
|
vec_model_vertex_t vertices;
|
|
|
|
vec_model_vertex_t normals;
|
|
|
|
vec_model_vertex_t texCoords;
|
|
|
|
} ModelMesh;
|
|
|
|
|
|
|
|
typedef vec_t(ModelMesh*) vec_model_mesh_t;
|
|
|
|
|
|
|
|
typedef struct ModelNode {
|
|
|
|
mat4 transform;
|
|
|
|
vec_uint_t meshes;
|
|
|
|
vec_void_t children;
|
|
|
|
} ModelNode;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
Ref ref;
|
|
|
|
ModelNode* root;
|
|
|
|
vec_model_mesh_t meshes;
|
|
|
|
int hasNormals;
|
|
|
|
int hasTexCoords;
|
|
|
|
} ModelData;
|
|
|
|
|
2016-10-04 04:54:27 +00:00
|
|
|
typedef struct {
|
2016-11-19 07:41:23 +00:00
|
|
|
Ref ref;
|
2016-10-04 04:54:27 +00:00
|
|
|
ModelData* modelData;
|
2016-10-31 20:54:32 +00:00
|
|
|
Buffer* buffer;
|
2016-11-08 22:51:58 +00:00
|
|
|
Texture* texture;
|
2016-10-04 04:54:27 +00:00
|
|
|
} Model;
|
2016-11-26 07:15:04 +00:00
|
|
|
|
2016-08-10 06:28:17 +00:00
|
|
|
#endif
|
2016-10-04 04:54:27 +00:00
|
|
|
|
2016-11-25 08:49:19 +00:00
|
|
|
Model* lovrModelCreate(ModelData* modelData);
|
2016-11-19 07:41:23 +00:00
|
|
|
void lovrModelDestroy(const Ref* ref);
|
2016-11-26 07:15:04 +00:00
|
|
|
void lovrModelDataDestroy(ModelData* modelData);
|
2016-11-02 03:56:29 +00:00
|
|
|
void lovrModelDraw(Model* model, float x, float y, float z, float scale, float angle, float ax, float ay, float az);
|
2016-11-08 22:51:58 +00:00
|
|
|
Texture* lovrModelGetTexture(Model* model);
|
|
|
|
void lovrModelSetTexture(Model* model, Texture* texture);
|