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  /** Dynamically generate a name for the object, based on the current time
692  */
693  virtual GLS_EXPORT void GenerateInstanceName( void );
694 
695  /** Handles an event that is sent to the object.
696  * \param ev The event to send to the object
697  * \returns Which object handled the event
698  */
699  virtual GLS_EXPORT DisplayObject* handle( DisplayEvent* ev );
700 
701  /** Determines if the object is hit by a pick ray starting at (x,y,z) and pointing towards directionVector in object logical coordinate system.
702  * If Pickable() == PICK_BEST it will return the closest point that was hit, otherwise it returns the first point that was hit.
703  * This method should not pick points behind the viewer.
704  *
705  * \param x X coordinate of pick ray start in logical coordinates.
706  * \param y Y coordinate of pick ray start in logical coordinates.
707  * \param y Y coordinate of pick ray start in logical coordinates.
708  * \param z Z coordinate of pick ray start in logical coordinates.
709  * \param scale The scale factor of the window. Affects picking of outlines. Standard value is 1.0.
710  * \param directionVector The direction of the pick ray.
711  * \param collisionPoint If this method returns true, this Vector will contain the location that was hit in logical coordinates.
712  * \return boolean indicating if the object was hit by the pick ray.
713  */
714  virtual GLS_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint );
715 
716  /** 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
717  * If Pickable() == PICK_BEST it will return the closest point that was hit, otherwise it returns the first point that was hit.
718  * This method should not pick points behind the viewer.
719  *
720  * \param x X coordinate of pick ray start in logical coordinates.
721  * \param y Y coordinate of pick ray start in logical coordinates.
722  * \param y Y coordinate of pick ray start in logical coordinates.
723  * \param z Z coordinate of pick ray start in logical coordinates.
724  * \param scale The scale factor of the window. Affects picking of outlines. Standard value is 1.0.
725  * \param vertices An array of vertices describing the Object.
726  * \param vertex_cnt Size of the vertices array.
727  * \param directionVector The direction of the pick vector.
728  * \param collisionPoint If this method returns true, this Vector will contain the location that was hit in logical coordinates.
729  * \return True if click is inside, false otherwise.
730  *
731  * Comment: The hit determination algorithm is based on the principle
732  * that a point is inside a polygon if a line drawn through the
733  * point intersects an even number of edges.
734  */
735  virtual GLS_EXPORT bool HitUtil( float x, float y, float z, float scale, Vertex* vertices, unsigned int vertex_cnt, const Vector& directionVector, Vector* collisionPoint );
736 
737  /** Insert a vertex at \a index. Duplicate the vertex pointed to
738  * by \a index, so that there are two vertices that are exactly the same.
739  * If \a index is greater than the number of vertices, then the last vertex is duplicated.
740  */
741  virtual GLS_EXPORT void InsertVertexAt( unsigned int index );
742 
743  /** Insert a new vertex into the vertex array, duplicating the vertex at (indexAfter - 1).
744  * \param indexAfter One past the index to insert. The vertex before this (or the last vertex,
745  * if more than the number of vertices) will be duplicated. If 0, the 0th vertex
746  * will be duplicated.
747  * \deprecated New code should use InsertVertexAt().
748  * \note This virtual function is kept for backwards compatibility only. It is marked 'final'
749  * (where supported). Subclasses should override InsertVertexAt() instead.
750  */
751  DISTI_DEPRECATED( "User code should use InsertVertexAt()." )
752  virtual GLS_EXPORT void InsertVertex( unsigned int indexAfter ) DISTI_FINAL
753  {
754  InsertVertexAt( indexAfter > 0 ? indexAfter - 1 : 0 );
755  }
756 
757  /** Gets the name for the object.
758  * \return The name of the object
759  */
760  GLS_EXPORT char* InstanceName( void );
761  GLS_EXPORT const char* InstanceName( void ) const;
762 
763  /** Sets the name for the object. This name corresponds to the name
764  * that is generated in the source code.
765  * \param name The new name for the object
766  */
767  GLS_EXPORT void InstanceName( const char* name );
768 
769  /** Gets the lighting state */
770  virtual GLS_EXPORT bool LightingEnabled();
771 
772  /** Sets the lighting state */
773  virtual GLS_EXPORT void LightingEnabled( bool lighting );
774 
775  /** Get the line stipple multiplier for this object
776  * \return The line stipple multiplier for this object
777  */
778  virtual GLS_EXPORT int LineStippleMultiplier( void );
779 
780  /** Set the line stipple multiplier for this object
781  * \param mult The new line stipple pattern
782  */
783  virtual GLS_EXPORT void LineStippleMultiplier( int mult );
784 
785  /** Get the line stipple pattern for this object
786  * \return The line stipple pattern for this object
787  */
788  virtual GLS_EXPORT int LineStipplePattern( void );
789 
790  /** Set the line stipple pattern for this object
791  * \param pattern The new line stipple pattern
792  */
793  virtual GLS_EXPORT void LineStipplePattern( int pattern );
794 
795  /** Gets the width of lines in the object.
796  * \return The line width of the object in logical units
797  */
798  virtual GLS_EXPORT float LineWidth( void );
799 
800  /** Sets the width of lines in the object.
801  * \param width The new line width of the object in logical units
802  */
803  virtual GLS_EXPORT void LineWidth( float width );
804 
805  /** \return The location of the origin of the object
806  * Lifetime is guaranteed to coincide with the DisplayObject's lifetime.
807  */
808  virtual GLS_EXPORT const Vertex& Location( void ) const;
809 
810  /** Sets the location of the origin of the object
811  * \param v The new location
812  */
813  virtual GLS_EXPORT void Location( const Vertex& v );
814 
815  /** Sets the location of the origin of the object
816  * \param x X Coordinate of the new location
817  * \param y Y Coordinate of the new location
818  * \param z Z Coordinate of the new location
819  */
820  virtual GLS_EXPORT void Location( float x, float y, float z );
821 
822  /** Gets the location of the origin of the object
823  * \param v Will be filled in with the current location
824  */
825  virtual GLS_EXPORT void GetLocation( Vertex& v );
826 
827  /** Gets the location of the origin of the object
828  * \param x Will be filled in with the x coordinate
829  * \param y Will be filled in with the y coordinate
830  * \param z Will be filled in with the z coordinate
831  */
832  virtual GLS_EXPORT void GetLocation( float& x, float& y, float& z );
833 
834  /** \return X component of location */
835  inline float X( void ) const { return Location().x; }
836 
837  /** \return Y component of location */
838  inline float Y( void ) const { return Location().y; }
839 
840  /** \return Z component of location */
841  inline float Z( void ) const { return Location().z; }
842 
843  /** Sets x component of location */
844  inline void X( const float x ) { Location( x, Y(), Z() ); }
845 
846  /** Sets y component of location */
847  inline void Y( const float y ) { Location( X(), y, Z() ); }
848 
849  /** Sets z component of location */
850  inline void Z( const float z ) { Location( X(), Y(), z ); }
851 
852  /** Gets material index. Returns -1 if multiple are applied. */
853  virtual GLS_EXPORT int MaterialIndex();
854 
855  /** Sets the material index. */
856  virtual GLS_EXPORT void MaterialIndex( int index );
857 
858  /** Gets a vector of material indices. */
859  virtual GLS_EXPORT DynamicArray<int>& MaterialIndices();
860 
861  /** Sets the vector of material indices. */
862  virtual GLS_EXPORT void MaterialIndices( DynamicArray<int> indices );
863 
864  /** \return The saved Model matrix, if any. Normally not used by the user.*/
865  GLS_EXPORT GlsMatrixType* ModelMatrix();
866 
867  /** \return true if Calculate() needs to be called on this object */
868  inline bool NeedCalculate() { return _needCalculate; }
869 
870  /** Gets the object's normals.
871  * \return Pointer to the object's normal vertex array
872  */
873  inline Vector* Normals() { return ( _normals ); }
874 
875  /** Sets the vertex normal data for this object
876  * \param nPoints The number of vertices in the object
877  * \param vertices The vertex normals for the object
878  */
879  virtual GLS_EXPORT void SetNormals( unsigned int nPoints, Vector* vertices );
880 
881  /** Sets the vertex normal data for this object
882  * \param nPoints The number of vertices in the object
883  * \param ... X,Y,Z for each vertex normal
884  */
885  GLS_EXPORT void VaSetNormals( unsigned int nPoints, ... );
886 
887  /** Gets the object's number of vertices.
888  * \return The integer number of vertices in the object
889  */
890  inline unsigned int NumberOfVertices() const { return ( _nVertices ); }
891 
892  /** Get the depth (in the Z Dimension) of the object in logical units. Value is based on the
893  * extents of the object and does not take into consideration dynamic rotation
894  * \return The depth in logical units (based on extents in the Z Dimension)
895  */
896  virtual GLS_EXPORT float ObjectDepth( void );
897 
898  /** Get the height (in the Y Dimension) of the object in logical units. Value is based on the
899  * extents of the object and does not take into consideration dynamic rotation
900  * \return The height in logical units (based on extents in the Y Dimension)
901  */
902  virtual GLS_EXPORT float ObjectHeight( void );
903 
904  /** Get the width (in the X Dimension) of the object in logical units. Value is based on the
905  * extents of the object and does not take into consideration dynamic rotation
906  * \return The width in logical units (based on extents in the X Dimension)
907  */
908  virtual GLS_EXPORT float ObjectWidth( void );
909 
910  /** Redefines the frame of reference for the object. Since the vertices in the object are
911  * specified relative to the _location member, this routine allows you to specify the
912  * absolute coordinate for _location and then recalculates the vertices to be relative to that
913  * new location
914  * \param vert The new origin point for the object
915  */
916  virtual GLS_EXPORT void SetOrigin( const Vertex& vert );
917 
918  /** Sets the parent display frame pointer for this object to the indicated display frame
919  * \param par The new display frame to be the parent object
920  */
921  virtual GLS_EXPORT void Parent( DisplayFrame* par );
922 
923  /** Gets the parent display frame pointer for this object
924  * \return The parent display frame of this object
925  */
926  inline DisplayFrame* Parent( void ) const { return _parent; }
927 
928  /** Sets the parentGroup pointer for this object
929  * \param group The group to which this object belongs
930  */
931  virtual GLS_EXPORT void ParentGroup( Group* group );
932 
933  /** Gets the parentGroup pointer for this object
934  * \return The group to which this object belongs
935  */
936  inline Group* ParentGroup( void ) const { return _parentGroup; }
937 
938  /** Attempts to pick an object in 3D and accounting for dynamic rotations and translations of this object or
939  * parent objects. It also looks at the pickable status and attempts to return the "Best" pick if that is
940  * what is desired.
941  *
942  * Note: This method will pick objects in the scene based on a pick ray starting at winLoc and pointing into the screen.
943  * It will not pick objects behind the depth specified by winLoc.z. Typically winLoc.z should be set to 0 to ensure that
944  * the pick ray starts at near clip plane.
945  *
946  * \param winLoc Device coordinates for the mouse click. Z value should be set to 0 to ensure pick ray starts at near clip plane.
947  * \param logicalCoords The start of the pick ray in logical coordinates. Should be calculated from the winLoc using this->WindowToLogical(winLoc, logicalCoords, &directionVector).
948  * \param scale Current window scale. Affects picking radius of outlines. Initial value should typically be 1.0.
949  * \param directionVector The direction of the pick ray in logical coordinates. Should be calculated from the winLoc using this->WindowToLogical(winLoc, logicalCoords, &directionVector).
950  * \param collisionWinLoc Returns where the pick vector intersects the object that is hit in device coordinates.
951  * \param drawnMatrices The matrices used to draw the object, including matrices set by parents that may have
952  * dynamically rotated, translated or scaled this object. Initial value should typically be a default OpenGLMatrices() object.
953  *
954  * \return The object that was hit, or NULL if no object hit
955  */
956  virtual GLS_EXPORT DisplayObject* Pick3D( const Vector& winLoc,
957  const Vector& logicalCoords,
958  float scale,
959  const Vector& directionVector,
960  Vector& collisionWinLoc, /*Returned*/
961  const OpenGLMatrices& drawnMatrices );
962 
963  /** Get the pickable state for this object
964  * \return The pick mode
965  * \sa PickableType_e
966  */
967  inline unsigned char Pickable() { return _pickable; }
968 
969  /** Set the pickable state for this object
970  * \param pick The pick mode
971  * \sa PickableType_e
972  */
973  virtual GLS_EXPORT void Pickable( unsigned char pick );
974 
975  /* Gets the polygon offset (Z buffer offset) for this object
976  * \return mode The new polygon offset for this object
977  * Currently unused.
978  */
979  virtual GLS_EXPORT int PolygonOffset( void ) const;
980 
981  /* Sets the polygon offset (Z buffer offset) for this object
982  * \param mode The new polygon offset for this object
983  * Currently unused.
984  */
985  virtual GLS_EXPORT void PolygonOffset( const int offset );
986 
987  /** Gets the polygon end mode (Open or Closed) for the polygon
988  * \return Enumeration indicating open or closed mode
989  * \sa PolygonClose_e
990  */
991  virtual GLS_EXPORT int PolygonEnd( void );
992 
993  /** Sets the polygon end mode (Open or Closed) for the polygon
994  * \param end Enumeration indicating open or closed mode
995  * \sa PolygonClose_e
996  */
997  virtual GLS_EXPORT void PolygonEnd( const int end );
998 
999  /** Gets the polygon drawing mode for this object
1000  * \return The polygon drawing mode for this object
1001  * \sa PolygonMode_e
1002  */
1003  virtual GLS_EXPORT int PolygonMode( void );
1004 
1005  /** Sets the polygon drawing mode for this object
1006  * \param mode The new polygon drawing mode for this object
1007  * \sa PolygonMode_e
1008  */
1009  virtual GLS_EXPORT void PolygonMode( int mode );
1010 
1011  /** Traverses the hierarchy calculating the
1012  * _modelMatrix, _projMatrix, _viewMatrix as needed.
1013  * \param current Current matrices inherited from parent
1014  * \param culler Object that possibly marks this object for culling
1015  */
1016  virtual GLS_EXPORT void PreDraw( const OpenGLMatrices& current, Culler& culler );
1017 
1018  /** \return The saved Projection matrix, if any. Normally not used by the user.
1019  */
1020  GLS_EXPORT GlsMatrixType* ProjMatrix();
1021 
1022  /** Reallocates the vertex and texture coordinate and normal arrays. Existing vertices are
1023  * copied . If the new size is less than the old size, the first numVertices vertices are
1024  * copied. If the new size is larger, all vertices are copied and the new vertices are
1025  * initialized to zero.
1026  * \param numVertices The new number of vertices for the object
1027  * \param initializeNew Whether or not to initialize the new vertices
1028  * \param copyOld Whether or not to copy the old data
1029  */
1030  virtual GLS_EXPORT void ReallocateVertices( unsigned int numVertices, bool initializeNew, bool copyOld );
1031 
1032  /** Return the relative angle of an line constructed from the given point
1033  * to the _location of the object, (in the xy plane)
1034  * \param x X coordinate of endpoint
1035  * \param y Y coordinate of endpoint
1036  * \return Relative angle in degrees
1037  */
1038  virtual GLS_EXPORT float RelativeAngle( const float x, const float y );
1039 
1040  /** Gets a reference to the specified attribute for reading and writing.
1041  * This reference can be streamed into and out of variables.
1042  * For Example: someObject->Resource("Visible") >> someBool;
1043  * someBool << someObject->Resource("Visible");
1044  */
1045  virtual GLS_EXPORT DistiAttributeBase& Resource( const char* name );
1046 
1047  /** Writes the resources (attributes) of this object to the specified stream.
1048  * The output of this method can be controlled by the GlsResourceFilter.
1049  * Note that if filter->NamesOnly() is false (the default), then only resources
1050  * that can return a value will appear in the list.
1051  *
1052  * \sa GlsResourceFilter
1053  * \sa DistiAttributeProperty
1054  * \param outstr The stream to write to
1055  * \param filter The filter to determine what to write
1056  */
1057  virtual GLS_EXPORT void GetResources( std::ostream& outstr, GlsResourceFilter* filter = NULL );
1058 
1059 #ifndef GLES
1060  /** Restores the alpha test/blend settings if they were changed from default
1061  * \sa SetupAlpha
1062  */
1063  GLS_EXPORT void RestoreAlpha( void );
1064 
1065  /** Restores the antialias settings if they were changed from default
1066  * \sa SetupAntiAlias
1067  */
1068  GLS_EXPORT void RestoreAntiAlias( void );
1069 
1070  /** Restores the lighting state
1071  * \sa SetupLighting
1072  */
1073  GLS_EXPORT void RestoreLighting( void );
1074 
1075  /** Sets the line style settings to their defaults
1076  * \sa SetupLineStyle
1077  */
1078  GLS_EXPORT void RestoreLineStyle( void );
1079 #endif
1080 
1081  /** \return The rotation point for the object.
1082  * Lifetime is guaranteed to coincide with the DisplayObject's lifetime.
1083  */
1084  const Vertex& RotationPoint() const { return _rotationPoint; }
1085 
1086  /** Sets the location of the rotation point for the object. Dynamic
1087  * rotation of the object will cause the object to be rotated around this
1088  * point.
1089  * \param v The new rotation point
1090  */
1091  virtual GLS_EXPORT void RotationPoint( const Vertex& v );
1092 
1093  /** Sets the location of the rotation point for the object. Dynamic
1094  * rotation of the object will cause the object to be rotated around this
1095  * point.
1096  * \param x X Coordinate of the new rotation point
1097  * \param y Y Coordinate of the new rotation point
1098  * \param z Z Coordinate of the new rotation point
1099  */
1100  virtual GLS_EXPORT void RotationPoint( float x, float y, float z );
1101 
1102  /** Gets the location of the rotation point for the object.
1103  * \param v Will be filled in with the current rotation point
1104  */
1105  virtual GLS_EXPORT void GetRotationPoint( Vertex& v );
1106 
1107  /** Rotates the object (around the specified axis) by the angle
1108  * indicated, at the object's rotation point. Recalculates the
1109  * vertex data.
1110  * \param angle The angle to rotate by, in degrees
1111  * \param axis The axis to rotate the object around.
1112  */
1113  virtual GLS_EXPORT void Rotate( float angle, int axis = Z_AXIS );
1114 
1115  /** Rotates the object (around the specified axis) by the angle indicated,
1116  * at the point specified. Recalculates the vertex data.
1117  * \param origin The point to rotate around
1118  * \param angle The angle to rotate by, in degrees
1119  * \param axis The axis to rotate the object around
1120  */
1121  virtual GLS_EXPORT void Rotate( const Vector& origin, float angle, int axis = Z_AXIS );
1122 
1123  /** Rotates the object (around the specified axis) by the angle indicated,
1124  * at the point specified. Recalculates the vertex data.
1125  * \param orig The point to rotate around
1126  * \param angle The angle to rotate by, in degrees
1127  * \param axis The arbitrary axis to rotate the object around
1128  */
1129  virtual GLS_EXPORT void Rotate( const Vector& orig, float angle, const Vector& axis );
1130 
1131  /** Causes the Projection, Model and View matrix for this object to be saved. Used by the 3D
1132  * picking algorithm. Normally not used by the user.
1133  */
1134  GLS_EXPORT void SaveMatrices();
1135 
1136  /** Scales the object, either the handleBar, or the Anchor is
1137  * used to translate the object, not both. Anchor takes
1138  * presidence, if it is set HandleBar is ignored.
1139  * The footprint is different from the 2D scale so the compiler can destinguish the two.
1140  * \param px Value of the percentage of scale in x-axis
1141  * \param py Value of the percentage of scale in y-axis
1142  * \param pz Value of the percentage of scale in z-axis
1143  * \param anchor Anchor from which to scale object relative to
1144  * \param handleBar Vertex that is being dragged
1145  */
1146  virtual GLS_EXPORT void Scale( float px, float py, float pz, Vertex* anchor, int handleBar = 0 );
1147 
1148  /** Set attributes of the object using VarArgs style interface
1149  * Object attributes are defined with an enumeration. This
1150  * routine is designed to make generated code very clean and readable.
1151  * \sa GLS_Initializers
1152  */
1153  GLS_EXPORT void Set( int spec, ... );
1154 
1155  /** Sets the alpha test/blend settings based on object settings
1156  * \sa RestoreAlpha
1157  */
1158  GLS_EXPORT bool SetupAlpha( void );
1159 
1160 #ifndef GLES
1161  /** Sets the antialias settings based on object settings
1162  * \sa RestoreAntiAlias
1163  */
1164  GLS_EXPORT bool SetupAntiAlias( void );
1165 #endif
1166 
1167  /** Sets the depth test settings based on object settings */
1168  GLS_EXPORT void SetupDepthTest( void );
1169 
1170  /** Sets the lighting state
1171  * \sa RestoreLighting
1172  */
1173  GLS_EXPORT void SetupLighting( void );
1174 
1175  /** Sets the line style settings based on object settings
1176  * \return True if the line style was set. If this method returns true
1177  * then the object must call RestoreLineStyle to cleanup
1178  * \sa RestoreLineStyle
1179  */
1180  GLS_EXPORT bool SetupLineStyle( void );
1181 
1182 #if !defined( GLES )
1183  /** Sets the polygon draw style based on object settings */
1184  GLS_EXPORT void SetupPolyDrawStyle( void );
1185 
1186  /** Sets the shading settings based on object settings */
1187  GLS_EXPORT void SetupShading( void );
1188 #endif
1189 
1190  /** First half of texture setup for the object.
1191  * \return True if the object will be textured False otherwise.
1192  * If this method returns true, then the caller needs to do
1193  * a glDisable(GL_TEXTURE_2D) afterwards to cleanup
1194  */
1195  GLS_EXPORT bool SetupTexture( void );
1196 
1197  /** Gets the polygon shading mode (Flat or gouraud) for the polygon
1198  * \return Enumeration indicating shading mode
1199  * \sa ShadingType_e
1200  */
1201  virtual GLS_EXPORT int Shading( void );
1202 
1203  /** Sets the polygon shading mode (Flat or gouraud) for the polygon
1204  * \param shading Enumeration indicating shading mode
1205  * \sa ShadingType_e
1206  */
1207  virtual GLS_EXPORT void Shading( const int shading );
1208 
1209  /** Determines the static extents of the geometry projected to the XY plane of an arbirary coordinate system.
1210  * \param min Returns the minimum values found in the traversal
1211  * \param max Returns the maximum values found in the traversal
1212  * \param matrix Transformation matrix from logical coordinates to the coordinate system to determine the extents in.
1213  * \param resetMinMax Normally not specified by user. Should be true for the initial call.
1214  */
1215  virtual GLS_EXPORT void GetTransformedExtents( Vector& min, Vector& max, const GlsMatrixType& matrix, bool resetMinMax = true );
1216 
1217  /** Sets the texture coordinate data for this object
1218  * \param nPoints The number of texture vertices in the object
1219  * \param new_tex_coord The texture coordinates for the object
1220  * \param isVectorArray true if array points to a Vector array, false if it
1221  * points to a Vertex array
1222  * \sa TextureCoordinates()
1223  * \sa VaSetTexCoords()
1224  * \sa SetTexCoords()
1225  */
1226  virtual GLS_EXPORT void SetTexCoords( unsigned int nPoints, Vector* new_tex_coord, bool isVectorArray = true );
1227 
1228  /** Vertex version of SetTexCoords
1229  * \sa VaSetTexCoords()
1230  * \sa TextureCoordinates()
1231  */
1232  void SetTexCoords( unsigned int nPoints, Vertex* new_tex_coord )
1233  {
1234  SetTexCoords( nPoints, new_tex_coord, false );
1235  }
1236 
1237  /** Sets the texture coordinate data for this object
1238  * \param nPoints The number of texture vertices in the object
1239  * \param ... X,Y,Z for each vertex
1240  * \sa TextureCoordinates()
1241  * \sa GetTextureCoordinates()
1242  */
1243  GLS_EXPORT void VaSetTexCoords( unsigned int nPoints, ... );
1244 
1245  /** Gets the object's texture coordinates
1246  * \note Texture Coordinates are vertex attributes. They can be two-dimensional
1247  * (UV-coordinates) or three-dimensional (UVW-coordinates). The texture coordinates at each
1248  * vertex are interpolated across the triangle generated from those vertices to determine
1249  * where to sample the texture applied to the object.
1250  * \note Some shaders use UVW coordinates as an input, but use them for some other purpose than texturing.
1251  * \return Pointer to the object's texture coordinate array. NULL if the object is not textured.
1252  * \sa GetTextureCoordinates()
1253  * \sa VaSetTexCoords()
1254  * \sa SetTexCoords()
1255  * \sa GetTexturePoints()
1256  */
1257  Vector* TextureCoordinates( void ) { return _texCoord; }
1258 
1259  /** Gets the object's texture coordinates
1260  * \return Pointer to the object's texture coordinate array. NULL if the object is not textured.
1261  * \sa TextureCoordinates()
1262  * \sa GetTexturePoints()
1263  */
1265 
1266  /** Get the texture index for this object
1267  * \return The texture index for this object
1268  */
1269  virtual GLS_EXPORT int TextureIndex( void );
1270 
1271  /** Sets the texture index to be used when drawing the object.
1272  * \param textureIndex The texture index to use.
1273  * -1 indicates that no texture will be drawn.
1274  */
1275  virtual GLS_EXPORT void TextureIndex( int textureIndex );
1276 
1277  /** Gets the object's texture points
1278  * \return Pointer to the object's texture point array.
1279  * \note For most DisplayObjects, the Texture Points are used to compute the texture coordinates.
1280  * The TexturePoints are four vertices that describe where the "corners" of the texture is in
1281  * Vertex Coordinates (i.e., the object's parent's logical coordinate space translated to
1282  * the object location). The DisplayObject then uses a projection to compute the texture
1283  * coordinates from these points. The most common is a Planar mapping, but a few objects
1284  * use other mappings (e.g. Spherical or Cylindrical).
1285  * \sa TextureCoordinates()
1286  * \sa GetTextureCoordinates()
1287  */
1288  virtual GLS_EXPORT Vector* GetTexturePoints( void );
1289 
1290  /** Gets the texturing repeat mode for this object
1291  * \return The texture repeat mode for this object
1292  */
1293  virtual GLS_EXPORT bool TextureRepeat( void );
1294 
1295  /** Sets the texturing repeat mode for this object
1296  * \param rep The new texture repeat mode for this object (boolean)
1297  */
1298  virtual GLS_EXPORT void TextureRepeat( const int rep );
1299 
1300  /** Gets the texturing mapping mode for this object
1301  * \return The texture mapping mode for this object
1302  * \sa TextureMap_e
1303  */
1304  virtual GLS_EXPORT int TextureMappingTechnique( void );
1305 
1306  /** Sets the texturing mapping mode for this object
1307  * \param map The new texture mapping mode for this object
1308  * \sa TextureMap_e
1309  */
1310  virtual GLS_EXPORT void TextureMappingTechnique( const int map );
1311 
1312  /** Gets the texture magnification filter for this object
1313  * \return The texture magnification filter for this object
1314  * \sa TextureFilter_e
1315  */
1316  virtual GLS_EXPORT int TextureMagnificationFilter( void );
1317 
1318  /** Sets the texture magnification filter for this object
1319  * \param filter The new texture magnification filter for this object
1320  * \sa TextureFilter_e
1321  */
1322  virtual GLS_EXPORT void TextureMagnificationFilter( const int filter );
1323 
1324  /** Gets the texture minification filter for this object
1325  * \return The texture minification filter for this object
1326  * \sa TextureFilter_e
1327  */
1328  virtual GLS_EXPORT int TextureMinificationFilter( void );
1329 
1330  /** Sets the texture minification filter for this object
1331  * \param filter The new texture minification filter for this object
1332  * \sa TextureFilter_e
1333  */
1334  virtual GLS_EXPORT void TextureMinificationFilter( const int filter );
1335 
1336  /** Moves the object by the amount indicated.
1337  * \param tr Float[3] array containing the x,y,z amounts to translate by
1338  */
1339  virtual GLS_EXPORT void Translate( float tr[] );
1340 
1341  /** Moves the object by the amount indicated.
1342  * \param x X amount to translate by
1343  * \param y Y amount to translate by
1344  * \param z Z amount to translate by
1345  */
1346  virtual GLS_EXPORT void Translate( float x, float y, float z );
1347 
1348  /** Moves the object's vertices by the amount indicated. Does not change _location.
1349  * \param x X amount to translate by
1350  * \param y Y amount to translate by
1351  * \param z Z amount to translate by
1352  */
1353  virtual GLS_EXPORT void TranslateVertices( float x, float y, float z );
1354 
1355  /** Updates the bounding volume of this object
1356  * This method should be called if the vertices change for picking and
1357  * culling to work correctly.
1358  * This will only update this object. If PerformGroupCullCheck is enabled
1359  * for one of the objects parents, you may also need to call
1360  * CalculateParentBoundingBox() to update all of the objects parents.
1361  */
1362  virtual void GLS_EXPORT UpdateBoundingVolume( void );
1363 
1364  /** Gets the current UserData pointer. UserData is a pointer the user can
1365  * use to attach user defined data to a GL Studio object.
1366  * \return The current UserData pointer
1367  */
1368  void* UserData( void ) const { return _userData; }
1369 
1370  /** Sets the current UserData pointer
1371  * \param data The new UserData pointer
1372  */
1373  void UserData( void* data ) { _userData = data; }
1374 
1375  /** Changes the color of a vertex
1376  * \param vertex 1 based index of the vertex to the change color for
1377  * \param CurrentFillColor The new RGBA (0-255 range) color for the vertex
1378  */
1379  virtual GLS_EXPORT void SetVertexColor( unsigned int vertex, unsigned char CurrentFillColor[] );
1380 
1381  /** Gets the object's vertices.
1382  * You should call UpdateBoundingVolume after changing an object's extents.
1383  * \sa UpdateBoundingVolume
1384  * \return Pointer to the object's vertex array
1385  */
1386  virtual GLS_EXPORT Vertex* Vertices() { return _vertices; }
1387 
1388  /** Sets the vertex data for this polygon
1389  * You should call UpdateBoundingVolume after changing an object's extents.
1390  * \sa UpdateBoundingVolume
1391  * \param nPoints The number of vertices in the object
1392  * \param vertices The vertex data for the object
1393  */
1394  virtual GLS_EXPORT void SetVertices( unsigned int nPoints, Vertex* vertices );
1395 
1396  /** Sets the vertex data for this object
1397  * You should call UpdateBoundingVolume after changing an object's extents.
1398  * \sa UpdateBoundingVolume
1399  * \param nPoints The number of vertices in the object
1400  * \param ... r,g,b,a,x,y,z for each vertex
1401  */
1402  GLS_EXPORT void VaSetVertices( unsigned int nPoints, ... );
1403 
1404 protected:
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 args va_list in the form r,g,b,a,x,y,z for each vertex
1410  */
1411  virtual GLS_EXPORT void VaListSetVertices( unsigned int nPoints, va_list args );
1412 
1413  /** Sets the normal data for this object
1414  * This function is called as part of VaSetNormals( unsigned int, ... )
1415  * \param nPoints The number of normals in the object
1416  * \param args va_list in the form x,y,z for each normal
1417  */
1418  virtual GLS_EXPORT void VaListSetNormals( unsigned int nPoints, va_list args );
1419 
1420  /** Sets the texture coordinate data for this object
1421  * This function is called as part of VaTexCoords( unsigned int, ... )
1422  * \param nPoints The number of texture coordinates in the object
1423  * \param args va_list in the form x,y,z for each texture coordinate
1424  */
1425  virtual GLS_EXPORT void VaListSetTexCoords( unsigned int nPoints, va_list args );
1426 
1427 public:
1428  /** \return The saved View matrix, if any. Normally not used by the user.*/
1429  GLS_EXPORT int* ViewMatrix();
1430 
1431  /** Get the visibility state this object
1432  * \return Whether or not this object is enabled for drawing
1433  */
1434  inline bool Visible( void ) const { return _visible; }
1435 
1436  /** Get the visibility state this object
1437  * \return Whether or not this object is enabled for drawing
1438  */
1439  inline bool Visibility( void ) const { return _visible; }
1440 
1441  /** Set the visiblity state for this object
1442  * \param vis Whether or not enable this object for drawing
1443  */
1444  virtual GLS_EXPORT void Visibility( const bool vis );
1445 
1446  /** Gets the rotation point for the object in world coordinates
1447  * \return The rotation point for the object in world coordinates
1448  */
1449  virtual GLS_EXPORT Vector WorldRotationPoint( void );
1450 
1451  /** Sets the rotation point for the object in world coordinates
1452  * \param vert The rotation point for the object in world coordinates
1453  */
1454  virtual GLS_EXPORT void WorldRotationPoint( const Vector& vert );
1455 
1456  /** Gets a vertex from the object, in World coordinates (i.e. not relative to the location
1457  * as is the case with the Vertices() API call).
1458  * \param i Index of the vertex to get
1459  * \return The vertex
1460  */
1461  virtual GLS_EXPORT Vertex WorldVertex( unsigned int i );
1462 
1463  /** Sets a vertex of the object, in World coordinates (i.e. not relative to the location
1464  * as is the case with the Vertices() API call. )
1465  * \param i The 0 based index of the vertex to get
1466  * \param vert The new vertex value
1467  */
1468  virtual GLS_EXPORT void WorldVertex( unsigned int i, const Vertex& vert );
1469 
1470  /** Convert a point from logical coordinates to window coordinates
1471  * \param logical The point in logical coordinates
1472  * \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.
1473  * \param alternateMatrices When supplied it is used instead of self determined matrices.
1474  */
1475  GLS_EXPORT bool LogicalToWindow( const Vector& logical,
1476  Vector& winLoc, /* .z is 0.0 -> 1.0 */
1477  const OpenGLMatrices& alternateMatrices = OpenGLMatrices() );
1478 
1479  /** Convert a point in window coordinates to logical coordinates
1480  * \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.
1481  * \param logical Coordinate in logical coordinates (returned)
1482  * \param directionVector normal into the screen at the point (returned)
1483  * \param alternateMatrices A Set of matrices that if supplied, will alter the point
1484  */
1485  GLS_EXPORT bool WindowToLogical(
1486  const Vector& winLoc,
1487  Vector& logical, /* returned */
1488  Vector* directionVector = NULL, /* returned if not NULL */
1489  const OpenGLMatrices& alternateMatrices = OpenGLMatrices() );
1490 
1491  /** PROJECT a point from logical coordinates to the object's DCS's XY plane
1492  * \param logicalPoint The original point in logical coordinates
1493  * \param objectLocal The returned point in the objects DCS coordinate system on the XY plane.
1494  * \param directionVector The direction vector to use when projecting the point. If NULL, the point will be converted but not projected.
1495  * \param planeNormal
1496  * \param planePoint
1497  * \param dcsMatrix An alternate DCS matrix to convert to.
1498  */
1499  GLS_EXPORT void LogicalToDCS(
1500  Vector logicalPoint,
1501  Vector& objectLocal, /* returned */
1502  const Vector* directionVector,
1503  const Vector& planeNormal = Vector( 0, 0, 1 ), /* X/Y plane */
1504  const Vector& planePoint = Vector(),
1505  const GlsMatrixType* dcsMatrix = NULL );
1506 
1507  /** Transform a point from the object's DCS coordinate system to the logical coordinate system.
1508  * \param dcsPoint The original point in dcs coordinates
1509  * \param logicalPoint The returned point in the objects DCS coordinate system on the XY plane.
1510  * \param dcsMatrix An alternate DCS matrix to convert from.
1511  */
1512  GLS_EXPORT void DCSToLogical(
1513  Vector dcsPoint,
1514  Vector& logicalPoint, /* returned */
1515  const GlsMatrixType* dcsMatrix = NULL );
1516 
1517 #ifdef GLES
1518  /** Create a new DisplayObject, reading the properties in order from our GLO.
1519  * \param dataStream The GLO data stream we are getting our properties from.
1520  * \param parent The Group that will be this object's parent.
1521  */
1522  GLS_EXPORT bool Create( GlsGloFile& dataStream, Group* parent );
1523 
1524  GLS_EXPORT void GeometryRefresh();
1525 #endif
1526 
1527 protected:
1528 #ifdef GLES
1529  bool _geometryRefresh; /**< Whether or not the geometry needs to be refreshed to the hardware */
1530 
1531  GLS_EXPORT void ApplyTextureMinMagSettings();
1532  GLS_EXPORT void ApplyTextureEnvModeSettings();
1533  GLS_EXPORT bool SetupTextureIsNeeded();
1534 
1535 #endif
1536 
1537  int _alphaMode; /**< Whether or not to perform alpha testing while drawing. */
1538 
1539  bool _antiAlias; /**< Whether or not to perform anti-aliasing while drawing. */
1540 
1541  bool _attributesAdded; /**< True if SetAvailableAttributes has been called. Users should not change this. */
1542 
1543  bool _blinking; /**< Whether or not the blinking mode is turned on */
1544 
1545  float _blinkRate; /**< Number of times per second the object will blink */
1546 
1547  GlsColor _color; /**< The RGBA color for drawing the outline of the object. */
1548 
1549  bool _cullBackFace; /**< Whether or not to remove backfaces */
1550 
1551  GlsMatrixType _dcsMatrix; /**< The dynamic coordinate system. The Dynamic changes to rotation, scale, and translate will
1552  * be modified by this and applied to the _drawMatrix. */
1553 
1554  unsigned char _depthTest; /**< What kind of depth testing while drawing. See DepthBuffer_e*/
1555 
1556  GlsMatrixType* _drawMatrix; /**< The objects current contribution to the draw matrix.
1557  * This will be multiplied by the current matrix at draw time.
1558  * If NULL, this object has no contribution (it is not dynamic)
1559  * See CalcDrawMatrix() for more */
1560 
1561  bool _needCalcDrawMatrix; /** True if CalcDrawMatrix() needs to be called on this object */
1562 
1563  unsigned char _lineStippleMultiplier; /**< The multiplier used when applying a line stipple pattern to a line. */
1564 
1565  unsigned short _lineStipplePattern; /**< A bit pattern indicating which pixels in a line should be drawn and which pixels should not. */
1566 
1567  float _lineWidth; /**< The current width of lines rendered in the object, in logical units */
1568 
1569  Vertex _location; /**< The location of the origin point for this object, in the world coordinate system. */
1570 
1571  DynamicArray<int> _materialIndices;
1572 
1573  GlsMatrixType* _modelMatrix; /**< Stores the Model matrix for this object, if needed. Used by Draw() and 3D picking. */
1574 
1575  Vector* _normals; /**< The array of vertex normals for this object.
1576  * The size of this array is based on _nVertices */
1577 
1578  unsigned int _nTex_vertices; /**< The number of Texture Coordinate Vertices in this object */
1579 
1580  unsigned int _nVertices; /**< The number of vertices in this object */
1581 
1582  unsigned char _polygonEnd; /**< Whether or not this is a CLOSED or OPEN polygon */
1583 
1584  unsigned char _polygonMode; /**< The mode for drawing the object. */
1585 
1586  int _polygonOffset; /**< The depth buffer offset for this object */
1587 
1588  GlsMatrixType* _projMatrix; /**< Stores the Projection matrix for this object, if needed. Used by Draw() and 3D picking. */
1589 
1590  unsigned char _shading; /**< The shading mode for this object */
1591 
1592  Vector* _texCoord; /**< The array of texture coordinates for this object. If an object is untextured,
1593  * this value is NULL. The size of this array is based on _nTex_vertices */
1594 
1595  GlsColor _textureBlendColor; /**< The current texture blend color (used if TextureMapMode is TEXTURE_MAP_BLEND mode only) */
1596 
1597  int _textureIndex; /**< The index into the texture palette array of the texture used to
1598  * to texture this object. A texture index of -1 indicates that no
1599  * texture is assigned to the object. */
1600 
1601  unsigned char _textureMagFilter; /**< The current texturing magnification filter mode for the object */
1602 
1603  unsigned char _textureMinFilter; /**< The current texturing minification filter mode for the object */
1604 
1605  unsigned char _textureMap; /**< The current texturing map mode for the object. */
1606 
1607  Vector _texturePoints[ NUM_TEXTURE_POINTS ]; /**< Used to store the relative placement and rotation of a texture on
1608  * the object. Texture coordinates are calculated from the texture points.
1609  * The _texturePoints are relative to the _location, which makes
1610  * them in the objects coordinate system.
1611  */
1612 
1613  unsigned char _textureRepeat; /**< The current texturing repeat mode for the object. */
1614 
1615  void* _userData; /**< Data pointer for the user to assign as needed */
1616 
1617  Vertex* _vertices; /**< The array of vertices for this object. The vertices are in the object's
1618  * coordinate system. That is, they are relative to the _location field.
1619  * This array always has a size based on _nVertices */
1620 
1621  int* _viewMatrix; /**< Stores the View matrix for this object, if needed. Used by Draw() and 3D picking. */
1622 
1623  bool _visible; /**< Whether or not the object is enabled for drawing */
1624 
1625  virtual GLS_EXPORT int ColorMaterialMode( void );
1626 
1627  /** Allocate the model matrix, if needed */
1628  GLS_EXPORT void AllocateModelMatrix();
1629 
1630  /** Applies dynamic rotation to object, saving the matrix stack
1631  * so that dynamic picking can occur
1632  * \return True if a rotation was performed. False otherwise.
1633  * If this method returns true, then the caller needs to do
1634  * a glPopMatrix to restore the stack after drawing
1635  */
1636  GLS_EXPORT bool ApplyDynamicRotation( void );
1637 
1638  /** Creates and recalculates the _drawMatrix
1639  * If _rotation, _dynamicScale, or _dynamicTranslate change you must call CalcDrawMatrix()
1640  * If _dcsMatrix, _location, or _rotationPoint change you need to call CalcDrawMatrixIfExists()
1641  * These are normally called automatically for you by the API Methods that affect those values.
1642  * Sub-classes may override CalcDrawMatrix() to include additional transformations in the _drawMatrix.
1643  */
1644  virtual GLS_EXPORT void CalcDrawMatrix();
1645 
1646  /** Recalculates the _drawMatrix if it exists.
1647  * See CalcDrawMatrix() for more info. */
1649  {
1650  if( _drawMatrix )
1651  {
1652  CalcDrawMatrix();
1653  }
1654  }
1655 
1656  /** Applies the _drawMatrix to the modelMatrix.
1657  * If necessary derived classes can save other matrices.
1658  * \param newMatrices A set of matrices passed down to this object from its parent.
1659  */
1660  virtual GLS_EXPORT void CalculateMatrices( const OpenGLMatrices& newMatrices );
1661 
1662  /** Returns true if the point is inside the 2D extents of the given vertices
1663  * \param x X coordinate of pick point
1664  * \param y Y coordinate of pick point
1665  * \param nVerts Number of vertices to try
1666  * \param verts Vertex array to try
1667  * \param tolerance Picking tolerance
1668  */
1669  GLS_EXPORT bool InsideVertexExtents( float x, float y, unsigned int nVerts, Vertex* verts, float tolerance );
1670 
1671  /* Used internally to determine if the user has modified the location */
1672  inline void LastDrawMatrixLocation( const Vertex& loc ) { _lastDrawMatrixLocation = loc; }
1673 
1674  /* Used internally to determine if the user has modified the location */
1675  inline const Vertex& LastDrawMatrixLocation() { return _lastDrawMatrixLocation; }
1676 
1677  /** Set the value of _needCalculate */
1678  inline void NeedCalculate( bool val ) { _needCalculate = val; }
1679 
1680  /** Sets up the object for picking by dynamically rotating vertices
1681  * \param x X coordinate of pick point
1682  * \param y Y coordinate of pick point
1683  * \param z Z coordinate of pick point
1684  * \param vertices Vertex array to setup
1685  * \param vertex_cnt Number of vertices to setup
1686  * \param directionVector dynamic rotation vector
1687  */
1688  GLS_EXPORT void PickSetup( float x, float y, float z, Vertex* vertices, unsigned int vertex_cnt, const Vector& directionVector );
1689 
1690  /** Restores the temporarily rotated vertices
1691  * \param vertices Vertex array to restore
1692  * \param vertex_cnt Number of vertices to restore
1693  */
1694  GLS_EXPORT void PickCleanup( Vertex* vertices, unsigned int vertex_cnt );
1695 
1696 #ifdef GLES
1697  /** Set a single attribute from the GLO file.
1698  * \param data The attribute to set and its associated data.
1699  */
1700  virtual GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data );
1701 #endif
1702 
1703  /** Finds three coplanar points and the surface normal, if possible. This calculation is performed using the
1704  * Vertices() of this object. Used in the editor to determine how to map a texture onto an object.
1705  * \param p1 Returns a point on the plane
1706  * \param p2 Returns a point on the plane
1707  * \param p3 Returns a point on the plane
1708  * \param planeVector Returns the surface normal of the plane
1709  * \return True if 3 coplanar points were found
1710  */
1711 public:
1712  virtual GLS_EXPORT bool GetPlaneVectorPoints( Vertex& p1, Vertex& p2, Vertex& p3, Vertex& planeVector );
1713 
1714  /** Implements AttributeChangedNotifier::NotifyAttributeChanged.
1715  * Notify the class that the attribute has changed. Observers of the attribute will have their callbacks called
1716  * \param name the name of the attribute
1717  */
1718  GLS_EXPORT void NotifyAttributeChanged( const AttributeName& name ) DISTI_METHOD_OVERRIDE;
1719 
1720  /** 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
1721  * in a way that affects its rendering.
1722  * \note This object only observers the painter, and does not delete it.
1723  * \param painter the painter that is drawing this class.
1724  */
1725  virtual GLS_EXPORT void SetPainter( GlsPainter* painter );
1726 
1727  /** Returns the painter for this object, or NULL of none. The return value is an observer pointer and should not be deleted
1728  */
1729  GLS_EXPORT virtual GlsPainter* GetPainter();
1730 
1731  /** Invalidates the painter set on this object if that painter exists.
1732  * Typically called by user code when it modifies an object in such a
1733  * way where the painter invalidation system wouldn't work automatically
1734  * (for example, directly modifying vertex data).
1735  */
1736  GLS_EXPORT void InvalidatePainter();
1737 
1738  /** Traverses upward in the hierarchy to determine if this object is visible in the scene.
1739  * Overloaded for classes that handle child visibility without using the Visibility flag such as GlsMutexGroup.
1740  */
1741  GLS_EXPORT virtual bool IsVisibleInScene( const DisplayObject* obj = NULL ) const;
1742 
1743 protected:
1744  /** Sets an attribute of this object using variable arguments
1745  * \param spec A GLS_Initializer tag
1746  * \param args A variable argument list
1747  */
1748  GLS_EXPORT virtual void SetValue( int spec, va_list& args );
1749 
1750 private:
1751  void CopyGeometryInternal( const DisplayObject* src );
1752  void CopyPropertiesInternal( const DisplayObject* src );
1753  void CopyHierarchyPropertiesInternal( const DisplayObject* src, bool copyName );
1754 
1755  DistiAttribDict* _attribDict; /**< Stores all of this object's metadata attributes */
1756 
1757  Vector _boundingVolumeCenter; /**< Center of the bounding volume (relative to Location())*/
1758 
1759  float _boundingVolumeRadius; /**< Radius of the bounding sphere */
1760 
1761  CallbackMethodCallerBase* _callbackCaller; /**< The pointer to the callback caller for this object.
1762  * This is currently unrelated to the InputDevice callback */
1763 
1764  bool _culled; /**< Whether or not this object is currently culled */
1765 
1766  float _dynamicTranslate[ 3 ]; /* The current (dynamic) translation of the object, in logical units and relative to the object's DCS.
1767  * _dynamicTranslate[0] = x traslation
1768  * _dynamicTranslate[1] = y traslation
1769  * _dynamicTranslate[2] = z traslation */
1770 
1771  float _dynamicScale[ 3 ]; /* The current (dynamic) scale of the object */
1772 
1773  EditorObjectBase* _editorObject; /* Used in the editor to access editor functionality */
1774 
1775  char* _instanceName; /**< A unique character string used to identify the object. This name
1776  * will correspond to the name of the C++ member variable generated for
1777  * this object in the output code. */
1778 
1779  Vertex _lastDrawMatrixLocation; /**< The value of _location the last time CalcDrawMatrix() was called */
1780 
1781  bool _lightingEnabled; /**< Stores the lighting enabled state */
1782 
1783  bool _needCalculate; /* true if Calculate() needs be called on this object.
1784  * Defaults to true.
1785  * Calculate() may still be called in some situations */
1786 
1787  DisplayFrame* _parent; /**< The display frame or component that contains this object */
1788 
1789  Group* _parentGroup; /**< The group of which this object is a member */
1790 
1791  GlsPainter* _painter; /** The painter, can be NULL, used for conditional rendering */
1792 
1793  unsigned char _pickable; /**< The type of picking that is enabled for this object */
1794 
1795  float _rotation[ 3 ]; /* The current (dynamic) rotation of the object, in degrees and relative to
1796  * the object's rotation point. Order of rotation is x, then y, then z
1797  * _rotation[0] = x rotation angle
1798  * _rotation[1] = y rotation angle
1799  * _rotation[2] = z rotation angle */
1800 
1801  Vertex _rotationPoint; /* The location, in the object coordinate system, of the point to rotate
1802  * this object around when the object is dynamically rotated.
1803  * So when we want to rotate this object (not just rotate the view), this
1804  * is the point to rotate about. This point is relative to the _location,
1805  * which makes in in the objects coordinate system. */
1806 
1807  GLS_EXPORT void DisplayColorMaterialModeError( const int mode );
1808  GLS_EXPORT int DisplayColorMaterialModeError();
1809 
1810  void CommonConstructorInit( float x, float y, float z );
1811 
1812  /** Callback for when DCS Matrix changes through the resource API */
1813  void OnDCSMatrixChanged();
1814 
1815  /** Callback for when Vertices change through the resource API */
1816  void OnVerticesChanged();
1817 
1818  /** Callback for when Texture coordinates change through the resource API */
1819  void OnTextureCoordsChanged();
1820 
1821  /** Assignment operator not implemented. Use CloneObject() or the copy constructor instead. */
1822  DisplayObject& operator=( const DisplayObject& that ); // = delete
1823 
1824 protected:
1825  /** Returns the local setting for _textureIndex if not -1,
1826  * otherwise returns the group texture index.
1827  */
1828  GLS_EXPORT int GetApplicableTextureIndex();
1829  /** Returns the local setting for _textureRepeat if
1830  * _textureIndex is not -1,
1831  * otherwise returns the group texture repeat setting.
1832  */
1833  GLS_EXPORT int GetApplicableTextureRepeat();
1834 
1835 #ifdef GLES
1836  IGlsStateManager* _stateManager;
1837 #endif
1838 
1839 #ifdef GLES20
1840  IGlsStateManagerES20* _stateManagerES20;
1841 #endif
1842 };
1843 
1844 } // namespace disti
1845 
1846 #endif
Definition: cull.h:49
GlsMatrixType * _drawMatrix
Definition: display.h:1556
float Y(void) const
Definition: display.h:838
GlsColor _textureBlendColor
Definition: display.h:1595
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:1368
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:1232
bool GetTexturePointTransformationMatrix(GlsMatrixType &world2tex)
Vector * _normals
Definition: display.h:1575
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:1569
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:1563
virtual void CopyProperties(DisplayObject *src)
void RestoreAlpha(void)
unsigned short _lineStipplePattern
Definition: display.h:1565
bool _visible
Definition: display.h:1623
DisplayFrame * Parent(void) const
Definition: display.h:926
virtual void VaListSetTexCoords(unsigned int nPoints, va_list args)
unsigned char _textureMagFilter
Definition: display.h:1601
virtual void SetValue(int spec, va_list &args)
Definition: display.h:98
unsigned char _textureMinFilter
Definition: display.h:1603
bool Visible(void) const
Definition: display.h:1434
virtual void SetTexCoords(unsigned int nPoints, Vector *new_tex_coord, bool isVectorArray=true)
bool Visibility(void) const
Definition: display.h:1439
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:873
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:1567
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:841
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:1607
GlsMatrixType * _projMatrix
Definition: display.h:1588
const Vector & BoundingVolumeCenter() const
Definition: display.h:259
Definition: gls_glo_file.h:982
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:1584
float _blinkRate
Definition: display.h:1545
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:1592
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:1578
bool _blinking
Definition: display.h:1543
virtual ~DisplayObject(void)
void Transform(Vector &v) const
Definition: gls_matrix_affine.h:271
VertexNoColor Vector
Definition: gls_font_base.h:66
virtual GlsColor GetFillColor(void)
GlsMatrixType * _modelMatrix
Definition: display.h:1573
virtual Vertex * Vertices()
Definition: display.h:1386
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:1541
float X(void) const
Definition: display.h:835
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:1373
unsigned char _shading
Definition: display.h:1590
void Y(const float y)
Definition: display.h:847
unsigned char _textureRepeat
Definition: display.h:1613
int _polygonOffset
Definition: display.h:1586
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:844
Definition: disti_metadata.h:183
void CalcDrawMatrixIfExists()
Definition: display.h:1648
virtual bool CullBackFace(void)
GlsColor _color
Definition: display.h:1547
void SetupLighting(void)
bool SetupTexture(void)
int _textureIndex
Definition: display.h:1597
Vector * GetTextureCoordinates(void)
Definition: display.h:1264
Definition: events.h:112
Definition: gls_color.h:53
void Z(const float z)
Definition: display.h:850
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:1605
Definition: disti_metadata.h:665
Definition: weak_referenceable_mixin.h:52
#define MAX(A, B)
Definition: util.h:167
unsigned int _nVertices
Definition: display.h:1580
virtual void GetCenter(Vector &center)
void VaSetNormals(unsigned int nPoints,...)
Vector * TextureCoordinates(void)
Definition: display.h:1257
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:1554
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:455
unsigned char Pickable()
Definition: display.h:967
virtual bool AntiAlias(void)
virtual void SetColor(const GlsColor &color)
unsigned char _polygonEnd
Definition: display.h:1582
GlsMatrixType _dcsMatrix
Definition: display.h:1551
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:1537
virtual Vector DynamicTranslation()
void NeedCalculate(bool val)
Definition: display.h:1678
virtual void DeleteVertexAt(unsigned int index)
const Vertex & RotationPoint() const
Definition: display.h:1084
virtual bool Blinking(void)
The GlsPainter interface.
Vertex * _vertices
Definition: display.h:1617
bool NeedCalculate()
Definition: display.h:868
virtual GlsPainter * GetPainter()
virtual bool LightingEnabled()
void * _userData
Definition: display.h:1615
Definition: vertex.h:77
virtual void SetAvailableAttributes(unsigned int value)
Definition: gls_resources.h:50
bool _antiAlias
Definition: display.h:1539
unsigned int NumberOfVertices() const
Definition: display.h:890
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:752
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:1549
virtual void CalcDrawMatrix()
void RestoreAntiAlias(void)
Group * ParentGroup(void) const
Definition: display.h:936
virtual float ObjectWidth(void)
int * _viewMatrix
Definition: display.h:1621
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