projects
/
carveJwlIkooP6JGAAIwe30JlM.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
stuff
[carveJwlIkooP6JGAAIwe30JlM.git]
/
model.h
diff --git
a/model.h
b/model.h
index 2aaf48358517283fa72d6c40a1e0b1d6194e28a7..430ed26d7425d684670bddeb0931a9b9b45039de 100644
(file)
--- a/
model.h
+++ b/
model.h
@@
-1,10
+1,13
@@
+#ifndef MODEL_H
+#define MODEL_H
+
#include "vg/vg.h"
typedef struct model model;
typedef struct glmesh glmesh;
typedef struct submodel submodel;
typedef struct model_vert model_vert;
#include "vg/vg.h"
typedef struct model model;
typedef struct glmesh glmesh;
typedef struct submodel submodel;
typedef struct model_vert model_vert;
-typedef struct
scene scene
;
+typedef struct
model_marker model_marker
;
typedef struct sdf_primative sdf_primative;
typedef enum esdf_type esdf_type;
typedef struct sdf_primative sdf_primative;
typedef enum esdf_type esdf_type;
@@
-15,17
+18,8
@@
struct model
u32 vertex_count,
indice_count,
u32 vertex_count,
indice_count,
- layer_count;
-};
-
-struct sdf_primative
-{
- v4f origin; /* xyz, yaw */
- /* Cone:
- x base scale
- y height
- */
- v4f info;
+ layer_count,
+ marker_count;
};
struct submodel
};
struct submodel
@@
-36,17
+30,24
@@
struct submodel
vertex_count;
boxf bbx;
vertex_count;
boxf bbx;
- sdf_primative sdf;
+ v3f pivot; /* same as co? */
+ v4f q;
+ char name[32];
+ char material[32];
+};
- enum esdf_type
- {
- k_sdf_none = 0,
- k_sdf_cone,
- k_sdf_sphere,
- k_sdf_box
- }
- sdf_type;
+struct classtype_gate
+{
+ u32 target;
+};
+struct model_marker
+{
+ v3f co;
+ v4f q;
+ v3f s;
+ u32 classtype;
+ u32 offset;
char name[32];
};
char name[32];
};
@@
-121,15
+122,21
@@
static void mesh_draw( glmesh *mesh )
/*
* Helper functions for file offsets
/*
* Helper functions for file offsets
+ * TODO: Revise this
*/
static submodel *model_get_submodel( model *mdl, int id )
{
return ((submodel*)(mdl+1)) + id;
}
*/
static submodel *model_get_submodel( model *mdl, int id )
{
return ((submodel*)(mdl+1)) + id;
}
+static model_marker *model_get_marker( model *mdl, int id )
+{
+ return ((model_marker*)model_get_submodel(mdl,mdl->layer_count)) + id;
+}
+
static model_vert *model_vertex_base( model *mdl )
{
static model_vert *model_vertex_base( model *mdl )
{
- return (model_vert *)model_get_
submodel( mdl, mdl->lay
er_count );
+ return (model_vert *)model_get_
marker( mdl, mdl->mark
er_count );
}
static u32 *model_indice_base( model *mdl )
}
static u32 *model_indice_base( model *mdl )
@@
-147,6
+154,12
@@
static u32 *submodel_indice_data( model *mdl, submodel *sub )
return model_indice_base(mdl) + sub->indice_start;
}
return model_indice_base(mdl) + sub->indice_start;
}
+static void *get_entdata_raw( model *mdl, model_marker *marker )
+{
+ return ((void *)(model_indice_base(mdl) + mdl->indice_count)) +
+ marker->offset;
+}
+
static submodel *submodel_get( model *mdl, const char *name )
{
for( int i=0; i<mdl->layer_count; i++ )
static submodel *submodel_get( model *mdl, const char *name )
{
for( int i=0; i<mdl->layer_count; i++ )
@@
-160,11
+173,31
@@
static submodel *submodel_get( model *mdl, const char *name )
return NULL;
}
return NULL;
}
+static model_marker *model_marker_get( model *mdl, const char *name )
+{
+ for( int i=0; i<mdl->marker_count; i++ )
+ {
+ model_marker *mk = model_get_marker( mdl,i );
+
+ if( !strcmp( mk->name, name ) )
+ return mk;
+ }
+
+ return NULL;
+}
+
static void submodel_draw( submodel *sm )
{
mesh_drawn( sm->indice_start, sm->indice_count );
}
static void submodel_draw( submodel *sm )
{
mesh_drawn( sm->indice_start, sm->indice_count );
}
+static void model_unpack_submodel( model *model, glmesh *mesh, submodel *sm )
+{
+ mesh_upload( mesh,
+ model_vertex_base( model ) + sm->vertex_start, sm->vertex_count,
+ model_indice_base( model ) + sm->indice_start, sm->indice_count );
+}
+
static void model_unpack( model *model, glmesh *mesh )
{
u32 offset = model_get_submodel( model, 0 )->vertex_count;
static void model_unpack( model *model, glmesh *mesh )
{
u32 offset = model_get_submodel( model, 0 )->vertex_count;
@@
-183,3
+216,12
@@
static void model_unpack( model *model, glmesh *mesh )
mesh_upload( mesh, model_vertex_base( model ), model->vertex_count,
model_indice_base( model ), model->indice_count );
}
mesh_upload( mesh, model_vertex_base( model ), model->vertex_count,
model_indice_base( model ), model->indice_count );
}
+
+static void mesh_free( glmesh *mesh )
+{
+ glDeleteVertexArrays( 1, &mesh->vao );
+ glDeleteBuffers( 1, &mesh->ebo );
+ glDeleteBuffers( 1, &mesh->vbo );
+}
+
+#endif