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