X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=model.h;h=21a4e2fe2e75a4a8917d4f6af09aee44574419f4;hb=d045af680c6b8ca267a7aded69e2e510e659d2ab;hp=f8b09b85fcbdb2af8f8d5ae6f0753b6114bdc0dc;hpb=d57b7661518800479c00300ce57407378696eec9;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/model.h b/model.h index f8b09b8..21a4e2f 100644 --- a/model.h +++ b/model.h @@ -25,8 +25,10 @@ struct mdl_vert { v3f co, norm; - v4f colour; v2f uv; + u8 colour[4]; + u16 weights[4]; + u8 groups[4]; }; struct mdl_submesh @@ -52,10 +54,12 @@ struct mdl_node v3f s; union{ u32 submesh_start, sub_uid; }; + u32 submesh_count, classtype, offset, + children, pstr_name; }; @@ -68,7 +72,8 @@ struct mdl_header submesh_count, submesh_offset, material_count, material_offset, node_count, node_offset, - strings_offset, entdata_offset; + strings_offset, entdata_offset, + anim_count, anim_offset; }; /* @@ -120,6 +125,23 @@ struct classtype_route { u32 pstr_name; u32 id_start; + v3f colour; +}; + +struct classtype_bone +{ + u32 deform; +}; + +struct classtype_skeleton +{ + u32 anim_start, + anim_count; +}; + +struct classtype_skin +{ + u32 skeleton; }; #pragma pack(pop) @@ -153,20 +175,35 @@ static void mesh_upload( glmesh *mesh, glBufferData( GL_ELEMENT_ARRAY_BUFFER, indice_count*sizeof(u32), indices, GL_STATIC_DRAW ); + /* 0: coordinates */ glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, stride, (void*)0 ); glEnableVertexAttribArray( 0 ); + /* 1: normal */ glVertexAttribPointer( 1, 3, GL_FLOAT, GL_FALSE, stride, (void *)offsetof(mdl_vert, norm) ); glEnableVertexAttribArray( 1 ); - glVertexAttribPointer( 2, 4, GL_FLOAT, GL_FALSE, - stride, (void *)offsetof(mdl_vert, colour) ); + /* 2: uv */ + glVertexAttribPointer( 2, 2, GL_FLOAT, GL_FALSE, + stride, (void *)offsetof(mdl_vert, uv) ); glEnableVertexAttribArray( 2 ); - glVertexAttribPointer( 3, 2, GL_FLOAT, GL_FALSE, - stride, (void *)offsetof(mdl_vert, uv) ); + /* 3: colour */ + glVertexAttribPointer( 3, 4, GL_UNSIGNED_BYTE, GL_TRUE, + stride, (void *)offsetof(mdl_vert, colour) ); glEnableVertexAttribArray( 3 ); + + /* 4: weights */ + glVertexAttribPointer( 4, 4, GL_UNSIGNED_SHORT, GL_TRUE, + stride, (void *)offsetof(mdl_vert, weights) ); + glEnableVertexAttribArray( 4 ); + + /* 5: groups */ + glVertexAttribIPointer( 5, 4, GL_UNSIGNED_BYTE, + stride, (void *)offsetof(mdl_vert, groups) ); + glEnableVertexAttribArray( 5 ); + VG_CHECK_GL(); mesh->indice_count = indice_count;