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