GL Studio C++ Runtime API
gls_cylinder.h
Go to the documentation of this file.
1/// \file gls_cylinder.h
2/// \brief The disti::GlsCylinder class.
3///
4/// \par Copyright Information
5///
6/// Copyright (c) 2017 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_CYLINDER_H
40#define DISTI_INCLUDED_GLS_CYLINDER_H
41
42#include "display.h"
43#include "dynamic_array.h"
44#include "glpolygon.h"
45#include "gls_color.h"
47#include "gls_include.h"
48#include "group.h"
49#include "timer.h"
50
51#define DEF_CYLINDER_SEGMENTS 1 ///< Default number of segments for new cylinders.
52#define DEF_CYLINDER_FACES 30 ///< Default number of faces for new cylinders.
53#define DEF_CYLINDER_FACE_START 0.0f ///< Default start angle for new cylinders in degrees.
54#define DEF_CYLINDER_FACE_END 360.0f ///< Default end angle for new cylinders in degrees.
55#define DEF_CYLINDER_TOP_SIZE 1.0f ///< Default top side scale for new cylinders.
56#define DEF_CYLINDER_BOTTOM_SIZE 1.0f ///< Default bottom side scale for new cylnders.
57#define DEF_CYLINDER_TOP_FACE false ///< Default value for top face visibility for new cylinders.
58#define DEF_CYLINDER_BOTTOM_FACE false ///< Default value for bottom face visibility for new cylinders.
59
60namespace disti
61{
62/**
63 Cylinder Initializers
64*/
65typedef enum
66{
67 GLS_CYLINDER_COLOR = GLS_LAST_INITIALIZER + 1,
68 GLS_CYLINDER_SEGMENTS,
69 GLS_CYLINDER_FACES,
70 GLS_CYLINDER_FACE_START,
71 GLS_CYLINDER_FACE_END,
72 GLS_CYLINDER_TOP_SIZE,
73 GLS_CYLINDER_BOTTOM_SIZE,
74 GLS_CYLINDER_TOP_FACE,
75 GLS_CYLINDER_BOTTOM_FACE,
76 GLS_CYLINDER_RADII
78
79/**
80 The Cylinder class. Implements Cylinder primitive
81*/
82
84{
85public:
86 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
87 typedef DisplayObject _BaseClass; ///< Deprecated typedef for the base class.
88 typedef DisplayObject BaseClass; ///< Typedef for the base class.
89 friend class GlsCylinderEditor;
90
91private:
92 /** Initialize data to default values */
93 void CommonConstructorInit();
94 /** Disabling default implicit assignment and copy constructors */
97
98 void CopyGeometryInternal( GlsCylinder* src );
99 void CopyPropertiesInternal( GlsCylinder* src );
100
101 /* Utility routine used by Hit. Performs a "FirstHit" test, which performs a hit test on the object
102 * but does not guarantee that the collision point returned by Hit is the closest collision point
103 * to the observer
104 * \param point The logical coordinate of the click, relative to the object
105 * \param directionVector The direction of the pick vector
106 * \param collisionPoint Set to the point on the object hit by directionVector
107 * \return boolean indicating if the object was hit by the mouse
108 */
109 bool FirstHit( const Vector& point, const Vector& directionVector, Vector* collisionPoint );
110
111 /* Utility routine used by Hit. Performs a "BestHit" test, which performs a hit test on the object
112 * and guarantees that the collision point returned by Hit is the closest collision point to the observer.
113 * \param point The logical coordinate of the click, relative to the object
114 * \param directionVector The direction of the pick vector
115 * \param collisionPoint Set to the point on the object hit by directionVector
116 * \return boolean indicating if the object was hit by the mouse
117 */
118 bool BestHit( const Vector& point, const Vector& directionVector, Vector* collisionPoint );
119
120 bool EndCapFirstPick( unsigned int startIndex, const Vector& point, const Vector& directionVector, Vector* collisionPoint );
121
122 void UpdateBestPickStatus( const Vector& point, const Vector& directionVector, Vector& tempCollisionPoint, Vector& closestPoint, float& pickDistance );
123
124protected:
125 Vector _radii[ 3 ]; ///< Cylinder radii, 3 vectors.
126
127 GlsColor _objectColor; ///< Fill color of the object.
128
129 float _faceStartDeg; ///< 0-360, where 0 is positive x-axis of cylinder.
130 float _faceEndDeg; ///< 0-360, where 0 is positive x-axis of cylinder.
131 float _topSize; ///< 0 - 1, scale of top and bottom ends.
132 float _bottomSize; ///< 0 - 1, scale of top and bottom ends.
133
134 unsigned int _segments; ///< Number of segments used to draw the cylinder.
135 unsigned int _faces; ///< Number of faces used to draw the cylinder.
136
137 bool _needsRecalculate; ///< True when the cylinder vertices need to be recalculated.
138 bool _needsResize; ///< True when the cylinder needs to be resized.
139 bool _topFace; ///< True when there is a circle on top of the cylinder.
140 bool _bottomFace; ///< True when there is a circle on bottom of the cylinder.
141
142 /** Sets the resize and recalculate flags, causing the cylinder to be resized and recalculated
143 * the next time the cylinder draws
144 */
146
147 /** Recalculates the cylinder vertices values */
149
150 /** Reallocates the vertices of the cylinder */
152
153 GLS_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
154
155#ifdef GLES
156 /** Set a single attribute from the GLO file.
157 * \param data The attribute to set and its associated data.
158 */
159 GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
160#endif
161
162public:
163 /** Constructor. Creates a new GlsCylinder object at given coordinates.
164 * \param x x-coordinate of new GlsCylinder
165 * \param y y-coordinate of new GlsCylinder
166 * \param z z-coordinate of new GlsCylinder
167 */
168 GLS_EXPORT GlsCylinder( float x, float y, float z );
169
170 /// Allocate a (blank) GlsCylinder object.
171 /// \param newGlsCylinder Unused, optional, kept for backward compatibility.
172 GLS_EXPORT GlsCylinder( bool newGlsCylinder = true );
173
174 /** The copy constructor for GlsCylinder
175 *
176 * \param that The GlsCylinder object that is being copied
177 * \param generateName Whether or not to generate a new instance name
178 */
179 GLS_EXPORT GlsCylinder( const GlsCylinder& that, const bool generateName );
180
181 /** Destroy a GlsCylinder object */
183
185
186 /** Finds three coplanar points and the surface normal, if possible. This calculation is performed using the
187 * Vertices() of this object. Used in the editor to determine how to map a texture onto an object.
188 * \param p1 Returns a point on the plane
189 * \param p2 Returns a point on the plane
190 * \param p3 Returns a point on the plane
191 * \param planeVector Returns the surface normal of the plane
192 * \return True if 3 coplanar points were found
193 */
195
197 GLS_EXPORT void GetExtents( float& x, float& y, float& z, float& x1, float& y1, float& z1 ) DISTI_METHOD_OVERRIDE;
199 GLS_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint ) DISTI_METHOD_OVERRIDE;
200
201 /* Unhides base class implementation. */
202 using BaseClass::Scale;
203
204 GLS_EXPORT void Scale( float px, float py, float pz, Vertex* anchor, int handleBar = 0 ) DISTI_METHOD_OVERRIDE;
205
206 /* Unhides base class implementation. */
207 using BaseClass::TextureIndex;
208
210
211 /* Usually copies the attributes except for geometry attributes from one object to another.
212 * However, since the GlsCylinder's geometry defines its properties, its geometry is copied.
213 * Used by the undo mechanism to undo most attribute change operations.
214 * \param src The object to copy properties from
215 */
217
220
221 /* Unhides base class implementation. */
222 using BaseClass::Rotate;
223
224 GLS_EXPORT void Rotate( const Vector& orig, float angle, const Vector& axis ) DISTI_METHOD_OVERRIDE;
225
226 /* Unhides base class implementation. */
227 using BaseClass::SetFillColor;
229
230 using BaseClass::GetFillColor;
232
233 /** Sets the starting degree value for the cylinder
234 * \param deg Degree value to which to set _faceStartDeg
235 */
236 virtual GLS_EXPORT void FaceStartAngle( float deg );
237
238 /** Gets the starting degree value for the cylinder
239 * \return Returns the value of _faceStartDeg
240 */
241 virtual GLS_EXPORT float FaceStartAngle();
242
243 /** Sets the ending degree value for the cylinder
244 * \param deg Degree value to which to set _faceEndDeg
245 */
246 virtual GLS_EXPORT void FaceEndAngle( float deg );
247
248 /** Gets the ending degree value for the cylinder
249 * \return Returns the value of _faceEndDeg
250 */
251 virtual GLS_EXPORT float FaceEndAngle();
252
253 /** Sets the size factor for the top of the cylinder
254 * \param size Factor to which to set _topSize
255 */
256 virtual GLS_EXPORT void TopSizeFactor( float size );
257
258 /** Gets the size factor for the top of the cylinder
259 * \return Returns the value of _topSize
260 */
261 virtual GLS_EXPORT float TopSizeFactor();
262
263 /** Sets the size factor for the bottom of the cylinder
264 * \param size Factor to which to set _bottomSize
265 */
266 virtual GLS_EXPORT void BottomSizeFactor( float size );
267
268 /** Gets the size factor for the bottom of the cylinder
269 * \return Returns the value of _bottomSize
270 */
272
273 /** Sets the number of vertical segments per face
274 * \param segments Desired number of segments to which to set _segments
275 */
276 virtual GLS_EXPORT void Segments( unsigned int segments );
277
278 /** Gets the number of vertical segments per face
279 * \return Returns the value of _segments
280 */
281 virtual GLS_EXPORT unsigned int Segments();
282
283 /** Sets the number of faces around the cylinder
284 * \param faces Desired number of faces to which to set _faces
285 */
286 virtual GLS_EXPORT void Faces( unsigned int faces );
287
288 /** Gets the number of faces around the cylinder
289 * \return Returns the value of _faces
290 */
291 virtual GLS_EXPORT unsigned int Faces();
292
293 /** Sets whether or not to draw a top face on the cylinder
294 * \param top Presences of a top face, value assigned to _topFace
295 */
296 virtual GLS_EXPORT void TopFace( bool top );
297
298 /** Gets whether or not to draw a top face on the cylinder
299 * \return Presences of a top face, returns the value of to _topFace
300 */
301 virtual GLS_EXPORT bool TopFace();
302
303 /** Sets whether or not to draw a bottom face on the cylinder
304 * \param bottom Presences of a bottom face, value assigned to _bottomFace
305 */
306 virtual GLS_EXPORT void BottomFace( bool bottom );
307
308 /** Gets whether or not to draw a bottom face on the cylinder
309 * \return Presences of a bottom face, returns the value of to _bottomFace
310 */
311 virtual GLS_EXPORT bool BottomFace();
312
313 /** Gets the radii vectors for the cylinder
314 * \param r1 First radius vector (width)
315 * \param r2 First radius vector (height)
316 * \param r3 First radius vector (depth)
317 */
318 virtual GLS_EXPORT void GetRadii( Vector& r1, Vector& r2, Vector& r3 );
319
320 /** Sets the radii vectors for the cylinder
321 * \param r1 First radius vector (width)
322 * \param r2 First radius vector (height)
323 * \param r3 First radius vector (depth)
324 */
325 virtual GLS_EXPORT void SetRadii( const Vector& r1, const Vector& r2, const Vector& r3 );
326
327#ifndef GLES
330#endif
331};
332
333} // namespace disti
334
335#endif
Definition: display.h:95
Definition: dynamic_array.h:79
Definition: gls_color.h:53
Definition: gls_cylinder.h:84
virtual float FaceStartAngle()
unsigned int _segments
Number of segments used to draw the cylinder.
Definition: gls_cylinder.h:134
bool _topFace
True when there is a circle on top of the cylinder.
Definition: gls_cylinder.h:139
virtual void GetRadii(Vector &r1, Vector &r2, Vector &r3)
float _topSize
0 - 1, scale of top and bottom ends.
Definition: gls_cylinder.h:131
void SetAvailableAttributes(unsigned int value) override
GlsCylinder(bool newGlsCylinder=true)
bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint) override
Vector _radii[3]
Cylinder radii, 3 vectors.
Definition: gls_cylinder.h:125
void CopyProperties(DisplayObject *src) override
bool _needsResize
True when the cylinder needs to be resized.
Definition: gls_cylinder.h:138
virtual void SetRadii(const Vector &r1, const Vector &r2, const Vector &r3)
float _faceStartDeg
0-360, where 0 is positive x-axis of cylinder.
Definition: gls_cylinder.h:129
virtual bool BottomFace()
void CopyGeometry(DisplayObject *src) override
void SetValue(int spec, va_list &args) override
GlsCylinder(const GlsCylinder &that, const bool generateName)
virtual float TopSizeFactor()
void SetResizeRecalculate()
InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) override
GlsCylinder(float x, float y, float z)
void SetFillColor(const GlsColor &color) override
virtual unsigned int Segments()
bool _bottomFace
True when there is a circle on bottom of the cylinder.
Definition: gls_cylinder.h:140
unsigned int _faces
Number of faces used to draw the cylinder.
Definition: gls_cylinder.h:135
GlsColor _objectColor
Fill color of the object.
Definition: gls_cylinder.h:127
virtual ~GlsCylinder()
DisplayObject * CloneObject(bool generateNames=false) override
GlsColor GetFillColor() override
virtual unsigned int Faces()
void CalculateTextureCoordinates() override
void GetCppInterfaceDescriptionFree(InterfaceListType *array) override
void Rotate(const Vector &orig, float angle, const Vector &axis) override
virtual int TextureIndex()
virtual float BottomSizeFactor()
void Scale(float px, float py, float pz, Vertex *anchor, int handleBar=0) override
virtual float FaceEndAngle()
bool _needsRecalculate
True when the cylinder vertices need to be recalculated.
Definition: gls_cylinder.h:137
virtual bool TopFace()
bool GetPlaneVectorPoints(Vertex &p1, Vertex &p2, Vertex &p3, Vertex &planeVector) override
void GetExtents(float &x, float &y, float &z, float &x1, float &y1, float &z1) override
void Draw() override
float _bottomSize
0 - 1, scale of top and bottom ends.
Definition: gls_cylinder.h:132
float _faceEndDeg
0-360, where 0 is positive x-axis of cylinder.
Definition: gls_cylinder.h:130
Definition: gls_glo_file.h:1241
Definition: vertex.h:84
Definition: vertex.h:419
The disti::DisplayObject class and global enumerations.
The disti::DynamicArray class. A templated array of objects capable of dynamically growing.
The disti::GLPolygon class. Implements Polygons.
The Color class: Implements a 4 component RGBA color.
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
A file for all GL Studio files to include.
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:50
The disti::Group class. Implements groups of objects.
Definition: bmpimage.h:46
GLS_Cylinder_Initializers
Definition: gls_cylinder.h:66
The disti::Timer class. An OS portable timing class.