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