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