afxPath3D.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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_PATH3D_UTIL_H_
  25. #define _AFX_PATH3D_UTIL_H_
  26. #include "afx/util/afxCurve3D.h"
  27. #include "afx/util/afxAnimCurve.h"
  28. #include "math/mMatrix.h"
  29. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  30. class afxPath3D : public EngineObject
  31. {
  32. private:
  33. // Path-related data
  34. afxCurve3D mCurve;
  35. afxAnimCurve mCurve_parameters;
  36. int mNum_points;
  37. // Time data
  38. F32 mStart_time;
  39. F32 mEnd_time;
  40. public:
  41. /*C*/ afxPath3D( );
  42. /*D*/ ~afxPath3D();
  43. void sortAll();
  44. void setStartTime(F32 time);
  45. F32 getEndTime();
  46. int getNumPoints();
  47. Point3F getPointPosition(int index);
  48. F32 getPointTime(int index);
  49. F32 getPointParameter(int index);
  50. Point2F getParameterSegment(F32 time);
  51. void setPointPosition(int index, Point3F &p);
  52. Point3F evaluateAtTime(F32 time);
  53. Point3F evaluateAtTime(F32 t0, F32 t1); // returns delta
  54. Point3F evaluateTangentAtTime(F32 time);
  55. Point3F evaluateTangentAtPoint(int index);
  56. void buildPath(int num_points, Point3F curve_points[], F32 start_time, F32 end_time);
  57. void buildPath(int num_points, Point3F curve_points[], F32 speed);
  58. void buildPath(int num_points, Point3F curve_points[], F32 point_times[], F32 time_offset, F32 time_factor);
  59. void buildPath(int num_points, Point3F curve_points[], Point2F curve_params[]);
  60. void reBuildPath();
  61. void print();
  62. enum LoopType
  63. {
  64. LOOP_CONSTANT,
  65. LOOP_CYCLE,
  66. LOOP_OSCILLATE
  67. };
  68. U32 mLoop_type;
  69. void setLoopType(U32);
  70. private:
  71. void initPathParameters(Point3F curve_points[], F32 speed);
  72. void initPathParametersNEW(Point3F curve_points[], F32 start_time, F32 end_time);
  73. F32 calcCurveTime(F32 time);
  74. };
  75. typedef afxPath3D::LoopType afxPath3DLoopType;
  76. DefineEnumType( afxPath3DLoopType );
  77. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  78. #endif // _AFX_PATH3D_UTIL_H_