Subversion Repositories spk

Rev

Rev 1 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1 Rev 114
Line 1... Line 1...
1
/*
1
/*
2
  defines bob_dom_cut - class that can manipulate the CUT1 format and all the 
2
  defines bob_dom_cut - class that can manipulate the CUT1 format and all the
3
  underlying objects
3
  underlying objects
4
*/
4
*/
5
 
5
 
6
#ifndef BOB_DOM_CUT_INCLUDED
6
#ifndef BOB_DOM_CUT_INCLUDED
7
#define BOB_DOM_CUT_INCLUDED
7
#define BOB_DOM_CUT_INCLUDED
Line 13... Line 13...
13
 
13
 
14
#include "../common/ext_utils.h"
14
#include "../common/ext_utils.h"
15
#include "../common/strutils.h"
15
#include "../common/strutils.h"
16
 
16
 
17
class bob_dom_cut;
17
class bob_dom_cut;
18
class bob_dom_path;
18
class bob_path;
19
class bob_dom_stat;
19
class bob_stat;
20
 
20
 
21
class bob_dom_name : public bob_dom_string
21
class bob_name : public bob_string
22
{
22
{
23
	public:
23
	public:
24
		static const int hdr_begin=BOB_SECTION_NAME_NAME_BEGIN;
24
		static const int HDR_BEGIN = BOB_SECTION_NAME_NAME_BEGIN;
25
		static const int hdr_end=BOB_SECTION_NAME_NAME_END;
25
		static const int HDR_END = BOB_SECTION_NAME_NAME_END;
26
		
-
 
27
		bool load(bob_dom_ibinaryfilestream& is) { return bob_dom_string::load(is, hdr_begin, hdr_end); }
-
 
28
		bool toFile(bob_dom_obinaryfilestream& os) { return bob_dom_string::toFile(os, hdr_begin, hdr_end); }
-
 
29
		bool toFile(bob_dom_otextfilestream& os);
-
 
30
};
-
 
31
 
26
 
-
 
27
		bool load(ibinaryfilestream& is) { return bob_string::load(is, HDR_BEGIN, HDR_END); }
-
 
28
		bool toFile(obinaryfilestream& os) { return bob_string::toFile(os, HDR_BEGIN, HDR_END); }
-
 
29
		bool toFile(otextfilestream& os);
-
 
30
};
-
 
31
 
32
class bob_dom_constants : public bob_dom_section
32
class bob_constants : public bob_section
33
{
33
{
34
	public:
34
	public:
35
		static const int hdr_begin=BOB_SECTION_NAME_CONST_BEGIN;
35
		static const int HDR_BEGIN = BOB_SECTION_NAME_CONST_BEGIN;
36
		static const int hdr_end=BOB_SECTION_NAME_CONST_END;
36
		static const int HDR_END = BOB_SECTION_NAME_CONST_END;
37
		
37
 
38
		struct constant
38
		struct constant
39
		{
39
		{
40
			int a;
40
			int a;
41
			double b;
41
			double b;
42
			
42
 
43
			constant() { a=0; b=0; }
43
			constant() { a=0; b=0; }
44
			bool load(bob_dom_ibinaryfilestream& is);
44
			bool load(ibinaryfilestream& is);
45
			
45
 
46
			bool toFile(bob_dom_obinaryfilestream& os);
46
			bool toFile(obinaryfilestream& os);
47
			bool toFile(bob_dom_otextfilestream& os);
47
			bool toFile(otextfilestream& os);
48
		};
48
		};
49
		
49
 
50
		typedef ext::list<constant>::iterator iterator;
50
		typedef ext::list<constant>::iterator iterator;
51
		
51
 
52
		ext::list<constant> values;
52
		ext::list<constant> values;
53
		
53
 
54
		bool load(bob_dom_ibinaryfilestream& is);
54
		bool load(ibinaryfilestream& is);
55
		
55
 
56
		bool toFile(bob_dom_obinaryfilestream& os);
56
		bool toFile(obinaryfilestream& os);
57
		bool toFile(bob_dom_otextfilestream& os);
57
		bool toFile(otextfilestream& os);
58
};
58
};
59
 
59
 
60
struct bob_note
60
struct bob_note
61
{
61
{
62
	int value;
62
	int value;
63
	char *text;
63
	char *text;
64
	bob_error_codes errorCode;
64
	bob_error_codes errorCode;
65
	
65
 
66
	bob_note() { value=0; text=0; errorCode=e_noError; }
66
	bob_note() { value=0; text=0; errorCode=e_noError; }
67
	~bob_note() { delete[] text; }
67
	~bob_note() { delete[] text; }
68
	
68
 
69
	bool load(bob_dom_ibinaryfilestream& is);
69
	bool load(ibinaryfilestream& is);
70
	bool toFile(bob_dom_obinaryfilestream& os);
70
	bool toFile(obinaryfilestream& os);
71
	bool toFile(bob_dom_otextfilestream& os);
71
	bool toFile(otextfilestream& os);
72
};
72
};
73
 
73
 
74
class bob_dom_notes : public bob_dom_section, public bob_dom_cantainer<bob_note>
74
class bob_notes : public bob_section, public bob_cantainer<bob_note>
75
{
-
 
76
	public:
-
 
77
		static const int hdr_begin=BOB_SECTION_NAME_NOTE_BEGIN;
-
 
78
		static const int hdr_end=BOB_SECTION_NAME_NOTE_END;
-
 
79
		
-
 
80
		bool load(bob_dom_ibinaryfilestream& is, int lineCount);
-
 
81
		
-
 
82
		bool toFile(bob_dom_obinaryfilestream& os);
-
 
83
		bool toFile(bob_dom_otextfilestream& os);
-
 
84
};
-
 
85
 
-
 
86
// frame
-
 
87
#ifdef X2BC_USE_INI_FORMATS
-
 
88
class bob_dom_stat : public bob_dom_section, public ext::list<int>
-
 
89
{
75
{
90
	public:
-
 
91
		typedef enum state
-
 
92
		{
-
 
93
			formatted,
-
 
94
			noFormat,
-
 
95
			cannotMatchFormat
-
 
96
		};
-
 
97
		
-
 
98
	private:
-
 
99
		const Settings::StatFormat *m_format;
-
 
100
		state m_state;
-
 
101
		void setstate(state newstate) { m_state=newstate; }
-
 
102
		
-
 
103
	public:
76
	public:
104
		int frameId;
77
		static const int HDR_BEGIN=BOB_SECTION_NAME_NOTE_BEGIN;
105
		
-
 
106
		bob_dom_stat(const Settings *settings) { frameId=0; m_format=0; setstate(formatted); }
78
		static const int HDR_END=BOB_SECTION_NAME_NOTE_END;
107
		
79
 
108
		state rdstate() const { return m_state; }
80
		bool load(ibinaryfilestream& is, int lineCount);
109
		
81
 
110
		bool toFile(bob_dom_obinaryfilestream& os);
82
		bool toFile(obinaryfilestream& os);
111
		bool toFile(bob_dom_otextfilestream& os, const Settings *settings);
83
		bool toFile(otextfilestream& os);
112
		
-
 
113
		bool load(bob_dom_ibinaryfilestream& is, const Settings *settings);
-
 
114
};
84
};
115
#endif // defined(X2BC_USE_INI_FORMATS)
-
 
116
 
-
 
117
#ifdef X2BC_USE_INI_FORMATS
-
 
118
	typedef bob_dom_cantainer<bob_dom_stat> FrameContainer;
-
 
119
#else
-
 
120
	typedef bob_dom_cantainer<bob_dom_frame> FrameContainer;
-
 
121
#endif
-
 
122
 
85
 
-
 
86
 
-
 
87
typedef bob_cantainer<bob_frame> FrameContainer;
-
 
88
 
-
 
89
 
123
class bob_dom_path : public bob_dom_section, public FrameContainer
90
class bob_path : public bob_section, public FrameContainer
124
{
91
{
125
	private:
92
	private:
126
		static const int hdr_stat_begin=BOB_SECTION_NAME_STAT_BEGIN;
93
		static const int HDR_STAT_BEGIN = BOB_SECTION_NAME_STAT_BEGIN;
127
		static const int hdr_stat_end=BOB_SECTION_NAME_STAT_END;
94
		static const int HDR_STAT_END = BOB_SECTION_NAME_STAT_END;
128
		typedef ext::list<int> TempStatList;
95
		typedef ext::list<int> TempStatList;
129
		
96
 
130
		bob_dom_notes m_notes;
97
		bob_notes m_notes;
131
		const Settings *m_settings;
98
		const Settings *m_settings;
132
		char *m_bodyId;
99
		char *m_bodyId;
133
		
100
 
134
		bool loadStatValues(bob_dom_ibinaryfilestream& is, int count);
101
		bool loadStatValues(ibinaryfilestream& is, int count);
135
 
102
 
136
	public:
103
	public:
137
		enum BodyFlags {
104
		enum BodyFlags {
138
			fCamera=1,
105
			fCamera=1,
139
			fDirLight=2,
106
			fDirLight=2,
140
			fOmniLight=10,
107
			fOmniLight=10,
141
			fBody=64,
108
			fBody=64,
142
			fScene=128
109
			fScene=128
143
		};
110
		};
144
		
111
 
145
		static const int hdr_begin=BOB_SECTION_NAME_PATH_BEGIN;
112
		static const int HDR_BEGIN = BOB_SECTION_NAME_PATH_BEGIN;
146
		static const int hdr_end=BOB_SECTION_NAME_PATH_END;
113
		static const int HDR_END = BOB_SECTION_NAME_PATH_END;
147
		
114
 
148
		bob_dom_name name;
115
		bob_name name;
149
		bob_dom_constants constants;
116
		bob_constants constants;
150
		
117
 
151
		int partIdx;
118
		int partIdx;
152
		int cockpitIdx;
119
		int cockpitIdx;
153
		int parentIdx;
120
		int parentIdx;
154
		int bodyFlags; // 'c' for cameras, 'l' for lights
121
		int bodyFlags; // 'c' for cameras, 'l' for lights
155
		
122
 
156
		bob_dom_bob *bob;
123
		bob_dom_bob *bob;
157
		
124
 
158
		bob_dom_path(const Settings *s) 
125
		bob_path(const Settings *s)
159
		{ 
126
		{
160
			partIdx=0; m_bodyId=0; cockpitIdx=0; bodyFlags=0; parentIdx=null_value; bob=0; 
127
			partIdx=0; m_bodyId=0; cockpitIdx=0; bodyFlags=0; parentIdx=null_value; bob=0;
161
			m_settings=s;
128
			m_settings=s;
162
		}
129
		}
163
		
130
 
164
		~bob_dom_path() { delete m_bodyId; delete bob; }
131
		~bob_path() { delete m_bodyId; delete bob; }
165
		
132
 
166
		const char * bodyId() const { return m_bodyId; }
133
		const char * bodyId() const { return m_bodyId; }
167
		void bodyId(const char *str) { strcreate(m_bodyId, str); }
134
		void bodyId(const char *str) { strcreate(m_bodyId, str); }
168
		
135
 
169
		bob_dom_notes& notes() { return m_notes; }
136
		bob_notes& notes() { return m_notes; }
170
		
137
 
171
		bool toFile(bob_dom_obinaryfilestream& os, int cutVersion);
138
		bool toFile(obinaryfilestream& os, int cutVersion);
172
		bool toFile(bob_dom_otextfilestream& os, int idx);
139
		bool toFile(otextfilestream& os, int idx);
173
		
140
 
174
		bool load(bob_dom_ibinaryfilestream& is, int version);
141
		bool load(ibinaryfilestream& is, int version);
175
		
-
 
176
		//bool formatStats();
-
 
177
		
142
 
178
		child_type* createChild() 
143
		child_type* createChild()
179
		{ 
144
		{
180
			child_type *ch; 
145
			child_type *ch=new bob_frame();
181
#ifdef X2BC_USE_INI_FORMATS
-
 
182
			ch=new bob_dom_stat(m_settings);
-
 
183
#else
-
 
184
			ch=new bob_dom_frame();
146
			children.push_back(ch); 
185
#endif
-
 
186
			children.push_back(ch); return ch; 
147
			return ch;
187
		}
148
		}
188
};
149
};
189
 
150
 
190
class bob_dom_cut : public bob_dom_section, public bob_dom_cantainer<bob_dom_path>
151
class bob_dom_cut : public bob_section, public bob_cantainer<bob_path>
191
{
152
{
192
	private:
153
	private:
193
		int m_storedPathCount;
154
		int m_storedPathCount;
194
		const Settings *m_settings;
155
		const Settings *m_settings;
195
 
156
 
196
	public:
157
	public:
197
		static const int hdr_begin=BOB_SECTION_NAME_CUT_BEGIN;
158
		static const int HDR_BEGIN = BOB_SECTION_NAME_CUT_BEGIN;
198
		static const int hdr_end=BOB_SECTION_NAME_CUT_END;
159
		static const int HDR_END =BOB_SECTION_NAME_CUT_END;
199
		
160
 
200
		static const int supported_version = 6;
161
		static const int supported_version = 6;
201
		
162
 
202
		int version;
163
		int version;
203
		bob_dom_info info;
164
		bob_info info;
204
		
165
 
205
		bob_dom_cut(const Settings *s) { m_settings=s; version=0; m_storedPathCount=0; }
166
		bob_dom_cut(const Settings *s) { m_settings=s; version=0; m_storedPathCount=0; }
206
		
-
 
207
		bool toFile(bob_dom_obinaryfilestream& os);
-
 
208
		bool toFile(bob_dom_otextfilestream& os);
-
 
209
		
-
 
210
		value_type_ptr createChild() { return *(children.push_back(new bob_dom_path(m_settings))); }
-
 
211
		
-
 
212
		
-
 
213
		bool load(bob_dom_ibinaryfilestream& is);
-
 
214
		
-
 
215
		bool convert(bob_dom_ibinaryfilestream& is, bob_dom_otextfilestream& os);
-
 
216
		
-
 
217
		//bool formatStats();
-
 
218
};
-
 
219
 
-
 
220
 
-
 
221
template <class Ty>
-
 
222
inline
-
 
223
Ty& operator << (Ty& os, bob_dom_info& info)
-
 
224
{
-
 
225
	info.toFile(os);
-
 
226
	return os;
-
 
227
}
-
 
228
 
-
 
229
template <class Ty>
-
 
230
inline
-
 
231
Ty& operator << (Ty& os, bob_dom_name& right)
-
 
232
{
-
 
233
	right.toFile(os);
-
 
234
	return os;
-
 
235
}
-
 
236
 
167
 
237
template <class Ty>
-
 
238
inline
-
 
239
Ty& operator << (Ty& os, bob_dom_path& right)
168
		bool toFile(obinaryfilestream& os);
240
{
-
 
241
	right.toFile(os);
169
		bool toFile(otextfilestream& os);
242
	return os;
-
 
243
}
170
 
-
 
171
		value_type_ptr createChild() { return *(children.push_back(new bob_path(m_settings))); }
244
 
172
 
245
#ifdef X2BC_USE_INI_FORMATS
-
 
246
template <class Ty>
-
 
247
inline
173
 
248
Ty& operator << (Ty& os, bob_dom_stat& right)
174
		bool load(ibinaryfilestream& is);
249
{
175
 
250
	right.toFile(os);
176
		bool convert(ibinaryfilestream& is, otextfilestream& os);
251
	return os;
-
 
252
}
177
};
253
#endif
-
 
254
 
178
 
255
#endif // !defined(BOB_DOM_CUT_INCLUDED)
179
#endif // !defined(BOB_DOM_CUT_INCLUDED)