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