-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.h
151 lines (105 loc) · 2.14 KB
/
model.h
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#ifndef INC_MODEL_H
#define INC_MODEL_H
#include <windows.h> // Header File For Windows
#include <gl\gl.h> // Header File For The OpenGL32 Library
#include <gl\glu.h> // Header File For The GLu32 Library
#include <stdio.h>
#include "common.h"
#include "tex.h"
typedef float vec3_t[3];
//MD2 header
struct md2_header_t
{
public:
int ident;
int version;
int skinwidth;
int skinheight;
int framesize;
int num_skins;
int num_vertices;
int num_st;
int num_tris;
int num_glcmds;
int num_frames;
int offset_skins;
int offset_st;
int offset_tris;
int offset_frames;
int offset_glcmds;
int offset_end;
};
//Texture name
struct md2_skin_t
{
char name[64];
};
//Texture coords
struct md2_texCoord_t
{
short s;
short t;
};
//Triangle info
struct md2_triangle_t
{
unsigned short vertex[3];
unsigned short st[3];
};
//Compressed vertex
struct md2_vertex_t
{
unsigned char v[3];
unsigned char normalIndex;
};
//model frame
struct md2_frame_t
{
vec3_t scale;
vec3_t translate;
char name[16];
struct md2_vertex_t *verts;
};
//GL command packet
struct md2_glcmd_t
{
float s;
float t;
int index;
};
//MD2 model structure
//Table of precalculated normals
/*
vec3_t anorms_table[162] = {
#include "anorms.h"
};
*/
class model {
private:
struct md2_header_t header;
struct md2_skin_t *skins;
struct md2_texCoord_t *texcoords;
struct md2_triangle_t *triangles;
struct md2_frame_t *frames;
int *glcmds;
GLuint tex_id;
GLuint list;
double frameNr;
//float interp;
int Openmodel(const char *filename);
int OpenTexture(const char *filename);
void RenderFrameItpWithGLCmds();
void RenderFrame(int n);
//void Strech(double k);//GAL BLOGAI VEIKIA IR TIK 0 FRAME
void Render();
unsigned long time;
void Progress();
public:
int Open(const char *modelFilename, const char *TexFilename);
int Open(const char *path);
void Draw();
void Draw(double x, double y, double z, double k = 0);
void Draw(point p, double k = 0);
void Draw(point3 p, double k = 0);
};
#endif