| 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 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.
69 static GLS_EXPORT DisplayObject* CreateInstance();
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 */
85 GLS_EXPORT GLPolygon();
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 */
94 virtual GLS_EXPORT ~GLPolygon();
95
96 /** Configures MetaData */
97 GLS_EXPORT void ConfigureMetaData();
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). */
114 virtual GLS_EXPORT void Draw() DISTI_METHOD_OVERRIDE;
115
116 /** Recalculates the texture coordinates for the object based on the TexturePoints.
117 */
118 virtual GLS_EXPORT void CalculateTextureCoordinates();
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
153 protected:
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.
161 void DrawOutlineGeometry();
162
163 /// Draws a point for each vertex of this polygon.
164 void DrawPoints();
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
disti::Culler
Definition: cull.h:50
disti::DisplayObject
Definition: display.h:96
disti::GLPolygon
The Polygon class. Implements Polygons.
Definition: glpolygon.h:56
disti::GLPolygon::CalculateTextureCoordinates
virtual void CalculateTextureCoordinates()
disti::GLPolygon::_vertArray
GlsVertexArray _vertArray
A vertex array that makes up this mesh. Each vertex contains data such as position,...
Definition: glpolygon.h:172
disti::GLPolygon::DrawSolidGeometry
void DrawSolidGeometry(bool textureObject, bool gouraudShading, bool normal)
disti::GLPolygon::DeleteVertexAt
virtual void DeleteVertexAt(unsigned int index)
disti::GLPolygon::SetFillColor
virtual void SetFillColor(const GlsColor &color)
disti::GLPolygon::CalcNormals
virtual void CalcNormals(int windingOrder=1)
disti::GLPolygon::CreateInstance
static DisplayObject * CreateInstance()
disti::GLPolygon::CloneObject
virtual DisplayObject * CloneObject(bool generateNames=false)
disti::GLPolygon::Pick3D
virtual DisplayObject * Pick3D(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &drawnMatrices) override
disti::GLPolygon::BakeVBO
void BakeVBO(bool hasT, bool hasC, bool hasN)
disti::GLPolygon::Draw
virtual void Draw() override
disti::GLPolygon::PreDraw
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler) override
disti::GLPolygon::_pendingFillColor
bool _pendingFillColor
If true and gouraudShading is true during a paint cycle, then it'll bake the VBO.
Definition: glpolygon.h:173
disti::GLPolygon::DrawPoints
void DrawPoints()
Draws a point for each vertex of this polygon.
disti::GLPolygon::DrawOutlineGeometry
void DrawOutlineGeometry()
Draws lines that form this polygon's outline.
disti::GLPolygon::SetFillColor
virtual void SetFillColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
disti::GLPolygon::ConfigureMetaData
void ConfigureMetaData()
disti::GLPolygon::GLPolygon
GLPolygon()
disti::GlsColor
Definition: gls_color.h:54
disti::GlsVertexArray
Definition: gls_vertex_array.h:60
disti::OpenGLMatrices
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:544
disti::VertexNoColor
Definition: vertex.h:85
disti::Vertex
Definition: vertex.h:420
display.h
The disti::DisplayObject class and global enumerations.
gls_cpp_lang_support.h
Macros and helper code to determine what subset of C++11/14/17 is available.
DISTI_SPECIAL_MEM_FUN_DELETE
#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
DISTI_DEPRECATED
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:488
DISTI_METHOD_OVERRIDE
#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
gls_include.h
A file for all GL Studio files to include.
GLS_EXPORT
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:52
gls_vertex_array.h
An object for managing vertices, texture coordinates, colors and normals for GLPolygon and other disp...
disti
Definition: bmpimage.h:47