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