GL Studio C++ Runtime API
glpolygon.h
Go to the documentation of this file.
1/// \file glpolygon.h
2/// \brief The disti::GLPolygon class. Implements Polygons.
3///
4/// \par Copyright Information
5///
6/// Copyright (c) 2017 by The DiSTI Corporation.<br>
7/// 12249 Science Drive; Suite 300<br>
8/// Orlando, Florida 32826<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#ifndef INCLUDED_DISTI_GLPOLYGON_H
40#define INCLUDED_DISTI_GLPOLYGON_H
41
42#include "gls_include.h"
43#ifdef GLES
44# include "gls_vertex_array.h"
45#endif
46#include "display.h"
48
49namespace disti
50{
51/**
52 \brief The Polygon class. Implements Polygons
53*/
55{
56private:
57 /** Assignment operator not implemented. Use CloneObject() or the copy constructor instead. */
58 GLPolygon& operator=( const GLPolygon& that ) DISTI_SPECIAL_MEM_FUN_DELETE;
60
61public:
62 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
63 typedef DisplayObject _BaseClass; ///< Deprecated typedef for the base class.
64 typedef DisplayObject BaseClass; ///< Typedef for the base class.
65 friend class GLPolygonEditor;
66
67 /// \return A new GLPolygon instance.
69
70 /** Creates a polygon with the vertices specified
71 * \param nPoints The number of vertices in the new polygon
72 * \param vertices The array of vertices for the polygon
73 */
74 GLS_EXPORT GLPolygon( unsigned int nPoints, const Vertex* vertices );
75
76 /** Creates a polygon with the vertices specified
77 * \param nPoints The number of vertices in the new polygon
78 * \param vertices The array of vertices for the polygon
79 * \param location The location point of the object
80 */
81 GLS_EXPORT GLPolygon( unsigned int nPoints, const Vertex* vertices, const Vertex& location );
82
83 /** Allocate a (blank) polygon object */
85
86 /** Copy construct a new GLPolygon object
87 * \param polygon The polygon to be cloned
88 * \param generateNames Whether or not to generate a new instance name
89 */
90 GLS_EXPORT GLPolygon( const GLPolygon& polygon, const bool generateNames );
91
92 /** Destroy a polygon object */
94
95 /** Configures MetaData */
97
98 /* Copy+Create operation in one method. In derived classes, this
99 * method will create a new instance of the derived class and then
100 * copy the object into the new instance. The cut,copy,paste and undo
101 * operations use this method.
102 * \param generateNames Whether or not to generate new names for cloned objects
103 * \return A new object, identical to the original, except for the instance name
104 */
106
107#ifdef GLES
108 /// \copydoc DisplayObject::PreDraw
109 GLS_EXPORT void PreDraw( const OpenGLMatrices& current, Culler& culler ) DISTI_METHOD_OVERRIDE;
110#endif
111
112 /** Draws this object on the current display frame (_parent member). */
114
115 /** Recalculates the texture coordinates for the object based on the TexturePoints.
116 */
118
119 /// Calculates normals based on the vertices and the specified winding order.
120 /// \param windingOrder Multiply calculated normals by -1 if less than 0.
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 */
136#endif
137
138 /// DeleteVertexAt 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 /// \param index The index of the vertex to delete.
142
143 /// \copydoc DisplayObject::Pick3D
145 const Vector& logicalCoords,
146 float scale,
147 const Vector& directionVector,
148 Vector& collisionWinLoc, /*Returned*/
149 const OpenGLMatrices& drawnMatrices ) DISTI_METHOD_OVERRIDE;
150
151#ifdef GLES
152protected:
153 /// Renders the vertex array as a triangle fan.
154 /// \param textureObject If true, then this will texture the mesh surface.
155 /// \param gouraudShading If true, then it'll apply gouraudShading. Otherwise, it'll use flat shading.
156 /// \param normal If true, then allow per vertex normals.
157 GLS_EXPORT void DrawSolidGeometry( bool textureObject, bool gouraudShading, bool normal );
158
159 /// Draws lines that form this polygon's outline.
160 GLS_EXPORT void DrawOutlineGeometry();
161
162 /// Draws a point for each vertex of this polygon.
163 GLS_EXPORT void DrawPoints();
164
165 /// Bakes the vertex array to a Vertext Buffer Object.
166 /// \param hasT If true, then the vertex array's texture coordinates will be updated.
167 /// \param hasN If true, then the vertex array's normals will be updated.
168 /// \param hasC If true, then the vertex array's colors will be updated.
169 GLS_EXPORT void BakeVBO( bool hasT, bool hasC, bool hasN );
170
171 GlsVertexArray _vertArray; ///< A vertex array that makes up this mesh. Each vertex contains data such as position, normal, texture coordinates, and color.
172 bool _pendingFillColor; ///< If true and gouraudShading is true during a paint cycle, then it'll bake the VBO.
173#endif
174};
175
176} // namespace disti
177
178#endif
Definition: cull.h:49
Definition: display.h:95
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler)
void SetFillColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Definition: display.h:685
The Polygon class. Implements Polygons.
Definition: glpolygon.h:55
void DeleteVertexAt(unsigned int index) override
virtual void CalcNormals(int windingOrder=1)
DisplayObject * Pick3D(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &drawnMatrices) override
static DisplayObject * CreateInstance()
DisplayObject * CloneObject(bool generateNames=false) override
void CalculateTextureCoordinates() override
void ConfigureMetaData()
void Draw() override
Definition: gls_color.h:53
Definition: gls_vertex_array.h:58
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:540
Definition: vertex.h:84
Definition: vertex.h:419
The disti::DisplayObject class and global enumerations.
Macros and helper code to determine what subset of C++11/14/17 is available.
#define DISTI_SPECIAL_MEM_FUN_DELETE
Macro to wrap function deletion, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:245
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:487
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:221
A file for all GL Studio files to include.
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:50
An object for managing vertices, texture coordinates, colors and normals for GLPolygon and other disp...
Definition: bmpimage.h:46