GL Studio C++ Runtime API
display.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::DisplayObject class and global enumerations.
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 INCLUDED_DISTI_DISPLAY_H
41 #define INCLUDED_DISTI_DISPLAY_H
42 
43 #include "cull.h"
44 #include "display_types.h"
45 #include "disti_metadata.h"
46 #include "dynamic_array.h"
47 #include "editor_object_base.h"
48 #include "gls_gl.h"
49 #include "gls_matrix_affine.h"
50 #include "gls_painter.h"
51 #include "util.h"
52 #include "vertex.h"
54 
55 #ifdef GLES
56 # include "gls_state_manager.h"
57 #endif
58 
59 /** \namespace disti
60  * Contains GL Studio classes and other DiSTI code.
61  */
62 namespace disti
63 {
64 // Forward declarations
65 class DisplayObject;
66 class DisplayFrame;
67 class Group;
68 class DisplayEvent;
69 class TexturePalette;
70 class CallbackMethodCallerBase;
71 class GlsResourceFilter;
72 class DisplayObjectEditor;
73 class Culler;
74 #ifdef GLES
75 class GlsGloFile;
76 class GlsGloFileAttribute;
77 #endif
78 
79 // Call this to unlock the GL Studio Runtime library.
80 // It must be called before any DisplayObject is constructed.
81 GLS_EXPORT void InitializeLibrary( const char* unlockString = NULL, const DisplayFrame* frame = NULL, bool checkLicense = false );
82 
83 // Returns a string with the name of the company which
84 // was passed in inside the unlockString of InitializeLibrary().
85 // Do not free the returned pointer
86 GLS_EXPORT const char* LicenseUnlockedBy();
87 
88 typedef DisplayObject* DisplayObjectPtr;
89 typedef DynamicArray<DisplayObjectPtr> DisplayObjectArray;
90 typedef DynamicArray<int> DynamicIntArray;
91 
92 /** \class DisplayObject
93  Base Class for all graphical objects. It is an abstract class. Each
94  object drawn in the editor will have a corresponding object. All drawn objects
95  are derived from this class.
96 */
97 
99  , virtual public WeakReferenceableMixin
100 {
101  friend class DisplayObjectEditor;
102 
103 public:
104  /** The default constructor for display objects. Generally invoked
105  * by constructors of derived classes.
106  * \param x X coordinate of object location
107  * \param y Y coordinate of object location
108  * \param z Z coordinate of object location
109  */
110  GLS_EXPORT DisplayObject( float x, float y, float z );
111 
112  /** The copy constructor for display objects
113  *
114  * \param object The display object that is being copied
115  * \param generateNames Whether or not to generate a new instance name
116  */
117  GLS_EXPORT DisplayObject( const DisplayObject& object, const bool generateNames );
118 
119  /** Virtual destructor for display object */
120  virtual GLS_EXPORT ~DisplayObject( void );
121 
122  /** Call this to delete objects, as it handles special cases
123  * like cleanup of LiveComponents.*/
124  GLS_EXPORT void Destroy();
125 
126 #ifndef GLES
127  static GLS_EXPORT InterfaceListType* StaticGetCppInterfaceDescription( InterfaceListType* addToThisList = NULL );
128 #endif
129  /** Sets and retrieves the current setting used for determining what attributes get
130  * created for each object.*/
131  typedef enum
132  {
133  GLS_ATTRIBUTES_BASIC = 1,
134  GLS_ATTRIBUTES_DYNAMIC = 2,
135  GLS_ATTRIBUTES_APPEARANCE = 4,
136  GLS_ATTRIBUTES_GEOMETRY = 8,
137  GLS_ATTRIBUTES_SPECIALIZED = 16,
138  GLS_ATTRIBUTES_ALL = ~0,
139  GLS_ATTRIBUTES_NONE = 0
141 
142  /** Specifies which attributes are available for the object.
143  * Currently the available attributes cannot be changed after they have been set.
144  * (Only the first call has an effect.)
145  * \param value A bitfield specifying which types of attributes to make available.
146  * \sa AvailableAttributesEnum
147  */
148  virtual GLS_EXPORT void SetAvailableAttributes( unsigned int value );
149 
150  /** Set the alpha mode state for this object
151  * \param mode which alpha mode to use when drawing
152  * \sa AlphaMode_e
153  */
154  virtual GLS_EXPORT void AlphaMode( int mode );
155 
156  /** Get the alpha mode for this object
157  * \return Whether or not alpha testing or blending is enabled when drawing
158  * \sa AlphaMode_e
159  */
160  virtual GLS_EXPORT int AlphaMode( void );
161 
162  /** Get the anti aliasing state this object
163  * \return Whether or not this object will be drawn antialiased
164  */
165  virtual GLS_EXPORT bool AntiAlias( void );
166 
167  /** Set the anti aliasing state for this object
168  * \param alias Whether or not to perform anti aliasing
169  */
170  virtual GLS_EXPORT void AntiAlias( bool alias );
171 
172  /** Second half of texture setup. Applies texture modes like modulate, decal, etc.
173  * \param textureIndex Index of the texture to apply
174  */
175  GLS_EXPORT void ApplyTextureSettings( int textureIndex = -1 /* will use _textureIndex by default */ );
176 
177  /** Gets the full list of attributes for this object
178  * \return A reference to the attribute dictionary in this object
179  */
180  inline DistiAttribDict& Attributes() { return *_attribDict; };
181  inline const DistiAttribDict& Attributes() const { return *_attribDict; };
182 
183  /** Sets the texture blend color for the object
184  * \param color A GlsColor
185  */
186  virtual GLS_EXPORT void SetBlendColor( const GlsColor& color );
187 
188  /** Gets the texture blend color for the object
189  * \param color Filled in with RGBA (0-255 range)
190  * NOTE: Not Virtual. Simply calls void GetBlendColor(const GlsColor& color);
191  */
192  GLS_EXPORT void GetBlendColor( unsigned char color[] );
193 
194  /** Gets the texture blend color for the object
195  * \param r Returns red color component (0-255 range)
196  * \param g Returns Green color component (0-255 range)
197  * \param b Returns Blue color component (0-255 range)
198  * \param a Returns Alpha color component (0-255 range)
199  * NOTE: Not Virtual. Simply calls void GetBlendColor(const GlsColor& color);
200  */
201  GLS_EXPORT void GetBlendColor( unsigned char& r, unsigned char& g, unsigned char& b, unsigned char& a );
202 
203  /** Gets the texture blend color for the object
204  * \return Returns the current texture blend color.
205  */
206  virtual GLS_EXPORT GlsColor GetBlendColor();
207 
208  /** Sets the texture blend color for the object
209  * \param color RGBA color (0-255 range)
210  * NOTE: Not Virtual. Simply calls void SetBlendColor(const GlsColor& color);
211  */
212  GLS_EXPORT void SetBlendColor( unsigned char color[] );
213 
214  /** Sets the texture blend color for the object
215  * \param r Red color component (0-255 range)
216  * \param g Green color component (0-255 range)
217  * \param b Blue color component (0-255 range)
218  * \param a Alpha color component (0-255 range)
219  * NOTE: Not Virtual. Simply calls void SetBlendColor(const GlsColor& color);
220  */
221  GLS_EXPORT void SetBlendColor( unsigned char r, unsigned char g, unsigned char b, unsigned char a );
222 
223  /** Determines if the object is blinked on or off */
224  GLS_EXPORT bool BlinkedOff( void );
225 
226  /** Get the blinking state this object
227  * \return Whether or not this object is blinking
228  */
229  virtual GLS_EXPORT bool Blinking( void );
230 
231  /** Set the blinking state for this object
232  * \param blink Whether or not to blink this object
233  */
234  virtual GLS_EXPORT void Blinking( const bool blink );
235 
236  /** Get the blinking rate this object
237  * \return The rate at which this object is blinking
238  */
239  virtual GLS_EXPORT float BlinkRate( void );
240 
241  /** Set the blinking rate for this object
242  * \param rate Number of times per second to blink this object
243  */
244  virtual GLS_EXPORT void BlinkRate( const float rate );
245 
246  /** Sets whether the application should use the system time or a manual time
247  * for calculating the blink state of objects
248  */
249  static GLS_EXPORT void UseManualBlinkElapsedTime( bool useManualTime );
250 
251  /** Sets the time the application will use to determine the blink state of
252  * objects. Has no effect if UseManualBlinkElapsedTime was not set to true.
253  */
254  static GLS_EXPORT void SetManualBlinkElapsedTime( double elapsedTime );
255 
256  /** Get the current bounding volume center
257  * \return The current bounding volume center
258  */
259  inline const Vector& BoundingVolumeCenter() const { return _boundingVolumeCenter; }
260 
261  /** Set the current bounding volume center
262  * \param center The new center
263  */
264  void GLS_EXPORT BoundingVolumeCenter( const Vector& center );
265 
266  /** Determines if the given ray hits this bounding volume
267  * \param start Starting point of the ray
268  * \param direction Direction vector of the ray
269  * \return True if this bounding volume hit by the ray
270  */
271  bool GLS_EXPORT BoundingVolumeHit( const Vector& start, const Vector& direction );
272 
273  /** Get the bounding sphere radius
274  * \return The bounding sphere radius
275  */
276  inline float BoundingVolumeRadius() const { return _boundingVolumeRadius; }
277 
278  /** Set the bounding sphere radius
279  * \param radius The bounding sphere radius
280  */
281  void GLS_EXPORT BoundingVolumeRadius( float radius );
282 
283  /** Provides a mechanism for performing regular calculations, seperate
284  * from drawing. In a standalone applicaton Calculate is recursively
285  * called by the main loop before the objects are drawn.
286  * \param time The elaspsed time in seconds since program start
287  */
288  virtual GLS_EXPORT void Calculate( double time );
289 
290  /** Calculates where the pick vector hit this object
291  * \param pickLoc Start of the pick vector
292  * \param directionVector Direction of the pick vector
293  * \param collisionPoint Returns the collision point
294  */
295  GLS_EXPORT void CalculateCollisionPoint( const Vector& pickLoc, const Vector& directionVector, Vector* collisionPoint );
296 
297  /** Calculates the bounding box of the parent group object.
298  */
299  virtual GLS_EXPORT void CalculateParentBoundingBox( void );
300 
301  /** Recalculates the texture coordinates for the object based on the TexturePoints.
302  */
303  virtual GLS_EXPORT void CalculateTextureCoordinates( void );
304 
305  /** Converts the object's texture points into a transformation matrix
306  * for use in calculating the object's texture coordinates
307  */
308  GLS_EXPORT bool GetTexturePointTransformationMatrix( GlsMatrixType& world2tex );
309 
310  /** \return The current callback method for this object */
311  inline CallbackMethodCallerBase* CallbackCaller() const { return _callbackCaller; }
312 
313  /** Sets the callback method for this object. cb MUST be dynamically allocated since
314  * memory management will be passed to this display object. cb will be deleted when
315  * a new callback is registered via this method or when the display object is
316  * destructed.
317  * \param cb The new callback method for this object
318  */
319  GLS_EXPORT void CallbackCaller( CallbackMethodCallerBase* cb );
320 
321  /** Gets the location of the center of the object in logical units. Value is based on the
322  * extents of the object and does not take into consideration dynamic rotation
323  * \param center Will contain the center coordinate on return
324  */
325  virtual GLS_EXPORT void GetCenter( Vector& center );
326 
327  /** Copy+Create operation in one method. In derived classes, this
328  * method will create a new instance of the derived class and then
329  * copy the object into the new instance. The cut,copy,paste and undo
330  * operations use this method.
331  * \param generateNames Whether or not to generate new names for cloned objects
332  * \return A new object, identical to the original, except for the instance name
333  */
334  virtual DisplayObject* CloneObject( bool generateNames = false ) = 0;
335 
336  /** Gets the color for the object outline
337  * \return The outline color
338  */
339  virtual GLS_EXPORT GlsColor GetColor();
340 
341  /** Gets the RGBA color for the object outline
342  * \param c4 Gets the RGBA line color (0-255 range) for the object
343  * NOTE: Not Virtual. Simply calls void GetColor(const GlsColor& color)
344  */
345  GLS_EXPORT void GetColor( unsigned char c4[] );
346 
347  /** Gets the RGBA color for the object outline
348  * \param r Gets the red component (0-255 range) of the line color for the object
349  * \param g Gets the blue component (0-255 range) of the line color for the object
350  * \param b Gets the green component (0-255 range) of the line color for the object
351  * \param a Gets the alpha component (0-255 range) of the line color for the object
352  * NOTE: Not Virtual. Simply calls void GetColor(const GlsColor& color)
353  */
354  GLS_EXPORT void GetColor( unsigned char& r, unsigned char& g, unsigned char& b, unsigned char& a );
355 
356  /** Sets the RGBA color for the object outline
357  * \param color The new color
358  */
359  virtual GLS_EXPORT void SetColor( const GlsColor& color );
360 
361  /** Sets the RGBA color for the object outline
362  * \param c4 The new RGBA (0-255 range) line color for the object
363  * NOTE: Not Virtual. Simply calls void SetColor(const GlsColor& color)
364  */
365  inline void SetColor( unsigned char c4[] ) { SetColor( GlsColor( c4 ) ); }
366 
367  /** Sets the RGBA color for the object outline
368  * \param r The new red component (0-255 range) of the line color for the object
369  * \param g The new blue component (0-255 range) of the line color for the object
370  * \param b The new green component (0-255 range) of the line color for the object
371  * \param a The new alpha component (0-255 range) of the line color for the object
372  * NOTE: Not Virtual. Simply calls void SetColor(const GlsColor& color)
373  */
374  inline void SetColor( unsigned char r, unsigned char g, unsigned char b, unsigned char a ) { SetColor( GlsColor( r, g, b, a ) ); }
375 
376  /** Copies the geometry information from one object to another. Used by
377  * the undo mechanism to allow user to undo a geometry change.
378  * \param src The object to copy geometry from */
379  virtual GLS_EXPORT void CopyGeometry( DisplayObject* src );
380 
381  /** Copies the hierarchy information from one object to another
382  * \param src The object to copy from
383  * \param copyName Whether or not to copy the object name
384  */
385  virtual GLS_EXPORT void CopyHierarchyProperties( DisplayObject* src, bool copyName );
386 
387  /** Copies the attributes except for geometry attributes from one object
388  * to another. Used by the undo mechanism to undo most attribute change
389  * operations.
390  * \param src The object to copy properties from */
391  virtual GLS_EXPORT void CopyProperties( DisplayObject* src );
392 
393 #ifndef GLES
394  /** Get the details of the Cpp Interface
395  * The actual interface is exposed in compiled code.
396  * \param addToThisList If not NULL this list will be added to then returned. If NULL a new list will be created.
397  * \return A templated list.
398  * The caller must call the corresponding free method to
399  * safely free the memory.
400  */
401  virtual GLS_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL );
402 
403  /** Frees the memory allocated by a previous call to GetCppInterfaceDescription
404  * \param array Memory allocated by a previous call to GetCppInterfaceDescription
405  */
406  virtual GLS_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array );
407 #endif
408 
409  /** Sets if back faces should be removed
410  * \param val True if back faces should be removed
411  */
412  virtual GLS_EXPORT void CullBackFace( const bool val );
413 
414  /** Returns if back faces should be removed
415  * \return True if backfaces are removed
416  */
417  virtual GLS_EXPORT bool CullBackFace( void );
418 
419  /** Whether or not this object is currently culled */
420  inline bool Culled() const { return _culled; }
421  inline void Culled( bool val ) { _culled = val; }
422 
423  /** This is the cull test normally performed within PreDraw()
424  * \param matrix transformation from vertices to the frustrums coordinate system
425  * \param culler Culler to perform the test
426  */
427  inline bool CullTest( const GlsMatrixType* matrix, const Culler& culler )
428  {
429  // Make some vectors representing a unit sphere
430  Vector loc( _boundingVolumeCenter + _location );
431  Vector i( loc );
432  Vector j( loc );
433  Vector k( loc );
434 
435  i.x += 1.0f;
436  j.y += 1.0f;
437  k.z += 1.0f;
438 
439  // Transform into the frustrums coordinate system
440  matrix->Transform( loc );
441  matrix->Transform( i );
442  matrix->Transform( j );
443  matrix->Transform( k );
444 
445  // Subtract the location to get the radius vectors
446  i -= loc;
447  j -= loc;
448  k -= loc;
449 
450  // Find the largest radius of the transformed sphere
451 #ifdef SUNOS
452  float maxRadius = sqrt( MAX( i.MagnitudeSquared(), MAX( j.MagnitudeSquared(), k.MagnitudeSquared() ) ) );
453 #else
454  float maxRadius = sqrtf( MAX( i.MagnitudeSquared(), MAX( j.MagnitudeSquared(), k.MagnitudeSquared() ) ) );
455 #endif
456  return culler.SphereOutsideFrustum( loc, maxRadius * _boundingVolumeRadius );
457  }
458 
459  /** Gets the objects Dynamic Coordinate System (DCS) Matrix
460  * \return A reference to the Dcs Matrix stored in the object
461  */
462  GlsMatrixType& DcsMatrix() { return _dcsMatrix; } // deprecated
463  GlsMatrixType DcsMatrix() const { return _dcsMatrix; }
464 
465  /** Sets the dcs matrix
466  * \param matrix the dcs matrix
467  */
468  void GLS_EXPORT DcsMatrix( const GlsMatrixType& matrix );
469 
470  /** Remove the Vertex at \a index. */
471  virtual GLS_EXPORT void DeleteVertexAt( unsigned int index );
472 
473  /** Remove the Vertex at (indexAfter - 1).
474  * \param indexAfter One past the index to delete. If it is beyond the number of vertices or
475  * is 0, the vertices will be unchanged.
476  * \deprecated User code should use DeleteVertexAt() instead.
477  * \note This virtual function is kept for backwards compatibility only. It is marked 'final'
478  * (where supported). Subclasses should override DeleteVertexAt() instead.
479  */
480  DISTI_DEPRECATED( "User code should use DeleteVertexAt()." )
481  virtual GLS_EXPORT void DeleteVertex( unsigned int indexAfter ) DISTI_FINAL
482  {
483  if( indexAfter > 0 )
484  {
485  DeleteVertexAt( indexAfter - 1 );
486  }
487  }
488 
489  /** Get the z buffering state for this object
490  * \return Whether or not this object will be draw Z buffered
491  */
492  virtual GLS_EXPORT int DepthTest( void );
493 
494  /** Set the z buffering state for this object
495  * \param zbuf Whether or not to perform z buffering
496  */
497  virtual GLS_EXPORT void DepthTest( unsigned char zbuf );
498 
499  /** Draws this object on the current display frame (_parent member).
500  Pure virtual method */
501  virtual void Draw( void ) = 0;
502 
503  /** \returns This object's _drawMatrix (it's contribution to the ModelMatrix)
504  * or NULL if the object does not have a _drawMatrix.
505  */
506  inline const GlsMatrixType* DrawMatrix() { return _drawMatrix; }
507 
508  /** \returns True if the draw matrix needs to be calculated
509  */
510  inline bool NeedCalcDrawMatrix() { return _needCalcDrawMatrix; }
511 
512  /** Sets the dynamic rotation to the specified value for the specified axis (in degrees)
513  * \param angle The new dynamic rotation angle for the object
514  * \param axis The axis to change
515  * NOTE: Not virtual
516  */
517  GLS_EXPORT void DynamicRotate( float angle, int axis );
518 
519  /** Sets the dynamic rotation to the specified value for all axes (in degrees)
520  * \param v Vector containing the new dynamic rotation angles for each axis
521  */
522  GLS_EXPORT void DynamicRotate( const Vector& v );
523 
524  /** Sets the dynamic rotation to the specified value for all axes (in degrees)
525  * \param angle Array of three floats containing the new dynamic rotation angles for each axis
526  */
527  GLS_EXPORT void DynamicRotate( float angle[] );
528 
529  /** Sets the dynamic rotation to the specified value for all axes (in degrees)
530  * \param x The new dynamic rotation angle for the X axis
531  * \param y The new dynamic rotation angle for the Y axis
532  * \param z The new dynamic rotation angle for the Z axis
533  * NOTE: Is virtual. If needed overload this method.
534  */
535  virtual GLS_EXPORT void DynamicRotate( float x, float y, float z );
536 
537  /** Changes the dynamic rotation by the specified value for the specified axis (in degrees)
538  * \param angle The change in dynamic rotation angle for the object
539  * \param axis The axis to change
540  */
541  virtual GLS_EXPORT void DynamicRotateRelative( float angle, int axis );
542 
543  /** Gets the dynamic rotation to the specified value for
544  * the specified axis.
545  * \param axis The axis to get the rotation from
546  * \return The dynamic rotation angle for the axis (in degrees)
547  */
548  virtual GLS_EXPORT float DynamicRotation( int axis );
549  virtual GLS_EXPORT Vector DynamicRotation();
550 
551  /** Returns the dynamic scale values in a Vertex
552  * \return The dynamic scale values
553  * NOTE: Not virtual
554  */
555  virtual GLS_EXPORT Vector DynamicScale();
556 
557  /** Sets the dynamic scale values for an object.
558  * \param x X scale
559  * \param y Y scale
560  * \param z Z scale
561  */
562  virtual GLS_EXPORT void DynamicScale( float x, float y, float z );
563 
564  /** Sets the dynamic scale values for an object.
565  * \param scale The new dynamic scale for the object
566  */
567  GLS_EXPORT void DynamicScale( const Vector& scale );
568 
569  /** Sets the dynamic translation to the specified value for all axes (in logical units)
570  * \note Make sure to pass float values for x,y,z here,
571  or the compiler may choose an unexpected method signature.
572  * \sa DynamicTranslate(float, int, bool)
573  * \param x The new dynamic translation for the X axis
574  * \param y The new dynamic translation for the Y axis
575  * \param z The new dynamic translation for the Z axis
576  * \param relative If true will add to existing dynamic translation
577  */
578  virtual GLS_EXPORT void DynamicTranslate( float x, float y, float z, bool relative = false );
579 
580  /** Sets the dynamic translation to the specified value for all axes (in logical units)
581  * \param amount The new dynamic translation for the X, Y, and Z axes
582  * \param relative If true will add to existing dynamic translation
583  * NOTE: Not virtual
584  */
585  GLS_EXPORT void DynamicTranslate( const Vertex& amount, bool relative );
586 
587  /** Sets the dynamic translation to the specified value for all axes (in logical units). Equivalent to DynamicTranslate( amount, false );
588  * \param amount The new dynamic translation for the X, Y, and Z axes
589  * NOTE: Not virtual
590  */
591  GLS_EXPORT void DynamicTranslate( const Vector& amount );
592 
593  /** Sets the dynamic translation to the specified value for the specified axis
594  * \param amount The new dynamic translation for the axis
595  * \param axis Z_AXIS, Y_AXIS, or X_AXIS
596  * \param relative If true will add to existing dynamic translation
597  */
598 #ifdef GLES
599  virtual GLS_EXPORT void DynamicTranslateAxis( float amount, int axis, bool relative );
600 #else
601  virtual GLS_EXPORT void DynamicTranslate( float amount, int axis, bool relative = false );
602 #endif
603  /** Returns the current dynamic translation for the specified axis
604  * \param axis Z_AXIS, Y_AXIS, or X_AXIS
605  * \returns the translation
606  */
607  virtual GLS_EXPORT float DynamicTranslation( int axis );
608 
609  /** Returns the current dynamic translation for all axes
610  * \returns the translation
611  */
612  virtual GLS_EXPORT Vector DynamicTranslation();
613 
614  /** Used in the editor to access editor functionality. Gets the editor object pointer.
615  * USER CODE SHOULD NOT USE THIS METHOD!
616  * \return Pointer to editor object.
617  */
618  GLS_EXPORT DisplayObjectEditor* Editor();
619 
620  /** Used in the editor to access editor functionality. Gets the editor object pointer.
621  * USER CODE SHOULD NOT USE THIS METHOD!
622  * \return Pointer to editor object.
623  */
624  GLS_EXPORT const DisplayObjectEditor* Editor() const;
625 
626  /** Used in the editor to access editor functionality. Sets the editor object pointer.
627  * USER CODE SHOULD NOT USE THIS METHOD!
628  * \param editor Pointer to editor object.
629  */
630  GLS_EXPORT void Editor( DisplayObjectEditor* editor );
631 
632  /** Figure out the static extents for the object.
633  * Used by the editor as part of the pick operation and
634  * for figuring out the size of groups.
635  * \param x Gets the minimum x extent
636  * \param y Gets the minimum y extent
637  * \param z Gets the minimum z extent
638  * \param x1 Gets the maximum x extent
639  * \param y1 Gets the maximum y extent
640  * \param z1 Gets the maximum z extent
641  */
642  virtual GLS_EXPORT void GetExtents( float& x, float& y, float& z, float& x1, float& y1, float& z1 );
643 
644  /** Determines the static extents of geometry projected to the XY plane of the object's DCS.
645  * \param min Returns the minimum values found in the traversal
646  * \param max Returns the maximum values found in the traversal
647  */
648  GLS_EXPORT void GetExtentsDCS( Vector& min, Vector& max );
649 
650  /** Gets the RGBA color for filling the object
651  * \param r Gets the red component (0-255 range) of the fill color for the object
652  * \param g Gets the blue component (0-255 range) of the fill color for the object
653  * \param b Gets the green component (0-255 range) of the fill color for the object
654  * \param a Gets the alpha component (0-255 range) of the fill color for the object
655  * NOTE: NOT Virtual Simply calls GlsColor GetFillColor()
656  */
657  GLS_EXPORT void GetFillColor( unsigned char& r, unsigned char& g,
658  unsigned char& b, unsigned char& a );
659 
660  /** Gets the RGBA color for filling the object
661  * \param c4 Gets the RGBA fill color (0-255 range) for the object
662  * NOTE: NOT Virtual. Simply calls GlsColor GetFillColor()
663  */
664  GLS_EXPORT void GetFillColor( unsigned char c4[] );
665 
666  /** Gets the fill color of the object
667  * \return The fill color
668  */
669  virtual GLS_EXPORT GlsColor GetFillColor( void );
670 
671  /** Sets the RGBA color for filling the object
672  * \param r The new red component (0-255 range) of the fill color for the object
673  * \param g The new blue component (0-255 range) of the fill color for the object
674  * \param b The new green component (0-255 range) of the fill color for the object
675  * \param a The new alpha component (0-255 range) of the fill color for the object
676  * NOTE: Not Virtual. Simply calls void SetFillColor(const GlsColor& color)
677  */
678  inline void SetFillColor( unsigned char r, unsigned char g, unsigned char b, unsigned char a ) { SetFillColor( GlsColor( r, g, b, a ) ); }
679 
680  /** Sets the RGBA color for filling the object
681  * \param c4 The new RGBA fill color (0-255 range) for the object
682  * NOTE: Not Virtual. Simply calls void SetFillColor(const GlsColor& color)
683  */
684  inline void SetFillColor( unsigned char c4[] ) { SetFillColor( GlsColor( c4 ) ); }
685 
686  /** Sets the RGBA color for filling the object
687  * \param color The new RGBA fill color (0-255 range) for the object
688  */
689  virtual GLS_EXPORT void SetFillColor( const GlsColor& color );
690 
691  /// Allows the object the opportunity to configure itself after having all its children initialized and properties set by the
692  /// code generator. By default, users do not need to call this function, it is called by the generated code in CreateObjects()
693  /// if the object is a user defined class. User defined classes can override this, calling BaseClass::FinishObject(),
694  /// before supplying class specific initialization code as needed.
695  /// User code should only conisder itself and its children as the hierarchy above will not have been set up yet.
696  /// User code should not call FinishObject on its children, since it will have already been called when those children were created.
697  /// This method will be called by generated code once this object and its children have been fully instantiated.
698  virtual GLS_EXPORT void FinishObject(){};
699 
700  /** Dynamically generate a name for the object, based on the current time
701  */
702  virtual GLS_EXPORT void GenerateInstanceName( void );
703 
704  /** Handles an event that is sent to the object.
705  * \param ev The event to send to the object
706  * \returns Which object handled the event
707  */
708  virtual GLS_EXPORT DisplayObject* handle( DisplayEvent* ev );
709 
710  /** Determines if the object is hit by a pick ray starting at (x,y,z) and pointing towards directionVector in object logical coordinate system.
711  * If Pickable() == PICK_BEST it will return the closest point that was hit, otherwise it returns the first point that was hit.
712  * This method should not pick points behind the viewer.
713  *
714  * \param x X coordinate of pick ray start in logical coordinates.
715  * \param y Y coordinate of pick ray start in logical coordinates.
716  * \param y Y coordinate of pick ray start in logical coordinates.
717  * \param z Z coordinate of pick ray start in logical coordinates.
718  * \param scale The scale factor of the window. Affects picking of outlines. Standard value is 1.0.
719  * \param directionVector The direction of the pick ray.
720  * \param collisionPoint If this method returns true, this Vector will contain the location that was hit in logical coordinates.
721  * \return boolean indicating if the object was hit by the pick ray.
722  */
723  virtual GLS_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint );
724 
725  /** Determines if the object is hit by a pick ray starting at (x,y,z) and pointing towards directionVector in the object logical coordinate system
726  * If Pickable() == PICK_BEST it will return the closest point that was hit, otherwise it returns the first point that was hit.
727  * This method should not pick points behind the viewer.
728  *
729  * \param x X coordinate of pick ray start in logical coordinates.
730  * \param y Y coordinate of pick ray start in logical coordinates.
731  * \param y Y coordinate of pick ray start in logical coordinates.
732  * \param z Z coordinate of pick ray start in logical coordinates.
733  * \param scale The scale factor of the window. Affects picking of outlines. Standard value is 1.0.
734  * \param vertices An array of vertices describing the Object.
735  * \param vertex_cnt Size of the vertices array.
736  * \param directionVector The direction of the pick vector.
737  * \param collisionPoint If this method returns true, this Vector will contain the location that was hit in logical coordinates.
738  * \return True if click is inside, false otherwise.
739  *
740  * Comment: The hit determination algorithm is based on the principle
741  * that a point is inside a polygon if a line drawn through the
742  * point intersects an even number of edges.
743  */
744  virtual GLS_EXPORT bool HitUtil( float x, float y, float z, float scale, Vertex* vertices, unsigned int vertex_cnt, const Vector& directionVector, Vector* collisionPoint );
745 
746  /** Insert a vertex at \a index. Duplicate the vertex pointed to
747  * by \a index, so that there are two vertices that are exactly the same.
748  * If \a index is greater than the number of vertices, then the last vertex is duplicated.
749  */
750  virtual GLS_EXPORT void InsertVertexAt( unsigned int index );
751 
752  /** Insert a new vertex into the vertex array, duplicating the vertex at (indexAfter - 1).
753  * \param indexAfter One past the index to insert. The vertex before this (or the last vertex,
754  * if more than the number of vertices) will be duplicated. If 0, the 0th vertex
755  * will be duplicated.
756  * \deprecated New code should use InsertVertexAt().
757  * \note This virtual function is kept for backwards compatibility only. It is marked 'final'
758  * (where supported). Subclasses should override InsertVertexAt() instead.
759  */
760  DISTI_DEPRECATED( "User code should use InsertVertexAt()." )
761  virtual GLS_EXPORT void InsertVertex( unsigned int indexAfter ) DISTI_FINAL
762  {
763  InsertVertexAt( indexAfter > 0 ? indexAfter - 1 : 0 );
764  }
765 
766  /** Gets the name for the object.
767  * \return The name of the object
768  */
769  GLS_EXPORT char* InstanceName( void );
770  GLS_EXPORT const char* InstanceName( void ) const;
771 
772  /** Sets the name for the object. This name corresponds to the name
773  * that is generated in the source code.
774  * \param name The new name for the object
775  */
776  GLS_EXPORT void InstanceName( const char* name );
777 
778  /** Gets the lighting state */
779  virtual GLS_EXPORT bool LightingEnabled();
780 
781  /** Sets the lighting state */
782  virtual GLS_EXPORT void LightingEnabled( bool lighting );
783 
784  /** Get the line stipple multiplier for this object
785  * \return The line stipple multiplier for this object
786  */
787  virtual GLS_EXPORT int LineStippleMultiplier( void );
788 
789  /** Set the line stipple multiplier for this object
790  * \param mult The new line stipple pattern
791  */
792  virtual GLS_EXPORT void LineStippleMultiplier( int mult );
793 
794  /** Get the line stipple pattern for this object
795  * \return The line stipple pattern for this object
796  */
797  virtual GLS_EXPORT int LineStipplePattern( void );
798 
799  /** Set the line stipple pattern for this object
800  * \param pattern The new line stipple pattern
801  */
802  virtual GLS_EXPORT void LineStipplePattern( int pattern );
803 
804  /** Gets the width of lines in the object.
805  * \return The line width of the object in logical units
806  */
807  virtual GLS_EXPORT float LineWidth( void );
808 
809  /** Sets the width of lines in the object.
810  * \param width The new line width of the object in logical units
811  */
812  virtual GLS_EXPORT void LineWidth( float width );
813 
814  /** \return The location of the origin of the object
815  * Lifetime is guaranteed to coincide with the DisplayObject's lifetime.
816  */
817  virtual GLS_EXPORT const Vertex& Location( void ) const;
818 
819  /** Sets the location of the origin of the object
820  * \param v The new location
821  */
822  virtual GLS_EXPORT void Location( const Vertex& v );
823 
824  /** Sets the location of the origin of the object
825  * \param x X Coordinate of the new location
826  * \param y Y Coordinate of the new location
827  * \param z Z Coordinate of the new location
828  */
829  virtual GLS_EXPORT void Location( float x, float y, float z );
830 
831  /** Gets the location of the origin of the object
832  * \param v Will be filled in with the current location
833  */
834  virtual GLS_EXPORT void GetLocation( Vertex& v );
835 
836  /** Gets the location of the origin of the object
837  * \param x Will be filled in with the x coordinate
838  * \param y Will be filled in with the y coordinate
839  * \param z Will be filled in with the z coordinate
840  */
841  virtual GLS_EXPORT void GetLocation( float& x, float& y, float& z );
842 
843  /** \return X component of location */
844  inline float X( void ) const { return Location().x; }
845 
846  /** \return Y component of location */
847  inline float Y( void ) const { return Location().y; }
848 
849  /** \return Z component of location */
850  inline float Z( void ) const { return Location().z; }
851 
852  /** Sets x component of location */
853  inline void X( const float x ) { Location( x, Y(), Z() ); }
854 
855  /** Sets y component of location */
856  inline void Y( const float y ) { Location( X(), y, Z() ); }
857 
858  /** Sets z component of location */
859  inline void Z( const float z ) { Location( X(), Y(), z ); }
860 
861  /** Gets material index. Returns -1 if multiple are applied. */
862  virtual GLS_EXPORT int MaterialIndex();
863 
864  /** Sets the material index. */
865  virtual GLS_EXPORT void MaterialIndex( int index );
866 
867  /** Gets a vector of material indices. */
868  virtual GLS_EXPORT DynamicArray<int>& MaterialIndices();
869 
870  /** Sets the vector of material indices. */
871  virtual GLS_EXPORT void MaterialIndices( DynamicArray<int> indices );
872 
873  /** \return The saved Model matrix, if any. Normally not used by the user.*/
874  GLS_EXPORT GlsMatrixType* ModelMatrix();
875 
876  /** \return true if Calculate() needs to be called on this object */
877  inline bool NeedCalculate() { return _needCalculate; }
878 
879  /** Gets the object's normals.
880  * \return Pointer to the object's normal vertex array
881  */
882  inline Vector* Normals() { return ( _normals ); }
883 
884  /** Sets the vertex normal data for this object
885  * \param nPoints The number of vertices in the object
886  * \param vertices The vertex normals for the object
887  */
888  virtual GLS_EXPORT void SetNormals( unsigned int nPoints, Vector* vertices );
889 
890  /** Sets the vertex normal data for this object
891  * \param nPoints The number of vertices in the object
892  * \param ... X,Y,Z for each vertex normal
893  */
894  GLS_EXPORT void VaSetNormals( unsigned int nPoints, ... );
895 
896  /** Gets the object's number of vertices.
897  * \return The integer number of vertices in the object
898  */
899  inline unsigned int NumberOfVertices() const { return ( _nVertices ); }
900 
901  /** Get the depth (in the Z Dimension) of the object in logical units. Value is based on the
902  * extents of the object and does not take into consideration dynamic rotation
903  * \return The depth in logical units (based on extents in the Z Dimension)
904  */
905  virtual GLS_EXPORT float ObjectDepth( void );
906 
907  /** Get the height (in the Y Dimension) of the object in logical units. Value is based on the
908  * extents of the object and does not take into consideration dynamic rotation
909  * \return The height in logical units (based on extents in the Y Dimension)
910  */
911  virtual GLS_EXPORT float ObjectHeight( void );
912 
913  /** Get the width (in the X Dimension) of the object in logical units. Value is based on the
914  * extents of the object and does not take into consideration dynamic rotation
915  * \return The width in logical units (based on extents in the X Dimension)
916  */
917  virtual GLS_EXPORT float ObjectWidth( void );
918 
919  /** Redefines the frame of reference for the object. Since the vertices in the object are
920  * specified relative to the _location member, this routine allows you to specify the
921  * absolute coordinate for _location and then recalculates the vertices to be relative to that
922  * new location
923  * \param vert The new origin point for the object
924  */
925  virtual GLS_EXPORT void SetOrigin( const Vertex& vert );
926 
927  /** Sets the parent display frame pointer for this object to the indicated display frame
928  * \param par The new display frame to be the parent object
929  */
930  virtual GLS_EXPORT void Parent( DisplayFrame* par );
931 
932  /** Gets the parent display frame pointer for this object
933  * \return The parent display frame of this object
934  */
935  inline DisplayFrame* Parent( void ) const { return _parent; }
936 
937  /** Sets the parentGroup pointer for this object
938  * \param group The group to which this object belongs
939  */
940  virtual GLS_EXPORT void ParentGroup( Group* group );
941 
942  /** Gets the parentGroup pointer for this object
943  * \return The group to which this object belongs
944  */
945  inline Group* ParentGroup( void ) const { return _parentGroup; }
946 
947  /** Attempts to pick an object in 3D and accounting for dynamic rotations and translations of this object or
948  * parent objects. It also looks at the pickable status and attempts to return the "Best" pick if that is
949  * what is desired.
950  *
951  * Note: This method will pick objects in the scene based on a pick ray starting at winLoc and pointing into the screen.
952  * It will not pick objects behind the depth specified by winLoc.z. Typically winLoc.z should be set to 0 to ensure that
953  * the pick ray starts at near clip plane.
954  *
955  * \param winLoc Device coordinates for the mouse click. Z value should be set to 0 to ensure pick ray starts at near clip plane.
956  * \param logicalCoords The start of the pick ray in logical coordinates. Should be calculated from the winLoc using this->WindowToLogical(winLoc, logicalCoords, &directionVector).
957  * \param scale Current window scale. Affects picking radius of outlines. Initial value should typically be 1.0.
958  * \param directionVector The direction of the pick ray in logical coordinates. Should be calculated from the winLoc using this->WindowToLogical(winLoc, logicalCoords, &directionVector).
959  * \param collisionWinLoc Returns where the pick vector intersects the object that is hit in device coordinates.
960  * \param drawnMatrices The matrices used to draw the object, including matrices set by parents that may have
961  * dynamically rotated, translated or scaled this object. Initial value should typically be a default OpenGLMatrices() object.
962  *
963  * \return The object that was hit, or NULL if no object hit
964  */
965  virtual GLS_EXPORT DisplayObject* Pick3D( const Vector& winLoc,
966  const Vector& logicalCoords,
967  float scale,
968  const Vector& directionVector,
969  Vector& collisionWinLoc, /*Returned*/
970  const OpenGLMatrices& drawnMatrices );
971 
972  /** Get the pickable state for this object
973  * \return The pick mode
974  * \sa PickableType_e
975  */
976  inline unsigned char Pickable() { return _pickable; }
977 
978  /** Set the pickable state for this object
979  * \param pick The pick mode
980  * \sa PickableType_e
981  */
982  virtual GLS_EXPORT void Pickable( unsigned char pick );
983 
984  /* Gets the polygon offset (Z buffer offset) for this object
985  * \return mode The new polygon offset for this object
986  * Currently unused.
987  */
988  virtual GLS_EXPORT int PolygonOffset( void ) const;
989 
990  /* Sets the polygon offset (Z buffer offset) for this object
991  * \param mode The new polygon offset for this object
992  * Currently unused.
993  */
994  virtual GLS_EXPORT void PolygonOffset( const int offset );
995 
996  /** Gets the polygon end mode (Open or Closed) for the polygon
997  * \return Enumeration indicating open or closed mode
998  * \sa PolygonClose_e
999  */
1000  virtual GLS_EXPORT int PolygonEnd( void );
1001 
1002  /** Sets the polygon end mode (Open or Closed) for the polygon
1003  * \param end Enumeration indicating open or closed mode
1004  * \sa PolygonClose_e
1005  */
1006  virtual GLS_EXPORT void PolygonEnd( const int end );
1007 
1008  /** Gets the polygon drawing mode for this object
1009  * \return The polygon drawing mode for this object
1010  * \sa PolygonMode_e
1011  */
1012  virtual GLS_EXPORT int PolygonMode( void );
1013 
1014  /** Sets the polygon drawing mode for this object
1015  * \param mode The new polygon drawing mode for this object
1016  * \sa PolygonMode_e
1017  */
1018  virtual GLS_EXPORT void PolygonMode( int mode );
1019 
1020  /** Traverses the hierarchy calculating the
1021  * _modelMatrix, _projMatrix, _viewMatrix as needed.
1022  * \param current Current matrices inherited from parent
1023  * \param culler Object that possibly marks this object for culling
1024  */
1025  virtual GLS_EXPORT void PreDraw( const OpenGLMatrices& current, Culler& culler );
1026 
1027  /** \return The saved Projection matrix, if any. Normally not used by the user.
1028  */
1029  GLS_EXPORT GlsMatrixType* ProjMatrix();
1030 
1031  /** Reallocates the vertex and texture coordinate and normal arrays. Existing vertices are
1032  * copied . If the new size is less than the old size, the first numVertices vertices are
1033  * copied. If the new size is larger, all vertices are copied and the new vertices are
1034  * initialized to zero.
1035  * \param numVertices The new number of vertices for the object
1036  * \param initializeNew Whether or not to initialize the new vertices
1037  * \param copyOld Whether or not to copy the old data
1038  */
1039  virtual GLS_EXPORT void ReallocateVertices( unsigned int numVertices, bool initializeNew, bool copyOld );
1040 
1041  /** Return the relative angle of an line constructed from the given point
1042  * to the _location of the object, (in the xy plane)
1043  * \param x X coordinate of endpoint
1044  * \param y Y coordinate of endpoint
1045  * \return Relative angle in degrees
1046  */
1047  virtual GLS_EXPORT float RelativeAngle( const float x, const float y );
1048 
1049  /** Gets a reference to the specified attribute for reading and writing.
1050  * This reference can be streamed into and out of variables.
1051  * For Example: someObject->Resource("Visible") >> someBool;
1052  * someBool << someObject->Resource("Visible");
1053  */
1054  virtual GLS_EXPORT DistiAttributeBase& Resource( const char* name );
1055 
1056  /** Writes the resources (attributes) of this object to the specified stream.
1057  * The output of this method can be controlled by the GlsResourceFilter.
1058  * Note that if filter->NamesOnly() is false (the default), then only resources
1059  * that can return a value will appear in the list.
1060  *
1061  * \sa GlsResourceFilter
1062  * \sa DistiAttributeProperty
1063  * \param outstr The stream to write to
1064  * \param filter The filter to determine what to write
1065  */
1066  virtual GLS_EXPORT void GetResources( std::ostream& outstr, GlsResourceFilter* filter = NULL );
1067 
1068 #ifndef GLES
1069  /** Restores the alpha test/blend settings if they were changed from default
1070  * \sa SetupAlpha
1071  */
1072  GLS_EXPORT void RestoreAlpha( void );
1073 
1074  /** Restores the antialias settings if they were changed from default
1075  * \sa SetupAntiAlias
1076  */
1077  GLS_EXPORT void RestoreAntiAlias( void );
1078 
1079  /** Restores the lighting state
1080  * \sa SetupLighting
1081  */
1082  GLS_EXPORT void RestoreLighting( void );
1083 
1084  /** Sets the line style settings to their defaults
1085  * \sa SetupLineStyle
1086  */
1087  GLS_EXPORT void RestoreLineStyle( void );
1088 #endif
1089 
1090  /** \return The rotation point for the object.
1091  * Lifetime is guaranteed to coincide with the DisplayObject's lifetime.
1092  */
1093  const Vertex& RotationPoint() const { return _rotationPoint; }
1094 
1095  /** Sets the location of the rotation point for the object. Dynamic
1096  * rotation of the object will cause the object to be rotated around this
1097  * point.
1098  * \param v The new rotation point
1099  */
1100  virtual GLS_EXPORT void RotationPoint( const Vertex& v );
1101 
1102  /** Sets the location of the rotation point for the object. Dynamic
1103  * rotation of the object will cause the object to be rotated around this
1104  * point.
1105  * \param x X Coordinate of the new rotation point
1106  * \param y Y Coordinate of the new rotation point
1107  * \param z Z Coordinate of the new rotation point
1108  */
1109  virtual GLS_EXPORT void RotationPoint( float x, float y, float z );
1110 
1111  /** Gets the location of the rotation point for the object.
1112  * \param v Will be filled in with the current rotation point
1113  */
1114  virtual GLS_EXPORT void GetRotationPoint( Vertex& v );
1115 
1116  /** Rotates the object (around the specified axis) by the angle
1117  * indicated, at the object's rotation point. Recalculates the
1118  * vertex data.
1119  * \param angle The angle to rotate by, in degrees
1120  * \param axis The axis to rotate the object around.
1121  */
1122  virtual GLS_EXPORT void Rotate( float angle, int axis = Z_AXIS );
1123 
1124  /** Rotates the object (around the specified axis) by the angle indicated,
1125  * at the point specified. Recalculates the vertex data.
1126  * \param origin The point to rotate around
1127  * \param angle The angle to rotate by, in degrees
1128  * \param axis The axis to rotate the object around
1129  */
1130  virtual GLS_EXPORT void Rotate( const Vector& origin, float angle, int axis = Z_AXIS );
1131 
1132  /** Rotates the object (around the specified axis) by the angle indicated,
1133  * at the point specified. Recalculates the vertex data.
1134  * \param orig The point to rotate around
1135  * \param angle The angle to rotate by, in degrees
1136  * \param axis The arbitrary axis to rotate the object around
1137  */
1138  virtual GLS_EXPORT void Rotate( const Vector& orig, float angle, const Vector& axis );
1139 
1140  /** Causes the Projection, Model and View matrix for this object to be saved. Used by the 3D
1141  * picking algorithm. Normally not used by the user.
1142  */
1143  GLS_EXPORT void SaveMatrices();
1144 
1145  /** Scales the object, either the handleBar, or the Anchor is
1146  * used to translate the object, not both. Anchor takes
1147  * presidence, if it is set HandleBar is ignored.
1148  * The footprint is different from the 2D scale so the compiler can destinguish the two.
1149  * \param px Value of the percentage of scale in x-axis
1150  * \param py Value of the percentage of scale in y-axis
1151  * \param pz Value of the percentage of scale in z-axis
1152  * \param anchor Anchor from which to scale object relative to
1153  * \param handleBar Vertex that is being dragged
1154  */
1155  virtual GLS_EXPORT void Scale( float px, float py, float pz, Vertex* anchor, int handleBar = 0 );
1156 
1157  /** Set attributes of the object using VarArgs style interface
1158  * Object attributes are defined with an enumeration. This
1159  * routine is designed to make generated code very clean and readable.
1160  * \sa GLS_Initializers
1161  */
1162  GLS_EXPORT void Set( int spec, ... );
1163 
1164  /** Sets the alpha test/blend settings based on object settings
1165  * \sa RestoreAlpha
1166  */
1167  GLS_EXPORT bool SetupAlpha( void );
1168 
1169 #ifndef GLES
1170  /** Sets the antialias settings based on object settings
1171  * \sa RestoreAntiAlias
1172  */
1173  GLS_EXPORT bool SetupAntiAlias( void );
1174 #endif
1175 
1176  /** Sets the depth test settings based on object settings */
1177  GLS_EXPORT void SetupDepthTest( void );
1178 
1179  /** Sets the lighting state
1180  * \sa RestoreLighting
1181  */
1182  GLS_EXPORT void SetupLighting( void );
1183 
1184  /** Sets the line style settings based on object settings
1185  * \return True if the line style was set. If this method returns true
1186  * then the object must call RestoreLineStyle to cleanup
1187  * \sa RestoreLineStyle
1188  */
1189  GLS_EXPORT bool SetupLineStyle( void );
1190 
1191 #if !defined( GLES )
1192  /** Sets the polygon draw style based on object settings */
1193  GLS_EXPORT void SetupPolyDrawStyle( void );
1194 
1195  /** Sets the shading settings based on object settings */
1196  GLS_EXPORT void SetupShading( void );
1197 #endif
1198 
1199  /** First half of texture setup for the object.
1200  * \return True if the object will be textured False otherwise.
1201  * If this method returns true, then the caller needs to do
1202  * a glDisable(GL_TEXTURE_2D) afterwards to cleanup
1203  */
1204  GLS_EXPORT bool SetupTexture( void );
1205 
1206  /** Gets the polygon shading mode (Flat or gouraud) for the polygon
1207  * \return Enumeration indicating shading mode
1208  * \sa ShadingType_e
1209  */
1210  virtual GLS_EXPORT int Shading( void );
1211 
1212  /** Sets the polygon shading mode (Flat or gouraud) for the polygon
1213  * \param shading Enumeration indicating shading mode
1214  * \sa ShadingType_e
1215  */
1216  virtual GLS_EXPORT void Shading( const int shading );
1217 
1218  /** Determines the static extents of the geometry projected to the XY plane of an arbirary coordinate system.
1219  * \param min Returns the minimum values found in the traversal
1220  * \param max Returns the maximum values found in the traversal
1221  * \param matrix Transformation matrix from logical coordinates to the coordinate system to determine the extents in.
1222  * \param resetMinMax Normally not specified by user. Should be true for the initial call.
1223  */
1224  virtual GLS_EXPORT void GetTransformedExtents( Vector& min, Vector& max, const GlsMatrixType& matrix, bool resetMinMax = true );
1225 
1226  /** Sets the texture coordinate data for this object
1227  * \param nPoints The number of texture vertices in the object
1228  * \param new_tex_coord The texture coordinates for the object
1229  * \param isVectorArray true if array points to a Vector array, false if it
1230  * points to a Vertex array
1231  * \sa TextureCoordinates()
1232  * \sa VaSetTexCoords()
1233  * \sa SetTexCoords()
1234  */
1235  virtual GLS_EXPORT void SetTexCoords( unsigned int nPoints, Vector* new_tex_coord, bool isVectorArray = true );
1236 
1237  /** Vertex version of SetTexCoords
1238  * \sa VaSetTexCoords()
1239  * \sa TextureCoordinates()
1240  */
1241  void SetTexCoords( unsigned int nPoints, Vertex* new_tex_coord )
1242  {
1243  SetTexCoords( nPoints, new_tex_coord, false );
1244  }
1245 
1246  /** Sets the texture coordinate data for this object
1247  * \param nPoints The number of texture vertices in the object
1248  * \param ... X,Y,Z for each vertex
1249  * \sa TextureCoordinates()
1250  * \sa GetTextureCoordinates()
1251  */
1252  GLS_EXPORT void VaSetTexCoords( unsigned int nPoints, ... );
1253 
1254  /** Gets the object's texture coordinates
1255  * \note Texture Coordinates are vertex attributes. They can be two-dimensional
1256  * (UV-coordinates) or three-dimensional (UVW-coordinates). The texture coordinates at each
1257  * vertex are interpolated across the triangle generated from those vertices to determine
1258  * where to sample the texture applied to the object.
1259  * \note Some shaders use UVW coordinates as an input, but use them for some other purpose than texturing.
1260  * \return Pointer to the object's texture coordinate array. NULL if the object is not textured.
1261  * \sa GetTextureCoordinates()
1262  * \sa VaSetTexCoords()
1263  * \sa SetTexCoords()
1264  * \sa GetTexturePoints()
1265  */
1266  Vector* TextureCoordinates( void ) { return _texCoord; }
1267 
1268  /** Gets the object's texture coordinates
1269  * \return Pointer to the object's texture coordinate array. NULL if the object is not textured.
1270  * \sa TextureCoordinates()
1271  * \sa GetTexturePoints()
1272  */
1274 
1275  /** Get the texture index for this object
1276  * \return The texture index for this object
1277  */
1278  virtual GLS_EXPORT int TextureIndex( void );
1279 
1280  /** Sets the texture index to be used when drawing the object.
1281  * \param textureIndex The texture index to use.
1282  * -1 indicates that no texture will be drawn.
1283  */
1284  virtual GLS_EXPORT void TextureIndex( int textureIndex );
1285 
1286  /** Gets the object's texture points
1287  * \return Pointer to the object's texture point array.
1288  * \note For most DisplayObjects, the Texture Points are used to compute the texture coordinates.
1289  * The TexturePoints are four vertices that describe where the "corners" of the texture is in
1290  * Vertex Coordinates (i.e., the object's parent's logical coordinate space translated to
1291  * the object location). The DisplayObject then uses a projection to compute the texture
1292  * coordinates from these points. The most common is a Planar mapping, but a few objects
1293  * use other mappings (e.g. Spherical or Cylindrical).
1294  * \sa TextureCoordinates()
1295  * \sa GetTextureCoordinates()
1296  */
1297  virtual GLS_EXPORT Vector* GetTexturePoints( void );
1298 
1299  /** Gets the texturing repeat mode for this object
1300  * \return The texture repeat mode for this object
1301  */
1302  virtual GLS_EXPORT bool TextureRepeat( void );
1303 
1304  /** Sets the texturing repeat mode for this object
1305  * \param rep The new texture repeat mode for this object (boolean)
1306  */
1307  virtual GLS_EXPORT void TextureRepeat( const int rep );
1308 
1309  /** Gets the texturing mapping mode for this object
1310  * \return The texture mapping mode for this object
1311  * \sa TextureMap_e
1312  */
1313  virtual GLS_EXPORT int TextureMappingTechnique( void );
1314 
1315  /** Sets the texturing mapping mode for this object
1316  * \param map The new texture mapping mode for this object
1317  * \sa TextureMap_e
1318  */
1319  virtual GLS_EXPORT void TextureMappingTechnique( const int map );
1320 
1321  /** Gets the texture magnification filter for this object
1322  * \return The texture magnification filter for this object
1323  * \sa TextureFilter_e
1324  */
1325  virtual GLS_EXPORT int TextureMagnificationFilter( void );
1326 
1327  /** Sets the texture magnification filter for this object
1328  * \param filter The new texture magnification filter for this object
1329  * \sa TextureFilter_e
1330  */
1331  virtual GLS_EXPORT void TextureMagnificationFilter( const int filter );
1332 
1333  /** Gets the texture minification filter for this object
1334  * \return The texture minification filter for this object
1335  * \sa TextureFilter_e
1336  */
1337  virtual GLS_EXPORT int TextureMinificationFilter( void );
1338 
1339  /** Sets the texture minification filter for this object
1340  * \param filter The new texture minification filter for this object
1341  * \sa TextureFilter_e
1342  */
1343  virtual GLS_EXPORT void TextureMinificationFilter( const int filter );
1344 
1345  /** Moves the object by the amount indicated.
1346  * \param tr Float[3] array containing the x,y,z amounts to translate by
1347  */
1348  virtual GLS_EXPORT void Translate( float tr[] );
1349 
1350  /** Moves the object by the amount indicated.
1351  * \param x X amount to translate by
1352  * \param y Y amount to translate by
1353  * \param z Z amount to translate by
1354  */
1355  virtual GLS_EXPORT void Translate( float x, float y, float z );
1356 
1357  /** Moves the object's vertices by the amount indicated. Does not change _location.
1358  * \param x X amount to translate by
1359  * \param y Y amount to translate by
1360  * \param z Z amount to translate by
1361  */
1362  virtual GLS_EXPORT void TranslateVertices( float x, float y, float z );
1363 
1364  /** Updates the bounding volume of this object
1365  * This method should be called if the vertices change for picking and
1366  * culling to work correctly.
1367  * This will only update this object. If PerformGroupCullCheck is enabled
1368  * for one of the objects parents, you may also need to call
1369  * CalculateParentBoundingBox() to update all of the objects parents.
1370  */
1371  virtual void GLS_EXPORT UpdateBoundingVolume( void );
1372 
1373  /** Gets the current UserData pointer. UserData is a pointer the user can
1374  * use to attach user defined data to a GL Studio object.
1375  * \return The current UserData pointer
1376  */
1377  void* UserData( void ) const { return _userData; }
1378 
1379  /** Sets the current UserData pointer
1380  * \param data The new UserData pointer
1381  */
1382  void UserData( void* data ) { _userData = data; }
1383 
1384  /** Changes the color of a vertex
1385  * \param vertex 1 based index of the vertex to the change color for
1386  * \param CurrentFillColor The new RGBA (0-255 range) color for the vertex
1387  */
1388  virtual GLS_EXPORT void SetVertexColor( unsigned int vertex, unsigned char CurrentFillColor[] );
1389 
1390  /** Gets the object's vertices.
1391  * You should call UpdateBoundingVolume after changing an object's extents.
1392  * \sa UpdateBoundingVolume
1393  * \return Pointer to the object's vertex array
1394  */
1395  virtual GLS_EXPORT Vertex* Vertices() { return _vertices; }
1396 
1397  /** Sets the vertex data for this polygon
1398  * You should call UpdateBoundingVolume after changing an object's extents.
1399  * \sa UpdateBoundingVolume
1400  * \param nPoints The number of vertices in the object
1401  * \param vertices The vertex data for the object
1402  */
1403  virtual GLS_EXPORT void SetVertices( unsigned int nPoints, Vertex* vertices );
1404 
1405  /** Sets the vertex data for this object
1406  * You should call UpdateBoundingVolume after changing an object's extents.
1407  * \sa UpdateBoundingVolume
1408  * \param nPoints The number of vertices in the object
1409  * \param ... r,g,b,a,x,y,z for each vertex
1410  */
1411  GLS_EXPORT void VaSetVertices( unsigned int nPoints, ... );
1412 
1413 protected:
1414  /** Sets the vertex data for this object
1415  * You should call UpdateBoundingVolume after changing an object's extents.
1416  * \sa UpdateBoundingVolume
1417  * \param nPoints The number of vertices in the object
1418  * \param args va_list in the form r,g,b,a,x,y,z for each vertex
1419  */
1420  virtual GLS_EXPORT void VaListSetVertices( unsigned int nPoints, va_list args );
1421 
1422  /** Sets the normal data for this object
1423  * This function is called as part of VaSetNormals( unsigned int, ... )
1424  * \param nPoints The number of normals in the object
1425  * \param args va_list in the form x,y,z for each normal
1426  */
1427  virtual GLS_EXPORT void VaListSetNormals( unsigned int nPoints, va_list args );
1428 
1429  /** Sets the texture coordinate data for this object
1430  * This function is called as part of VaTexCoords( unsigned int, ... )
1431  * \param nPoints The number of texture coordinates in the object
1432  * \param args va_list in the form x,y,z for each texture coordinate
1433  */
1434  virtual GLS_EXPORT void VaListSetTexCoords( unsigned int nPoints, va_list args );
1435 
1436 public:
1437  /** \return The saved View matrix, if any. Normally not used by the user.*/
1438  GLS_EXPORT int* ViewMatrix();
1439 
1440  /** Get the visibility state this object
1441  * \return Whether or not this object is enabled for drawing
1442  */
1443  inline bool Visible( void ) const { return _visible; }
1444 
1445  /** Get the visibility state this object
1446  * \return Whether or not this object is enabled for drawing
1447  */
1448  inline bool Visibility( void ) const { return _visible; }
1449 
1450  /** Set the visiblity state for this object
1451  * \param vis Whether or not enable this object for drawing
1452  */
1453  virtual GLS_EXPORT void Visibility( const bool vis );
1454 
1455  /** Gets the rotation point for the object in world coordinates
1456  * \return The rotation point for the object in world coordinates
1457  */
1458  virtual GLS_EXPORT Vector WorldRotationPoint( void );
1459 
1460  /** Sets the rotation point for the object in world coordinates
1461  * \param vert The rotation point for the object in world coordinates
1462  */
1463  virtual GLS_EXPORT void WorldRotationPoint( const Vector& vert );
1464 
1465  /** Gets a vertex from the object, in World coordinates (i.e. not relative to the location
1466  * as is the case with the Vertices() API call).
1467  * \param i Index of the vertex to get
1468  * \return The vertex
1469  */
1470  virtual GLS_EXPORT Vertex WorldVertex( unsigned int i );
1471 
1472  /** Sets a vertex of the object, in World coordinates (i.e. not relative to the location
1473  * as is the case with the Vertices() API call. )
1474  * \param i The 0 based index of the vertex to get
1475  * \param vert The new vertex value
1476  */
1477  virtual GLS_EXPORT void WorldVertex( unsigned int i, const Vertex& vert );
1478 
1479  /** Convert a point from logical coordinates to window coordinates
1480  * \param logical The point in logical coordinates
1481  * \param winLoc The returned value in window coordinates. Z Ranges from 0.0 to 1.0. 0.0 is near clip, 1.0 is far clip.
1482  * \param alternateMatrices When supplied it is used instead of self determined matrices.
1483  */
1484  GLS_EXPORT bool LogicalToWindow( const Vector& logical,
1485  Vector& winLoc, /* .z is 0.0 -> 1.0 */
1486  const OpenGLMatrices& alternateMatrices = OpenGLMatrices() );
1487 
1488  /** Convert a point in window coordinates to logical coordinates
1489  * \param winLoc Coordinate in window coordinates. X and Y are in pixels. Z Ranges from 0.0 to 1.0. 0.0 is near clip, 1.0 is far clip.
1490  * \param logical Coordinate in logical coordinates (returned)
1491  * \param directionVector normal into the screen at the point (returned)
1492  * \param alternateMatrices A Set of matrices that if supplied, will alter the point
1493  */
1494  GLS_EXPORT bool WindowToLogical(
1495  const Vector& winLoc,
1496  Vector& logical, /* returned */
1497  Vector* directionVector = NULL, /* returned if not NULL */
1498  const OpenGLMatrices& alternateMatrices = OpenGLMatrices() );
1499 
1500  /** PROJECT a point from logical coordinates to the object's DCS's XY plane
1501  * \param logicalPoint The original point in logical coordinates
1502  * \param objectLocal The returned point in the objects DCS coordinate system on the XY plane.
1503  * \param directionVector The direction vector to use when projecting the point. If NULL, the point will be converted but not projected.
1504  * \param planeNormal
1505  * \param planePoint
1506  * \param dcsMatrix An alternate DCS matrix to convert to.
1507  */
1508  GLS_EXPORT void LogicalToDCS(
1509  Vector logicalPoint,
1510  Vector& objectLocal, /* returned */
1511  const Vector* directionVector,
1512  const Vector& planeNormal = Vector( 0, 0, 1 ), /* X/Y plane */
1513  const Vector& planePoint = Vector(),
1514  const GlsMatrixType* dcsMatrix = NULL );
1515 
1516  /** Transform a point from the object's DCS coordinate system to the logical coordinate system.
1517  * \param dcsPoint The original point in dcs coordinates
1518  * \param logicalPoint The returned point in the objects DCS coordinate system on the XY plane.
1519  * \param dcsMatrix An alternate DCS matrix to convert from.
1520  */
1521  GLS_EXPORT void DCSToLogical(
1522  Vector dcsPoint,
1523  Vector& logicalPoint, /* returned */
1524  const GlsMatrixType* dcsMatrix = NULL );
1525 
1526 #ifdef GLES
1527  /** Create a new DisplayObject, reading the properties in order from our GLO.
1528  * \param dataStream The GLO data stream we are getting our properties from.
1529  * \param parent The Group that will be this object's parent.
1530  */
1531  GLS_EXPORT bool Create( GlsGloFile& dataStream, Group* parent );
1532 
1533  GLS_EXPORT void GeometryRefresh();
1534 #endif
1535 
1536 protected:
1537 #ifdef GLES
1538  bool _geometryRefresh; /**< Whether or not the geometry needs to be refreshed to the hardware */
1539 
1540  GLS_EXPORT void ApplyTextureMinMagSettings();
1541  GLS_EXPORT void ApplyTextureEnvModeSettings();
1542  GLS_EXPORT bool SetupTextureIsNeeded();
1543 
1544 #endif
1545 
1546  int _alphaMode; /**< Whether or not to perform alpha testing while drawing. */
1547 
1548  bool _antiAlias; /**< Whether or not to perform anti-aliasing while drawing. */
1549 
1550  bool _attributesAdded; /**< True if SetAvailableAttributes has been called. Users should not change this. */
1551 
1552  bool _blinking; /**< Whether or not the blinking mode is turned on */
1553 
1554  float _blinkRate; /**< Number of times per second the object will blink */
1555 
1556  GlsColor _color; /**< The RGBA color for drawing the outline of the object. */
1557 
1558  bool _cullBackFace; /**< Whether or not to remove backfaces */
1559 
1560  GlsMatrixType _dcsMatrix; /**< The dynamic coordinate system. The Dynamic changes to rotation, scale, and translate will
1561  * be modified by this and applied to the _drawMatrix. */
1562 
1563  unsigned char _depthTest; /**< What kind of depth testing while drawing. See DepthBuffer_e*/
1564 
1565  GlsMatrixType* _drawMatrix; /**< The objects current contribution to the draw matrix.
1566  * This will be multiplied by the current matrix at draw time.
1567  * If NULL, this object has no contribution (it is not dynamic)
1568  * See CalcDrawMatrix() for more */
1569 
1570  bool _needCalcDrawMatrix; /** True if CalcDrawMatrix() needs to be called on this object */
1571 
1572  unsigned char _lineStippleMultiplier; /**< The multiplier used when applying a line stipple pattern to a line. */
1573 
1574  unsigned short _lineStipplePattern; /**< A bit pattern indicating which pixels in a line should be drawn and which pixels should not. */
1575 
1576  float _lineWidth; /**< The current width of lines rendered in the object, in logical units */
1577 
1578  Vertex _location; /**< The location of the origin point for this object, in the world coordinate system. */
1579 
1580  DynamicArray<int> _materialIndices;
1581 
1582  GlsMatrixType* _modelMatrix; /**< Stores the Model matrix for this object, if needed. Used by Draw() and 3D picking. */
1583 
1584  Vector* _normals; /**< The array of vertex normals for this object.
1585  * The size of this array is based on _nVertices */
1586 
1587  unsigned int _nTex_vertices; /**< The number of Texture Coordinate Vertices in this object */
1588 
1589  unsigned int _nVertices; /**< The number of vertices in this object */
1590 
1591  unsigned char _polygonEnd; /**< Whether or not this is a CLOSED or OPEN polygon */
1592 
1593  unsigned char _polygonMode; /**< The mode for drawing the object. */
1594 
1595  int _polygonOffset; /**< The depth buffer offset for this object */
1596 
1597  GlsMatrixType* _projMatrix; /**< Stores the Projection matrix for this object, if needed. Used by Draw() and 3D picking. */
1598 
1599  unsigned char _shading; /**< The shading mode for this object */
1600 
1601  Vector* _texCoord; /**< The array of texture coordinates for this object. If an object is untextured,
1602  * this value is NULL. The size of this array is based on _nTex_vertices */
1603 
1604  GlsColor _textureBlendColor; /**< The current texture blend color (used if TextureMapMode is TEXTURE_MAP_BLEND mode only) */
1605 
1606  int _textureIndex; /**< The index into the texture palette array of the texture used to
1607  * to texture this object. A texture index of -1 indicates that no
1608  * texture is assigned to the object. */
1609 
1610  unsigned char _textureMagFilter; /**< The current texturing magnification filter mode for the object */
1611 
1612  unsigned char _textureMinFilter; /**< The current texturing minification filter mode for the object */
1613 
1614  unsigned char _textureMap; /**< The current texturing map mode for the object. */
1615 
1616  Vector _texturePoints[ NUM_TEXTURE_POINTS ]; /**< Used to store the relative placement and rotation of a texture on
1617  * the object. Texture coordinates are calculated from the texture points.
1618  * The _texturePoints are relative to the _location, which makes
1619  * them in the objects coordinate system.
1620  */
1621 
1622  unsigned char _textureRepeat; /**< The current texturing repeat mode for the object. */
1623 
1624  void* _userData; /**< Data pointer for the user to assign as needed */
1625 
1626  Vertex* _vertices; /**< The array of vertices for this object. The vertices are in the object's
1627  * coordinate system. That is, they are relative to the _location field.
1628  * This array always has a size based on _nVertices */
1629 
1630  int* _viewMatrix; /**< Stores the View matrix for this object, if needed. Used by Draw() and 3D picking. */
1631 
1632  bool _visible; /**< Whether or not the object is enabled for drawing */
1633 
1634  virtual GLS_EXPORT int ColorMaterialMode( void );
1635 
1636  /** Allocate the model matrix, if needed */
1637  GLS_EXPORT void AllocateModelMatrix();
1638 
1639  /** Applies dynamic rotation to object, saving the matrix stack
1640  * so that dynamic picking can occur
1641  * \return True if a rotation was performed. False otherwise.
1642  * If this method returns true, then the caller needs to do
1643  * a glPopMatrix to restore the stack after drawing
1644  */
1645  GLS_EXPORT bool ApplyDynamicRotation( void );
1646 
1647  /** Creates and recalculates the _drawMatrix
1648  * If _rotation, _dynamicScale, or _dynamicTranslate change you must call CalcDrawMatrix()
1649  * If _dcsMatrix, _location, or _rotationPoint change you need to call CalcDrawMatrixIfExists()
1650  * These are normally called automatically for you by the API Methods that affect those values.
1651  * Sub-classes may override CalcDrawMatrix() to include additional transformations in the _drawMatrix.
1652  */
1653  virtual GLS_EXPORT void CalcDrawMatrix();
1654 
1655  /** Recalculates the _drawMatrix if it exists.
1656  * See CalcDrawMatrix() for more info. */
1658  {
1659  if( _drawMatrix )
1660  {
1661  CalcDrawMatrix();
1662  }
1663  }
1664 
1665  /** Applies the _drawMatrix to the modelMatrix.
1666  * If necessary derived classes can save other matrices.
1667  * \param newMatrices A set of matrices passed down to this object from its parent.
1668  */
1669  virtual GLS_EXPORT void CalculateMatrices( const OpenGLMatrices& newMatrices );
1670 
1671  /** Returns true if the point is inside the 2D extents of the given vertices
1672  * \param x X coordinate of pick point
1673  * \param y Y coordinate of pick point
1674  * \param nVerts Number of vertices to try
1675  * \param verts Vertex array to try
1676  * \param tolerance Picking tolerance
1677  */
1678  GLS_EXPORT bool InsideVertexExtents( float x, float y, unsigned int nVerts, Vertex* verts, float tolerance );
1679 
1680  /* Used internally to determine if the user has modified the location */
1681  inline void LastDrawMatrixLocation( const Vertex& loc ) { _lastDrawMatrixLocation = loc; }
1682 
1683  /* Used internally to determine if the user has modified the location */
1684  inline const Vertex& LastDrawMatrixLocation() { return _lastDrawMatrixLocation; }
1685 
1686  /** Set the value of _needCalculate */
1687  inline void NeedCalculate( bool val ) { _needCalculate = val; }
1688 
1689  /** Sets up the object for picking by dynamically rotating vertices
1690  * \param x X coordinate of pick point
1691  * \param y Y coordinate of pick point
1692  * \param z Z coordinate of pick point
1693  * \param vertices Vertex array to setup
1694  * \param vertex_cnt Number of vertices to setup
1695  * \param directionVector dynamic rotation vector
1696  */
1697  GLS_EXPORT void PickSetup( float x, float y, float z, Vertex* vertices, unsigned int vertex_cnt, const Vector& directionVector );
1698 
1699  /** Restores the temporarily rotated vertices
1700  * \param vertices Vertex array to restore
1701  * \param vertex_cnt Number of vertices to restore
1702  */
1703  GLS_EXPORT void PickCleanup( Vertex* vertices, unsigned int vertex_cnt );
1704 
1705 #ifdef GLES
1706  /** Set a single attribute from the GLO file.
1707  * \param data The attribute to set and its associated data.
1708  */
1709  virtual GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data );
1710 #endif
1711 
1712  /** Finds three coplanar points and the surface normal, if possible. This calculation is performed using the
1713  * Vertices() of this object. Used in the editor to determine how to map a texture onto an object.
1714  * \param p1 Returns a point on the plane
1715  * \param p2 Returns a point on the plane
1716  * \param p3 Returns a point on the plane
1717  * \param planeVector Returns the surface normal of the plane
1718  * \return True if 3 coplanar points were found
1719  */
1720 public:
1721  virtual GLS_EXPORT bool GetPlaneVectorPoints( Vertex& p1, Vertex& p2, Vertex& p3, Vertex& planeVector );
1722 
1723  /** Implements AttributeChangedNotifier::NotifyAttributeChanged.
1724  * Notify the class that the attribute has changed. Observers of the attribute will have their callbacks called
1725  * \param name the name of the attribute
1726  */
1727  GLS_EXPORT void NotifyAttributeChanged( const AttributeName& name ) DISTI_METHOD_OVERRIDE;
1728 
1729  /** Sets the painter for this object. Can be NULL. If the painter is set, this object will call Invalidate() on the painter anytime it changes
1730  * in a way that affects its rendering.
1731  * \note This object only observers the painter, and does not delete it.
1732  * \param painter the painter that is drawing this class.
1733  */
1734  virtual GLS_EXPORT void SetPainter( GlsPainter* painter );
1735 
1736  /** Returns the painter for this object, or NULL of none. The return value is an observer pointer and should not be deleted
1737  */
1738  GLS_EXPORT virtual GlsPainter* GetPainter();
1739 
1740  /** Invalidates the painter set on this object if that painter exists.
1741  * Typically called by user code when it modifies an object in such a
1742  * way where the painter invalidation system wouldn't work automatically
1743  * (for example, directly modifying vertex data).
1744  */
1745  GLS_EXPORT void InvalidatePainter();
1746 
1747  /** Traverses upward in the hierarchy to determine if this object is visible in the scene.
1748  * Overloaded for classes that handle child visibility without using the Visibility flag such as GlsMutexGroup.
1749  */
1750  GLS_EXPORT virtual bool IsVisibleInScene( const DisplayObject* obj = NULL ) const;
1751 
1752 protected:
1753  /** Sets an attribute of this object using variable arguments
1754  * \param spec A GLS_Initializer tag
1755  * \param args A variable argument list
1756  */
1757  GLS_EXPORT virtual void SetValue( int spec, va_list& args );
1758 
1759 private:
1760  void CopyGeometryInternal( const DisplayObject* src );
1761  void CopyPropertiesInternal( const DisplayObject* src );
1762  void CopyHierarchyPropertiesInternal( const DisplayObject* src, bool copyName );
1763 
1764  DistiAttribDict* _attribDict; /**< Stores all of this object's metadata attributes */
1765 
1766  Vector _boundingVolumeCenter; /**< Center of the bounding volume (relative to Location())*/
1767 
1768  float _boundingVolumeRadius; /**< Radius of the bounding sphere */
1769 
1770  CallbackMethodCallerBase* _callbackCaller; /**< The pointer to the callback caller for this object.
1771  * This is currently unrelated to the InputDevice callback */
1772 
1773  bool _culled; /**< Whether or not this object is currently culled */
1774 
1775  float _dynamicTranslate[ 3 ]; /* The current (dynamic) translation of the object, in logical units and relative to the object's DCS.
1776  * _dynamicTranslate[0] = x traslation
1777  * _dynamicTranslate[1] = y traslation
1778  * _dynamicTranslate[2] = z traslation */
1779 
1780  float _dynamicScale[ 3 ]; /* The current (dynamic) scale of the object */
1781 
1782  EditorObjectBase* _editorObject; /* Used in the editor to access editor functionality */
1783 
1784  char* _instanceName; /**< A unique character string used to identify the object. This name
1785  * will correspond to the name of the C++ member variable generated for
1786  * this object in the output code. */
1787 
1788  Vertex _lastDrawMatrixLocation; /**< The value of _location the last time CalcDrawMatrix() was called */
1789 
1790  bool _lightingEnabled; /**< Stores the lighting enabled state */
1791 
1792  bool _needCalculate; /* true if Calculate() needs be called on this object.
1793  * Defaults to true.
1794  * Calculate() may still be called in some situations */
1795 
1796  DisplayFrame* _parent; /**< The display frame or component that contains this object */
1797 
1798  Group* _parentGroup; /**< The group of which this object is a member */
1799 
1800  GlsPainter* _painter; /** The painter, can be NULL, used for conditional rendering */
1801 
1802  unsigned char _pickable; /**< The type of picking that is enabled for this object */
1803 
1804  float _rotation[ 3 ]; /* The current (dynamic) rotation of the object, in degrees and relative to
1805  * the object's rotation point. Order of rotation is x, then y, then z
1806  * _rotation[0] = x rotation angle
1807  * _rotation[1] = y rotation angle
1808  * _rotation[2] = z rotation angle */
1809 
1810  Vertex _rotationPoint; /* The location, in the object coordinate system, of the point to rotate
1811  * this object around when the object is dynamically rotated.
1812  * So when we want to rotate this object (not just rotate the view), this
1813  * is the point to rotate about. This point is relative to the _location,
1814  * which makes in in the objects coordinate system. */
1815 
1816  GLS_EXPORT void DisplayColorMaterialModeError( const int mode );
1817  GLS_EXPORT int DisplayColorMaterialModeError();
1818 
1819  void CommonConstructorInit( float x, float y, float z );
1820 
1821  /** Callback for when DCS Matrix changes through the resource API */
1822  void OnDCSMatrixChanged();
1823 
1824  /** Callback for when Vertices change through the resource API */
1825  void OnVerticesChanged();
1826 
1827  /** Callback for when Texture coordinates change through the resource API */
1828  void OnTextureCoordsChanged();
1829 
1830  /** Assignment operator not implemented. Use CloneObject() or the copy constructor instead. */
1831  DisplayObject& operator=( const DisplayObject& that ); // = delete
1832 
1833 protected:
1834  /** Returns the local setting for _textureIndex if not -1,
1835  * otherwise returns the group texture index.
1836  */
1837  GLS_EXPORT int GetApplicableTextureIndex();
1838  /** Returns the local setting for _textureRepeat if
1839  * _textureIndex is not -1,
1840  * otherwise returns the group texture repeat setting.
1841  */
1842  GLS_EXPORT int GetApplicableTextureRepeat();
1843 
1844 #ifdef GLES
1845  IGlsStateManager* _stateManager;
1846 #endif
1847 
1848 #ifdef GLES20
1849  IGlsStateManagerES20* _stateManagerES20;
1850 #endif
1851 };
1852 
1853 } // namespace disti
1854 
1855 #endif
Definition: cull.h:49
GlsMatrixType * _drawMatrix
Definition: display.h:1565
float Y(void) const
Definition: display.h:847
GlsColor _textureBlendColor
Definition: display.h:1604
bool InsideVertexExtents(float x, float y, unsigned int nVerts, Vertex *verts, float tolerance)
Definition: display_frame.h:85
void RestoreLighting(void)
virtual void CalculateMatrices(const OpenGLMatrices &newMatrices)
void * UserData(void) const
Definition: display.h:1377
void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Definition: display.h:374
void SetTexCoords(unsigned int nPoints, Vertex *new_tex_coord)
Definition: display.h:1241
bool GetTexturePointTransformationMatrix(GlsMatrixType &world2tex)
Vector * _normals
Definition: display.h:1584
virtual const Vertex & Location(void) const
DistiAttribDict & Attributes()
Definition: display.h:180
virtual void CopyGeometry(DisplayObject *src)
Definition: vertex.h:409
virtual void UpdateBoundingVolume(void)
CallbackMethodCallerBase * CallbackCaller() const
Definition: display.h:311
The disti metadata.
void SetupShading(void)
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:436
virtual void Calculate(double time)
virtual float BlinkRate(void)
virtual void SetVertices(unsigned int nPoints, Vertex *vertices)
void VaSetTexCoords(unsigned int nPoints,...)
void SetupPolyDrawStyle(void)
virtual void SetVertexColor(unsigned int vertex, unsigned char CurrentFillColor[])
Vertex _location
Definition: display.h:1578
GlsMatrixType & DcsMatrix()
Definition: display.h:462
virtual void CalculateParentBoundingBox(void)
void SetFillColor(unsigned char c4[])
Definition: display.h:684
Definition: gls_state_manager_es20_interface.h:65
virtual void SetBlendColor(const GlsColor &color)
virtual void GetRotationPoint(Vertex &v)
Definition: dynamic_array.h:66
bool BoundingVolumeHit(const Vector &start, const Vector &direction)
The disti::DynamicArray class. A templated array of objects capable of dynamically growing...
GlsMatrixType * ModelMatrix()
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:296
bool SetupLineStyle(void)
void CalculateCollisionPoint(const Vector &pickLoc, const Vector &directionVector, Vector *collisionPoint)
Defines a base class which editor objects can derive.
virtual int TextureMagnificationFilter(void)
void NotifyAttributeChanged(const AttributeName &name) override
float MagnitudeSquared() const
Definition: vertex.h:335
virtual Vertex WorldVertex(unsigned int i)
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler)
virtual float LineWidth(void)
virtual bool IsVisibleInScene(const DisplayObject *obj=NULL) const
void ApplyTextureSettings(int textureIndex=-1)
virtual int AlphaMode(void)
virtual void CalculateTextureCoordinates(void)
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array)
The GlsMatrixAffine class.
unsigned char _lineStippleMultiplier
Definition: display.h:1572
virtual void CopyProperties(DisplayObject *src)
void RestoreAlpha(void)
unsigned short _lineStipplePattern
Definition: display.h:1574
bool _visible
Definition: display.h:1632
DisplayFrame * Parent(void) const
Definition: display.h:935
virtual void VaListSetTexCoords(unsigned int nPoints, va_list args)
unsigned char _textureMagFilter
Definition: display.h:1610
virtual void SetValue(int spec, va_list &args)
Definition: display.h:98
unsigned char _textureMinFilter
Definition: display.h:1612
bool Visible(void) const
Definition: display.h:1443
virtual void SetTexCoords(unsigned int nPoints, Vector *new_tex_coord, bool isVectorArray=true)
bool Visibility(void) const
Definition: display.h:1448
virtual void GetResources(std::ostream &outstr, GlsResourceFilter *filter=NULL)
virtual void CopyHierarchyProperties(DisplayObject *src, bool copyName)
Definition: gls_state_manager_interface.h:67
Vector * Normals()
Definition: display.h:882
virtual void InsertVertexAt(unsigned int index)
virtual int MaterialIndex()
bool ApplyDynamicRotation(void)
bool CullTest(const GlsMatrixType *matrix, const Culler &culler)
Definition: display.h:427
virtual float ObjectHeight(void)
static void SetManualBlinkElapsedTime(double elapsedTime)
float _lineWidth
Definition: display.h:1576
DisplayObject(float x, float y, float z)
virtual bool HitUtil(float x, float y, float z, float scale, Vertex *vertices, unsigned int vertex_cnt, const Vector &directionVector, Vector *collisionPoint)
float Z(void) const
Definition: display.h:850
weak reference and related classes
The disti::GlsStateManager factory class. Creates an instance of a state manager that manages the GL ...
virtual DisplayObject * Pick3D(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &drawnMatrices)
bool SphereOutsideFrustum(const Vector &center, const float radius) const
Definition: cull.h:96
virtual void VaListSetNormals(unsigned int nPoints, va_list args)
static void UseManualBlinkElapsedTime(bool useManualTime)
Vector _texturePoints[4]
Definition: display.h:1616
GlsMatrixType * _projMatrix
Definition: display.h:1597
const Vector & BoundingVolumeCenter() const
Definition: display.h:259
Definition: gls_glo_file.h:988
void SetupDepthTest(void)
void SetColor(unsigned char c4[])
Definition: display.h:365
virtual Vector WorldRotationPoint(void)
virtual void Translate(float tr[])
unsigned char _polygonMode
Definition: display.h:1593
float _blinkRate
Definition: display.h:1554
void DynamicRotate(float angle, int axis)
virtual void ReallocateVertices(unsigned int numVertices, bool initializeNew, bool copyOld)
Definition: gls_glo_file.h:81
Vector * _texCoord
Definition: display.h:1601
Definition: gls_painter.h:51
void DCSToLogical(Vector dcsPoint, Vector &logicalPoint, const GlsMatrixType *dcsMatrix=NULL)
void LogicalToDCS(Vector logicalPoint, Vector &objectLocal, const Vector *directionVector, const Vector &planeNormal=Vector(0, 0, 1), const Vector &planePoint=Vector(), const GlsMatrixType *dcsMatrix=NULL)
virtual int Shading(void)
virtual Vector DynamicScale()
unsigned int _nTex_vertices
Definition: display.h:1587
bool _blinking
Definition: display.h:1552
virtual ~DisplayObject(void)
void Transform(Vector &v) const
Definition: gls_matrix_affine.h:271
virtual void FinishObject()
Definition: display.h:698
VertexNoColor Vector
Definition: gls_font_base.h:66
virtual GlsColor GetFillColor(void)
GlsMatrixType * _modelMatrix
Definition: display.h:1582
virtual Vertex * Vertices()
Definition: display.h:1395
virtual float ObjectDepth(void)
const GlsMatrixType * DrawMatrix()
Definition: display.h:506
GlsMatrixType * ProjMatrix()
bool NeedCalcDrawMatrix()
Definition: display.h:510
virtual int TextureIndex(void)
GL Studio Enumerations and constants.
bool _attributesAdded
Definition: display.h:1550
float X(void) const
Definition: display.h:844
virtual void SetNormals(unsigned int nPoints, Vector *vertices)
virtual DistiAttributeBase & Resource(const char *name)
The disti::Vertex class. A class for manipulating 3D vertices.
virtual void SetOrigin(const Vertex &vert)
virtual Vector * GetTexturePoints(void)
Generally useful defines, macros, enumerations and function prototypes.
virtual void DynamicRotateRelative(float angle, int axis)
virtual int TextureMappingTechnique(void)
virtual bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint)
virtual DynamicArray< int > & MaterialIndices()
void UserData(void *data)
Definition: display.h:1382
unsigned char _shading
Definition: display.h:1599
void Y(const float y)
Definition: display.h:856
unsigned char _textureRepeat
Definition: display.h:1622
int _polygonOffset
Definition: display.h:1595
void PickSetup(float x, float y, float z, Vertex *vertices, unsigned int vertex_cnt, const Vector &directionVector)
bool Culled() const
Definition: display.h:420
void X(const float x)
Definition: display.h:853
Definition: disti_metadata.h:186
void CalcDrawMatrixIfExists()
Definition: display.h:1657
virtual bool CullBackFace(void)
GlsColor _color
Definition: display.h:1556
void SetupLighting(void)
bool SetupTexture(void)
int _textureIndex
Definition: display.h:1606
Vector * GetTextureCoordinates(void)
Definition: display.h:1273
Definition: events.h:112
Definition: gls_color.h:53
void Z(const float z)
Definition: display.h:859
virtual void Rotate(float angle, int axis=Z_AXIS)
char * InstanceName(void)
virtual void GetTransformedExtents(Vector &min, Vector &max, const GlsMatrixType &matrix, bool resetMinMax=true)
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL)
unsigned char _textureMap
Definition: display.h:1614
Definition: disti_metadata.h:668
Definition: weak_referenceable_mixin.h:52
#define MAX(A, B)
Definition: util.h:167
unsigned int _nVertices
Definition: display.h:1589
virtual void GetCenter(Vector &center)
void VaSetNormals(unsigned int nPoints,...)
Vector * TextureCoordinates(void)
Definition: display.h:1266
Definition: callback_caller_base.h:55
virtual int DepthTest(void)
virtual DisplayObject * CloneObject(bool generateNames=false)=0
virtual void SetPainter(GlsPainter *painter)
void VaSetVertices(unsigned int nPoints,...)
unsigned char _depthTest
Definition: display.h:1563
virtual float RelativeAngle(const float x, const float y)
The disti::Culler class. Implements view frustum culling.
virtual void Scale(float px, float py, float pz, Vertex *anchor, int handleBar=0)
Definition: group.h:52
virtual void GenerateInstanceName(void)
bool LogicalToWindow(const Vector &logical, Vector &winLoc, const OpenGLMatrices &alternateMatrices=OpenGLMatrices())
Definition: disti_metadata.h:458
unsigned char Pickable()
Definition: display.h:976
virtual bool AntiAlias(void)
virtual void SetColor(const GlsColor &color)
unsigned char _polygonEnd
Definition: display.h:1591
GlsMatrixType _dcsMatrix
Definition: display.h:1560
virtual void GetLocation(Vertex &v)
void PickCleanup(Vertex *vertices, unsigned int vertex_cnt)
virtual GlsColor GetColor()
virtual void TranslateVertices(float x, float y, float z)
virtual void Draw(void)=0
Definition: vertex.h:84
int _alphaMode
Definition: display.h:1546
virtual Vector DynamicTranslation()
void NeedCalculate(bool val)
Definition: display.h:1687
virtual void DeleteVertexAt(unsigned int index)
const Vertex & RotationPoint() const
Definition: display.h:1093
virtual bool Blinking(void)
The GlsPainter interface.
Vertex * _vertices
Definition: display.h:1626
bool NeedCalculate()
Definition: display.h:877
virtual GlsPainter * GetPainter()
virtual bool LightingEnabled()
void * _userData
Definition: display.h:1624
Definition: vertex.h:77
virtual void SetAvailableAttributes(unsigned int value)
Definition: gls_resources.h:50
bool _antiAlias
Definition: display.h:1548
unsigned int NumberOfVertices() const
Definition: display.h:899
virtual bool TextureRepeat(void)
float BoundingVolumeRadius() const
Definition: display.h:276
bool WindowToLogical(const Vector &winLoc, Vector &logical, Vector *directionVector=NULL, const OpenGLMatrices &alternateMatrices=OpenGLMatrices())
bool SetupAntiAlias(void)
AvailableAttributesEnum
Definition: display.h:131
void GetExtentsDCS(Vector &min, Vector &max)
virtual void DeleteVertex(unsigned int indexAfter) final
Definition: display.h:481
virtual void InsertVertex(unsigned int indexAfter) final
Definition: display.h:761
Definition: disti_metadata.h:85
virtual bool GetPlaneVectorPoints(Vertex &p1, Vertex &p2, Vertex &p3, Vertex &planeVector)
int GetApplicableTextureRepeat()
void RestoreLineStyle(void)
Definition: bmpimage.h:46
virtual int LineStippleMultiplier(void)
virtual void GetExtents(float &x, float &y, float &z, float &x1, float &y1, float &z1)
virtual int PolygonMode(void)
virtual void VaListSetVertices(unsigned int nPoints, va_list args)
virtual int TextureMinificationFilter(void)
DisplayObjectEditor * Editor()
void SetFillColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Definition: display.h:678
virtual int PolygonEnd(void)
virtual GlsColor GetBlendColor()
virtual int LineStipplePattern(void)
void Set(int spec,...)
bool _cullBackFace
Definition: display.h:1558
virtual void CalcDrawMatrix()
void RestoreAntiAlias(void)
Group * ParentGroup(void) const
Definition: display.h:945
virtual float ObjectWidth(void)
int * _viewMatrix
Definition: display.h:1630
virtual DisplayObject * handle(DisplayEvent *ev)
virtual void DynamicTranslate(float x, float y, float z, bool relative=false)
The gls_gl.
Definition: editor_object_base.h:48