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