afxCurve3D.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  2. // Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
  3. // Copyright (C) 2015 Faust Logic, Inc.
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to
  7. // deal in the Software without restriction, including without limitation the
  8. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9. // sell copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. // IN THE SOFTWARE.
  22. //
  23. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  24. #ifndef _AFX_CURVE_3D_H_
  25. #define _AFX_CURVE_3D_H_
  26. #include "core/util/tVector.h"
  27. #include "math/mPoint3.h"
  28. class afxCurveEval;
  29. class afxCurve3D
  30. {
  31. class CurvePoint
  32. {
  33. public:
  34. F32 parameter;
  35. Point3F point;
  36. // new:
  37. Point3F tangent;
  38. };
  39. private:
  40. afxCurveEval* evaluator;
  41. Point3F start_value;
  42. Point3F final_value;
  43. Point3F start_tangent;
  44. Point3F final_tangent;
  45. bool usable;
  46. //std::vector<CurvePoint> points;
  47. Vector<CurvePoint> points;
  48. Point3F default_vector;
  49. //static bool compare_CurvePoint( const CurvePoint &a, const CurvePoint &b );
  50. static S32 QSORT_CALLBACK compare_CurvePoint( const void* a, const void* b );
  51. // new
  52. Point3F last_tangent;
  53. bool flip;
  54. public:
  55. afxCurve3D();
  56. ~afxCurve3D();
  57. void addPoint( F32 param, Point3F &v );
  58. void setPoint( int index, Point3F &v );
  59. void sort( );
  60. int numPoints();
  61. F32 getParameter( int index );
  62. Point3F getPoint( int index );
  63. Point3F evaluate( F32 param );
  64. Point3F evaluateTangent( F32 param );
  65. void print();
  66. void computeTangents();
  67. //MatrixF createOrientFromDir( Point3F &direction );
  68. private:
  69. Point3F computeTangentP0( Point3F &p0, Point3F &p1, int start_index );
  70. Point3F computeTangentP1( Point3F &p0, Point3F &p1, int end_index );
  71. };
  72. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  73. #endif // _AFX_CURVE_3D_H_