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
14reproduced, in whole or part, in any form, or by any means of electronic,
15mechanical, or otherwise, without the written permission of DiSTI. Said
16permission may be derived through the purchase of applicable DiSTI product
17licenses which detail the distribution rights of this content and any
18Derivative Works based on this or other copyrighted DiSTI Software.
19
20 NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26
27 LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34EXCEED FIVE DOLLARS (US$5.00).
35
36 The aforementioned terms and restrictions are governed by the laws of the
37State 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"
49
50namespace disti
51{
52/**
53 \brief The Polygon class. Implements Polygons
54*/
56{
57private:
58 /** Assignment operator not implemented. Use CloneObject() or the copy constructor instead. */
59 GLPolygon& operator=( const GLPolygon& that ) DISTI_SPECIAL_MEM_FUN_DELETE;
61
62public:
63 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
64 typedef DisplayObject _BaseClass; ///< Deprecated typedef for the base class.
65 typedef DisplayObject BaseClass; ///< Typedef for the base class.
66 friend class GLPolygonEditor;
67
68 /// \return A new GLPolygon instance.
70
71 /** Creates a polygon with the vertices specified
72 * \param nPoints The number of vertices in the new polygon
73 * \param vertices The array of vertices for the polygon
74 */
75 GLS_EXPORT GLPolygon( unsigned int nPoints, const Vertex* vertices );
76
77 /** Creates a polygon with the vertices specified
78 * \param nPoints The number of vertices in the new polygon
79 * \param vertices The array of vertices for the polygon
80 * \param location The location point of the object
81 */
82 GLS_EXPORT GLPolygon( unsigned int nPoints, const Vertex* vertices, const Vertex& location );
83
84 /** Allocate a (blank) polygon object */
86
87 /** Copy construct a new GLPolygon object
88 * \param polygon The polygon to be cloned
89 * \param generateNames Whether or not to generate a new instance name
90 */
91 GLS_EXPORT GLPolygon( const GLPolygon& polygon, const bool generateNames );
92
93 /** Destroy a polygon object */
95
96 /** Configures MetaData */
98
99 /* Copy+Create operation in one method. In derived classes, this
100 * method will create a new instance of the derived class and then
101 * copy the object into the new instance. The cut,copy,paste and undo
102 * operations use this method.
103 * \param generateNames Whether or not to generate new names for cloned objects
104 * \return A new object, identical to the original, except for the instance name
105 */
106 virtual GLS_EXPORT DisplayObject* CloneObject( bool generateNames = false );
107
108#ifdef GLES
109 /// \copydoc DisplayObject::PreDraw
110 virtual GLS_EXPORT void PreDraw( const OpenGLMatrices& current, Culler& culler ) DISTI_METHOD_OVERRIDE;
111#endif
112
113 /** Draws this object on the current display frame (_parent member). */
115
116 /** Recalculates the texture coordinates for the object based on the TexturePoints.
117 */
119
120 /// Calculates normals based on the vertices and the specified winding order.
121 /// \param windingOrder Multiply calculated normals by -1 if less than 0.
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 /// DeleteVertexAt is overloaded in polygon to prevent having a poly with less than 2 verts. This
140 /// prevents incorrect GL calls when polygon is set to POLY_MODE_FILLED
141 /// \param index The index of the vertex to delete.
142 virtual GLS_EXPORT void DeleteVertexAt( unsigned int index );
143
144 /// \copydoc DisplayObject::Pick3D
145 virtual GLS_EXPORT DisplayObject* Pick3D( const Vector& winLoc,
146 const Vector& logicalCoords,
147 float scale,
148 const Vector& directionVector,
149 Vector& collisionWinLoc, /*Returned*/
150 const OpenGLMatrices& drawnMatrices ) DISTI_METHOD_OVERRIDE;
151
152#ifdef GLES
153protected:
154 /// Renders the vertex array as a triangle fan.
155 /// \param textureObject If true, then this will texture the mesh surface.
156 /// \param gouraudShading If true, then it'll apply gouraudShading. Otherwise, it'll use flat shading.
157 /// \param normal If true, then allow per vertex normals.
158 void DrawSolidGeometry( bool textureObject, bool gouraudShading, bool normal );
159
160 /// Draws lines that form this polygon's outline.
162
163 /// Draws a point for each vertex of this polygon.
165
166 /// Bakes the vertex array to a Vertext Buffer Object.
167 /// \param hasT If true, then the vertex array's texture coordinates will be updated.
168 /// \param hasN If true, then the vertex array's normals will be updated.
169 /// \param hasC If true, then the vertex array's colors will be updated.
170 void BakeVBO( bool hasT, bool hasC, bool hasN );
171
172 GlsVertexArray _vertArray; ///< A vertex array that makes up this mesh. Each vertex contains data such as position, normal, texture coordinates, and color.
173 bool _pendingFillColor; ///< If true and gouraudShading is true during a paint cycle, then it'll bake the VBO.
174#endif
175};
176
177} // namespace disti
178
179#endif
Definition: cull.h:50
Definition: display.h:96
The Polygon class. Implements Polygons.
Definition: glpolygon.h:56
virtual void CalculateTextureCoordinates()
GlsVertexArray _vertArray
A vertex array that makes up this mesh. Each vertex contains data such as position,...
Definition: glpolygon.h:172
void DrawSolidGeometry(bool textureObject, bool gouraudShading, bool normal)
virtual void DeleteVertexAt(unsigned int index)
virtual void SetFillColor(const GlsColor &color)
virtual void CalcNormals(int windingOrder=1)
static DisplayObject * CreateInstance()
virtual DisplayObject * CloneObject(bool generateNames=false)
virtual DisplayObject * Pick3D(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &drawnMatrices) override
void BakeVBO(bool hasT, bool hasC, bool hasN)
virtual void Draw() override
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler) override
bool _pendingFillColor
If true and gouraudShading is true during a paint cycle, then it'll bake the VBO.
Definition: glpolygon.h:173
void DrawPoints()
Draws a point for each vertex of this polygon.
void DrawOutlineGeometry()
Draws lines that form this polygon's outline.
virtual void SetFillColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
void ConfigureMetaData()
Definition: gls_color.h:54
Definition: gls_vertex_array.h:60
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:544
Definition: vertex.h:85
Definition: vertex.h:420
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:246
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:488
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:222
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:52
An object for managing vertices, texture coordinates, colors and normals for GLPolygon and other disp...
Definition: bmpimage.h:47