| 1 |
#ifndef CMODELSWITCH_H_INCLUDED |
| 2 |
#define CMODELSWITCH_H_INCLUDED |
| 3 |
|
| 4 |
#include "CCustomizer.h" |
| 5 |
#include "CEffector.h" |
| 6 |
|
| 7 |
class CListView; |
| 8 |
class CListElement; |
| 9 |
class CExpression; |
| 10 |
class CModelPlugin; |
| 11 |
class CModelInst; |
| 12 |
|
| 13 |
// システムスイッチ番号 |
| 14 |
extern enum{ |
| 15 |
SYS_SW_FRONT = 0, |
| 16 |
SYS_SW_CONNECT1, |
| 17 |
SYS_SW_CONNECT2, |
| 18 |
SYS_SW_DOOR1, |
| 19 |
SYS_SW_DOOR2, |
| 20 |
SYS_SW_SERIAL, |
| 21 |
SYS_SW_CAMDIST, |
| 22 |
SYS_SW_VELOCITY, |
| 23 |
SYS_SW_ACCEL, |
| 24 |
SYS_SW_CABINVIEW, |
| 25 |
SYS_SW_APPROACH1, |
| 26 |
SYS_SW_APPROACH2, |
| 27 |
SYS_SW_STOPPING, |
| 28 |
// ↑ instance switches (repaired when afterrender) |
| 29 |
SYS_SW_NIGHT, |
| 30 |
SYS_SW_WEATHER, |
| 31 |
SYS_SW_SEASON, |
| 32 |
SYS_SW_SHADOW, |
| 33 |
SYS_SW_ENVMAP, |
| 34 |
SYS_SW_YEAR, |
| 35 |
SYS_SW_MONTH, |
| 36 |
SYS_SW_DAY, |
| 37 |
SYS_SW_DAYOFWEEK, |
| 38 |
SYS_SW_HOUR, |
| 39 |
SYS_SW_MINUTE, |
| 40 |
SYS_SW_SECOND, |
| 41 |
SYS_SW_FORCE_DWORD = 0xffffffff |
| 42 |
} SYS_SW_ID; |
| 43 |
|
| 44 |
// 内部定数 |
| 45 |
const int SYSTEM_SWITCH_NUM = 25; // システムスイッチ数 |
| 46 |
const int INSTANCE_SWITCH_NUM = 13; // 内、インスタンススイッチ数 |
| 47 |
|
| 48 |
/* |
| 49 |
* モデルスイッチ |
| 50 |
*/ |
| 51 |
class CModelSwitch{ |
| 52 |
friend class CModelPlugin; |
| 53 |
friend class CSwitchApplier; |
| 54 |
private: |
| 55 |
int m_ID; // 番号 |
| 56 |
int m_Value; // 値 |
| 57 |
string m_SwitchName; // スイッチ名 |
| 58 |
string m_GroupCommon; // 編成共通識別子 |
| 59 |
list<string> m_Entry; // エントリ |
| 60 |
CListElement *m_ListElement; // リスト要素 |
| 61 |
public: |
| 62 |
CModelSwitch(); |
| 63 |
CModelSwitch(int); |
| 64 |
void Init(int, char *); |
| 65 |
int GetValue(){ return m_Value; } |
| 66 |
void SetValue(int v){ m_Value = v; } |
| 67 |
char *Read(char *, CModelPlugin *); |
| 68 |
CModelSwitch *Check(const string &name){ return m_SwitchName==name ? this : NULL; } |
| 69 |
bool IsGroupCommon(){ return !!m_GroupCommon.size(); } |
| 70 |
CModelSwitch *CheckGroupCommon(CModelSwitch *rhs){ |
| 71 |
return m_GroupCommon==rhs->m_GroupCommon ? this : NULL; |
| 72 |
} |
| 73 |
char *GetCurrentOptionName(); |
| 74 |
void ListEntry(CListView *); |
| 75 |
void EditSwitch(CListView *, int *, int); |
| 76 |
void SetListElement(CListElement *le){ m_ListElement = le; } |
| 77 |
}; |
| 78 |
|
| 79 |
// 反復子 |
| 80 |
typedef list<CModelSwitch>::iterator IModelSwitch; |
| 81 |
|
| 82 |
/* |
| 83 |
* ネットワーク同期用スイッチ識別情報 |
| 84 |
*/ |
| 85 |
struct CStaticSwitchID{ |
| 86 |
CModelInst *inst; |
| 87 |
int index; |
| 88 |
int tmp_opt; |
| 89 |
bool net_sync; |
| 90 |
CStaticSwitchID(CModelInst *ins, int idx) |
| 91 |
: inst(ins), index(idx), tmp_opt(-1), net_sync(false) |
| 92 |
{} |
| 93 |
}; |
| 94 |
|
| 95 |
//////////////////////////////////////////////////////////////////////////////// |
| 96 |
//////////////////////////////////////////////////////////////////////////////// |
| 97 |
|
| 98 |
/* |
| 99 |
* スイッチ適用エントリ |
| 100 |
*/ |
| 101 |
class CSwitchEntry{ |
| 102 |
friend class CSwitchApplier; |
| 103 |
protected: |
| 104 |
int m_TypeFlag; // タイプフラグ |
| 105 |
int m_ConditionType; // 0: case, 1: always, 2: true, 3: false, 4: default |
| 106 |
vector<int> m_Value; // 適用番号 |
| 107 |
public: |
| 108 |
virtual ~CSwitchEntry(){} |
| 109 |
char *Read(char *, CModelPlugin *, int); |
| 110 |
virtual char *Read2(char *, CModelPlugin *) = 0; |
| 111 |
int GetTypeFlag(){ return m_TypeFlag; } |
| 112 |
bool CheckValue(int, bool); |
| 113 |
}; |
| 114 |
|
| 115 |
/* |
| 116 |
* スイッチ適用子 |
| 117 |
*/ |
| 118 |
class CSwitchApplier{ |
| 119 |
protected: |
| 120 |
int m_TypeFlag; // タイプフラグ |
| 121 |
CExpression *m_Expression; // 接続先スイッチ |
| 122 |
public: |
| 123 |
CSwitchApplier(){ m_Expression = NULL; } |
| 124 |
CSwitchApplier(const CSwitchApplier *); |
| 125 |
virtual ~CSwitchApplier(); |
| 126 |
char *Read(char *, CModelPlugin *); |
| 127 |
virtual char *Read2(char *, CModelPlugin *, int) = 0; |
| 128 |
int GetSwitchValue(); |
| 129 |
}; |
| 130 |
|
| 131 |
//////////////////////////////////////////////////////////////////////////////// |
| 132 |
//////////////////////////////////////////////////////////////////////////////// |
| 133 |
|
| 134 |
/* |
| 135 |
* カスタマイザスイッチ適用エントリ |
| 136 |
*/ |
| 137 |
class CCustomizerSwitchEntry: public CSwitchEntry{ |
| 138 |
friend class CSwitchApplier; |
| 139 |
private: |
| 140 |
list<CCustomizerContainer> m_Customizer; // カスタマイザリスト |
| 141 |
public: |
| 142 |
char *Read2(char *, CModelPlugin *); |
| 143 |
void LoadData(CModelPlugin *); |
| 144 |
void SetOffList(CNamedObject *); |
| 145 |
CMesh *GetMesh(float *); |
| 146 |
void SetPosture(CObject *); |
| 147 |
void Apply(CMesh *); |
| 148 |
}; |
| 149 |
|
| 150 |
// 反復子 |
| 151 |
typedef list<CCustomizerSwitchEntry>::iterator ICustomizerSwitchEntry; |
| 152 |
|
| 153 |
/* |
| 154 |
* カスタマイザスイッチ適用子 |
| 155 |
*/ |
| 156 |
class CCustomizerSwitchApplier: public CCustomizerBase, public CSwitchApplier{ |
| 157 |
private: |
| 158 |
list<CCustomizerSwitchEntry> m_Entry; // エントリ |
| 159 |
public: |
| 160 |
CCustomizerSwitchApplier(){} |
| 161 |
CCustomizerSwitchApplier(const CCustomizerSwitchApplier &rhs): |
| 162 |
CSwitchApplier(&rhs){ m_Entry = rhs.m_Entry; } |
| 163 |
CCustomizerBase *Duplicate(){ return new CCustomizerSwitchApplier(*this); } |
| 164 |
char *Read2(char *, CModelPlugin *, int); |
| 165 |
void LoadDataCustomizer(CModelPlugin *); |
| 166 |
void SetOffListCustomizer(CNamedObject *); |
| 167 |
int GetTypeFlagCustomizer(){ return m_TypeFlag; } |
| 168 |
CMesh *GetMeshCustomizer(float *); |
| 169 |
void SetPostureCustomizer(CObject *); |
| 170 |
void ApplyCustomizer(CMesh *); |
| 171 |
}; |
| 172 |
|
| 173 |
//////////////////////////////////////////////////////////////////////////////// |
| 174 |
//////////////////////////////////////////////////////////////////////////////// |
| 175 |
|
| 176 |
/* |
| 177 |
* エフェクタスイッチ適用エントリ |
| 178 |
*/ |
| 179 |
class CEffectorSwitchEntry: public CSwitchEntry{ |
| 180 |
friend class CSwitchApplier; |
| 181 |
private: |
| 182 |
list<CEffectorContainer> m_Effector; // カスタマイザリスト |
| 183 |
public: |
| 184 |
char *Read2(char *, CModelPlugin *); |
| 185 |
void LoadData(CModelPlugin *); |
| 186 |
void Apply(CScene *); |
| 187 |
}; |
| 188 |
|
| 189 |
// 反復子 |
| 190 |
typedef list<CEffectorSwitchEntry>::iterator IEffectorSwitchEntry; |
| 191 |
|
| 192 |
/* |
| 193 |
* エフェクタスイッチ適用子 |
| 194 |
*/ |
| 195 |
class CEffectorSwitchApplier: public CEffectorBase, public CSwitchApplier{ |
| 196 |
private: |
| 197 |
list<CEffectorSwitchEntry> m_Entry; // エントリ |
| 198 |
public: |
| 199 |
CEffectorSwitchApplier(){} |
| 200 |
CEffectorSwitchApplier(const CEffectorSwitchApplier &rhs): |
| 201 |
CSwitchApplier(&rhs){ m_Entry = rhs.m_Entry; } |
| 202 |
CEffectorBase *Duplicate(){ return new CEffectorSwitchApplier(*this); } |
| 203 |
char *Read2(char *, CModelPlugin *, int); |
| 204 |
void LoadDataEffector(CModelPlugin *); |
| 205 |
int GetTypeFlagEffector(){ return m_TypeFlag; } |
| 206 |
void ApplyEffector(CScene *); |
| 207 |
}; |
| 208 |
|
| 209 |
// 関数宣言 |
| 210 |
void InitSystemSwitch(); |
| 211 |
void SetCamDistSwitch(VEC3); |
| 212 |
|
| 213 |
// 外部グローバル |
| 214 |
extern CModelSwitch g_SystemSwitch[]; |
| 215 |
extern vector<CStaticSwitchID> g_StaticSwitchTable; |
| 216 |
|
| 217 |
#endif |