scenefile

diff src/mesh.h @ 1:38489ad82bf4

foo
author John Tsiombikas <nuclear@mutantstargoat.com>
date Sat, 14 Jan 2012 08:10:50 +0200
parents 8c6d64af9505
children b30f83409769
line diff
     1.1 --- a/src/mesh.h	Fri Jan 13 09:34:16 2012 +0200
     1.2 +++ b/src/mesh.h	Sat Jan 14 08:10:50 2012 +0200
     1.3 @@ -1,42 +1,48 @@
     1.4  #ifndef MESH_H_
     1.5  #define MESH_H_
     1.6  
     1.7 -struct mesh_attrib {
     1.8 -	char *name;
     1.9 -	int count, elem_size;
    1.10 -	void *data;
    1.11 -
    1.12 -	int datasz;
    1.13 -};
    1.14 -
    1.15 -struct mesh {
    1.16 -	char *name;
    1.17 -	int poly_nverts;	/* 3, 4, etc */
    1.18 -
    1.19 -	struct mesh_attrib *attr;
    1.20 -	int num_attr;
    1.21 -
    1.22 -	int **polyidx;
    1.23 -	int num_poly;
    1.24 -};
    1.25 +struct mesh_vertattr;
    1.26 +struct mesh_polyidx;
    1.27 +struct mesh;
    1.28  
    1.29  #ifdef __cplusplus
    1.30  extern "C" {
    1.31  #endif
    1.32  
    1.33 -int mattr_init(struct mesh_attrib *ma);
    1.34 -void mattr_destroy(struct mesh_attrib *ma);
    1.35 +/* --- vertex attributes --- */
    1.36  
    1.37 -int mattr_set_name(struct mesh_attrib *ma, const char *name);
    1.38 -int mattr_add_elem(struct mesh_attrib *ma, void *data);
    1.39 +int vattr_init(struct mesh_vertattr *ma, int elem_sz);
    1.40 +void vattr_destroy(struct mesh_vertattr *ma);
    1.41  
    1.42 -int mesh_init(struct mesh *m);
    1.43 +int vattr_set_name(struct mesh_vertattr *ma, const char *name);
    1.44 +const char *vattr_get_name(struct mesh_vertattr *ma);
    1.45 +
    1.46 +int vattr_add_elem(struct mesh_vertattr *ma, void *elem);
    1.47 +
    1.48 +void *vattr_pointer(struct mesh_vertattr *ma);
    1.49 +int vattr_count(struct mesh_vertattr *ma);
    1.50 +int vattr_elem_size(struct mesh_vertattr *ma);
    1.51 +
    1.52 +/* --- mesh --- */
    1.53 +
    1.54 +int mesh_init(struct mesh *m, int nverts);
    1.55  void mesh_destroy(struct mesh *m);
    1.56  
    1.57  int mesh_set_name(struct mesh *m, const char *name);
    1.58 -int mesh_add_attrib(struct mesh *m, struct mesh_attrib *attr);
    1.59 +const char *mesh_get_name(struct mesh *m);
    1.60 +
    1.61 +int mesh_add_attrib(struct mesh *m, struct mesh_vertattr *attr);
    1.62  int mesh_find_attrib(struct mesh *m, const char *name);
    1.63  
    1.64 +int mesh_attr_count(struct mesh *m);
    1.65 +int mesh_poly_count(struct mesh *m);
    1.66 +
    1.67 +/* the variable arguments correspond to the N indices of the N-gon
    1.68 + * for this particular vertex attribute (attr_loc, retrieved by
    1.69 + * mesh_find_attrib)
    1.70 + */
    1.71 +int mesh_add_polyref(struct mesh *m, int attr_loc, ...);
    1.72 +
    1.73  #ifdef __cplusplus
    1.74  }
    1.75  #endif