Starshatter_Open
Open source Starshatter engine
 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;
51  int sortval;
52  float flatness;
54 };
55 
56 // +--------------------------------------------------------------------+
57 
58 struct Material
59 {
60  static const char* TYPENAME() { return "Material"; }
61 
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 
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 
106 
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 
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();
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 
145  float* rw;
146  float* tu;
147  float* tv;
148  float* tu1;
149  float* tv1;
150  DWORD* diffuse;
151  DWORD* specular;
154 };
155 
156 // +--------------------------------------------------------------------+
157 
158 #endif Polygon_h
159