X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fcmesh.h;h=6500bc3422674552b5824ec8e5793db1038e9ff9;hb=257b041b5f6f64b53bafe5b4d4f8ffa67a39c0e5;hp=4531d0bc04cd4a80baa6f88cf2ccefb45319fc2d;hpb=6ad6cf2cb2e82d8dcc1535a031a38eb991d2b396;p=vrtris diff --git a/src/cmesh.h b/src/cmesh.h index 4531d0b..6500bc3 100644 --- a/src/cmesh.h +++ b/src/cmesh.h @@ -3,7 +3,6 @@ #include #include -#include "dynarr.h" enum { CMESH_ATTR_VERTEX, @@ -33,9 +32,9 @@ int cmesh_init(struct cmesh *cm); void cmesh_destroy(struct cmesh *cm); void cmesh_clear(struct cmesh *cm); -void cmesh_copy(struct cmesh *cmdest, struct cmesh *cmsrc); +int cmesh_clone(struct cmesh *cmdest, struct cmesh *cmsrc); -void cmesh_set_name(struct cmesh *cm, const char *name); +int cmesh_set_name(struct cmesh *cm, const char *name); const char *cmesh_name(struct cmesh *cm); int cmesh_has_attrib(struct cmesh *cm, int attr); @@ -46,9 +45,16 @@ int cmesh_indexed(struct cmesh *cm); */ float *cmesh_set_attrib(struct cmesh *cm, int attr, int nelem, unsigned int num, const float *vdata); -float *cmesh_attrib(struct cmesh *cm, int attr); /* invalidates VBO */ +float *cmesh_attrib(struct cmesh *cm, int attr); /* invalidates VBO */ const float *cmesh_attrib_ro(struct cmesh *cm, int attr); /* doesn't invalidate */ +float *cmesh_attrib_at(struct cmesh *cm, int attr, int idx); +const float *cmesh_attrib_at_ro(struct cmesh *cm, int attr, int idx); int cmesh_attrib_count(struct cmesh *cm, int attr); +int cmesh_push_attrib(struct cmesh *cm, int attr, float *v); +int cmesh_push_attrib1f(struct cmesh *cm, int attr, float x); +int cmesh_push_attrib2f(struct cmesh *cm, int attr, float x, float y); +int cmesh_push_attrib3f(struct cmesh *cm, int attr, float x, float y, float z); +int cmesh_push_attrib4f(struct cmesh *cm, int attr, float x, float y, float z, float w); /* indices can be 0, in which case only memory is allocated * returns pointer to the index array @@ -57,22 +63,23 @@ unsigned int *cmesh_set_index(struct cmesh *cm, int num, const unsigned int *ind unsigned int *cmesh_index(struct cmesh *cm); /* invalidates IBO */ const unsigned int *cmesh_index_ro(struct cmesh *cm); /* doesn't invalidate */ int cmesh_index_count(struct cmesh *cm); +int cmesh_push_index(struct cmesh *cm, unsigned int idx); -int get_poly_count(struct cmesh *cm); +int cmesh_poly_count(struct cmesh *cm); /* attr can be -1 to invalidate all attributes */ -void cmesh_invalidate_attrib(struct cmesh *cm, int attr); -void cmesh_invalidate_index(struct cmesh *cm); +void cmesh_invalidate_vbo(struct cmesh *cm, int attr); +void cmesh_invalidate_ibo(struct cmesh *cm); int cmesh_append(struct cmesh *cmdest, struct cmesh *cmsrc); /* immediate-mode style mesh construction interface */ int cmesh_vertex(struct cmesh *cm, float x, float y, float z); -int cmesh_normal(struct cmesh *cm, float nx, float ny, float nz); -int cmesh_tangent(struct cmesh *cm, float tx, float ty, float tz); -int cmesh_texcoord(struct cmesh *cm, float u, float v, float w); -int cmesh_boneweights(struct cmesh *cm, float w1, float w2, float w3, float w4); -int cmesh_boneidx(struct cmesh *cm, int idx1, int idx2, int idx3, int idx4); +void cmesh_normal(struct cmesh *cm, float nx, float ny, float nz); +void cmesh_tangent(struct cmesh *cm, float tx, float ty, float tz); +void cmesh_texcoord(struct cmesh *cm, float u, float v, float w); +void cmesh_boneweights(struct cmesh *cm, float w1, float w2, float w3, float w4); +void cmesh_boneidx(struct cmesh *cm, int idx1, int idx2, int idx3, int idx4); /* dir_xform can be null, in which case it's calculated from xform */ void cmesh_apply_xform(struct cmesh *cm, float *xform, float *dir_xform); @@ -81,7 +88,7 @@ void cmesh_flip(struct cmesh *cm); /* flip faces (winding) and normals */ void cmesh_flip_faces(struct cmesh *cm); void cmesh_flip_normals(struct cmesh *cm); -void cmesh_explode(struct cmesh *cm); /* undo all vertex sharing */ +int cmesh_explode(struct cmesh *cm); /* undo all vertex sharing */ /* this is only guaranteed to work on an exploded mesh */ void cmesh_calc_face_normals(struct cmesh *cm); @@ -107,6 +114,9 @@ void cmesh_texcoord_gen_plane(struct cmesh *cm, cgm_vec3 *norm, cgm_vec3 *tang); void cmesh_texcoord_gen_box(struct cmesh *cm); void cmesh_texcoord_gen_cylinder(struct cmesh *cm); + +int cmesh_load(struct cmesh *cm, const char *fname); + int cmesh_dump(struct cmesh *cm, const char *fname); int cmesh_dump_file(struct cmesh *cm, FILE *fp); int cmesh_dump_obj(struct cmesh *cm, const char *fname);