afxCurve3D.h

Engine/source/afx/util/afxCurve3D.h

More...

Classes:

Detailed Description

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