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> 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  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  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  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  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  DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
187  typedef Group _BaseClass;
188  typedef Group BaseClass;
189 
190  enum
191  {
192  TEXTUREPOINT_MULT = 50
193  };
194 
195  /** Sides limits */
196  enum
197  {
198  MIN_NUMBER_OF_SIDES = 1,
199  MAX_NUMBER_OF_SIDES = 100 // visually 50 looked good, 100 gives the user room
200  };
201 
202  /** Segement limits */
203  enum
204  {
205  MIN_SEGEMENTS = 1,
206  MAX_SEGEMENTS = 10000 // Seems like 10,000 segements should be way big enough
207  };
208 
209  enum ECollisionStyle
210  {
211  COLLISIONSTYLE_NONE = 0,
212  COLLISIONSTYLE_FAST
213 #if defined( USE_COLLISIONSTYLE_SLOW )
214  ,
215  COLLISIONSTYLE_SLOW
216 #endif
217  };
218 
219  friend class Gls3DCableEditor;
220 
221  /** Create a new Gls3DCable.
222  * \param generateInstance Whether or not to generate an instance name
223  * for this inputdevice
224  */
225  GLSGEN_GLS3DCABLE_EXPORT Gls3DCable( bool generateInstance = false );
226 
227  /* Copy constructor for Gls3DCable
228  * \param that The Gls3DCable to be copied from
229  * \param generateNames Whether or not to generate a new instance name
230  */
231  GLSGEN_GLS3DCABLE_EXPORT Gls3DCable( const Gls3DCable& that, const bool generateNames );
232 
233  /** Destructs a Gls3DCable object */
234  virtual GLSGEN_GLS3DCABLE_EXPORT ~Gls3DCable();
235 
236  static GLSGEN_GLS3DCABLE_EXPORT DisplayObject* CreateInstance();
237 
238  //////////////////////////////////////////////////
239  // Overridden base class methods
240  // The base class methods are overridden so that the Group Class methods
241  // are not called, generally DisplayObject methods are called, there
242  // are a few exceptions.
243  //////////////////////////////////////////////////
244 
245  virtual void GetResources( std::ostream& outstr, GlsResourceFilter* filter );
246  virtual DistiAttributeBase& Resource( const char* name );
247 
248  virtual GLSGEN_GLS3DCABLE_EXPORT void SetAvailableAttributes( unsigned int value );
249  virtual GLSGEN_GLS3DCABLE_EXPORT DisplayObject* CloneObject( bool generateNames = false );
250  virtual GLSGEN_GLS3DCABLE_EXPORT void CopyProperties( DisplayObject* src );
251 
252  virtual GLSGEN_GLS3DCABLE_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL );
253  virtual GLSGEN_GLS3DCABLE_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array );
254 
255  virtual GLSGEN_GLS3DCABLE_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices, Culler& culler );
256  virtual GLSGEN_GLS3DCABLE_EXPORT void Draw( void );
257 
258  virtual GLSGEN_GLS3DCABLE_EXPORT void Calculate( double time );
259 
260  virtual GLSGEN_GLS3DCABLE_EXPORT DisplayObject* handle( DisplayEvent* ev );
261 
262  virtual GLSGEN_GLS3DCABLE_EXPORT void SetValue( int spec, va_list& args );
263 
264  virtual GLSGEN_GLS3DCABLE_EXPORT void CalculateBoundingBox( void );
265 
266  /** Determines if the indicated x,y,z point is inside the object. This is
267  * used by the editor to determine which object a user clicked on. It
268  * is also used in the generated code to send mouse events to the
269  * graphical objects for processing
270  * \param x X coordinate of mouse click
271  * \param y Y coordinate of mouse click
272  * \param z Z coordinate of mouse click
273  * \param scale The scale factor of the window
274  * \param directionVector The direction of the pick vector. Vector(0.0f, 0.0f, 1.0f) is for picking in the XY plane
275  * \param collisionPoint Returns the collision point
276  * \return boolean indicating if the object was hit by the mouse
277  */
278  virtual GLSGEN_GLS3DCABLE_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint );
279 
280  virtual GLSGEN_GLS3DCABLE_EXPORT DisplayObject* Pick3D( const Vector& winLoc, const Vector& logicalCoords, float scale,
281  const Vector& directionVector, Vector& collisionWinLoc, const OpenGLMatrices& parentDrawn );
282 
283  virtual GLSGEN_GLS3DCABLE_EXPORT void CalculateTextureCoordinates( void );
284 
285  virtual GLSGEN_GLS3DCABLE_EXPORT void LineWidth( float width );
286  virtual GLSGEN_GLS3DCABLE_EXPORT float LineWidth( void );
287 
288  virtual GLSGEN_GLS3DCABLE_EXPORT void LineStipplePattern( int pattern );
289  virtual GLSGEN_GLS3DCABLE_EXPORT int LineStipplePattern( void );
290 
291  virtual GLSGEN_GLS3DCABLE_EXPORT void LineStippleMultiplier( int mult );
292  virtual GLSGEN_GLS3DCABLE_EXPORT int LineStippleMultiplier( void );
293 
294  virtual GLSGEN_GLS3DCABLE_EXPORT int PolygonMode( void );
295  virtual GLSGEN_GLS3DCABLE_EXPORT void PolygonMode( int mode );
296 
297  virtual GLSGEN_GLS3DCABLE_EXPORT void PolygonEnd( const int mode );
298  virtual GLSGEN_GLS3DCABLE_EXPORT int PolygonEnd( void );
299 
300  virtual GLSGEN_GLS3DCABLE_EXPORT void Shading( const int mode );
301  virtual GLSGEN_GLS3DCABLE_EXPORT int Shading( void );
302 
303  virtual GLSGEN_GLS3DCABLE_EXPORT void DepthTest( unsigned char mode );
304  virtual GLSGEN_GLS3DCABLE_EXPORT int DepthTest( void );
305 
306  virtual GLSGEN_GLS3DCABLE_EXPORT void AntiAlias( bool mode );
307  virtual GLSGEN_GLS3DCABLE_EXPORT bool AntiAlias( void );
308 
309  virtual GLSGEN_GLS3DCABLE_EXPORT void AlphaMode( int mode );
310  virtual GLSGEN_GLS3DCABLE_EXPORT int AlphaMode( void );
311 
312  virtual GLSGEN_GLS3DCABLE_EXPORT void CullBackFace( const bool mode );
313  virtual GLSGEN_GLS3DCABLE_EXPORT bool CullBackFace( void );
314 
315  virtual GLSGEN_GLS3DCABLE_EXPORT bool LightingEnabled();
316  virtual GLSGEN_GLS3DCABLE_EXPORT void LightingEnabled( bool lighting );
317 
318  virtual GLSGEN_GLS3DCABLE_EXPORT void SetBlendColor( const GlsColor& color );
319  virtual GLSGEN_GLS3DCABLE_EXPORT GlsColor GetBlendColor( void );
320 
321  virtual GLSGEN_GLS3DCABLE_EXPORT void SetColor( const GlsColor& color );
322  virtual GLSGEN_GLS3DCABLE_EXPORT GlsColor GetColor( void );
323 
324  virtual GLSGEN_GLS3DCABLE_EXPORT void SetFillColor( const GlsColor& color );
325  virtual GLSGEN_GLS3DCABLE_EXPORT GlsColor GetFillColor( void );
326 
327  virtual GLSGEN_GLS3DCABLE_EXPORT void TextureRepeat( const int rep );
328  virtual GLSGEN_GLS3DCABLE_EXPORT bool TextureRepeat( void );
329 
330  virtual GLSGEN_GLS3DCABLE_EXPORT void TextureMappingTechnique( const int map );
331  virtual GLSGEN_GLS3DCABLE_EXPORT int TextureMappingTechnique( void );
332 
333  virtual GLSGEN_GLS3DCABLE_EXPORT void TextureMinificationFilter( const int filter );
334  virtual GLSGEN_GLS3DCABLE_EXPORT int TextureMinificationFilter( void );
335 
336  virtual GLSGEN_GLS3DCABLE_EXPORT void TextureMagnificationFilter( const int filter );
337  virtual GLSGEN_GLS3DCABLE_EXPORT int TextureMagnificationFilter( void );
338 
339  //////////////////////////////////////////////////
340  // Gls3DCable specific operations
341  //////////////////////////////////////////////////
342 
343  /** Sets flexibility.
344  * \param value Controls how stiff the cable is. The value should be in the
345  range of 0 to 1, inclusive. 0 is very inflexible, while 1 is very flexible.
346  \pre value must be in the range of 0 to 1
347  \post None
348  */
349  GLSGEN_GLS3DCABLE_EXPORT void Flexibility( const float& value );
350  /** Gets flexibility.
351  * \return How stiff the cable is.
352  */
353  GLSGEN_GLS3DCABLE_EXPORT float Flexibility();
354 
355  /** Sets Number of Segements.
356  * \param value The number of cylindrical segments that will traverse
357  * the entire length of the cable. A cable with one section
358  * (that is, with only two control objects) would be a straight cylinder
359  * connecting two points, incapable of bending.
360  * The higher this number, the smoother your cable will appear.
361  \pre value must be in the range MIN_SEGEMENTS to MAX_SEGEMENTS
362  \post none
363  */
364  GLSGEN_GLS3DCABLE_EXPORT void NumberOfSegments( const unsigned int& value );
365 
366  /** Gets the Number of Segements.
367  * \return The Number of Segments
368  */
369  GLSGEN_GLS3DCABLE_EXPORT unsigned int NumberOfSegments();
370 
371  /** Sets the Number Of Sides.
372  * \param value The number of sides the cable "tube" will have.
373  * The more sides, the smoother the cable will appear.
374  * A value of two will produce a ribbon-like cable.
375  * A value of one will render only a line.
376  \pre value must be in the range of 1 to 100 inclusive.
377  \post None
378  */
379  GLSGEN_GLS3DCABLE_EXPORT void NumberOfSides( const unsigned int& value );
380 
381  /** Gets the Number of Sides.
382  * \return The number of sides
383  */
384  GLSGEN_GLS3DCABLE_EXPORT unsigned int NumberOfSides();
385 
386  /** Sets the Radius of the cable in logical units
387  \param value The radius in logical units.
388  \pre value must be plus/minus MAX_FLT
389  \post none
390  */
391  GLSGEN_GLS3DCABLE_EXPORT void Radius( const float& value );
392 
393  /** Gets the Radius of the cable
394  * \return The radius in logical units
395  */
396  GLSGEN_GLS3DCABLE_EXPORT float Radius();
397 
398  /** Sets the Length of the cable.
399  * when not under duress (the cable will stretch when the end-points
400  * are moved too far from each other).
401  * \param value The approximate length of the cable in logical units
402  \pre value must be 0.0 to MAX_FLT
403  \post None
404  */
405  GLSGEN_GLS3DCABLE_EXPORT void Length( const float& value );
406 
407  /** Gets the Length of the cable.
408  * \return The length of the cable in logical units
409  */
410  GLSGEN_GLS3DCABLE_EXPORT float Length();
411 
412  /** Sets the CollisionStyle.
413  * \param value The collision mode for the cable.
414  * COLLISIONSTYLE_NONE will disable all collision detection and
415  * therefore any cable deformation caused thereby.
416  * COLLISIONSTYLE_FAST will check for collisions with other objects in
417  * the scene, but will only move / orient the cable midpoint such that it
418  * appears as though the cable is laying flat on a single surface.
419  *
420  * Check if USE_COLLISIONSTYLE_SLOW is defined before using Slow.
421  */
422  GLSGEN_GLS3DCABLE_EXPORT void CollisionStyle( const int& value );
423 
424  /** Gets the Collision Style
425  * \return The current Collision Style
426  */
427  GLSGEN_GLS3DCABLE_EXPORT int CollisionStyle();
428 
429  /** Sets the Slack Percentage
430  * \param section Which section of the cable, 0 based
431  * \param pct The percent of the slace (0.0 -> 1.0)
432  * This will adjust the slack percentage in the cable for the section,
433  * the caller must ensure that all percents sum up to 1.0.
434  \pre section must be < _sectionSlackPct.Count(), and pct must be 0.0-1.0
435  \post Slack percentage will not change if preconditions are not met.
436  */
437  GLSGEN_GLS3DCABLE_EXPORT void SlackPct( unsigned int section, double pct );
438 
439  /** Gets the Slack Percentage for a particular section
440  * \param section The section of interest.
441  * \return The slack percentage for the specified section.
442  \pre section must be < _sectionSlackPct.Count()
443  \post if preconditions are not met 0.0 is returned
444  */
445  GLSGEN_GLS3DCABLE_EXPORT double SlackPct( unsigned int section );
446 
447  /**
448  How many Slack Sections are there? Can be used with SlackPct() to
449  get set Slack Sections.
450  \return Return the number of Slack Sections, 0 to N
451  \pre none
452  \post none
453  */
454  GLSGEN_GLS3DCABLE_EXPORT unsigned int SlackSectionCount() const;
455 
456  /**
457  Sometimes an outside source may need to recalculate the cable, such as
458  when the scene changes and the cable may not be colliding with another
459  object in the scene.
460  \pre None
461  \post None
462  */
463  GLSGEN_GLS3DCABLE_EXPORT void ForceCableRecalc();
464 
465  /**
466  Wether or not to simulate gavity on the cable.
467  \pre None
468  \post None
469  */
470  GLSGEN_GLS3DCABLE_EXPORT void Gravity( const bool& value );
471 
472  /**
473  Returns wether or not gavity is simulated on the cable.
474  \return Returns wether or not gavity is simulated on the cable
475  \pre none
476  \post none
477  */
478  GLSGEN_GLS3DCABLE_EXPORT bool Gravity()
479  {
480  return _gravity;
481  }
482 
483 private:
484  /**
485  Reallocate, but do not set the vertices that make up the cable line
486  \pre None
487  \post Will clear _needNewLineVerts, and will set _needCableRecalc
488  */
489  void AllocateLineVertices();
490 
491  /**
492  \param *root Pointer to a list of objects to search for a collision
493  \param &pos Starting point of the ray
494  \param &vec Direction vector of the ray
495  \param *mag_pct_chg If a float pointer is provided, this will return the percent
496  change between the new/old Ray magnitude.
497  This is an optional parameter.
498  \return Return true if the new magnitude is smaller than the old
499  \pre root must exist
500  \post
501  */
502  bool RaycastAdjusted( DisplayObject* root, Vector& pos, Vector& vec, float* mag_pct_chg = NULL );
503 
504  /**
505  Determine if something is colliding with the cable.
506  \param *root Pointer to a list of objects to search for a collision
507  \param x The x starting location of the ray
508  \param y The y starting location of the ray
509  \param z The z starting location of the ray
510  \param scale The Scale factor of the window
511  \param directionVector Direction vector of the ray
512  \param &collideDist Return the distance to the collision point from the start point
513  \param *collisionPoint Return the closest collision point
514  \return true if a hit occurs
515  \pre root must exist
516  \post None
517  */
518  bool GlobalHit( DisplayObject* root, float x, float y, float z, float scale, const Vector& directionVector, float& collideDist, Vector* collisionPoint );
519 
520  /**
521  Recompute the line vertices of the cable.
522  \return success or failure
523  \pre
524  \post will clear _needCableRecalc
525  */
526  bool RecalculateCable();
527 
528  /**
529  Fill out/calculate the cable mesh.
530  \pre None
531  \post None
532  */
533  void TubeGeneration();
534 
535 protected:
536  /**
537  How flexibile is the cable, more flexibility gives a more rounded cable
538  This has a range of 0 to 1, 0 is inflexible, 1 is flexible.
539  */
541 
542  /**
543  The number of pieces that the entire cable has, the more
544  segements the more smooth a cable will appear, e.g., 1 segment
545  gives you a straight line, two gives you a 'V', etc.
546  This has a range of MIN_SEGEMENTS to MAX_SEGEMENTS
547  */
548  unsigned int _numberOfSegments;
549 
550  /**
551  How many sides does the cable have. 1 is a wire
552  2 is a ribbon cable, 3 a triangle, 4 a sqaure, etc. the more
553  sides the closer to a circle you get.
554  This has a range of MIN_NUMBER_OF_SIDES to MAX_NUMBER_OF_SIDES.
555  */
556  unsigned int _numberOfSides;
557 
558  /**
559  The Radius of the cable. Units are in pixels.
560  This has a range of plus/minus FLT_MAX
561  */
562  float _radius;
563 
564  /**
565  The requested length of the cable, the cable may be longer, if needed to
566  reach between the end points. A zero length cable can be used to "hide"
567  the cable, while leaving the end points intact. Units are in logical units.
568  This has a range of zero to FLT_MAX.
569  */
570  float _length;
571 
572  /**
573  Does RecalculateCable () need to be called next frame?
574  */
576 
577  /**
578  Does TubeGeneration () need to be called next frame?
579  */
581 
582  /**
583  Prevents "Hit()" from being called from within RecalculateCable()
584  */
586 
587  /**
588  The _lineVerts are stored in the _line object. The _line object is used
589  for drawing if sides == 1.
590  */
592 
593  /**
594  The Mesh Verts, Normals, and TexCoords are stored in this object. The _mesh object
595  is used for drawing when sides > 1.
596  */
598 
599  /**
600  Stores the locations of all of the "EndPoint" objects for ease of use in future calculations.
601  Also used to check if any of the positions have changed.
602  Endpoints, can be in the middle section of the cable, by "endpoints" it is meant the ends of the sections.
603  */
604  std::vector<Vector> _endPointPos;
605 
606  /**
607  Stores the dcs orientations of all of the "EndPoint" objects for ease of use in future calculations.
608  Also used to check if any of the orientations have changed.
609  Endpoints, can be in the middle section of the cable, by "endpoints" it is meant the ends of the sections.
610  */
611  std::vector<GlsMatrixAffineD> _endPointOri;
612 
613  /**
614  The percentage of slack that each cable segment has (starts out equally divided)...
615  but the User can set the percentages.
616  This has a range of >= 0 and <= 1. The total of all sections should add to 1.
617  */
618  DynamicDoubleArray _sectionSlackPct;
619 
620  /**
621  Store the DCS Rotation matrix used to calculate the mesh object. The
622  Z is the direction of gravity, so this will effect the slack in the cable.
623  Compare this old DCS with the current to determine if we need to recalculate
624  the mesh.
625  */
627 
628  /**
629  The collision type.
630  */
631  ECollisionStyle _collisionStyle;
632 
633  bool _gravity;
634 
635  // The number of vertices in the cable line, for each section of the cable.
636  // This INCLUDES the first vertex and the last vertex of each section.
637  int _lineVertsPerSection;
638 
639  // This will be the summed arc length for all sections.
640  // It is stored because it is used for tube generation.
641  float _realCableLength;
642 
643 private:
644  // Disable implicit generated Members
645  Gls3DCable& operator=( const Gls3DCable& rhs ) DISTI_SPECIAL_MEM_FUN_DELETE;
646  Gls3DCable( const Gls3DCable& src ) DISTI_SPECIAL_MEM_FUN_DELETE;
647 };
648 
649 } // namespace disti
650 
651 #endif
Definition: cull.h:49
float _radius
Definition: gls_3d_cable.h:562
virtual int LineStippleMultiplier(void)
virtual DisplayObject * CloneObject(bool generateNames=false)
float _length
Definition: gls_3d_cable.h:570
virtual void SetColor(const GlsColor &color)
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:436
virtual void Draw(void)
virtual bool LightingEnabled()
virtual int PolygonMode(void)
virtual int AlphaMode(void)
virtual void Calculate(double time)
Definition: dynamic_array.h:66
The disti::Group class. Implements groups of objects.
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:473
bool _needTubeGeneration
Definition: gls_3d_cable.h:580
Definition: gls_3d_cable.h:183
The Polygon class. Implements Polygons.
Definition: glpolygon.h:55
virtual int TextureMappingTechnique(void)
void Normalize(void)
Definition: gls_3d_cable.h:133
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:128
virtual int LineStipplePattern(void)
bool operator==(const VertexNoColor &arg) const
Definition: gls_3d_cable.h:161
The disti::GLPolygon class. Implements Polygons.
unsigned int _numberOfSegments
Definition: gls_3d_cable.h:548
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)
void NearZero()
Definition: gls_3d_cable.h:112
GlsMatrixAffineD _cableDcs
Definition: gls_3d_cable.h:626
bool _inCableRecalc
Definition: gls_3d_cable.h:585
DynamicDoubleArray _sectionSlackPct
Definition: gls_3d_cable.h:618
The glTriMesh class. Implements Triangle Meshes.
Definition: gltrimesh.h:92
std::vector< Vector > _endPointPos
Definition: gls_3d_cable.h:604
virtual int DepthTest(void)
virtual float LineWidth(void)
float _flexibility
Definition: gls_3d_cable.h:540
GLTriMesh _mesh
Definition: gls_3d_cable.h:597
unsigned int SlackSectionCount() const
std::vector< GlsMatrixAffineD > _endPointOri
Definition: gls_3d_cable.h:611
virtual void CopyProperties(DisplayObject *src)
bool _needCableRecalc
Definition: gls_3d_cable.h:575
unsigned int _numberOfSides
Definition: gls_3d_cable.h:556
virtual void SetValue(int spec, va_list &args)
Definition: disti_metadata.h:186
unsigned int NumberOfSides()
Definition: events.h:112
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:478
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 GetCppInterfaceDescriptionFree(InterfaceListType *array)
GLPolygon _line
Definition: gls_3d_cable.h:591
Definition: gls_resources.h:50
Macros and helper code to determine what subset of C++11/14/17 is available.
ECollisionStyle _collisionStyle
Definition: gls_3d_cable.h:631
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()