GL Studio C++ Runtime API
gls_3d_cable.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::Gls3DCable class.
3 
4  \par Copyright Information
5 
6  Copyright (c) 2017 by The DiSTI Corporation.<br>
7  11301 Corporate Blvd; Suite 100<br>
8  Orlando, Florida 32817<br>
9  USA<br>
10  <br>
11  All rights reserved.<br>
12 
13  This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19 
20  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26 
27  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35 
36  The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America.
38 */
39 
40 #ifndef _GLS3DCABLE_H
41 #define _GLS3DCABLE_H
42 
43 #include <vector>
44 
45 #include "glpolygon.h"
46 #include "gls_cpp_lang_support.h"
47 #include "gls_quaternion.h"
48 #include "gltrimesh.h"
49 #include "group.h"
50 
51 //////////////////// Provides support for creating DLLs ////////////////////////
52 #if( defined( GLSGEN_EXPORT_GLS3DCABLE ) || defined( GLSGEN_IMPORT_GLS3DCABLE ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
53  && defined( _MSC_VER )
54 # if defined( GLSGEN_EXPORT_GLS3DCABLE ) || defined( GLS_EXPORT_GENERATED )
55 # define GLSGEN_GLS3DCABLE_EXPORT __declspec( dllexport )
56 # else
57 # define GLSGEN_GLS3DCABLE_EXPORT __declspec( dllimport )
58 # endif
59 #else
60 # define GLSGEN_GLS3DCABLE_EXPORT
61 #endif
62 ///////////////////////////////////////////////////////////////////////////////
63 
64 //#ifndef GLS_IMPORT_EDITOR
65 #define LIB_BASE_NAME "gls_3d_cable"
66 #include "gls_auto_lib.h"
67 #undef LIB_BASE_NAME
68 //#endif
69 
70 namespace disti
71 {
72 // SetValue enumerations
73 enum
74 {
75  GLS_3DCABLE_FIRST_VALUE = GLS_LAST_INITIALIZER + 1,
76 
77  GLS_3DCABLE_FLEXIBILITY,
78  GLS_3DCABLE_NUMBEROFSEGMENTS,
79  GLS_3DCABLE_NUMBEROFSIDES,
80  GLS_3DCABLE_RADIUS,
81  GLS_3DCABLE_LENGTH,
82  GLS_3DCABLE_GRAVITY,
83  GLS_3DCABLE_SECTIONSLACKPCT,
84  GLS_3DCABLE_SECTIONFLOORDIST,
85  GLS_3DCABLE_COLLISIONSTYLE,
86  GLS_3DCABLE_FILLCOLOR,
87  GLS_3DCABLE_LINECOLOR
88 };
89 
90 typedef DynamicArray<double, false> DynamicDoubleArray; // Typedef for dynamic array of slack percentges
91 
93 {
94 public:
96  : VertexNoColor()
97  {}
98 
99  PreciseVertex( const Vector& vector )
100  : VertexNoColor( vector.x, vector.y, vector.z )
101  {}
102 
103  PreciseVertex( float x, float y, float z )
104  : VertexNoColor( x, y, z )
105  {}
106 
107  /**
108  If the values are near zero, force them to be Zero!
109  \pre
110  \post
111  */
112  virtual void NearZero()
113  {
114  const float DIFF = 0.0001f;
115 
116  if( BETWEEN( x, 0.0 - DIFF, 0.0 + DIFF ) )
117  {
118  x = 0.0f;
119  }
120 
121  if( BETWEEN( y, 0.0 - DIFF, 0.0 + DIFF ) )
122  {
123  y = 0.0f;
124  }
125 
126  if( BETWEEN( z, 0.0 - DIFF, 0.0 + DIFF ) )
127  {
128  z = 0.0f;
129  }
130  }
131 
132  /** Normalizes the vector into a unit vector */
133  virtual void Normalize( void )
134  {
135  double length = Magnitude();
136 
137  // how close to zero do we want to be?
138  const double DIFF = 0.0001;
139 
140  if( !BETWEEN( length, 0.0 - DIFF, 0.0 + DIFF ) )
141  {
142  // Divide is slow so calculate 1/length and multiply to save time
143  double inv_length = 1.0 / length;
144 
145  x = float( x * inv_length );
146  y = float( y * inv_length );
147  z = float( z * inv_length );
148  }
149  else
150  {
151  x = 0.0f;
152  y = 0.0f;
153  z = 0.0f;
154  }
155  }
156 
157  /** Determines if the vertex is identical to the supplied vertex, ignoring color
158  \param arg vertex to compare to
159  \return TRUE if equal, else FALSE
160  */
161  virtual bool operator==( const VertexNoColor& arg ) const
162  {
163  const double DIFF = 0.0001;
164  return ( BETWEEN( x, arg.x - DIFF, arg.x + DIFF ) && BETWEEN( y, arg.y - DIFF, arg.y + DIFF ) && BETWEEN( z, arg.z - DIFF, arg.z + DIFF ) );
165  }
166 
167  /** Determines if the vertex is identical to the supplied vertex, ignoring color
168  \param arg vertex to compare to
169  \return TRUE if equal, else FALSE
170  */
171  inline bool operator!=( const VertexNoColor& arg ) const
172  {
173  const double DIFF = 0.0001;
174  return ( !BETWEEN( x, arg.x - DIFF, arg.x + DIFF ) || !BETWEEN( y, arg.y - DIFF, arg.y + DIFF ) || !BETWEEN( z, arg.z - DIFF, arg.z + DIFF ) );
175  }
176 };
177 
178 /**
179  Runtime implementation of a Gls3DCable. The Gls3DCable is a cable mesh between
180  two or more endpoint objects. The user controls the length, the flexibility, the
181  diameter, the smoothness (segments and sides), and the droop of the cable.
182 */
183 class Gls3DCable : public Group
184 {
185 public:
186  typedef Group _BaseClass;
187 
188  enum
189  {
190  TEXTUREPOINT_MULT = 50
191  };
192 
193  /** Sides limits */
194  enum
195  {
196  MIN_NUMBER_OF_SIDES = 1,
197  MAX_NUMBER_OF_SIDES = 100 // visually 50 looked good, 100 gives the user room
198  };
199 
200  /** Segement limits */
201  enum
202  {
203  MIN_SEGEMENTS = 1,
204  MAX_SEGEMENTS = 10000 // Seems like 10,000 segements should be way big enough
205  };
206 
207  enum ECollisionStyle
208  {
209  COLLISIONSTYLE_NONE = 0,
210  COLLISIONSTYLE_FAST
211 #if defined( USE_COLLISIONSTYLE_SLOW )
212  ,
213  COLLISIONSTYLE_SLOW
214 #endif
215  };
216 
217  friend class Gls3DCableEditor;
218 
219  /** Create a new Gls3DCable.
220  * \param generateInstance Whether or not to generate an instance name
221  * for this inputdevice
222  */
223  GLSGEN_GLS3DCABLE_EXPORT Gls3DCable( bool generateInstance = false );
224 
225  /* Copy constructor for Gls3DCable
226  * \param that The Gls3DCable to be copied from
227  * \param generateNames Whether or not to generate a new instance name
228  */
229  GLSGEN_GLS3DCABLE_EXPORT Gls3DCable( const Gls3DCable& that, const bool generateNames );
230 
231  /** Destructs a Gls3DCable object */
232  virtual GLSGEN_GLS3DCABLE_EXPORT ~Gls3DCable();
233 
234  static GLSGEN_GLS3DCABLE_EXPORT DisplayObject* CreateInstance();
235 
236  //////////////////////////////////////////////////
237  // Overridden base class methods
238  // The base class methods are overridden so that the Group Class methods
239  // are not called, generally DisplayObject methods are called, there
240  // are a few exceptions.
241  //////////////////////////////////////////////////
242 
243  virtual void GetResources( std::ostream& outstr, GlsResourceFilter* filter );
244  virtual DistiAttributeBase& Resource( const char* name );
245 
246  virtual GLSGEN_GLS3DCABLE_EXPORT void SetAvailableAttributes( unsigned int value );
247  virtual GLSGEN_GLS3DCABLE_EXPORT DisplayObject* CloneObject( bool generateNames = false );
248  virtual GLSGEN_GLS3DCABLE_EXPORT void CopyProperties( DisplayObject* src );
249 
250  virtual GLSGEN_GLS3DCABLE_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL );
251  virtual GLSGEN_GLS3DCABLE_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array );
252 
253  virtual GLSGEN_GLS3DCABLE_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices, Culler& culler );
254  virtual GLSGEN_GLS3DCABLE_EXPORT void Draw( void );
255 
256  virtual GLSGEN_GLS3DCABLE_EXPORT void Calculate( double time );
257 
258  virtual GLSGEN_GLS3DCABLE_EXPORT DisplayObject* handle( DisplayEvent* ev );
259 
260  virtual GLSGEN_GLS3DCABLE_EXPORT void SetValue( int spec, va_list& args );
261 
262  virtual GLSGEN_GLS3DCABLE_EXPORT void CalculateBoundingBox( void );
263 
264  /** Determines if the indicated x,y,z point is inside the object. This is
265  * used by the editor to determine which object a user clicked on. It
266  * is also used in the generated code to send mouse events to the
267  * graphical objects for processing
268  * \param x X coordinate of mouse click
269  * \param y Y coordinate of mouse click
270  * \param z Z coordinate of mouse click
271  * \param scale The scale factor of the window
272  * \param directionVector The direction of the pick vector. Vector(0.0f, 0.0f, 1.0f) is for picking in the XY plane
273  * \param collisionPoint Returns the collision point
274  * \return boolean indicating if the object was hit by the mouse
275  */
276  virtual GLSGEN_GLS3DCABLE_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint );
277 
278  virtual GLSGEN_GLS3DCABLE_EXPORT DisplayObject* Pick3D( const Vector& winLoc, const Vector& logicalCoords, float scale,
279  const Vector& directionVector, Vector& collisionWinLoc, const OpenGLMatrices& parentDrawn );
280 
281  virtual GLSGEN_GLS3DCABLE_EXPORT void CalculateTextureCoordinates( void );
282 
283  virtual GLSGEN_GLS3DCABLE_EXPORT void LineWidth( float width );
284  virtual GLSGEN_GLS3DCABLE_EXPORT float LineWidth( void );
285 
286  virtual GLSGEN_GLS3DCABLE_EXPORT void LineStipplePattern( int pattern );
287  virtual GLSGEN_GLS3DCABLE_EXPORT int LineStipplePattern( void );
288 
289  virtual GLSGEN_GLS3DCABLE_EXPORT void LineStippleMultiplier( int mult );
290  virtual GLSGEN_GLS3DCABLE_EXPORT int LineStippleMultiplier( void );
291 
292  virtual GLSGEN_GLS3DCABLE_EXPORT int PolygonMode( void );
293  virtual GLSGEN_GLS3DCABLE_EXPORT void PolygonMode( int mode );
294 
295  virtual GLSGEN_GLS3DCABLE_EXPORT void PolygonEnd( const int mode );
296  virtual GLSGEN_GLS3DCABLE_EXPORT int PolygonEnd( void );
297 
298  virtual GLSGEN_GLS3DCABLE_EXPORT void Shading( const int mode );
299  virtual GLSGEN_GLS3DCABLE_EXPORT int Shading( void );
300 
301  virtual GLSGEN_GLS3DCABLE_EXPORT void DepthTest( unsigned char mode );
302  virtual GLSGEN_GLS3DCABLE_EXPORT int DepthTest( void );
303 
304  virtual GLSGEN_GLS3DCABLE_EXPORT void AntiAlias( bool mode );
305  virtual GLSGEN_GLS3DCABLE_EXPORT bool AntiAlias( void );
306 
307  virtual GLSGEN_GLS3DCABLE_EXPORT void AlphaMode( int mode );
308  virtual GLSGEN_GLS3DCABLE_EXPORT int AlphaMode( void );
309 
310  virtual GLSGEN_GLS3DCABLE_EXPORT void CullBackFace( const bool mode );
311  virtual GLSGEN_GLS3DCABLE_EXPORT bool CullBackFace( void );
312 
313  virtual GLSGEN_GLS3DCABLE_EXPORT bool LightingEnabled();
314  virtual GLSGEN_GLS3DCABLE_EXPORT void LightingEnabled( bool lighting );
315 
316  virtual GLSGEN_GLS3DCABLE_EXPORT void SetBlendColor( const GlsColor& color );
317  virtual GLSGEN_GLS3DCABLE_EXPORT GlsColor GetBlendColor( void );
318 
319  virtual GLSGEN_GLS3DCABLE_EXPORT void SetColor( const GlsColor& color );
320  virtual GLSGEN_GLS3DCABLE_EXPORT GlsColor GetColor( void );
321 
322  virtual GLSGEN_GLS3DCABLE_EXPORT void SetFillColor( const GlsColor& color );
323  virtual GLSGEN_GLS3DCABLE_EXPORT GlsColor GetFillColor( void );
324 
325  virtual GLSGEN_GLS3DCABLE_EXPORT void TextureRepeat( const int rep );
326  virtual GLSGEN_GLS3DCABLE_EXPORT bool TextureRepeat( void );
327 
328  virtual GLSGEN_GLS3DCABLE_EXPORT void TextureMappingTechnique( const int map );
329  virtual GLSGEN_GLS3DCABLE_EXPORT int TextureMappingTechnique( void );
330 
331  virtual GLSGEN_GLS3DCABLE_EXPORT void TextureMinificationFilter( const int filter );
332  virtual GLSGEN_GLS3DCABLE_EXPORT int TextureMinificationFilter( void );
333 
334  virtual GLSGEN_GLS3DCABLE_EXPORT void TextureMagnificationFilter( const int filter );
335  virtual GLSGEN_GLS3DCABLE_EXPORT int TextureMagnificationFilter( void );
336 
337  //////////////////////////////////////////////////
338  // Gls3DCable specific operations
339  //////////////////////////////////////////////////
340 
341  /** Sets flexibility.
342  * \param value Controls how stiff the cable is. The value should be in the
343  range of 0 to 1, inclusive. 0 is very inflexible, while 1 is very flexible.
344  \pre value must be in the range of 0 to 1
345  \post None
346  */
347  GLSGEN_GLS3DCABLE_EXPORT void Flexibility( const float& value );
348  /** Gets flexibility.
349  * \return How stiff the cable is.
350  */
351  GLSGEN_GLS3DCABLE_EXPORT float Flexibility();
352 
353  /** Sets Number of Segements.
354  * \param value The number of cylindrical segments that will traverse
355  * the entire length of the cable. A cable with one section
356  * (that is, with only two control objects) would be a straight cylinder
357  * connecting two points, incapable of bending.
358  * The higher this number, the smoother your cable will appear.
359  \pre value must be in the range MIN_SEGEMENTS to MAX_SEGEMENTS
360  \post none
361  */
362  GLSGEN_GLS3DCABLE_EXPORT void NumberOfSegments( const unsigned int& value );
363 
364  /** Gets the Number of Segements.
365  * \return The Number of Segments
366  */
367  GLSGEN_GLS3DCABLE_EXPORT unsigned int NumberOfSegments();
368 
369  /** Sets the Number Of Sides.
370  * \param value The number of sides the cable "tube" will have.
371  * The more sides, the smoother the cable will appear.
372  * A value of two will produce a ribbon-like cable.
373  * A value of one will render only a line.
374  \pre value must be in the range of 1 to 100 inclusive.
375  \post None
376  */
377  GLSGEN_GLS3DCABLE_EXPORT void NumberOfSides( const unsigned int& value );
378 
379  /** Gets the Number of Sides.
380  * \return The number of sides
381  */
382  GLSGEN_GLS3DCABLE_EXPORT unsigned int NumberOfSides();
383 
384  /** Sets the Radius of the cable in logical units
385  \param value The radius in logical units.
386  \pre value must be plus/minus MAX_FLT
387  \post none
388  */
389  GLSGEN_GLS3DCABLE_EXPORT void Radius( const float& value );
390 
391  /** Gets the Radius of the cable
392  * \return The radius in logical units
393  */
394  GLSGEN_GLS3DCABLE_EXPORT float Radius();
395 
396  /** Sets the Length of the cable.
397  * when not under duress (the cable will stretch when the end-points
398  * are moved too far from each other).
399  * \param value The approximate length of the cable in logical units
400  \pre value must be 0.0 to MAX_FLT
401  \post None
402  */
403  GLSGEN_GLS3DCABLE_EXPORT void Length( const float& value );
404 
405  /** Gets the Length of the cable.
406  * \return The length of the cable in logical units
407  */
408  GLSGEN_GLS3DCABLE_EXPORT float Length();
409 
410  /** Sets the CollisionStyle.
411  * \param value The collision mode for the cable.
412  * COLLISIONSTYLE_NONE will disable all collision detection and
413  * therefore any cable deformation caused thereby.
414  * COLLISIONSTYLE_FAST will check for collisions with other objects in
415  * the scene, but will only move / orient the cable midpoint such that it
416  * appears as though the cable is laying flat on a single surface.
417  *
418  * Check if USE_COLLISIONSTYLE_SLOW is defined before using Slow.
419  */
420  GLSGEN_GLS3DCABLE_EXPORT void CollisionStyle( const int& value );
421 
422  /** Gets the Collision Style
423  * \return The current Collision Style
424  */
425  GLSGEN_GLS3DCABLE_EXPORT int CollisionStyle();
426 
427  /** Sets the Slack Percentage
428  * \param section Which section of the cable, 0 based
429  * \param pct The percent of the slace (0.0 -> 1.0)
430  * This will adjust the slack percentage in the cable for the section,
431  * the caller must ensure that all percents sum up to 1.0.
432  \pre section must be < _sectionSlackPct.Count(), and pct must be 0.0-1.0
433  \post Slack percentage will not change if preconditions are not met.
434  */
435  GLSGEN_GLS3DCABLE_EXPORT void SlackPct( unsigned int section, double pct );
436 
437  /** Gets the Slack Percentage for a particular section
438  * \param section The section of interest.
439  * \return The slack percentage for the specified section.
440  \pre section must be < _sectionSlackPct.Count()
441  \post if preconditions are not met 0.0 is returned
442  */
443  GLSGEN_GLS3DCABLE_EXPORT double SlackPct( unsigned int section );
444 
445  /**
446  How many Slack Sections are there? Can be used with SlackPct() to
447  get set Slack Sections.
448  \return Return the number of Slack Sections, 0 to N
449  \pre none
450  \post none
451  */
452  GLSGEN_GLS3DCABLE_EXPORT unsigned int SlackSectionCount() const;
453 
454  /**
455  Sometimes an outside source may need to recalculate the cable, such as
456  when the scene changes and the cable may not be colliding with another
457  object in the scene.
458  \pre None
459  \post None
460  */
461  GLSGEN_GLS3DCABLE_EXPORT void ForceCableRecalc();
462 
463  /**
464  Wether or not to simulate gavity on the cable.
465  \pre None
466  \post None
467  */
468  GLSGEN_GLS3DCABLE_EXPORT void Gravity( const bool& value );
469 
470  /**
471  Returns wether or not gavity is simulated on the cable.
472  \return Returns wether or not gavity is simulated on the cable
473  \pre none
474  \post none
475  */
476  GLSGEN_GLS3DCABLE_EXPORT bool Gravity()
477  {
478  return _gravity;
479  }
480 
481 private:
482  /**
483  Reallocate, but do not set the vertices that make up the cable line
484  \pre None
485  \post Will clear _needNewLineVerts, and will set _needCableRecalc
486  */
487  void AllocateLineVertices();
488 
489  /**
490  \param *root Pointer to a list of objects to search for a collision
491  \param &pos Starting point of the ray
492  \param &vec Direction vector of the ray
493  \param *mag_pct_chg If a float pointer is provided, this will return the percent
494  change between the new/old Ray magnitude.
495  This is an optional parameter.
496  \return Return true if the new magnitude is smaller than the old
497  \pre root must exist
498  \post
499  */
500  bool RaycastAdjusted( DisplayObject* root, Vector& pos, Vector& vec, float* mag_pct_chg = NULL );
501 
502  /**
503  Determine if something is colliding with the cable.
504  \param *root Pointer to a list of objects to search for a collision
505  \param x The x starting location of the ray
506  \param y The y starting location of the ray
507  \param z The z starting location of the ray
508  \param scale The Scale factor of the window
509  \param directionVector Direction vector of the ray
510  \param &collideDist Return the distance to the collision point from the start point
511  \param *collisionPoint Return the closest collision point
512  \return true if a hit occurs
513  \pre root must exist
514  \post None
515  */
516  bool GlobalHit( DisplayObject* root, float x, float y, float z, float scale, const Vector& directionVector, float& collideDist, Vector* collisionPoint );
517 
518  /**
519  Recompute the line vertices of the cable.
520  \return success or failure
521  \pre
522  \post will clear _needCableRecalc
523  */
524  bool RecalculateCable();
525 
526  /**
527  Fill out/calculate the cable mesh.
528  \pre None
529  \post None
530  */
531  void TubeGeneration();
532 
533 protected:
534  /**
535  How flexibile is the cable, more flexibility gives a more rounded cable
536  This has a range of 0 to 1, 0 is inflexible, 1 is flexible.
537  */
539 
540  /**
541  The number of pieces that the entire cable has, the more
542  segements the more smooth a cable will appear, e.g., 1 segment
543  gives you a straight line, two gives you a 'V', etc.
544  This has a range of MIN_SEGEMENTS to MAX_SEGEMENTS
545  */
546  unsigned int _numberOfSegments;
547 
548  /**
549  How many sides does the cable have. 1 is a wire
550  2 is a ribbon cable, 3 a triangle, 4 a sqaure, etc. the more
551  sides the closer to a circle you get.
552  This has a range of MIN_NUMBER_OF_SIDES to MAX_NUMBER_OF_SIDES.
553  */
554  unsigned int _numberOfSides;
555 
556  /**
557  The Radius of the cable. Units are in pixels.
558  This has a range of plus/minus FLT_MAX
559  */
560  float _radius;
561 
562  /**
563  The requested length of the cable, the cable may be longer, if needed to
564  reach between the end points. A zero length cable can be used to "hide"
565  the cable, while leaving the end points intact. Units are in logical units.
566  This has a range of zero to FLT_MAX.
567  */
568  float _length;
569 
570  /**
571  Does RecalculateCable () need to be called next frame?
572  */
574 
575  /**
576  Does TubeGeneration () need to be called next frame?
577  */
579 
580  /**
581  Prevents "Hit()" from being called from within RecalculateCable()
582  */
584 
585  /**
586  The _lineVerts are stored in the _line object. The _line object is used
587  for drawing if sides == 1.
588  */
590 
591  /**
592  The Mesh Verts, Normals, and TexCoords are stored in this object. The _mesh object
593  is used for drawing when sides > 1.
594  */
596 
597  /**
598  Stores the locations of all of the "EndPoint" objects for ease of use in future calculations.
599  Also used to check if any of the positions have changed.
600  Endpoints, can be in the middle section of the cable, by "endpoints" it is meant the ends of the sections.
601  */
602  std::vector<Vector> _endPointPos;
603 
604  /**
605  Stores the dcs orientations of all of the "EndPoint" objects for ease of use in future calculations.
606  Also used to check if any of the orientations have changed.
607  Endpoints, can be in the middle section of the cable, by "endpoints" it is meant the ends of the sections.
608  */
609  std::vector<GlsMatrixAffineD> _endPointOri;
610 
611  /**
612  The percentage of slack that each cable segment has (starts out equally divided)...
613  but the User can set the percentages.
614  This has a range of >= 0 and <= 1. The total of all sections should add to 1.
615  */
616  DynamicDoubleArray _sectionSlackPct;
617 
618  /**
619  Store the DCS Rotation matrix used to calculate the mesh object. The
620  Z is the direction of gravity, so this will effect the slack in the cable.
621  Compare this old DCS with the current to determine if we need to recalculate
622  the mesh.
623  */
625 
626  /**
627  The collision type.
628  */
629  ECollisionStyle _collisionStyle;
630 
631  bool _gravity;
632 
633  // The number of vertices in the cable line, for each section of the cable.
634  // This INCLUDES the first vertex and the last vertex of each section.
635  int _lineVertsPerSection;
636 
637  // This will be the summed arc length for all sections.
638  // It is stored because it is used for tube generation.
639  float _realCableLength;
640 
641 private:
642  // Disable implicit generated Members
643  Gls3DCable& operator=( const Gls3DCable& rhs ) DISTI_SPECIAL_MEM_FUN_DELETE;
644  Gls3DCable( const Gls3DCable& src ) DISTI_SPECIAL_MEM_FUN_DELETE;
645 };
646 
647 } // namespace disti
648 
649 #endif
Definition: cull.h:49
float _radius
Definition: gls_3d_cable.h:560
virtual int LineStippleMultiplier(void)
virtual DisplayObject * CloneObject(bool generateNames=false)
float _length
Definition: gls_3d_cable.h:568
virtual void SetColor(const GlsColor &color)
virtual void Draw(void)
virtual bool LightingEnabled()
virtual int PolygonMode(void)
virtual void Normalize(void)
Definition: gls_3d_cable.h:133
virtual int AlphaMode(void)
virtual void Calculate(double time)
Definition: dynamic_array.h:62
The disti::Group class. Implements groups of objects.
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:301
bool _needTubeGeneration
Definition: gls_3d_cable.h:578
Definition: gls_3d_cable.h:183
The Polygon class. Implements Polygons.
Definition: glpolygon.h:55
virtual int TextureMappingTechnique(void)
virtual GlsColor GetBlendColor(void)
virtual DistiAttributeBase & Resource(const char *name)
Definition: display.h:98
unsigned int NumberOfSegments()
bool BETWEEN(const X &x, const X1 &x1, const X2 &x2)
Definition: util.h:131
virtual int LineStipplePattern(void)
The disti::GLPolygon class. Implements Polygons.
unsigned int _numberOfSegments
Definition: gls_3d_cable.h:546
bool operator!=(const VertexNoColor &arg) const
Definition: gls_3d_cable.h:171
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL)
Gls3DCable(bool generateInstance=false)
VertexNoColor()
Definition: vertex.h:90
virtual bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint)
GlsMatrixAffineD _cableDcs
Definition: gls_3d_cable.h:624
bool _inCableRecalc
Definition: gls_3d_cable.h:583
DynamicDoubleArray _sectionSlackPct
Definition: gls_3d_cable.h:616
The glTriMesh class. Implements Triangle Meshes.
Definition: gltrimesh.h:92
std::vector< Vector > _endPointPos
Definition: gls_3d_cable.h:602
virtual int DepthTest(void)
virtual float LineWidth(void)
float _flexibility
Definition: gls_3d_cable.h:538
GLTriMesh _mesh
Definition: gls_3d_cable.h:595
unsigned int SlackSectionCount() const
std::vector< GlsMatrixAffineD > _endPointOri
Definition: gls_3d_cable.h:609
virtual void CopyProperties(DisplayObject *src)
bool _needCableRecalc
Definition: gls_3d_cable.h:573
unsigned int _numberOfSides
Definition: gls_3d_cable.h:554
virtual void SetValue(int spec, va_list &args)
Definition: disti_metadata.h:182
unsigned int NumberOfSides()
Definition: events.h:111
Definition: gls_color.h:53
virtual void SetAvailableAttributes(unsigned int value)
virtual DisplayObject * Pick3D(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &parentDrawn)
virtual GlsColor GetColor(void)
virtual void CalculateTextureCoordinates(void)
virtual void SetBlendColor(const GlsColor &color)
virtual bool TextureRepeat(void)
The gls_auto_lib.
virtual int TextureMinificationFilter(void)
Definition: group.h:52
Definition: vertex.h:84
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler)
bool Gravity()
Definition: gls_3d_cable.h:476
virtual int Shading(void)
The disti::GlsQuaternion class.
virtual bool CullBackFace(void)
void SlackPct(unsigned int section, double pct)
float Magnitude() const
Definition: vertex.h:327
virtual void NearZero()
Definition: gls_3d_cable.h:112
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array)
GLPolygon _line
Definition: gls_3d_cable.h:589
Definition: gls_resources.h:50
Macros and helper code to determine what subset of C++11/14/17 is available.
virtual bool operator==(const VertexNoColor &arg) const
Definition: gls_3d_cable.h:161
ECollisionStyle _collisionStyle
Definition: gls_3d_cable.h:629
Definition: bmpimage.h:46
virtual int PolygonEnd(void)
virtual GlsColor GetFillColor(void)
virtual void GetResources(std::ostream &outstr, GlsResourceFilter *filter)
virtual void SetFillColor(const GlsColor &color)
virtual DisplayObject * handle(DisplayEvent *ev)
Definition: gls_3d_cable.h:92
Definition: gls_matrix_affine.h:60
virtual bool AntiAlias(void)
The disti::GLTriMesh class. Implements Triangle Meshes.
virtual int TextureMagnificationFilter(void)
virtual ~Gls3DCable()