-
Notifications
You must be signed in to change notification settings - Fork 8
/
BasicStructure.h
95 lines (81 loc) · 2.06 KB
/
BasicStructure.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
#ifndef _BASIC_STRUCTURE_H_
#define _BASIC_STRUCTURE_H_
#include "MathDefs.h"
#include "Mat.h"
//////////////////////////////////////////////////////////////////////////
// Render System Flags
//////////////////////////////////////////////////////////////////////////
// Target Type
enum TargetType { SL_NONE = 0,
SL_TRIANGLES, SL_TRIANGLE_STRIP, SL_TRIANGLE_FAN,
SL_QUADS, SL_QUAD_STRIP, SL_POLYGON
};
// Light Type
enum LightType { SL_LIGHT_NONE = 0,
SL_LIGHT_POINT, SL_LIGHT_SPOT, SL_LIGHT_DIRECTIONAL };
//////////////////////////////////////////////////////////////////////////
// Useful Macro
//////////////////////////////////////////////////////////////////////////
#ifndef SAFE_DELETE
#define SAFE_DELETE(p) if(p) { delete (p); (p)=0; }
#endif
#ifndef SAFE_DELETE_ARRAY
#define SAFE_DELETE_ARRAY(p) if(p) { delete[] (p); (p)=0; }
#endif
//////////////////////////////////////////////////////////////////////////
// Definitions
//////////////////////////////////////////////////////////////////////////
// Matrix
typedef Mat22<double> Mat22d;
typedef Mat33<double> Mat33d;
typedef Matrix<4, double> Mat44d;
// Light
class Light
{
public:
LightType type;
Color4d ambient;
Color4d diffuse;
Color4d specular;
Vec4d position;
Vec3d direction;
float spot_falloff;
float spot_exponent;
float attenuation0;
float attenuation1;
float attenuation2;
Light()
: type(SL_LIGHT_NONE)
, ambient(0, 0 ,0, 1)
, diffuse(1, 1, 1, 1)
, specular(1, 1, 1, 1)
, position(0, 0, 1, 1)
, direction(0, 0, -1)
, spot_falloff(180)
, attenuation0(1)
, attenuation1(0)
, attenuation2(0)
, spot_exponent(30)
{
}
};
class Material
{
public:
Color4d ambient;
Color4d diffuse;
Color4d ambient_diffuse;
Color4d specular;
double shiness;
Color4d emission;
Material()
: ambient(0.2, 0.2, 0.2, 1.0)
, diffuse(0.8, 0.8, 0.8, 1.0)
, ambient_diffuse(0.5, 0.5, 0.5, 1.0)
, specular(0.0, 0.0, 0.0, 1.0)
, shiness(0.0)
, emission(0.0, 0.0, 0.0, 1.0)
{
}
};
#endif //_BASIC_STRUCTURE_H_