| 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
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*/
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"
47#include "gls_cpp_lang_support.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
61 namespace disti
62{
63/**
64 Cylinder Initializers
65*/
66 typedef 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
78} GLS_Cylinder_Initializers;
79
80/**
81 The Cylinder class. Implements Cylinder primitive
82*/
83
84 class GlsCylinder : public DisplayObject
85{
86 public:
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 */
96 GlsCylinder& operator=( const GlsCylinder& that ) DISTI_SPECIAL_MEM_FUN_DELETE;
97 GlsCylinder( const GlsCylinder& ) DISTI_SPECIAL_MEM_FUN_DELETE;
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 */
146 GLS_EXPORT void SetResizeRecalculate();
147
148 /** Recalculates the cylinder vertices values */
149 GLS_EXPORT void Recalculate();
150
151 /** Reallocates the vertices of the cylinder */
152 GLS_EXPORT void Resize();
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
163 public:
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 */
183 virtual GLS_EXPORT ~GlsCylinder();
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 */
195 virtual GLS_EXPORT bool GetPlaneVectorPoints( Vertex& p1, Vertex& p2, Vertex& p3, Vertex& planeVector ) DISTI_METHOD_OVERRIDE;
196
197 virtual GLS_EXPORT void CalculateTextureCoordinates() DISTI_METHOD_OVERRIDE;
198 virtual GLS_EXPORT void GetExtents( float& x, float& y, float& z, float& x1, float& y1, float& z1 ) DISTI_METHOD_OVERRIDE;
199 virtual GLS_EXPORT void Draw() 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
210 virtual GLS_EXPORT void TextureIndex( int index ) DISTI_METHOD_OVERRIDE;
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 */
217 virtual GLS_EXPORT void CopyProperties( DisplayObject* src ) DISTI_METHOD_OVERRIDE;
218
219 virtual GLS_EXPORT void CopyGeometry( DisplayObject* src ) DISTI_METHOD_OVERRIDE;
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;
229 virtual GLS_EXPORT void SetFillColor( const GlsColor& color ) DISTI_METHOD_OVERRIDE;
230
231 using BaseClass::GetFillColor;
232 virtual GLS_EXPORT GlsColor GetFillColor() DISTI_METHOD_OVERRIDE;
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 */
272 virtual GLS_EXPORT float BottomSizeFactor();
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
329 virtual GLS_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL ) DISTI_METHOD_OVERRIDE;
330 virtual GLS_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array ) DISTI_METHOD_OVERRIDE;
331#endif
332};
333
334} // namespace disti
335
336#endif
disti::DisplayObject
Definition: display.h:96
disti::DynamicArray
Definition: dynamic_array.h:79
disti::GlsColor
Definition: gls_color.h:54
disti::GlsCylinder
Definition: gls_cylinder.h:85
disti::GlsCylinder::FaceStartAngle
virtual float FaceStartAngle()
disti::GlsCylinder::Recalculate
void Recalculate()
disti::GlsCylinder::_segments
unsigned int _segments
Number of segments used to draw the cylinder.
Definition: gls_cylinder.h:135
disti::GlsCylinder::Resize
void Resize()
disti::GlsCylinder::_topFace
bool _topFace
True when there is a circle on top of the cylinder.
Definition: gls_cylinder.h:140
disti::GlsCylinder::GetRadii
virtual void GetRadii(Vector &r1, Vector &r2, Vector &r3)
disti::GlsCylinder::_topSize
float _topSize
0 - 1, scale of top and bottom ends.
Definition: gls_cylinder.h:132
disti::GlsCylinder::CloneObject
virtual DisplayObject * CloneObject(bool generateNames=false) override
disti::GlsCylinder::GlsCylinder
GlsCylinder(bool newGlsCylinder=true)
disti::GlsCylinder::SetFromGloData
virtual void SetFromGloData(GlsGloFileAttribute &data) override
disti::GlsCylinder::_radii
Vector _radii[3]
Cylinder radii, 3 vectors.
Definition: gls_cylinder.h:126
disti::GlsCylinder::_needsResize
bool _needsResize
True when the cylinder needs to be resized.
Definition: gls_cylinder.h:139
disti::GlsCylinder::SetRadii
virtual void SetRadii(const Vector &r1, const Vector &r2, const Vector &r3)
disti::GlsCylinder::Rotate
virtual void Rotate(const Vector &orig, float angle, const Vector &axis) override
disti::GlsCylinder::SetAvailableAttributes
virtual void SetAvailableAttributes(unsigned int value) override
disti::GlsCylinder::_faceStartDeg
float _faceStartDeg
0-360, where 0 is positive x-axis of cylinder.
Definition: gls_cylinder.h:130
disti::GlsCylinder::GetPlaneVectorPoints
virtual bool GetPlaneVectorPoints(Vertex &p1, Vertex &p2, Vertex &p3, Vertex &planeVector) override
disti::GlsCylinder::BottomFace
virtual bool BottomFace()
disti::GlsCylinder::SetValue
virtual void SetValue(int spec, va_list &args) override
disti::GlsCylinder::GetFillColor
virtual GlsColor GetFillColor() override
disti::GlsCylinder::GlsCylinder
GlsCylinder(const GlsCylinder &that, const bool generateName)
disti::GlsCylinder::TopSizeFactor
virtual float TopSizeFactor()
disti::GlsCylinder::SetResizeRecalculate
void SetResizeRecalculate()
disti::GlsCylinder::CalculateTextureCoordinates
virtual void CalculateTextureCoordinates() override
disti::GlsCylinder::GlsCylinder
GlsCylinder(float x, float y, float z)
disti::GlsCylinder::Segments
virtual unsigned int Segments()
disti::GlsCylinder::_bottomFace
bool _bottomFace
True when there is a circle on bottom of the cylinder.
Definition: gls_cylinder.h:141
disti::GlsCylinder::SetFillColor
virtual void SetFillColor(const GlsColor &color) override
disti::GlsCylinder::_faces
unsigned int _faces
Number of faces used to draw the cylinder.
Definition: gls_cylinder.h:136
disti::GlsCylinder::_objectColor
GlsColor _objectColor
Fill color of the object.
Definition: gls_cylinder.h:128
disti::GlsCylinder::GetExtents
virtual void GetExtents(float &x, float &y, float &z, float &x1, float &y1, float &z1) override
disti::GlsCylinder::~GlsCylinder
virtual ~GlsCylinder()
disti::GlsCylinder::Hit
virtual bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint) override
disti::GlsCylinder::CopyProperties
virtual void CopyProperties(DisplayObject *src) override
disti::GlsCylinder::Draw
virtual void Draw() override
disti::GlsCylinder::Faces
virtual unsigned int Faces()
disti::GlsCylinder::TextureIndex
virtual int TextureIndex()
disti::GlsCylinder::Scale
virtual void Scale(float px, float py, float pz, Vertex *anchor, int handleBar=0) override
disti::GlsCylinder::BottomSizeFactor
virtual float BottomSizeFactor()
disti::GlsCylinder::FaceEndAngle
virtual float FaceEndAngle()
disti::GlsCylinder::_needsRecalculate
bool _needsRecalculate
True when the cylinder vertices need to be recalculated.
Definition: gls_cylinder.h:138
disti::GlsCylinder::CopyGeometry
virtual void CopyGeometry(DisplayObject *src) override
disti::GlsCylinder::TopFace
virtual bool TopFace()
disti::GlsCylinder::_bottomSize
float _bottomSize
0 - 1, scale of top and bottom ends.
Definition: gls_cylinder.h:133
disti::GlsCylinder::_faceEndDeg
float _faceEndDeg
0-360, where 0 is positive x-axis of cylinder.
Definition: gls_cylinder.h:131
disti::GlsGloFileAttribute
Definition: gls_glo_file.h:1243
disti::VertexNoColor
Definition: vertex.h:85
disti::Vertex
Definition: vertex.h:420
display.h
The disti::DisplayObject class and global enumerations.
dynamic_array.h
The disti::DynamicArray class. A templated array of objects capable of dynamically growing.
glpolygon.h
The disti::GLPolygon class. Implements Polygons.
gls_color.h
The Color class: Implements a 4 component RGBA color.
gls_cpp_lang_support.h
Macros and helper code to determine what subset of C++11/14/17 is available.
DISTI_SPECIAL_MEM_FUN_DELETE
#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:246
DISTI_DEPRECATED
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:488
DISTI_METHOD_OVERRIDE
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:222
gls_include.h
A file for all GL Studio files to include.
GLS_EXPORT
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:52
group.h
The disti::Group class. Implements groups of objects.
disti
Definition: bmpimage.h:47
disti::GLS_Cylinder_Initializers
GLS_Cylinder_Initializers
Definition: gls_cylinder.h:67
timer.h
The disti::Timer class. An OS portable timing class.