GL Studio C++ Runtime API
gls_nurb_curve.h
Go to the documentation of this file.
1/// \file gls_nurb_curve.h
2/// \brief The disti::GlsNurbCurve 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 DISTI_INCLUDED_GLS_NURB_CURVE_H
40#define DISTI_INCLUDED_GLS_NURB_CURVE_H
41
42#include "display.h"
43#include "glpolygon.h"
45
46/// Provides support for creating DLLs.
47#if( defined( GLSGEN_EXPORT_GLSNURBCURVE ) || defined( GLSGEN_IMPORT_GLSNURBCURVE ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
48 && defined( _MSC_VER )
49# if defined( GLSGEN_EXPORT_GLSNURBCURVE ) || defined( GLS_EXPORT_GENERATED )
50# define GLSGEN_GLSNURBCURVE_EXPORT __declspec( dllexport )
51# else
52# define GLSGEN_GLSNURBCURVE_EXPORT __declspec( dllimport )
53# endif
54#else
55# define GLSGEN_GLSNURBCURVE_EXPORT
56#endif
57///////////////////////////////////////////////////////////////////////////////
58
59/// Automatically link the runtime library plugin (on Windows).
60#define LIB_BASE_NAME "gls_nurb_curve"
61#include "gls_auto_lib.h"
62#undef LIB_BASE_NAME
63
64namespace disti
65{
66/** Maximum number of tesselated vertices in a spline */
67const int MAX_SPLINE_VERTICES = 2000;
68
69/** smallest number of control points in a spline */
70const int MIN_NUMBER_POINTS = 2;
71
72/** When calculating the current vertices, how many control
73 * points should we consider */
75
76// SetValue enumerations
77enum
78{
79 GLS_GLSNURBCURVE_FIRST_VALUE = GLS_LAST_INITIALIZER + 1,
80 GLS_GLSNURBCURVE_EMITEVENT // example
81};
82
83/** Runtime implementation of a GlsNurbCurve */
85{
86public:
87 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
88 typedef DisplayObject _BaseClass; ///< Deprecated typedef for the base class.
89 typedef DisplayObject BaseClass; ///< Typedef for the base class.
90 friend class GlsNurbCurveEditor;
91
92private:
93 // We capture the tesselated vertices from the NURB render function
94 // and store them here, to be used by the draw routine.
95 // This is not to be confused with the editor Tesselator functions.
96 // These are the points that the NURB render function generates to
97 // draw the curve.
98 Vertex* _tesselated_vertices; /** The tesselated vertices, computed from the control points */
99 unsigned int _tesselated_vertices_count; /** The number of tesselated vertices */
100
101 // disabling default implicit assignment and copy constructor
104
105public:
106 /** Creates a NURB Curve with the vertices specified
107 * \param nPoints Number of control points in the NURB
108 * \param vertices An array of allocated vertices
109 * \pre vertices is not NULL
110 */
111 GLSGEN_GLSNURBCURVE_EXPORT GlsNurbCurve( unsigned int nPoints, Vertex* vertices );
112
113 /// Allocate a (blank) NURB Curve object.
114 /// \param generateInstanceName Whether or not to generate an instance name for this object.
115 GLSGEN_GLSNURBCURVE_EXPORT GlsNurbCurve( bool generateInstanceName = false );
116
117 /** NurbCurve Constructor. Creates a new NURBCurve object with
118 * the number of vertices and vertex data specified.
119 * \param n_points Number of control points in the NURB
120 * \param vertices An array of allocated vertices
121 * \param location Initial location of the NURB
122 */
123 GLSGEN_GLSNURBCURVE_EXPORT GlsNurbCurve( unsigned int n_points, Vertex* vertices, Vertex& location );
124
125 /// Copy constructor
126 /// \param that The object to copy from.
127 /// \param generateNames Whether or not to generate an instance name for this object.
128 GLSGEN_GLSNURBCURVE_EXPORT GlsNurbCurve( const GlsNurbCurve& that, const bool generateNames );
129
130 /** Destructs a GlsNurbCurve object */
132
133 /// \return A pointer to a new GlsNurbCurve object.
135
136 /** Generate a list of vertices describing the NURB curve, save those
137 * vertices in the NURBCurve object for use in drawing.
138 */
140
141 /** Gets the object's number of Tesselated vertices.
142 * These tesselated vertices are generated by the NURB render function.
143 * \return The number of vertices in the object
144 */
145 unsigned int NumberOfTessVertices() const { return _tesselated_vertices_count; }
146
147 /** Gets the object's tesselated vertices.
148 * \return Pointer the the object's tesselated vertices
149 */
150 Vertex* TessVertices() { return _tesselated_vertices; }
151
152 //////////////////////////////////////////////////
153 // Overridden base class methods
154 //////////////////////////////////////////////////
155
159
160#ifndef GLES
163#endif
164
168 GLSGEN_GLSNURBCURVE_EXPORT void VaListSetVertices( unsigned int nPoints, va_list args ) DISTI_METHOD_OVERRIDE;
169
170 /* Unhides base class implementation. */
171 using BaseClass::Scale;
172 GLSGEN_GLSNURBCURVE_EXPORT void Scale( float px, float py, float pz, Vertex* a, int handleBar ) DISTI_METHOD_OVERRIDE;
173
175
176 /* Unhides base class implementation. */
177 using BaseClass::Rotate;
178 GLSGEN_GLSNURBCURVE_EXPORT void Rotate( const Vector& orig, float angle, const Vector& axis ) DISTI_METHOD_OVERRIDE;
179
180 GLSGEN_GLSNURBCURVE_EXPORT void GetExtents( float& x, float& y, float& z, float& x1, float& y1, float& z1 ) DISTI_METHOD_OVERRIDE;
181 GLSGEN_GLSNURBCURVE_EXPORT void GetTransformedExtents( Vector& min, Vector& max, const GlsMatrixType& matrix, bool resetMinMax = true ) DISTI_METHOD_OVERRIDE;
182 GLSGEN_GLSNURBCURVE_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint ) DISTI_METHOD_OVERRIDE;
183
185 GLSGEN_GLSNURBCURVE_EXPORT void SetVertexColor( unsigned int index, unsigned char col[] ) DISTI_METHOD_OVERRIDE;
186
187 /* Unhides base class implementation. */
188 using BaseClass::SetFillColor;
190
191 /// Calculates normals based on the vertices and the specified winding order.
192 /// \param windingOrder If less than zero, all normals will be mirrored (*= -1.0f).
193 virtual GLSGEN_GLSNURBCURVE_EXPORT void CalcNormals( int windingOrder = 1 );
194
195 /// Create a spline from a set of control points. Return the vertices, so that the user can draw the spline as they wish.
196 /// \param num_vertices The number of control points to make a spline out of.
197 /// \param vertices The control points.
198 /// \param curve_array_size Originally the size of the curve array.
199 /// \param curve_array The actually used size is returned here.
200 GLSGEN_GLSNURBCURVE_EXPORT void GenerateSpline( unsigned int num_vertices, Vertex* vertices, unsigned int* curve_array_size, Vertex* curve_array );
201
202protected:
203#ifdef GLES
204 /// BakeVBO is a helper function only used for GLES drawing and should not be considered missing external api
205 void BakeVBO();
206 GlsVertexArray _curve; ///< The geometric object composed of a list of vertices for rendering.
207 GlsVertexArray _fill; ///< Tesselated vertices used to fill in color.
208#endif
209};
210
211} // namespace disti
212
213#endif
Definition: cull.h:49
Definition: display.h:95
Definition: dynamic_array.h:79
Definition: gls_color.h:53
Definition: gls_nurb_curve.h:85
void CopyGeometry(DisplayObject *src) DISTI_METHOD_OVERRIDE
void VaListSetVertices(unsigned int nPoints, va_list args) DISTI_METHOD_OVERRIDE
void SetFillColor(const GlsColor &color) DISTI_METHOD_OVERRIDE
void GetTransformedExtents(Vector &min, Vector &max, const GlsMatrixType &matrix, bool resetMinMax=true) DISTI_METHOD_OVERRIDE
void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
void DeleteVertexAt(unsigned int index) DISTI_METHOD_OVERRIDE
void Scale(float px, float py, float pz, Vertex *a, int handleBar) DISTI_METHOD_OVERRIDE
unsigned int NumberOfTessVertices() const
Definition: gls_nurb_curve.h:145
void GenerateTessellatedVertices()
virtual void CalcNormals(int windingOrder=1)
void SetVertices(unsigned int nPoints, Vertex *vertices) DISTI_METHOD_OVERRIDE
void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler) DISTI_METHOD_OVERRIDE
static DisplayObject * CreateInstance()
void Draw() DISTI_METHOD_OVERRIDE
void SetVertexColor(unsigned int index, unsigned char col[]) DISTI_METHOD_OVERRIDE
void CalculateTextureCoordinates() DISTI_METHOD_OVERRIDE
bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint) DISTI_METHOD_OVERRIDE
Vertex * TessVertices()
Definition: gls_nurb_curve.h:150
DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
void GenerateSpline(unsigned int num_vertices, Vertex *vertices, unsigned int *curve_array_size, Vertex *curve_array)
void GetExtents(float &x, float &y, float &z, float &x1, float &y1, float &z1) DISTI_METHOD_OVERRIDE
void SetAvailableAttributes(unsigned int availableAttributes) DISTI_METHOD_OVERRIDE
InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
void Rotate(const Vector &orig, float angle, const Vector &axis) DISTI_METHOD_OVERRIDE
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.
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_GLSNURBCURVE_EXPORT
Provides support for creating DLLs.
Definition: gls_nurb_curve.h:55
Definition: bmpimage.h:46
const int MAX_SPLINE_VERTICES
Definition: gls_nurb_curve.h:67
const int NUMBER_POINTS_TO_CONSIDER
Definition: gls_nurb_curve.h:74
const int MIN_NUMBER_POINTS
Definition: gls_nurb_curve.h:70