Subversion Repositories spk

Rev

Rev 1 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 cycrow 1
/*
114 cycrow 2
  defines bob_dom_cut - class that can manipulate the CUT1 format and all the
1 cycrow 3
  underlying objects
4
*/
5
 
6
#ifndef BOB_DOM_CUT_INCLUDED
7
#define BOB_DOM_CUT_INCLUDED
8
 
9
#include "bob_dom_base.h"
10
#include "bob_dom_bob.h"
11
#include "Settings.h"
12
#include "bob_dom_frame.h"
13
 
14
#include "../common/ext_utils.h"
15
#include "../common/strutils.h"
16
 
17
class bob_dom_cut;
114 cycrow 18
class bob_path;
19
class bob_stat;
1 cycrow 20
 
114 cycrow 21
class bob_name : public bob_string
1 cycrow 22
{
23
	public:
114 cycrow 24
		static const int HDR_BEGIN = BOB_SECTION_NAME_NAME_BEGIN;
25
		static const int HDR_END = BOB_SECTION_NAME_NAME_END;
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);
1 cycrow 30
};
31
 
114 cycrow 32
class bob_constants : public bob_section
1 cycrow 33
{
34
	public:
114 cycrow 35
		static const int HDR_BEGIN = BOB_SECTION_NAME_CONST_BEGIN;
36
		static const int HDR_END = BOB_SECTION_NAME_CONST_END;
37
 
1 cycrow 38
		struct constant
39
		{
40
			int a;
41
			double b;
114 cycrow 42
 
1 cycrow 43
			constant() { a=0; b=0; }
114 cycrow 44
			bool load(ibinaryfilestream& is);
45
 
46
			bool toFile(obinaryfilestream& os);
47
			bool toFile(otextfilestream& os);
1 cycrow 48
		};
114 cycrow 49
 
1 cycrow 50
		typedef ext::list<constant>::iterator iterator;
114 cycrow 51
 
1 cycrow 52
		ext::list<constant> values;
114 cycrow 53
 
54
		bool load(ibinaryfilestream& is);
55
 
56
		bool toFile(obinaryfilestream& os);
57
		bool toFile(otextfilestream& os);
1 cycrow 58
};
59
 
60
struct bob_note
61
{
62
	int value;
63
	char *text;
64
	bob_error_codes errorCode;
114 cycrow 65
 
1 cycrow 66
	bob_note() { value=0; text=0; errorCode=e_noError; }
67
	~bob_note() { delete[] text; }
114 cycrow 68
 
69
	bool load(ibinaryfilestream& is);
70
	bool toFile(obinaryfilestream& os);
71
	bool toFile(otextfilestream& os);
1 cycrow 72
};
73
 
114 cycrow 74
class bob_notes : public bob_section, public bob_cantainer<bob_note>
1 cycrow 75
{
76
	public:
114 cycrow 77
		static const int HDR_BEGIN=BOB_SECTION_NAME_NOTE_BEGIN;
78
		static const int HDR_END=BOB_SECTION_NAME_NOTE_END;
1 cycrow 79
 
114 cycrow 80
		bool load(ibinaryfilestream& is, int lineCount);
81
 
82
		bool toFile(obinaryfilestream& os);
83
		bool toFile(otextfilestream& os);
1 cycrow 84
};
85
 
86
 
114 cycrow 87
typedef bob_cantainer<bob_frame> FrameContainer;
88
 
89
 
90
class bob_path : public bob_section, public FrameContainer
1 cycrow 91
{
92
	private:
114 cycrow 93
		static const int HDR_STAT_BEGIN = BOB_SECTION_NAME_STAT_BEGIN;
94
		static const int HDR_STAT_END = BOB_SECTION_NAME_STAT_END;
1 cycrow 95
		typedef ext::list<int> TempStatList;
114 cycrow 96
 
97
		bob_notes m_notes;
1 cycrow 98
		const Settings *m_settings;
99
		char *m_bodyId;
100
 
114 cycrow 101
		bool loadStatValues(ibinaryfilestream& is, int count);
102
 
1 cycrow 103
	public:
104
		enum BodyFlags {
105
			fCamera=1,
106
			fDirLight=2,
107
			fOmniLight=10,
108
			fBody=64,
109
			fScene=128
110
		};
114 cycrow 111
 
112
		static const int HDR_BEGIN = BOB_SECTION_NAME_PATH_BEGIN;
113
		static const int HDR_END = BOB_SECTION_NAME_PATH_END;
114
 
115
		bob_name name;
116
		bob_constants constants;
117
 
1 cycrow 118
		int partIdx;
119
		int cockpitIdx;
120
		int parentIdx;
121
		int bodyFlags; // 'c' for cameras, 'l' for lights
114 cycrow 122
 
1 cycrow 123
		bob_dom_bob *bob;
114 cycrow 124
 
125
		bob_path(const Settings *s)
126
		{
127
			partIdx=0; m_bodyId=0; cockpitIdx=0; bodyFlags=0; parentIdx=null_value; bob=0;
1 cycrow 128
			m_settings=s;
129
		}
114 cycrow 130
 
131
		~bob_path() { delete m_bodyId; delete bob; }
132
 
1 cycrow 133
		const char * bodyId() const { return m_bodyId; }
134
		void bodyId(const char *str) { strcreate(m_bodyId, str); }
114 cycrow 135
 
136
		bob_notes& notes() { return m_notes; }
137
 
138
		bool toFile(obinaryfilestream& os, int cutVersion);
139
		bool toFile(otextfilestream& os, int idx);
140
 
141
		bool load(ibinaryfilestream& is, int version);
142
 
143
		child_type* createChild()
144
		{
145
			child_type *ch=new bob_frame();
146
			children.push_back(ch); 
147
			return ch;
1 cycrow 148
		}
149
};
150
 
114 cycrow 151
class bob_dom_cut : public bob_section, public bob_cantainer<bob_path>
1 cycrow 152
{
153
	private:
154
		int m_storedPathCount;
155
		const Settings *m_settings;
156
 
157
	public:
114 cycrow 158
		static const int HDR_BEGIN = BOB_SECTION_NAME_CUT_BEGIN;
159
		static const int HDR_END =BOB_SECTION_NAME_CUT_END;
160
 
1 cycrow 161
		static const int supported_version = 6;
114 cycrow 162
 
1 cycrow 163
		int version;
114 cycrow 164
		bob_info info;
165
 
1 cycrow 166
		bob_dom_cut(const Settings *s) { m_settings=s; version=0; m_storedPathCount=0; }
167
 
114 cycrow 168
		bool toFile(obinaryfilestream& os);
169
		bool toFile(otextfilestream& os);
1 cycrow 170
 
114 cycrow 171
		value_type_ptr createChild() { return *(children.push_back(new bob_path(m_settings))); }
1 cycrow 172
 
173
 
114 cycrow 174
		bool load(ibinaryfilestream& is);
1 cycrow 175
 
114 cycrow 176
		bool convert(ibinaryfilestream& is, otextfilestream& os);
177
};
1 cycrow 178
 
179
#endif // !defined(BOB_DOM_CUT_INCLUDED)