[go: up one dir, main page]

File: structure.h

package info (click to toggle)
libmodelfile 0.1.92-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,476 kB
  • ctags: 139
  • sloc: sh: 8,211; ansic: 896; makefile: 20
file content (114 lines) | stat: -rw-r--r-- 3,924 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* Copyright (C) 2004 Alistair Riddoch <alriddoch@zepler.org>
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 *
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
 *    appreciated but is not required.
 * 2. Altered source versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 * 3. This notice may not be removed or altered from any source distribution.
 */

#ifndef LIBMD3_STRUCTURE_H
#define LIBMD3_STRUCTURE_H

#include <libmd3/inttypes.h>

/* This file contains definitions for the structures in a .md3 file on disk
 * They are typically used as targets for reading blocks of data from
 * disk.
 */

/* This is the md3 file header. It tells us how much of everything the file
 * contains.
 *
 * 108 bytes
 */
typedef struct _md3_header {
    uint8_t         ident[4];       /* Always "IDP3" */
    int32_t         version;        /* Always 15 */
    int8_t          filename[68];   /* Name of file */
    int32_t         frame_count;    /* Number of frames */
    int32_t         tag_count;      /* Number of tags */
    int32_t         mesh_count;     /* Number of meshes */
    int32_t         skin_count;     /* Number of skins */
    int32_t         frame_start;    /* Start of frames length */
    int32_t         tag_start;      /* Start of tags */
    int32_t         mesh_start;     /* Start of meshes */
    int32_t         file_end;       /* End of file */
} md3_header;

/* Frames for the bone animation.
 *
 * 56 bytes
 */
typedef struct _md3_frame {
    float           mins[3];
    float           maxs[3];
    float           position[3];
    float           scale;
    int8_t          string[16];
} md3_frame;

/* Tag indicating a connection to a tag in another file.
 *
 * 112 bytes
 */
typedef struct _md3_tag {
    int8_t          name[64];       /* Name */
    float           position[3];   /* Position */
    float           rotation[9];    /* Rotation */
} md3_tag;

/* Header for each mesh in the file, indicating how many frames, skins
 * triangles, texcoords and vertixes are present. In some files we
 * need to pay attention to the starts for each of these sets of data.
 *
 * 108 bytes
 */
typedef struct _md3_mesh {
    uint8_t         ident[4];       /* Always "IDP3" */ 
    int8_t          name[68];       /* Name */ 
    int32_t         frame_count;    /* Number of mesh frames */
    int32_t         skin_count;     /* Number of skins */
    int32_t         vertex_count;   /* Number of vertices */
    int32_t         triangle_count; /* Number of triangles */
    int32_t         triangle_start; /* Relative start of triangles */
    int32_t         skin_start;     /* Relative start of skins */
    int32_t         texcoord_start; /* Relative start of texcoords */
    int32_t         vertex_start;   /* Relative start of vertices */
    int32_t         mesh_len;       /* End of mesh */
} md3_mesh;

/* Name of texture or skin file.
 *
 * 68 bytes
 */
typedef struct _md3_skin {
    uint8_t         name[68];       /* Name */
} md3_skin;

/* Index numbers of three vertices which make a triangle
 *
 * 12 bytes
 */
typedef struct _md3_triangle {
    int32_t         vertices[3];    /* Indexes of vertices */
} md3_triangle;

/* Texture coordinate
 *
 * 8 bytes
 */
typedef struct _md3_texcoord {
    float           texcoord[2];    /* Indexes of vertices */
} md3_texcoord;

#endif /* LIBMD3_STRUCTURE_H */