/afs/csl.tjhsst.edu/students/2007/kkassing/work/libhemi/mesh.h

Go to the documentation of this file.
00001 #ifndef __HEMI__MESH_H__
00002 #define __HEMI__MESH_H__
00003 
00004 #include "hemi.h"
00005 #include "md2.h"
00006 #include "md3.h"
00007 #include "md5.h"
00008 #include "smd.h"
00009 
00010 typedef struct hemi_buffer hemi_buffer_t;
00011 typedef struct hemi_edge hemi_edge_t;
00012 typedef struct hemi_face hemi_face_t;
00013 typedef struct hemi_opts hemi_opts_t;
00014 typedef struct hemi_model hemi_model_t;
00015 typedef struct hemi_mesh hemi_mesh_t;
00016 typedef struct hemi_part hemi_part_t;
00017 typedef struct hemi_action hemi_action_t;
00018 typedef struct hemi_tag hemi_tag_t;
00019 typedef struct hemi_bone hemi_bone_t;
00020 typedef struct hemi_hdr hemi_hdr_t;
00021 typedef struct hemi_animparams hemi_animparams_t;
00022 typedef struct hemi_attachment hemi_attachment_t;
00023 typedef struct hemi_svert hemi_svert_t;
00024 typedef struct hemi_weight hemi_weight_t;
00025 
00026 #define HEMI_VERSION 3
00027 
00028 // changed normals to per-frame
00029 // changed materials to indexes into a hemi_mesh array of material pointers
00030 
00031 struct hemi_buffer
00032 {
00033         vec3** verts;
00034         int num_verts;
00035         int num_frames;
00036 
00037         vec2* coords;
00038         int num_coords;
00039 
00040         vec3** normals;
00041         int num_normals;
00042 
00043         hemi_tag_t** tags;
00044         int num_tags;
00045 
00046 // skeletal animation
00047         hemi_svert_t* sverts;
00048         int num_sverts;
00049 
00050         hemi_bone_t* bones;
00051         int num_bones;
00052 
00053         hemi_weight_t* weights;
00054         int num_weights;
00055 };
00056 
00057 struct hemi_weight
00058 {
00059         int bone;
00060         float bias;
00061         vec3 pos;
00062 };
00063 
00064 struct hemi_svert
00065 {
00066         int* weights;
00067         int num_weights;
00068 
00069         vec4 pos; // cached vertex (4th val is cache status)
00070 };
00071 
00072 struct hemi_bone
00073 {
00074         char* name;
00075         hemi_bone_t* parent;
00076 
00077         vec3* offset;
00078         quat* orient;
00079 
00080         mat44 trans; // this is temporary
00081 };
00082 
00083 struct hemi_tag
00084 {
00085         vec3 offset;
00086         quat rotation;
00087 };
00088 
00089 struct hemi_edge
00090 {
00091         int vert;                       // start pos
00092         int coord;      
00093         int normal;
00094 
00095         hemi_edge_t* opposite;
00096         hemi_face_t* face;
00097         hemi_edge_t* next;
00098 };
00099 
00100 struct hemi_face
00101 {
00102         hemi_edge_t* edge;              // first edge
00103         int normal;
00104 };
00105 
00106 struct hemi_opts
00107 {
00108         uint ** tris;   // temporary
00109         uint * trilens; // for debug only
00110 
00111         uint** strips;
00112         uint* strip_lens;
00113         uint num_strips;
00114         uint* free_tris;
00115         uint free_tri_len;
00116 };
00117 
00118 struct hemi_action
00119 {
00120         char* name;
00121         int start;
00122         int end;
00123         float fps;
00124 };
00125 
00126 struct hemi_animparams
00127 {
00128         int action;
00129         int frame;
00130         float interp;
00131         int nextaction;
00132 };
00133 
00134 struct hemi_attachment
00135 {
00136         int tag;
00137         hemi_model_t* model;
00138 
00139         hemi_attachment_t* next;
00140 };
00141 
00142 struct hemi_model
00143 {
00144         hemi_animparams_t anim;
00145         hemi_attachment_t* attachments;
00146 };
00147 
00148 struct hemi_mesh
00149 {
00150         hemi_buffer_t* buffer;
00151         
00152         hemi_part_t* parts;
00153         int num_parts;
00154 
00155         hemi_action_t* actions;
00156         int num_actions;
00157 
00158         alloy_material_t** materials;
00159         int num_materials;
00160 };
00161 
00162 struct hemi_part
00163 {
00164         hemi_mesh_t* mesh;
00165 
00166         int material;
00167         
00168         hemi_edge_t* edges;
00169         uint num_edges;
00170 
00171         hemi_face_t* faces;
00172         uint num_faces;
00173         
00174         hemi_opts_t* opts;
00175 };
00176 
00177 struct hemi_hdr
00178 {
00179         char id[5];
00180         int ver;
00181 
00182         int num_parts;          
00183         int ofs_parts;          
00184         
00185         int num_normals;        
00186         int ofs_normals;        
00187         int num_coords;         
00188         int ofs_coords;         
00189 
00190         int num_frames;         
00191         int num_verts;          
00192         int ofs_verts;          
00193         int num_tags;           
00194         int ofs_tags;           
00195         
00196         int num_bones;
00197         int ofs_bones;
00198         int num_weights;
00199         int ofs_weights;
00200 
00201         int num_actions;
00202         int ofs_actions;
00203 
00204         int num_materials;
00205         int ofs_materials;
00206 
00207 
00208         // reserved for animation
00209         // reserved for bones
00210         // reserved for packed-in textures
00211         // reserved for collision hull
00212         // reserved for LOD
00213         // reserved for optimizations
00214 };
00215 
00216 void hemi_initmesh(hemi_mesh_t*);
00217 
00218 int hemi_convert_md2(hemi_md2_t*,hemi_mesh_t*);
00219 int hemi_convert_md3(hemi_md3_t*,hemi_mesh_t*);
00220 int hemi_convert_md5(hemi_md5_t*,hemi_mesh_t*);
00221 int hemi_convert_smd(hemi_smd_t*,hemi_mesh_t*);
00222 
00223 void hemi_render(hemi_mesh_t*);
00224 void hemi_render_frame(hemi_mesh_t*,int);
00225 void hemi_render_interpolated(hemi_mesh_t*,int,int,float);
00226 void hemi_render_skeletal(hemi_mesh_t*,int);
00227 void hemi_render_skeletal_interpolated(hemi_mesh_t*,int,int,float);
00228 void hemi_render_skeletal_optimized(hemi_mesh_t*,int);
00229 void hemi_render_skeletal_optimized_interpolated(hemi_mesh_t*,int,int,float);
00230 void hemi_render_md5(hemi_md5_t*,int);
00231 
00232 
00233 void hemi_apply_tag(hemi_mesh_t*,int,int,int,float);
00234 
00235 void hemi_free_mesh(hemi_mesh_t*);
00236 
00237 void hemi_save(const char*, hemi_mesh_t*);
00238 void hemi_load(const char*, hemi_mesh_t*);
00239 
00240 
00241 #endif

Generated on Fri Jun 1 09:08:56 2007 for Antigone by  doxygen 1.4.7