Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Polygon.h
Go to the documentation of this file.
1
/* Project nGenEx
2
Destroyer Studios LLC
3
Copyright © 1997-2004. All Rights Reserved.
4
5
SUBSYSTEM: nGenEx.lib
6
FILE: Polygon.h
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Polygon structures: VertexSet, Poly, Material
13
*/
14
15
#ifndef Polygon_h
16
#define Polygon_h
17
18
#include "
Geometry.h
"
19
#include "
Color.h
"
20
21
// +--------------------------------------------------------------------+
22
23
class
Bitmap
;
24
struct
Poly
;
25
struct
Material
;
26
struct
VertexSet
;
27
28
// +--------------------------------------------------------------------+
29
30
struct
Poly
31
{
32
static
const
char
*
TYPENAME
() {
return
"Poly"
; }
33
34
enum
{
MAX_VERTS
= 4 };
35
36
Poly
() { }
37
Poly
(
int
init);
38
~Poly
() { }
39
40
int
operator <
(
const
Poly
& p)
const
{
return
sortval
< p.
sortval
; }
41
int
operator ==
(
const
Poly
& p)
const
{
return
this
== &p; }
42
43
int
Contains
(
const
Vec3
& pt)
const
;
44
45
BYTE
nverts
;
46
BYTE
visible
;
47
WORD
verts
[
MAX_VERTS
];
48
WORD
vlocs
[
MAX_VERTS
];
49
VertexSet
*
vertex_set
;
50
Material
*
material
;
51
int
sortval
;
52
float
flatness
;
53
Plane
plane
;
54
};
55
56
// +--------------------------------------------------------------------+
57
58
struct
Material
59
{
60
static
const
char
*
TYPENAME
() {
return
"Material"
; }
61
62
enum
BLEND_TYPE
{
MTL_SOLID
=1,
MTL_TRANSLUCENT
=2,
MTL_ADDITIVE
=4 };
63
enum
{
NAMELEN
=32 };
64
65
Material
();
66
~Material
();
67
68
int
operator ==
(
const
Material
& m)
const
;
69
70
void
Clear
();
71
72
char
name
[
NAMELEN
];
73
char
shader
[
NAMELEN
];
74
75
ColorValue
Ka
;
// ambient color
76
ColorValue
Kd
;
// diffuse color
77
ColorValue
Ks
;
// specular color
78
ColorValue
Ke
;
// emissive color
79
float
power
;
// highlight sharpness (big=shiny)
80
float
brilliance
;
// diffuse power function
81
float
bump
;
// bump level (0=none)
82
DWORD
blend
;
// alpha blend type
83
bool
shadow
;
// casts shadow
84
bool
luminous
;
// verts have their own lighting
85
86
Bitmap
*
tex_diffuse
;
87
Bitmap
*
tex_specular
;
88
Bitmap
*
tex_bumpmap
;
89
Bitmap
*
tex_emissive
;
90
Bitmap
*
tex_alternate
;
91
Bitmap
*
tex_detail
;
92
93
bool
IsSolid
()
const
{
return
blend
==
MTL_SOLID
; }
94
bool
IsTranslucent
()
const
{
return
blend
==
MTL_TRANSLUCENT
; }
95
bool
IsGlowing
()
const
{
return
blend
==
MTL_ADDITIVE
; }
96
const
char
*
GetShader
(
int
n)
const
;
97
98
//
99
// Support for Magic GUI
100
//
101
102
Color
ambient_color
;
103
Color
diffuse_color
;
104
Color
specular_color
;
105
Color
emissive_color
;
106
107
float
ambient_value
;
108
float
diffuse_value
;
109
float
specular_value
;
110
float
emissive_value
;
111
112
Bitmap
*
thumbnail
;
// preview image
113
114
void
CreateThumbnail
(
int
size=128);
115
DWORD
GetThumbColor
(
int
i,
int
j,
int
size);
116
};
117
118
// +--------------------------------------------------------------------+
119
120
struct
VertexSet
121
{
122
static
const
char
*
TYPENAME
() {
return
"VertexSet"
; }
123
124
enum
VertexSpaces
{
OBJECT_SPACE
,
WORLD_SPACE
,
VIEW_SPACE
,
SCREEN_SPACE
};
125
126
VertexSet
(
int
m);
127
~VertexSet
();
128
129
void
Resize
(
int
m,
bool
preserve=
false
);
130
void
Delete
();
131
void
Clear
();
132
void
CreateTangents
();
133
void
CreateAdditionalTexCoords
();
134
bool
CopyVertex
(
int
dst,
int
src);
135
void
CalcExtents
(
Point
& plus,
Point
& minus);
136
137
VertexSet
*
Clone
()
const
;
138
139
int
nverts
;
140
int
space
;
141
142
Vec3
*
loc
;
143
Vec3
*
nrm
;
144
Vec3
*
s_loc
;
145
float
*
rw
;
146
float
*
tu
;
147
float
*
tv
;
148
float
*
tu1
;
149
float
*
tv1
;
150
DWORD*
diffuse
;
151
DWORD*
specular
;
152
Vec3
*
tangent
;
153
Vec3
*
binormal
;
154
};
155
156
// +--------------------------------------------------------------------+
157
158
#endif Polygon_h
159
nGenEx
Polygon.h
Generated on Tue Jun 5 2012 20:46:25 for Starshatter_Open by
1.8.1