summaryrefslogtreecommitdiff
path: root/common/curve.h
blob: f9a90a6a4ef7e14da8536d4818b286d43420c05f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#ifndef _CURVE_H_
#define _CURVE_H_

#include "object.h"
#include "opengl.h"
#include "array.h"

class Curve;
class CurvePoint;
class PieceInfo;

//#define LC_CURVE_POINT_HIDDEN             0x01
#define LC_CURVE_POINT_SELECTED           0x02
#define LC_CURVE_POINT_FOCUSED            0x04
#define LC_CURVE_POINT_ARROW1_FOCUSED     0x08
#define LC_CURVE_POINT_ARROW2_FOCUSED     0x10
#define LC_CURVE_POINT_CONTINUOUS         0x20

typedef enum
{
  LC_CURVE_POINT_KEY_POSITION,
  LC_CURVE_POINT_KEY_DIRECTION1,
  LC_CURVE_POINT_KEY_DIRECTION2,
  LC_CURVE_POINT_KEY_ANGLE,
  LC_CURVE_POINT_KEY_COUNT
} LC_CURVE_POINT_KEY_TYPES;

class CurvePoint : public Object
{
 public:
  // constructors / destructor
  CurvePoint (Curve *pParent);
  CurvePoint (Curve *pParent, const float *pos, const float *dir);
  virtual ~CurvePoint ();

  // object functions
  bool FileLoad (File& file);
  void FileSave (File& file) const;
  void MinIntersectDist (LC_CLICKLINE* pLine);
	bool IntersectsVolume(const Vector4* Planes, int NumPlanes)
	{ return false; }
  void UpdatePosition (unsigned short nTime, bool bAnimation);
  void Move (unsigned short nTime, bool bAnimation, bool bAddKey, float dx, float dy, float dz);
  void Render (LC_RENDER_INFO* pInfo);
  void Select (bool bSelecting, bool bFocus, bool bMultiple);

  // query functions
  Curve* GetParent () const
    { return m_pParent; }
  const float* GetPosition () const
    { return m_fPos; }
  const float* GetDirection1 () const
    { return m_fDir1; }
  const float* GetDirection2 () const
    { return m_fDir2; }
  float GetAngle () const
    { return m_fAngle; }

 protected:
  void Initialize ();

  Curve* m_pParent;
  static GLuint m_nArrowList;
  static GLuint m_nSphereList;

  unsigned char m_nState;

  // temporary
  float m_fPos[3];
  float m_fDir1[3];
  float m_fDir2[3];
  float m_fAngle;

  unsigned char m_nLastHit; // FIXME: create arrow objects, ugly hack for now
};

// =============================================================================

#define LC_CURVE_HIDDEN         0x01
#define LC_CURVE_SELECTED       0x02
#define LC_CURVE_FOCUSED        0x04
#define LC_CURVE_LOOP           0x10
#define LC_CURVE_FIXED_SIZE     0x20

// all the different types of curved objects
typedef enum
{
  LC_CURVE_TYPE_HOSE
} LC_CURVE_TYPE;

class Curve : public Object
{
 public:
  // constructors / destructor
  Curve ();
  Curve (PieceInfo *pInfo, const float *pos, unsigned char color);
  virtual ~Curve ();

  // object functions
  bool FileLoad (File& file);
  void FileSave (File& file) const;
  void MinIntersectDist (LC_CLICKLINE* pLine);
  void UpdatePosition (unsigned short nTime, bool bAnimation);
  void Move (unsigned short nTime, bool bAnimation, bool bAddKey, float dx, float dy, float dz);
  void Render (LC_RENDER_INFO* pInfo);
  void Select (bool bSelecting, bool bFocus, bool bMultiple);

  // implementation
  void DeselectOtherPoints (CurvePoint *pSender, bool bFocusOnly);

 protected:
  void Initialize ();
  void TesselateHose ();

  LC_CURVE_TYPE m_nCurveType;
  unsigned char m_nState;
  unsigned char m_nColor;
  float m_fLength;

  float m_fUp0[3];

  GLuint m_nDisplayList;

  PtrArray<CurvePoint> m_Points;
};

#endif // _CURVE_H_