| 1 |
#ifndef CLINE_H_INCLUDED |
| 2 |
#define CLINE_H_INCLUDED |
| 3 |
|
| 4 |
class CPole; |
| 5 |
class CLine; |
| 6 |
class CScene; |
| 7 |
class CLinePlugin; |
| 8 |
class CPolePlugin; |
| 9 |
|
| 10 |
/* |
| 11 |
* 架線柱リンク |
| 12 |
*/ |
| 13 |
class CPoleLink{ |
| 14 |
public: |
| 15 |
int m_Side; // サイド |
| 16 |
int m_Track; // 軌道番号 |
| 17 |
CPole *m_Link; // リンク |
| 18 |
public: |
| 19 |
CPoleLink(){ m_Side = m_Track = NULL; m_Link = NULL; } |
| 20 |
CPoleLink(int, int, CPole *); |
| 21 |
bool IsValid(){ return !!m_Link; } |
| 22 |
void Connect(CLine *); |
| 23 |
void Disconnect(CLine *); |
| 24 |
VEC3 GetPos(); |
| 25 |
VEC3 GetOrigPos(); |
| 26 |
VEC3 GetRight(); |
| 27 |
VEC3 GetUp(); |
| 28 |
VEC3 GetDir(); |
| 29 |
VEC3 GetOrigDir(); |
| 30 |
void Render(D3DCOLOR); |
| 31 |
void RestoreAddress(); |
| 32 |
char *Read(char *, char *); |
| 33 |
void Save(FILE *, char *); |
| 34 |
}; |
| 35 |
|
| 36 |
//////////////////////////////////////////////////////////////////////////////// |
| 37 |
//////////////////////////////////////////////////////////////////////////////// |
| 38 |
|
| 39 |
/* |
| 40 |
* 架線柱インスタンス |
| 41 |
*/ |
| 42 |
class CPole{ |
| 43 |
friend class CPoleLink; |
| 44 |
private: |
| 45 |
static CPole **ms_Root; // 接続ルート |
| 46 |
static float ms_MinDist; // 最小検出距離 |
| 47 |
static CPoleLink ms_Detect; // 検出情報 |
| 48 |
int m_Selected; // 選択フラグ |
| 49 |
VEC3 m_Pos; // 位置 |
| 50 |
VEC3 m_Right; // 右 |
| 51 |
VEC3 m_Up; // 上 |
| 52 |
VEC3 m_Dir; // 方向 |
| 53 |
VEC3 m_OrigDir; // 旧 dir |
| 54 |
CObject m_Object; // オブジェクト |
| 55 |
list<CLine *> m_LineList; // 架線リスト |
| 56 |
CPolePlugin *m_PolePlugin; // 架線柱プラグイン |
| 57 |
CPole *m_Next; // リスト次 |
| 58 |
public: |
| 59 |
static void SetRoot(CPole **r){ ms_Root = r; } |
| 60 |
static void ResetDetect(){ ms_MinDist = -1.0f; } |
| 61 |
static bool RenderLink(); |
| 62 |
static bool IsDetected(){ return ms_MinDist>=0.0f; } |
| 63 |
static CPoleLink &GetDetect(){ return ms_Detect; } |
| 64 |
CPole(); |
| 65 |
CPole(const VEC3 &, const VEC3 &, CPolePlugin *); |
| 66 |
~CPole(); |
| 67 |
void Delete(CScene *); |
| 68 |
CPole *Next(){ return m_Next; } |
| 69 |
CPole **NextAdr(){ return &m_Next; } |
| 70 |
CPoleLink CreateLink(int s, int t){ return CPoleLink(s, t, this); } |
| 71 |
void AddLine(CLine *line){ m_LineList.push_back(line); } |
| 72 |
void DeleteLine(CLine *line){ m_LineList.remove(line); } |
| 73 |
VEC3 GetJointPos(int); |
| 74 |
VEC3 GetOrigPos(){ return m_Pos; } |
| 75 |
int GetSelectFlag(){ return m_Selected; } |
| 76 |
void AddSelectFlag(int s){ m_Selected |= s; } |
| 77 |
void ScanInput(int, VEC3 &, VEC3 &); |
| 78 |
void Render(); |
| 79 |
void RestoreAddress(); |
| 80 |
char *Read(char *); |
| 81 |
void Save(FILE *); |
| 82 |
}; |
| 83 |
|
| 84 |
/* |
| 85 |
* 架線インスタンス |
| 86 |
*/ |
| 87 |
class CLine{ |
| 88 |
private: |
| 89 |
static CLine **ms_Root; // 接続ルート |
| 90 |
static float ms_MinDist; // 最小検出距離 |
| 91 |
static CLine *ms_Detect; // 検出情報 |
| 92 |
int m_Selected; // 選択フラグ |
| 93 |
vector<float> m_LineMapV; // 架線マッピング V 座標 |
| 94 |
VEC3 m_Right; // right |
| 95 |
VEC3 m_Dir; // dir |
| 96 |
CPoleLink m_Link[2]; // 接続架線柱 |
| 97 |
CLinePlugin *m_LinePlugin; // 架線プラグイン |
| 98 |
CLine *m_Next; // リスト次 |
| 99 |
public: |
| 100 |
static void SetRoot(CLine **r){ ms_Root = r; } |
| 101 |
static void ResetDetect(){ ms_MinDist = -1.0f; } |
| 102 |
static bool IsDetected(){ return ms_MinDist>=0.0f; } |
| 103 |
static CLine *GetDetect(){ return ms_Detect; } |
| 104 |
CLine(); |
| 105 |
CLine(CPoleLink, CPoleLink, CLinePlugin *); |
| 106 |
~CLine(); |
| 107 |
void Delete(); |
| 108 |
CLine *Next(){ return m_Next; } |
| 109 |
CLine **NextAdr(){ return &m_Next; } |
| 110 |
CPoleLink GetLink(int s){ return m_Link[s]; } |
| 111 |
int GetSelectFlag(){ return m_Selected; } |
| 112 |
void AddSelectFlag(int s){ m_Selected |= s; } |
| 113 |
void ScanInput(int, VEC3 &, VEC3 &); |
| 114 |
void Dump(); |
| 115 |
void Render(); |
| 116 |
void RestoreAddress(); |
| 117 |
char *Read(char *); |
| 118 |
void Save(FILE *); |
| 119 |
}; |
| 120 |
|
| 121 |
// 反復子 |
| 122 |
typedef list<CLine *>::iterator IPLine; |
| 123 |
|
| 124 |
/* |
| 125 |
* 架線柱に接続 |
| 126 |
*/ |
| 127 |
inline void CPoleLink::Connect( |
| 128 |
CLine *line // 架線インスタンス |
| 129 |
){ |
| 130 |
m_Link->AddLine(line); |
| 131 |
} |
| 132 |
|
| 133 |
/* |
| 134 |
* 架線柱の接続解除 |
| 135 |
*/ |
| 136 |
inline void CPoleLink::Disconnect( |
| 137 |
CLine *line // 架線インスタンス |
| 138 |
){ |
| 139 |
m_Link->DeleteLine(line); |
| 140 |
} |
| 141 |
|
| 142 |
/* |
| 143 |
* 接続先座標を求める |
| 144 |
*/ |
| 145 |
inline VEC3 CPoleLink::GetPos(){ |
| 146 |
return m_Link->GetJointPos(m_Track); |
| 147 |
} |
| 148 |
|
| 149 |
/* |
| 150 |
* 接続先座標を求める |
| 151 |
*/ |
| 152 |
inline VEC3 CPoleLink::GetOrigPos(){ |
| 153 |
return m_Link->GetOrigPos(); |
| 154 |
} |
| 155 |
|
| 156 |
/* |
| 157 |
* 接続先 right ベクトルを求める |
| 158 |
*/ |
| 159 |
inline VEC3 CPoleLink::GetRight(){ |
| 160 |
return m_Side ? -m_Link->m_Right : m_Link->m_Right; |
| 161 |
} |
| 162 |
|
| 163 |
/* |
| 164 |
* 接続先 up ベクトルを求める |
| 165 |
*/ |
| 166 |
inline VEC3 CPoleLink::GetUp(){ |
| 167 |
return m_Link->m_Up; |
| 168 |
} |
| 169 |
|
| 170 |
/* |
| 171 |
* 接続先 dir ベクトルを求める |
| 172 |
*/ |
| 173 |
inline VEC3 CPoleLink::GetDir(){ |
| 174 |
return m_Side ? -m_Link->m_Dir : m_Link->m_Dir; |
| 175 |
} |
| 176 |
|
| 177 |
/* |
| 178 |
* 接続先 dir ベクトルを求める |
| 179 |
*/ |
| 180 |
inline VEC3 CPoleLink::GetOrigDir(){ |
| 181 |
return m_Side ? -m_Link->m_OrigDir : m_Link->m_OrigDir; |
| 182 |
} |
| 183 |
|
| 184 |
// 外部グローバル |
| 185 |
extern vector<CPoleLink> g_LastPole; |
| 186 |
extern vector<CPoleLink> g_FinishPole; |
| 187 |
|
| 188 |
#endif |