summaryrefslogtreecommitdiff
path: root/source/r_models.h
blob: ef5b33b12503efa1fd3617729598d14baa4a8ad1 (plain)
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
/*
Copyright (C) 2008 Andrey Nazarov

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program 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.  

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/

/*
=============================================================================

MODEL MANAGER

=============================================================================
*/

#define Model_Malloc( size )    Hunk_Alloc( &model->pool, size )

// FIXME: MD3 has 256 limit
#define MAX_ALIAS_SKINS     32

typedef struct mspriteframe_s {
    int             width, height;
    int             origin_x, origin_y;
    struct image_s  *image;
} mspriteframe_t;

typedef struct model_s {
    char name[MAX_QPATH];
    int registration_sequence;
    mempool_t pool;

    // alias models
    int numframes;
    struct maliasframe_s *frames;
#if USE_REF == REF_GL
    int nummeshes;
    struct maliasmesh_s *meshes;
#else
    int numskins;
    struct image_s *skins[MAX_ALIAS_SKINS];
    int numtris;
    struct maliastri_s *tris;
    int numsts;
    struct maliasst_s *sts;
    int numverts;
#endif

    // sprite models
    struct mspriteframe_s *spriteframes;
} model_t;

extern int registration_sequence;

// these are implemented in r_models.c
void MOD_FreeUnused( void );
void MOD_FreeAll( void );
void MOD_Init( void );
void MOD_Shutdown( void );

model_t *MOD_ForHandle( qhandle_t h );
qhandle_t R_RegisterModel( const char *name );

struct dmd2header_s;
qerror_t MOD_ValidateMD2( model_t *model, struct dmd2header_s *header, size_t length );

// these are implemented in [gl,sw]_models.c
typedef qerror_t (*mod_load_t)( model_t *, const void *, size_t );
qerror_t MOD_LoadMD2( model_t *model, const void *rawdata, size_t length );
#if USE_MD3
qerror_t MOD_LoadMD3( model_t *model, const void *rawdata, size_t length );
#endif
void MOD_Reference( model_t *model );