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