BezierSegment.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // BezierSegment.h ////////////////////////////////////////////////////////////////////////////////
  24. // John K McDonald, Jr.
  25. // September 2002
  26. // DO NOT DISTRIBUTE
  27. #pragma once
  28. #ifndef __BEZIERSEGMENT_H__
  29. #define __BEZIERSEGMENT_H__
  30. #include <D3DX8Math.h>
  31. #include "Common/STLTypeDefs.h"
  32. #define USUAL_TOLERANCE 1.0f
  33. class BezierSegment
  34. {
  35. protected:
  36. static const D3DXMATRIX s_bezBasisMatrix;
  37. Coord3D m_controlPoints[4];
  38. public: // Constructors
  39. BezierSegment();
  40. BezierSegment(Real x0, Real y0, Real z0,
  41. Real x1, Real y1, Real z1,
  42. Real x2, Real y2, Real z2,
  43. Real x3, Real y3, Real z3);
  44. BezierSegment(Real cp[16]);
  45. BezierSegment(const Coord3D& cp0,
  46. const Coord3D& cp1,
  47. const Coord3D& cp2,
  48. const Coord3D& cp3);
  49. BezierSegment(Coord3D cp[4]);
  50. public:
  51. void evaluateBezSegmentAtT(Real tValue, Coord3D *outResult) const;
  52. void getSegmentPoints(Int numSegments, VecCoord3D *outResult) const;
  53. Real getApproximateLength(Real withinTolerance = USUAL_TOLERANCE) const;
  54. void splitSegmentAtT(Real tValue, BezierSegment &outSeg1, BezierSegment &outSeg2) const;
  55. public: // He get's friendly access.
  56. friend class BezFwdIterator;
  57. };
  58. #endif /* __BEZIERSEGMENT_H__ */