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