GL Studio C++ Runtime 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) 2017 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  \brief The Polygon class. Implements Polygons
54 */
55 class GLPolygon : public DisplayObject
56 {
57 private:
58  /** Assignment operator not implemented. Use CloneObject() or the copy constructor instead. */
59  GLPolygon& operator=( const GLPolygon& that ) DISTI_SPECIAL_MEM_FUN_DELETE;
60  GLPolygon( const GLPolygon& that ) DISTI_SPECIAL_MEM_FUN_DELETE;
61 
62  void CopyGeometryInternal( GLPolygon* src );
63  void CopyPropertiesInternal( GLPolygon* src );
64  void CopyHierarchyPropertiesInternal( GLPolygon* src, bool copyName );
65 
66 public:
67  typedef DisplayObject _BaseClass;
68  friend class GLPolygonEditor;
69 
70  static GLS_EXPORT DisplayObject* CreateInstance();
71 
72  /** Creates a polygon with the vertices specified
73  * \param nPoints The number of vertices in the new polygon
74  * \param vertices The array of vertices for the polygon
75  */
76  GLS_EXPORT GLPolygon( unsigned int nPoints, Vertex* vertices );
77 
78  /** Creates a polygon with the vertices specified
79  * \param nPoints The number of vertices in the new polygon
80  * \param vertices The array of vertices for the polygon
81  * \param location The location point of the object
82  */
83  GLS_EXPORT GLPolygon( unsigned int nPoints, Vertex* vertices, Vertex& location );
84 
85  /** Allocate a (blank) polygon object */
86  GLS_EXPORT GLPolygon( void );
87 
88  /** Copy construct a new GLPolygon object
89  * \param polygon The polygon to be cloned
90  * \param generateNames Whether or not to generate a new instance name
91  */
92  GLS_EXPORT GLPolygon( const GLPolygon& polygon, const bool generateNames );
93 
94  /** Destroy a polygon object */
95  virtual GLS_EXPORT ~GLPolygon( void );
96 
97  /** Configures MetaData */
98  GLS_EXPORT void ConfigureMetaData( void );
99 
100  /* Copy+Create operation in one method. In derived classes, this
101  * method will create a new instance of the derived class and then
102  * copy the object into the new instance. The cut,copy,paste and undo
103  * operations use this method.
104  * \param generateNames Whether or not to generate new names for cloned objects
105  * \return A new object, identical to the original, except for the instance name
106  */
107  virtual GLS_EXPORT DisplayObject* CloneObject( bool generateNames = false );
108 
109 #ifdef GLES
110  virtual GLS_EXPORT void PreDraw( const OpenGLMatrices& current, Culler& culler );
111 #endif
112 
113  /** Draws this object on the current display frame (_parent member). */
114  virtual GLS_EXPORT void Draw( void );
115 
116  /** Recalculates the texture coordinates for the object based on the TexturePoints.
117  */
118  virtual GLS_EXPORT void CalculateTextureCoordinates( void );
119 
120  /** Calculates normals based on the vertices and the specified winding order */
121  virtual GLS_EXPORT void CalcNormals( int windingOrder = 1 );
122 
123 #ifdef GLES
124  /** Sets the RGBA color for filling the object
125  * \param r The new Red fill color (0-255 range) for the object
126  * \param g The new Green fill color (0-255 range) for the object
127  * \param b The new Blue fill color (0-255 range) for the object
128  * \param a The new Alpha fill color (0-255 range) for the object
129  */
130  virtual GLS_EXPORT void SetFillColor( unsigned char r, unsigned char g, unsigned char b, unsigned char a );
131 
132  /** Sets the RGBA color for filling the object
133  * \param color The new RGBA fill color (0-255 range) for the object
134  */
135  virtual GLS_EXPORT void SetFillColor( const GlsColor& color );
136 #endif
137 
138  /* Unhides base class implementation. */
139 
141 
142  /** DeleteVertex is overloaded in polygon to prevent having a poly with less than 2 verts. This
143  * prevents incorrect GL calls when polygon is set to POLY_MODE_FILLED
144  */
145  virtual GLS_EXPORT void DeleteVertex( unsigned int index );
146 
147  virtual GLS_EXPORT DisplayObject* Pick3D( const Vector& winLoc,
148  const Vector& logicalCoords,
149  float scale,
150  const Vector& directionVector,
151  Vector& collisionWinLoc, /*Returned*/
152  const OpenGLMatrices& parentDrawn );
153 
154 #ifdef GLES
155 protected:
156  void DrawSolidGeometry( bool textureObject, bool color, bool normal );
157  void DrawOutlineGeometry();
158  void DrawPoints();
159  void BakeVBO( bool hasT, bool hasC, bool hasN );
160 
161  GlsVertexArray _vertArray;
162  bool _pendingFillColor;
163 #endif
164 };
165 
166 } // namespace disti
167 
168 #endif
Definition: cull.h:49
Definition: vertex.h:408
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:278
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler)
The Polygon class. Implements Polygons.
Definition: glpolygon.h:55
Definition: display.h:97
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_vertex_array.h:58
Definition: gls_color.h:53
void ConfigureMetaData(void)
virtual void CalculateTextureCoordinates(void)
An object for managing vertices, texture coordinates, colors and normals for GLPolygon and other disp...
Definition: vertex.h:83
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)