GL Studio C++ Runtime API
gls_sphere.h
Go to the documentation of this file.
1/*! \file
2 \brief The disti::GlsSphere 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_SPHERE_H
41#define _GLS_SPHERE_H
42
43#include "display.h"
44#include "dynamic_array.h"
45#include "gls_color.h"
47#include "gls_include.h"
48
49#define DEF_SPHERE_STACKS 10 ///< The default number of stacks for a new GlsSphere.
50#define DEF_SPHERE_SLICES 10 ///< The default number of slices for a new GlsSphere.
51#define DEF_SPHERE_SLICE_START 0.0f ///< The default slice start angle in degrees for a new GlsSphere.
52#define DEF_SPHERE_SLICE_END 360.0f ///< The default slice end angle in degrees for a new GlsSphere.
53#define DEF_SPHERE_STACK_START 0.0f ///< The default stack start angle in degrees for a new GlsSphere.
54#define DEF_SPHERE_STACK_END 180.0f ///< The default stack end angle in degrees for a new GlsSphere.
55
56namespace disti
57{
58/** gls Sphere Mapping */
59typedef enum
60{
61 GLS_SPHERE_SPHERICAL_MAP, /**< Spherical texture map */
62 GLS_SPHERE_CYLINDER_MAP /**< Cylindrical texture map */
64
65/**
66 Sphere Initializers
67*/
68typedef enum
69{
70 GLS_SPHERE_MAPPING = GLS_LAST_INITIALIZER + 1,
71 GLS_SPHERE_COLOR,
72 GLS_SPHERE_STACKS,
73 GLS_SPHERE_SLICES,
74 GLS_SPHERE_SLICE_START,
75 GLS_SPHERE_SLICE_END,
76 GLS_SPHERE_STACK_START,
77 GLS_SPHERE_STACK_END,
78 GLS_SPHERE_RADII
80
81/** The Sphere class. Implements Sphere primitive */
83{
84private:
85 /** Factors out common code shared by the various glsSphere constructors */
86 void CommonConstructorInit();
87 /** Assignment operator not implemented. Use CloneObject() or the copy constructor instead. */
90
91protected:
92 Vector _radii[ 3 ]; ///< Sphere radii
93
94 GlsColor _objectColor; ///< Fill color of object.
95
96 float _sliceStartDeg; ///< 0-180, where 0 is the bottom and 180 the top of the sphere.
97 float _sliceEndDeg; ///< 0-180, where 0 is the bottom and 180 the top of the sphere.
98 float _stackStartDeg; ///< 0-360, where 0 is the positive x-axis of the sphere.
99 float _stackEndDeg; ///< 0-360, where 0 is the positive x-axis of the sphere.
100
101 unsigned int _stacks; ///< Number of stacks used to draw the sphere.
102 unsigned int _slices; ///< Number of slices used to draw the sphere.
103
104 bool _needsRecalculate; ///< True when the sphere vertices need to be recalculated.
105 bool _needsResize; ///< True when the sphere needs to be resized.
106
107 glsSphereMapping_e _textureMappingType; ///< Texture mapping method.
108
109 /** Sets the resize and recalculate flags, causing the sphere to be resized and recalculated
110 * the next time the sphere draws
111 */
113
114 /** Recalculates the sphere vertices values */
116
117 /** Reallocates the vertices of the sphere */
119
120 virtual GLS_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
121
122#ifdef GLES
123 /** Set a single attribute from the GLO file.
124 * \param data The attribute to set and its associated data.
125 */
126 virtual GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
127#endif
128
129private:
130 /* Utility routine used by Hit. Performs a "FirstHit" test, which performs a hit test on the object
131 * but does not guarantee that the collision point returned by Hit is the closest collision point
132 * to the observer
133 * \param point The logical coordinate of the click, relative to the object
134 * \param directionVector The direction of the pick vector
135 * \param collisionPoint Set to the point on the object hit by directionVector
136 * \return boolean indicating if the object was hit by the mouse
137 */
138 bool FirstHit( const Vector& point, const Vector& directionVector, Vector* collisionPoint );
139
140 /* Utility routine used by Hit. Performs a "BestHit" test, which performs a hit test on the object
141 * and guarantees that the collision point returned by Hit is the closest collision point to the observer.
142 * \param point The logical coordinate of the click, relative to the object
143 * \param directionVector The direction of the pick vector
144 * \param collisionPoint Set to the point on the object hit by directionVector
145 * \return boolean indicating if the object was hit by the mouse
146 */
147 bool BestHit( const Vector& point, const Vector& directionVector, Vector* collisionPoint );
148
149public:
150 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
151 typedef DisplayObject _BaseClass; ///< Deprecated typedef for the base class.
152 typedef DisplayObject BaseClass; ///< Typedef for the base class.
153
154 friend class GlsSphereEditor;
155
156 /** Constructor. Creates a new GlsSphere object at given coordinates.
157 * \param x x-coordinate of new GlsSphere
158 * \param y y-coordinate of new GlsSphere
159 * \param z z-coordinate of new GlsSphere
160 */
161 GLS_EXPORT GlsSphere( float x, float y, float z );
162
163 /// Allocate a (blank) GlsSphere object.
164 /// \param newGlsSphere Unused, kept for backward compatibility.
165 GLS_EXPORT GlsSphere( bool newGlsSphere = true );
166
167 /// Copy constructor
168 /// \param that The object to copy from.
169 /// \param generateNames Whether or not to generate an instance name for this object.
170 GLS_EXPORT GlsSphere( const GlsSphere& that, const bool generateNames );
171
172 /** Destroy a GlsSphere object */
174
175 virtual GLS_EXPORT void SetAvailableAttributes( unsigned int value ) DISTI_METHOD_OVERRIDE;
176
177 /** Gets the texture mapping method.
178 * \return Enumerative representation of texture mapping method
179 */
181
182 /* Unhides base class implementation. */
183 using BaseClass::TextureIndex;
185
186 /** Sets the texture mapping type
187 * \param value The texture mapping value (e.g. cylindrical or spherical)
188 */
190
191 /** Finds three coplanar points and the surface normal, if possible. This calculation is performed using the
192 * Vertices() of this object. Used in the editor to determine how to map a texture onto an object.
193 * \param p1 Returns a point on the plane
194 * \param p2 Returns a point on the plane
195 * \param p3 Returns a point on the plane
196 * \param planeVector Returns the surface normal of the plane
197 * \return True if 3 coplanar points were found
198 */
200
202 virtual GLS_EXPORT void GetExtents( float& x, float& y, float& z, float& x1, float& y1, float& z1 ) DISTI_METHOD_OVERRIDE;
204 virtual GLS_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint ) DISTI_METHOD_OVERRIDE;
205
206 /* Unhides base class implementation. */
207 using BaseClass::Scale;
208 virtual GLS_EXPORT void Scale( float px, float py, float pz, Vertex* anchor, int handleBar ) DISTI_METHOD_OVERRIDE;
209
210 /* Usually copies the attributes except for geometry attributes from one object to another.
211 * However, since the GlsSphere's geometry defines its properties, its geometry is copied.
212 * Used by the undo mechanism to undo most attribute change operations.
213 * \param src The object to copy properties from */
215
217 virtual GLS_EXPORT DisplayObject* CloneObject( bool generateNames = false ) DISTI_METHOD_OVERRIDE;
218
219 /* Unhides base class implementation. */
220 using BaseClass::Rotate;
221 virtual GLS_EXPORT void Rotate( const Vector& orig, float angle, const Vector& axis ) DISTI_METHOD_OVERRIDE;
222
223 /* Unhides base class implementation. */
224 using BaseClass::SetFillColor;
225
227
228 /* Unhides base class implementation. */
229 using BaseClass::GetFillColor;
230
232
233 /** Sets the starting degree value for the stacks
234 * \param deg Degree value to which to set _stackStartDeg
235 */
236 virtual GLS_EXPORT void StackStartAngle( float deg );
237
238 /** Gets the starting degree value for the stacks
239 * \return Returns the value of _stackStartDeg
240 */
242
243 /** Sets the ending degree value for the stacks
244 * \param deg Degree value to which to set _stackEndDeg
245 */
246 virtual GLS_EXPORT void StackEndAngle( float deg );
247
248 /** Gets the ending degree value for the stacks
249 * \return Returns the value of _stackEndDeg
250 */
251 virtual GLS_EXPORT float StackEndAngle();
252
253 /** Sets the starting degree value for the slices
254 * \param deg Degree value to which to set _sliceStartDeg
255 */
256 virtual GLS_EXPORT void SliceStartAngle( float deg );
257
258 /** Gets the starting degree value for the slices
259 * \return Returns the value of _sliceStartDeg
260 */
262
263 /** Sets the ending degree value for the slices
264 * \param deg Degree value to which to set _sliceEndDeg
265 */
266 virtual GLS_EXPORT void SliceEndAngle( float deg );
267
268 /** Gets the ending degree value for the slices
269 * \return Returns the value of _sliceEndDeg
270 */
271 virtual GLS_EXPORT float SliceEndAngle();
272
273 /** Sets the number of horizontal slices
274 * \param slices Desired number of slices to which to set _slices
275 */
276 virtual GLS_EXPORT void Slices( unsigned int slices );
277
278 /** Gets the number of horizontal slices
279 * \return Returns the value of _slices
280 */
281 virtual GLS_EXPORT unsigned int Slices();
282
283 /** Sets the number of vertical stacks
284 * \param stacks Desired number of stacks to which to set _stacks
285 */
286 virtual GLS_EXPORT void Stacks( unsigned int stacks );
287
288 /** Gets the number of vertical stacks
289 * \return Returns the value of _stacks
290 */
291 virtual GLS_EXPORT unsigned int Stacks();
292
293 /** Gets the radii vectors for the sphere
294 * \param r1 First radius vector (width)
295 * \param r2 First radius vector (height)
296 * \param r3 First radius vector (depth)
297 */
298 virtual GLS_EXPORT void GetRadii( Vector& r1, Vector& r2, Vector& r3 );
299
300 /** Sets the radii vectors for the sphere
301 * \param r1 First radius vector (width)
302 * \param r2 First radius vector (height)
303 * \param r3 First radius vector (depth)
304 */
305 virtual GLS_EXPORT void SetRadii( const Vector& r1, const Vector& r2, const Vector& r3 );
306
307#ifndef GLES
310#endif
311};
312
313#define DEF_SPHERE_MAPPING GLS_SPHERE_SPHERICAL_MAP ///< The default texture mapping behavior for a new GlsSphere.
314
315/** Defines metadata for glsSphereMapping_e */
316class DistiAttributeSphereMappingTypeEnum : public DistiAttributeEnum<GlsSphere, glsSphereMapping_e, glsSphereMapping_e>
317{
318public:
319 /// Constructor
320 /// \param frame The object containing the property.
321 /// \param setMethod The set method function pointer.
322 /// \param getMethod The get method function pointer.
323 /// \param name The name of the associated property.
325
327};
328
329} // namespace disti
330
331#endif
Definition: disti_metadata.h:87
Definition: display.h:96
Definition: disti_metadata.h:1005
void(containerClass::* SetMethodType)(glsSphereMapping_e)
Typedef for the set method function pointer.
Definition: disti_metadata.h:1007
glsSphereMapping_e(containerClass::* GetMethodType)()
Typedef for the get method function pointer.
Definition: disti_metadata.h:1008
Definition: gls_sphere.h:317
DistiAttributeSphereMappingTypeEnum(GlsSphere *frame, SetMethodType setMethod, GetMethodType getMethod, const AttributeName &name)
Definition: dynamic_array.h:79
Definition: gls_color.h:54
Definition: gls_glo_file.h:1243
Definition: gls_sphere.h:83
float _stackEndDeg
0-360, where 0 is the positive x-axis of the sphere.
Definition: gls_sphere.h:99
virtual void GetRadii(Vector &r1, Vector &r2, Vector &r3)
glsSphereMapping_e _textureMappingType
Texture mapping method.
Definition: gls_sphere.h:107
virtual DisplayObject * CloneObject(bool generateNames=false) override
Vector _radii[3]
Sphere radii.
Definition: gls_sphere.h:92
virtual float SliceStartAngle()
virtual float SliceEndAngle()
bool _needsResize
True when the sphere needs to be resized.
Definition: gls_sphere.h:105
virtual void SetRadii(const Vector &r1, const Vector &r2, const Vector &r3)
virtual float StackStartAngle()
virtual void Rotate(const Vector &orig, float angle, const Vector &axis) override
virtual unsigned int Slices()
virtual void SetAvailableAttributes(unsigned int value) override
virtual bool GetPlaneVectorPoints(Vertex &p1, Vertex &p2, Vertex &p3, Vertex &planeVector) override
virtual float StackEndAngle()
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array) override
virtual void SetValue(int spec, va_list &args) override
virtual GlsColor GetFillColor() override
void SetResizeRecalculate()
virtual void CalculateTextureCoordinates() override
virtual void SetFillColor(const GlsColor &color) override
GlsColor _objectColor
Fill color of object.
Definition: gls_sphere.h:94
unsigned int _stacks
Number of stacks used to draw the sphere.
Definition: gls_sphere.h:101
virtual void GetExtents(float &x, float &y, float &z, float &x1, float &y1, float &z1) override
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 Scale(float px, float py, float pz, Vertex *anchor, int handleBar) override
virtual void Draw() override
float _sliceEndDeg
0-180, where 0 is the bottom and 180 the top of the sphere.
Definition: gls_sphere.h:97
virtual int TextureIndex()
float _stackStartDeg
0-360, where 0 is the positive x-axis of the sphere.
Definition: gls_sphere.h:98
bool _needsRecalculate
True when the sphere vertices need to be recalculated.
Definition: gls_sphere.h:104
virtual void CopyGeometry(DisplayObject *src) override
unsigned int _slices
Number of slices used to draw the sphere.
Definition: gls_sphere.h:102
glsSphereMapping_e TextureMappingType()
virtual unsigned int Stacks()
float _sliceStartDeg
0-180, where 0 is the bottom and 180 the top of the sphere.
Definition: gls_sphere.h:96
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 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
Force inclusion of the DirectShow library.
Definition: bmpimage.h:47
GLS_Sphere_Initializers
Definition: gls_sphere.h:69
glsSphereMapping_e
Definition: gls_sphere.h:60
@ GLS_SPHERE_CYLINDER_MAP
Definition: gls_sphere.h:62
@ GLS_SPHERE_SPHERICAL_MAP
Definition: gls_sphere.h:61