GL Studio API
glpolygon.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::GLPolygon class. Implements Polygons.
3 
4  \par Copyright Information
5 
6  Copyright (c) 2015 by The DiSTI Corporation.<br>
7  11301 Corporate Blvd; Suite 100<br>
8  Orlando, Florida 32817<br>
9  USA<br>
10  <br>
11  All rights reserved.<br>
12 
13  This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19 
20  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26 
27  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35 
36  The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America.
38 
39 */
40 #ifndef _GLPOLYGON_H
41 #define _GLPOLYGON_H
42 
43 #include "gls_include.h"
44 #ifdef GLES
45 #include "gls_vertex_array.h"
46 #endif
47 #include "display.h"
48 #include "gls_cpp_lang_support.h"
49 
50 namespace disti
51 {
52 
53 /**
54  \brief The Polygon class. Implements Polygons
55 */
56 class GLPolygon : public DisplayObject
57 {
58 private:
59  /** Assignment operator not implemented. Use CloneObject() or the copy constructor instead. */
60  GLPolygon& operator=( const GLPolygon& that ) DISTI_SPECIAL_MEM_FUN_DELETE;
61  GLPolygon( const GLPolygon& that ) DISTI_SPECIAL_MEM_FUN_DELETE;
62 
63  void CopyGeometryInternal( GLPolygon* src );
64  void CopyPropertiesInternal( GLPolygon* src );
65  void CopyHierarchyPropertiesInternal( GLPolygon* src, bool copyName );
66 
67 public:
68  typedef DisplayObject _BaseClass;
69  friend class GLPolygonEditor;
70 
71  static GLS_EXPORT DisplayObject *CreateInstance();
72 
73  /** Creates a polygon with the vertices specified
74  * \param nPoints The number of vertices in the new polygon
75  * \param vertices The array of vertices for the polygon
76  */
77  GLS_EXPORT GLPolygon(unsigned int nPoints,Vertex *vertices);
78 
79  /** Creates a polygon with the vertices specified
80  * \param nPoints The number of vertices in the new polygon
81  * \param vertices The array of vertices for the polygon
82  * \param location The location point of the object
83  */
84  GLS_EXPORT GLPolygon(unsigned int nPoints,Vertex *vertices, Vertex &location);
85 
86  /** Allocate a (blank) polygon object */
87  GLS_EXPORT GLPolygon(void);
88 
89  /** Copy construct a new GLPolygon object
90  * \param polygon The polygon to be cloned
91  * \param generateNames Whether or not to generate a new instance name
92  */
93  GLS_EXPORT GLPolygon( const GLPolygon& polygon, const bool generateNames );
94 
95  /** Destroy a polygon object */
96  virtual GLS_EXPORT ~GLPolygon(void);
97 
98  /** Configures MetaData */
99  GLS_EXPORT void ConfigureMetaData(void);
100 
101  /* Copy+Create operation in one method. In derived classes, this
102  * method will create a new instance of the derived class and then
103  * copy the object into the new instance. The cut,copy,paste and undo
104  * operations use this method.
105  * \param generateNames Whether or not to generate new names for cloned objects
106  * \return A new object, identical to the original, except for the instance name
107  */
108  virtual GLS_EXPORT DisplayObject *CloneObject(bool generateNames = false);
109 
110 #ifdef GLES
111  virtual GLS_EXPORT void PreDraw(const OpenGLMatrices& current, Culler& culler);
112 #endif
113 
114  /** Draws this object on the current display frame (_parent member). */
115  virtual GLS_EXPORT void Draw(void);
116 
117  /** Recalculates the texture coordinates for the object based on the TexturePoints.
118  */
119  virtual GLS_EXPORT void CalculateTextureCoordinates(void);
120 
121  /** Calculates normals based on the vertices and the specified winding order */
122  virtual GLS_EXPORT void CalcNormals(int windingOrder = 1);
123 
124 #ifdef GLES
125  /** Sets the RGBA color for filling the object
126  * \param r The new Red fill color (0-255 range) for the object
127  * \param g The new Green fill color (0-255 range) for the object
128  * \param b The new Blue fill color (0-255 range) for the object
129  * \param a The new Alpha fill color (0-255 range) for the object
130  */
131  virtual GLS_EXPORT void SetFillColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
132 
133  /** Sets the RGBA color for filling the object
134  * \param color The new RGBA fill color (0-255 range) for the object
135  */
136  virtual GLS_EXPORT void SetFillColor(const glsColor& color);
137 #endif
138 
139  /* Unhides base class implementation. */
140 
142 
143  /** DeleteVertex is overloaded in polygon to prevent having a poly with less than 2 verts. This
144  * prevents incorrect GL calls when polygon is set to POLY_MODE_FILLED
145  */
146  virtual GLS_EXPORT void DeleteVertex(unsigned int index);
147 
148  virtual GLS_EXPORT DisplayObject *Pick3D(const Vector& winLoc,
149  const Vector& logicalCoords,
150  float scale,
151  const Vector& directionVector,
152  Vector &collisionWinLoc, /*Returned*/
153  const OpenGLMatrices& parentDrawn);
154 
155 #ifdef GLES
156 protected:
157 
158  void DrawSolidGeometry(bool textureObject,bool color,bool normal);
159  void DrawOutlineGeometry();
160  void DrawPoints();
161  void BakeVBO(bool hasT,bool hasC,bool hasN);
162 
163  GlsVertexArray _vertArray;
164  bool _pendingFillColor;
165 #endif
166 
167 };
168 
169 } // namespace disti
170 
171 #endif
Definition: cull.h:50
Definition: vertex.h:365
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:281
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler)
The Polygon class. Implements Polygons.
Definition: glpolygon.h:56
Definition: display.h:98
A file for all GL Studio files to include.
The disti::DisplayObject class and global enumerations.
virtual void DeleteVertex(unsigned int index)
virtual void DeleteVertex(unsigned int index)
virtual void Draw(void)
virtual DisplayObject * Pick3D(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &parentDrawn)
virtual void CalcNormals(int windingOrder=1)
Definition: gls_color.h:54
void ConfigureMetaData(void)
virtual void CalculateTextureCoordinates(void)
Definition: vertex.h:84
virtual ~GLPolygon(void)
Macros and helper code to determine what subset of C++11/14/17 is available.
Definition: bmpimage.h:46
void SetFillColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Definition: display.h:663
virtual DisplayObject * CloneObject(bool generateNames=false)