summary refs log tree commit diff
path: root/src/Models.h
blob: e49b8f1e50edd5ac39d432b94c58ab28fb2002eb (plain) (blame)
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
#ifndef _MODELS_H_
#define _MODELS_H_

/**> Model Loading <**/
//
// Model Maximums
//
#include "Quaternions.h"
#ifdef OS9 
#include <gl.h>
#include <glu.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#endif
#include "Files.h"
#include "Constants.h"

#define max_textured_triangle		400		// maximum number of texture-filled triangles in a model
#define max_model_vertex			max_textured_triangle*3		// maximum number of vertexs


//
// Model Structures
//
					
class TexturedTriangle{
	public:
				short			vertex[3];
				float r,g,b;
};

class Model{
	public:
				short	vertexNum,TriangleNum;
				
				XYZ					vertex[max_model_vertex];
				XYZ					normals[max_textured_triangle];
				TexturedTriangle	Triangles[max_textured_triangle];
				GLfloat 			vArray[max_textured_triangle*27];
				
				XYZ boundingspherecenter;
				float boundingsphereradius;
				int LineCheck(XYZ p1,XYZ p2, XYZ *p);
				int LineCheck2(XYZ p1,XYZ p2, XYZ *p,XYZ move,float rotate);
				int LineCheck2(XYZ *p1,XYZ *p2, XYZ *p,XYZ *move,float *rotate);
				int LineCheck3(XYZ p1,XYZ p2, XYZ *p,XYZ move,float rotate,float *d);
				
				void UpdateVertexArray();
				bool load(Str255 Name);
				void Scale(float xscale,float yscale,float zscale);
				void ScaleNormals(float xscale,float yscale,float zscale);
				void Translate(float xtrans,float ytrans,float ztrans);
				void CalculateNormals();
				void draw();
				void draw(float r,float g,float b);
				void draw(float r,float g,float b, float o);
				void draw(float r,float g,float b, float x, float y, float z);
				void Rotate(float xang,float yang,float zang);
				void MultColor(float howmuch);
				
				XYZ boundingboxmin,boundingboxmax;
};

#endif