File: Polygon.h

package info (click to toggle)
pinball 0.3.20201218-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 8,452 kB
  • sloc: cpp: 15,230; makefile: 840; sh: 381; xml: 24
file content (88 lines) | stat: -rw-r--r-- 2,762 bytes parent folder | download | duplicates (9)
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
/***************************************************************************
                          Polygon.h  -  description
                             -------------------
    begin                : Wed Jan 26 2000
    copyright            : (C) 2000 by Henrik Enqvist
    email                : henqvist@excite.com
 ***************************************************************************/

#ifndef POLYGON_H
#define POLYGON_H

//#define EM_POLY_FLAT 1
//#define EM_POLY_SMOOTH 2
//#define EM_POLY_HIDDEN 4
//#define EM_WIREFRAME 8
//#define EM_ALLWAYS_LIT 16
//#define EM_POLY_DOUBLE 32
#define EM_POLY_TRANS 64
//#define EM_POLY_CCW_VIEW 128

using namespace std;

#include <vector>

#include "EMath.h"

class Shape3D;

/**
 * Polygons are part of Shape3Ds. Polygons are built by first creating
 * a Polygon object and then adding the vertices which define the polygon.
 *
 * Look out i can be a bit confusing to handle two types of indices. Will
 * call the vertex index in the shape for shindex and the index for the edge in the
 * polygon for polyindex. A polyindex edge always has a connection to one shindex vertex.
 * A shindex vertex may be refered by several polygons ie. polyindex edges.
 * @see Shape3D
 */
class Polygon3D {
	public:
		Polygon3D(Shape3D* s, int size = 3);
		~Polygon3D();
		void copy(Polygon3D * poly);
		/** Add add a shape vertex into this polygon- */
		void add(int shindex);
		/** Returns the polyindex if the vertex is included. Else -1. */
		int includes(int shindex);
		void setProperty(int p);
		void unsetProperty(int p);
		int getProperties();
		/** Get shape vertex index for edge in polygon. */
		int getIndex(int polyindex);
		int getIndexSize();
		void setColor(float r, float g, float b, float a);
		Color * getColor(int polyindex);
		void setColor(int polyindex, float r, float g, float b, float a);
		TexCoord * getTexCoord(int polyindex);
		void setTexCoord(int polyindex, float u, float v);
		Shape3D * getShape3D() { return p_Shape3D; };
		void countNormal();
		void decrement(int shindex);
		/** Move vertex at index one step up in polygon order. */
		void moveUp(int polyindex);
		void moveDown(int polyindex);
		/** Are the vertices follow each other in this polygon. */
		bool connected(int shindexA, int shindexB);

/*	private:
		friend class Shape3D;
		friend class RendererVisitor;
		friend class PNormalVisitor;
		friend class PointLightVisitor;
		friend class NCollisionVisitor;
		friend class GLightVisitor;
		friend class NestedBounds;
		friend class ClipperVisitor;
		friend class PaintersSorter;
		friend class OpenGLVisitor;*/
		
		Vertex3D m_nmlSrc;
		Vertex3D m_nmlTrans;
		Color m_colFlatLight;
		vector<int> m_vIndex;
		int m_iProperties;
		Shape3D* p_Shape3D;
};

#endif // POLYGON_H