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