1#pragma once
2
3//********************************************************************************************
4//*
5//*    This file is part of Egoboo.
6//*
7//*    Egoboo is free software: you can redistribute it and/or modify it
8//*    under the terms of the GNU General Public License as published by
9//*    the Free Software Foundation, either version 3 of the License, or
10//*    (at your option) any later version.
11//*
12//*    Egoboo is distributed in the hope that it will be useful, but
13//*    WITHOUT ANY WARRANTY; without even the implied warranty of
14//*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15//*    General Public License for more details.
16//*
17//*    You should have received a copy of the GNU General Public License
18//*    along with Egoboo.  If not, see <http://www.gnu.org/licenses/>.
19//*
20//********************************************************************************************
21
22///
23/// @file md2.inl
24/// @brief Implementation Egoboo's Md2 loading and saving
25/// @details functions that will be declared inside the base class
26/// @note You will routinely include "md2.inl" in all *.inl files or *.c/*.cpp files, instead of "md2.h"
27
28#include "md2.h"
29#include "id_md2.h"
30
31//--------------------------------------------------------------------------------------------
32//--------------------------------------------------------------------------------------------
33
34static INLINE EGO_CONST MD2_SkinName_t  *md2_get_Skin( MD2_Model_t * m, int index );
35static INLINE EGO_CONST MD2_Frame_t     *md2_get_Frame( MD2_Model_t * m, int index );
36static INLINE EGO_CONST MD2_Triangle_t  *md2_get_Triangle( MD2_Model_t * m, int index );
37
38static INLINE EGO_CONST int md2_get_numVertices( MD2_Model_t * m );
39static INLINE EGO_CONST int md2_get_numTexCoords( MD2_Model_t * m );
40static INLINE EGO_CONST int md2_get_numTriangles( MD2_Model_t * m );
41static INLINE EGO_CONST int md2_get_numSkins( MD2_Model_t * m );
42static INLINE EGO_CONST int md2_get_numFrames( MD2_Model_t * m );
43static INLINE EGO_CONST int md2_get_numCommands( MD2_Model_t * m );
44
45static INLINE EGO_CONST MD2_SkinName_t  *md2_get_SkinNames( MD2_Model_t * m );
46static INLINE EGO_CONST MD2_TexCoord_t  *md2_get_TexCoords( MD2_Model_t * m );
47static INLINE EGO_CONST MD2_Triangle_t  *md2_get_Triangles( MD2_Model_t * m );
48static INLINE EGO_CONST MD2_Frame_t     *md2_get_Frames( MD2_Model_t * m );
49static INLINE EGO_CONST MD2_GLCommand_t *md2_get_Commands( MD2_Model_t * m );
50
51//--------------------------------------------------------------------------------------------
52//--------------------------------------------------------------------------------------------
53static INLINE EGO_CONST int md2_get_numVertices( MD2_Model_t * m )  { return m->m_numVertices;  }
54static INLINE EGO_CONST int md2_get_numTexCoords( MD2_Model_t * m ) { return m->m_numTexCoords; }
55static INLINE EGO_CONST int md2_get_numTriangles( MD2_Model_t * m ) { return m->m_numTriangles; }
56static INLINE EGO_CONST int md2_get_numSkins( MD2_Model_t * m )     { return m->m_numSkins;     }
57static INLINE EGO_CONST int md2_get_numFrames( MD2_Model_t * m )    { return m->m_numFrames;    }
58static INLINE EGO_CONST int md2_get_numCommands( MD2_Model_t * m )  { return m->m_numCommands;  }
59
60static INLINE EGO_CONST MD2_SkinName_t  *md2_get_SkinNames( MD2_Model_t * m ) { return m->m_skins;     }
61static INLINE EGO_CONST MD2_TexCoord_t  *md2_get_TexCoords( MD2_Model_t * m ) { return m->m_texCoords; }
62static INLINE EGO_CONST MD2_Triangle_t  *md2_get_Triangles( MD2_Model_t * m ) { return m->m_triangles; }
63static INLINE EGO_CONST MD2_Frame_t     *md2_get_Frames( MD2_Model_t * m ) { return m->m_frames;    }
64static INLINE EGO_CONST MD2_GLCommand_t *md2_get_Commands( MD2_Model_t * m ) { return m->m_commands;  }
65
66//--------------------------------------------------------------------------------------------
67//--------------------------------------------------------------------------------------------
68static INLINE EGO_CONST MD2_SkinName_t *md2_get_Skin( MD2_Model_t * m, int index )
69{
70    if ( index >= 0 && index < m->m_numSkins )
71    {
72        return m->m_skins + index;
73    }
74    return NULL;
75}
76
77//--------------------------------------------------------------------------------------------
78static INLINE EGO_CONST MD2_Frame_t *md2_get_Frame( MD2_Model_t * m, int index )
79{
80    if ( index >= 0 && index < m->m_numFrames )
81    {
82        return m->m_frames + index;
83    }
84    return NULL;
85}
86
87//--------------------------------------------------------------------------------------------
88static INLINE EGO_CONST MD2_Triangle_t  *md2_get_Triangle( MD2_Model_t * m, int index )
89{
90    if ( index >= 0 && index < m->m_numTriangles )
91    {
92        return m->m_triangles + index;
93    }
94    return NULL;
95}
96