GL Studio C++ Runtime API
gls_poly_line.h
Go to the documentation of this file.
1/*! \file
2 \brief The disti::GlsPolyLine class.
3
4 \par Copyright Information
5
6 Copyright (c) 2016 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 INCLUDED_GLS_POLYLINE_H
41#define INCLUDED_GLS_POLYLINE_H
42#include "dynamic_array.h"
43#include "glpolygon.h"
45#include "gltrimesh.h"
46
47#ifdef GLES
48# include "gls_vertex_array.h"
49#endif
50
51/// Provides support for creating DLLs.
52#if( defined( GLSGEN_EXPORT_GLSPOLYLINE ) || defined( GLSGEN_IMPORT_GLSPOLYLINE ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
53 && defined( _MSC_VER )
54# if defined( GLSGEN_EXPORT_GLSPOLYLINE ) || defined( GLS_EXPORT_GENERATED )
55# define GLSGEN_GLSPOLYLINE_EXPORT __declspec( dllexport )
56# else
57# define GLSGEN_GLSPOLYLINE_EXPORT __declspec( dllimport )
58# endif
59#else
60# define GLSGEN_GLSPOLYLINE_EXPORT
61#endif
62///////////////////////////////////////////////////////////////////////////////
63
64/// Automatically link the runtime library plugin (on Windows).
65#define LIB_BASE_NAME "gls_poly_line"
66#include "gls_auto_lib.h"
67#undef LIB_BASE_NAME
68
69namespace disti
70{
71// SetValue enumerations
72enum
73{
74 GLS_POLY_LINE_FIRST_VALUE = GLS_LAST_INITIALIZER + 1,
75 GLS_POLY_LINE_THICKNESS,
76 GLS_POLY_LINE_HALO,
77 GLS_POLY_LINE_HALO_COLOR,
78 GLS_POLY_LINE_HALO_THICKNESS,
79 GLS_POLY_LINE_NORMAL,
80 GLS_POLY_LINE_LAST_INITIALIZER = GLS_POLY_LINE_NORMAL
81};
82
83/// \details The GlsPolyLineVertex struct. Describes a vertex generated by GlsPolyLine.
84typedef struct
85{
86 Vector vertex; /**< The vertex coordinate */
87 Vector texCoord; /**< The texture coordinate */
88 Vector normal; /**< The vertex normal */
90
91/// \details The GlsPolyLineFace struct. Describes a face generated by GlsPolyLine.
92typedef struct
93{
94 GlsPolyLineVertex a; ///< The first vertex of the face.
95 GlsPolyLineVertex b; ///< The second vertex of the face.
96 GlsPolyLineVertex c; ///< The third vertex of the face.
98
99/** Runtime implementation of a GlsPolyLine */
100class GlsPolyLine : public GLPolygon
101{
102 friend class GlsPolyLineEditor;
103
104private:
107
108public:
109 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
110 typedef GLPolygon _BaseClass; ///< Deprecated typedef for the base class.
111 typedef GLPolygon BaseClass; ///< Typedef for the base class.
112 typedef DynamicArray<GlsPolyLineFace> GlsPolyLineTriangleList; ///< Typedef for a list of triangles.
113
114 /** Create a new GlsPolyLine.*/
116
117 /// Copy constructor
118 /// \param that The object to copy from.
119 /// \param generateNames Whether or not to generate an instance name for this object.
120 GLSGEN_GLSPOLYLINE_EXPORT GlsPolyLine( const GlsPolyLine& that, const bool generateNames );
121
122 /** Destructs a GlsPolyLine object */
124
125 /// \return A pointer to a new GlsPolyLine object.
127
129 virtual GLSGEN_GLSPOLYLINE_EXPORT void GetExtents( float& minx, float& miny, float& minz, float& maxx, float& maxy, float& maxz ) DISTI_METHOD_OVERRIDE;
130
131 using BaseClass::SetColor;
133
134 using BaseClass::SetFillColor;
136
139
140#ifndef GLES
143#endif
144
145 virtual GLSGEN_GLSPOLYLINE_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices, Culler& culler ) DISTI_METHOD_OVERRIDE;
147
148 /* Unhides base class implementation. */
149 using BaseClass::Scale;
150 virtual GLSGEN_GLSPOLYLINE_EXPORT void Scale( float px, float py, float pz, Vertex* anchor, int handleBar ) DISTI_METHOD_OVERRIDE;
151
152 /* Unhides base class implementation. */
153 using BaseClass::Rotate;
154 virtual GLSGEN_GLSPOLYLINE_EXPORT void Rotate( const Vector& orig, float angle, const Vector& axis ) DISTI_METHOD_OVERRIDE;
155
156 virtual GLSGEN_GLSPOLYLINE_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint ) DISTI_METHOD_OVERRIDE;
157 virtual GLSGEN_GLSPOLYLINE_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
159
160 /* Unhides base class implementation. */
161 using BaseClass::PolygonEnd;
163
164 //////////////////////////////////////////////////
165 // GlsPolyLine specific operations
166 //////////////////////////////////////////////////
167
168 /** Sets the line thickness
169 * \param val The new line thickness in logical units
170 */
171 GLSGEN_GLSPOLYLINE_EXPORT void Thickness( const float& val );
172
173 /** Gets the line thickness
174 * \return The line thickness in logical units
175 */
177
178 /// \return The normal for the polyline.
180
181 /// Enable/Disable halo.
182 /// \param val The new halo enabled state.
183 GLSGEN_GLSPOLYLINE_EXPORT void Halo( const bool& val );
184
185 /// \return The halo enabled state.
187
188 /// Set the halo color.
189 /// \param val The new halo color to set.
191
192 /// \return The halo color.
194
195 /** Set the halo thickness
196 * \param val The new halo thickness in logical units
197 */
198 GLSGEN_GLSPOLYLINE_EXPORT void HaloThickness( const float& val );
199
200 /** Get the halo thickness
201 * \return The line thickness in logical units
202 */
204
205 virtual GLSGEN_GLSPOLYLINE_EXPORT void SetVertices( unsigned int nPoints, Vertex* vertices ) DISTI_METHOD_OVERRIDE;
206
208
209 /** Set the recalculate flag for the object to force it to recalculate
210 */
212
213protected:
214#ifdef GLES
215 // These are helper functions, only used for GLES, and should not be considered missing external api
217 void BakeVBO( GlsVertexArray& vbo, GlsPolyLineTriangleList& vertices, GlsColor color );
218 void BakeLinesVBO( GlsVertexArray& vbo, GlsPolyLineTriangleList& vertices );
219
220 GlsVertexArray _gles_triangles;
221 GlsVertexArray _gles_haloTriangles;
222 GlsVertexArray _gles_antiAliasLines;
223#endif
224
225 GlsPolyLineTriangleList _triangles; ///< The triangles to render, derived from vertices and thickness.
226 float _thickness; ///< The thickness of the line in logical units.
227 Vector _normal; ///< The normal vector (for all triangles).
228
229 bool _halo; ///< If true, a halo (outline) will be drawn.
230 GlsColor _haloColor; ///< The color of the halo.
231 float _haloThickness; ///< The thickness of the halo in logical units.
232 GlsPolyLineTriangleList _haloTriangles; ///< The triangles to render, derived from vertices and halo thickness.
233
234 bool _needsRecalculate; ///< If true, the triangles will be recalculated the next frame.
235
236 unsigned int _endCapIndex; ///< The index of the triangle forming the end cap.
237
238 /// Updates the end-cap hang over for the halos.
239 /// \note Not normally called by users.
241
242 /// Notify that vertices have changed, updates bounding volume and sets recalculate for polyline.
243 /// \note Not normally called by users.
245
246 /// Computes the geometry for the line segments and invokes the appropriate corner method.
247 /// \note Not normally called by users.
249
250 /// ComputeSegments helper method.
251 /// \note Not normally called by users.
252 /// \param array The returned computed triangle list.
253 /// \param thickness The thickness in logical units.
254 /// \param calculatingHalos If true will use halo specific logic during calculation.
255 void ComputeSegments( GlsPolyLineTriangleList& array, float thickness, bool calculatingHalos = false );
256
257 /// Compute a corner.
258 /// \note Not normally called by users.
259 /// \param array The returned computed triangle list.
260 /// \param thickness The thickness in logical units.
261 /// \param cornerRadius The corner radius in logical units.
262 /// \param refVert The vertex at this corner.
263 /// \param v1
264 /// \param v2
265 /// \param v3
266 /// \param v4
267 /// \param l1 Vector from refVert to the previous vertex.
268 /// \param l2 Vector refVert to the next vertex.
269 /// \param calculatingHalos If true will use halo specific logic during calculation.
270 void ComputeCorner( GlsPolyLineTriangleList& array, float thickness, float cornerRadius, const Vector& refVert, const Vector& v1, const Vector& v2, const Vector& v3, const Vector& v4, const Vector& l1, const Vector& l2, bool calculatingHalos = false );
271
272 /// Helper method to draw a list of triangles.
273 /// \note Not normally called by users.
274 /// \param array The triangle list to draw.
276};
277
278} // namespace disti
279
280#endif
Definition: cull.h:50
Definition: display.h:96
Definition: dynamic_array.h:79
The Polygon class. Implements Polygons.
Definition: glpolygon.h:56
Definition: gls_color.h:54
Definition: gls_glo_file.h:1243
Definition: gls_poly_line.h:101
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
GlsColor _haloColor
The color of the halo.
Definition: gls_poly_line.h:230
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
virtual void Draw() DISTI_METHOD_OVERRIDE
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
GlsPolyLineTriangleList _triangles
The triangles to render, derived from vertices and thickness.
Definition: gls_poly_line.h:225
bool Halo()
Definition: gls_poly_line.h:186
GlsColor HaloColor()
Definition: gls_poly_line.h:193
virtual void SetColor(const GlsColor &color) DISTI_METHOD_OVERRIDE
void Halo(const bool &val)
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
virtual bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint) DISTI_METHOD_OVERRIDE
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler) DISTI_METHOD_OVERRIDE
virtual void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
void DeleteVertexAt(unsigned int index) DISTI_METHOD_OVERRIDE
virtual void SetRecalculate()
virtual void Rotate(const Vector &orig, float angle, const Vector &axis) DISTI_METHOD_OVERRIDE
void DrawTriangles(GlsPolyLineTriangleList &array)
float _haloThickness
The thickness of the halo in logical units.
Definition: gls_poly_line.h:231
void ComputeSegments(GlsPolyLineTriangleList &array, float thickness, bool calculatingHalos=false)
static DisplayObject * CreateInstance()
virtual void GetExtents(float &minx, float &miny, float &minz, float &maxx, float &maxy, float &maxz) DISTI_METHOD_OVERRIDE
float Thickness()
Definition: gls_poly_line.h:176
virtual void CopyGeometry(DisplayObject *srcArg) DISTI_METHOD_OVERRIDE
void ComputeCorner(GlsPolyLineTriangleList &array, float thickness, float cornerRadius, const Vector &refVert, const Vector &v1, const Vector &v2, const Vector &v3, const Vector &v4, const Vector &l1, const Vector &l2, bool calculatingHalos=false)
GlsPolyLineTriangleList _haloTriangles
The triangles to render, derived from vertices and halo thickness.
Definition: gls_poly_line.h:232
virtual void SetVertices(unsigned int nPoints, Vertex *vertices) DISTI_METHOD_OVERRIDE
void HaloThickness(const float &val)
void HaloColor(const GlsColor &val)
bool _halo
If true, a halo (outline) will be drawn.
Definition: gls_poly_line.h:229
float _thickness
The thickness of the line in logical units.
Definition: gls_poly_line.h:226
virtual void Scale(float px, float py, float pz, Vertex *anchor, int handleBar) DISTI_METHOD_OVERRIDE
virtual int PolygonEnd()
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
unsigned int _endCapIndex
The index of the triangle forming the end cap.
Definition: gls_poly_line.h:236
bool _needsRecalculate
If true, the triangles will be recalculated the next frame.
Definition: gls_poly_line.h:234
Vector GlobalNormal()
Definition: gls_poly_line.h:179
virtual void SetFillColor(const GlsColor &color) DISTI_METHOD_OVERRIDE
Vector _normal
The normal vector (for all triangles).
Definition: gls_poly_line.h:227
float HaloThickness()
Definition: gls_poly_line.h:203
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::DynamicArray class. A templated array of objects capable of dynamically growing.
The disti::GLPolygon class. Implements Polygons.
The gls_auto_lib.
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:235
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:457
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:214
#define GLSGEN_GLSPOLYLINE_EXPORT
Provides support for creating DLLs.
Definition: gls_poly_line.h:60
An object for managing vertices, texture coordinates, colors and normals for GLPolygon and other disp...
The disti::GLTriMesh class. Implements Triangle Meshes.
Force inclusion of the DirectShow library.
Definition: bmpimage.h:47
DistiAttribDict::const_iterator end(const DistiAttribDict &dict)
Definition: disti_metadata.h:959
Definition: gls_poly_line.h:93
GlsPolyLineVertex a
The first vertex of the face.
Definition: gls_poly_line.h:94
GlsPolyLineVertex c
The third vertex of the face.
Definition: gls_poly_line.h:96
GlsPolyLineVertex b
The second vertex of the face.
Definition: gls_poly_line.h:95
Definition: gls_poly_line.h:85
Vector normal
Definition: gls_poly_line.h:88
Vector vertex
Definition: gls_poly_line.h:86
Vector texCoord
Definition: gls_poly_line.h:87