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_bob - class that can manipulate the BOB1 format and all the
1 cycrow 3
  underlying objects
4
*/
5
 
114 cycrow 6
#ifndef BOB_BOB_INCLUDED
7
#define BOB_BOB_INCLUDED
1 cycrow 8
 
9
#include "bob_dom_base.h"
10
#include "settings.h"
11
#include "../common/ext_utils.h"
12
#include "../common/ext_array.h"
13
#include "../common/ext_simple_list.h"
14
#include "../common/strutils.h"
114 cycrow 15
#include "../common/ptr_list.h"
1 cycrow 16
 
114 cycrow 17
#include "conversion.h"
18
 
1 cycrow 19
class bob_dom_bob;
20
 
114 cycrow 21
class bob_bodies;
22
class bob_body;
1 cycrow 23
 
114 cycrow 24
class bob_materials;
25
class bob_material3;
26
class bob_material5;
1 cycrow 27
 
114 cycrow 28
class bob_points;
29
class bob_vertex;
1 cycrow 30
 
114 cycrow 31
class bob_part;
32
class bob_face;
1 cycrow 33
 
34
class bob_point_map;
35
 
36
enum X2BobType
37
{
38
	bobX2,
39
	bobX3
40
};
41
 
42
 
114 cycrow 43
class bob_weight
1 cycrow 44
{
45
	public:
46
		struct value
47
		{
114 cycrow 48
			static const int MULTIPLIER = 65536;
49
 
1 cycrow 50
			short boneIdx;
51
			int boneCoefficient;
114 cycrow 52
 
53
			void toFile(otextfilestream& os)
1 cycrow 54
			{
114 cycrow 55
				os << boneIdx << (boneCoefficient / (double)MULTIPLIER);
1 cycrow 56
			}
57
 
58
		};
114 cycrow 59
 
1 cycrow 60
	private:
114 cycrow 61
 
1 cycrow 62
	public:
63
		typedef ext::list<value>::iterator iterator;
64
		typedef ext::list<value>::const_iterator const_iterator;
114 cycrow 65
 
1 cycrow 66
		bob_error_codes errorCode;
67
		ext::list<value> values;
114 cycrow 68
 
69
		bob_weight() { errorCode=e_noError; }
70
		bob_weight(const bob_weight& other)
71
		{
72
			errorCode=other.errorCode;
1 cycrow 73
			for(const_iterator &it=other.values.begin(); it!=other.values.end(); ++it){
74
				values.push_back(*it);
75
			}
76
		}
114 cycrow 77
 
78
		bool load(ibinaryfilestream& is);
79
 
80
		bool toFile(obinaryfilestream& os);
81
		bool toFile(otextfilestream& os, int idx);
1 cycrow 82
};
83
 
114 cycrow 84
class bob_weights : public bob_section, public ptr_list<ext::array<bob_weight*> >
1 cycrow 85
{
86
	public:
114 cycrow 87
		static const int HDR_BEGIN = BOB_SECTION_NAME_WEIGHT_BEGIN;
88
		static const int HDR_END = BOB_SECTION_NAME_WEIGHT_END;
89
 
90
		typedef ptr_list<ext::simple_list<bob_weight*> > WeightList;
91
 
1 cycrow 92
		WeightList new_weights;
114 cycrow 93
 
94
		bool load(ibinaryfilestream& is);
95
 
96
		bool toFile(obinaryfilestream& os);
97
		bool toFile(otextfilestream& os, const bob_point_map *pointMap);
1 cycrow 98
};
99
 
114 cycrow 100
class bob_bones : public bob_section, public ptr_list<ext::list<char*> >
1 cycrow 101
{
102
	public:
114 cycrow 103
		static const int HDR_BEGIN = BOB_SECTION_NAME_BONE_BEGIN;
104
		static const int HDR_END = BOB_SECTION_NAME_BONE_END;
105
 
106
		bool load(ibinaryfilestream &is);
107
 
108
		bool toFile(obinaryfilestream& os);
109
		bool toFile(otextfilestream& os);
110
 
1 cycrow 111
};
112
 
114 cycrow 113
class bob_material
1 cycrow 114
{
115
	public:
116
		enum materialType
117
		{
118
			mat1,
119
			mat3,
120
			mat5,
121
			mat6
122
		};
114 cycrow 123
 
1 cycrow 124
		materialType type;
125
		short index;
114 cycrow 126
 
1 cycrow 127
		bob_error_codes errorCode;
128
 
114 cycrow 129
		bob_material() { index=0; }
130
		virtual ~bob_material() { }
131
 
132
		virtual bool load(ibinaryfilestream& is) = 0;
133
 
134
		virtual bool toFile(obinaryfilestream& os) = 0;
135
		virtual bool toFile(otextfilestream& os) = 0;
1 cycrow 136
};
137
 
114 cycrow 138
class bob_material1 : public bob_material
1 cycrow 139
{
140
	public:
141
		struct rgb
142
		{
143
			short r, g, b;
144
			rgb() { r=g=b=0; }
145
		};
114 cycrow 146
 
1 cycrow 147
		struct pair
148
		{
149
			short value;
150
			short strength;
151
			pair() { value=0; strength=0; }
152
		};
114 cycrow 153
 
1 cycrow 154
		short textureID;
155
		rgb ambient;
156
		rgb diffuse;
157
		rgb specular;
114 cycrow 158
 
159
		bob_material1()
1 cycrow 160
		{
161
			type=mat1;
162
			index=0; textureID=0; errorCode=e_noError;
163
		}
114 cycrow 164
 
165
		bool load(ibinaryfilestream& is);
166
 
167
		bool toFile(obinaryfilestream& os);
168
		bool toFile(otextfilestream& os);
1 cycrow 169
};
170
 
171
inline
114 cycrow 172
ibinaryfilestream& operator >> (ibinaryfilestream& is, bob_material1::pair& right)
1 cycrow 173
{
174
	is >> right.value >> right.strength;
175
	return is;
176
}
177
 
178
inline
114 cycrow 179
obinaryfilestream& operator << (obinaryfilestream& os, bob_material1::pair& right)
1 cycrow 180
{
181
	os << right.value << right.strength;
182
	return os;
183
}
184
 
185
inline
114 cycrow 186
ibinaryfilestream& operator >> (ibinaryfilestream& is, bob_material1::rgb& r)
1 cycrow 187
{
188
	is >> r.r >> r.g >> r.b;
189
	return is;
190
}
191
 
192
inline
114 cycrow 193
obinaryfilestream& operator << (obinaryfilestream& os, bob_material1::rgb& right)
1 cycrow 194
{
195
	os << right.r << right.g << right.b;
196
	return os;
197
}
198
 
199
inline
114 cycrow 200
otextfilestream& operator << (otextfilestream& os, bob_material1::pair& right)
1 cycrow 201
{
202
	int f=os.flags();
203
	os << noSemicolons;
204
	os << right.value << ';' << right.strength << "; ";
205
	os.flags(f);
206
	return os;
207
}
208
 
209
inline
114 cycrow 210
otextfilestream& operator << (otextfilestream& os, bob_material1::rgb& right)
1 cycrow 211
{
212
	int f=os.flags();
213
	os << noSemicolons;
214
	os << right.r << ';' << right.g << ';' << right.b << "; ";
215
	os.flags(f);
216
	return os;
217
}
218
 
114 cycrow 219
class bob_material3 : public bob_material1
1 cycrow 220
{
221
	public:
222
		int transparency;
223
		short selfIllumination;
224
		pair shininess;
225
		bool destinationBlend;
226
		bool twoSided;
227
		bool wireframe;
228
		short textureValue;
229
		pair enviromentMap;
230
		pair bumpMap;
114 cycrow 231
 
232
		typedef bob_material1 base;
233
 
234
		bob_material3() {
1 cycrow 235
			type=mat3;
236
			transparency=0; selfIllumination=0; destinationBlend=0;
114 cycrow 237
			twoSided=0; wireframe=0; textureValue=0;
1 cycrow 238
		}
114 cycrow 239
 
240
		bool load(ibinaryfilestream& is);
241
 
242
		bool toFile(obinaryfilestream& os);
243
		bool toFile(otextfilestream& os);
1 cycrow 244
};
245
 
114 cycrow 246
class bob_material5 : public bob_material3
1 cycrow 247
{
248
	private:
114 cycrow 249
 
1 cycrow 250
	public:
114 cycrow 251
		typedef bob_material3 base;
252
 
1 cycrow 253
		pair lightMap;
114 cycrow 254
 
255
		bob_material5() { type=mat5; }
256
 
257
		bool load(ibinaryfilestream& is);
258
 
259
		bool toFile(obinaryfilestream& os);
260
		bool toFile(otextfilestream& os);
261
 
1 cycrow 262
};
263
 
264
class material6_value
265
{
266
	private:
267
		static char *m_stringTypes[];
268
		static int m_stringTypesCount;
114 cycrow 269
 
1 cycrow 270
	public:
114 cycrow 271
		enum Type
1 cycrow 272
		{
273
			typeLong=0,
274
			typeBool=1,
275
			typeFloat=2,
276
			typeFloat4=5,
277
			typeString=8
278
		};
114 cycrow 279
 
1 cycrow 280
		struct float4
281
		{
282
			float f[4];
283
		};
114 cycrow 284
 
1 cycrow 285
		union TagValue
286
		{
287
			bool b;
288
			int i;
289
			char *psz;
290
			float f;
291
			float4 f4;
292
		} val;
293
 
294
		Type type;
295
		char *name;
114 cycrow 296
 
1 cycrow 297
		material6_value() { val.i=0; type=typeLong; name=0; }
298
		material6_value(Type type) { val.i=0; this->type=type; name=0; }
299
 
300
		~material6_value() { delete name; if(type==typeString) delete val.psz; }
114 cycrow 301
 
1 cycrow 302
		static const char * typeName(int type) { return type < m_stringTypesCount ? m_stringTypes[type] : ""; }
303
		const char * typeName() const { return typeName(type); }
304
		static int typeNameCount() { return m_stringTypesCount; }
114 cycrow 305
 
306
		bob_error_codes load(ibinaryfilestream& is);
307
		bool toFile(otextfilestream& os);
308
		bool toFile(obinaryfilestream& os);
1 cycrow 309
};
310
 
114 cycrow 311
inline ibinaryfilestream& operator >> (ibinaryfilestream& is, material6_value::float4 &val)
1 cycrow 312
{
313
	for(int i=0; i < 4; i++){
314
		is >> val.f[i];
315
	}
316
	return is;
317
}
318
 
114 cycrow 319
inline obinaryfilestream& operator << (obinaryfilestream& os, material6_value::float4 &val)
1 cycrow 320
{
321
	for(int i=0; i < 4; i++){
322
		os << val.f[i];
323
	}
324
	return os;
325
}
326
 
114 cycrow 327
class bob_material6_values : public ptr_list<ext::simple_list<material6_value*> >
1 cycrow 328
{
329
	public:
330
		typedef ext::simple_list<material6_value*> base;
331
		typedef base::iterator iterator;
114 cycrow 332
 
1 cycrow 333
	public:
114 cycrow 334
		bob_error_codes load(ibinaryfilestream& is);
335
 
336
		bool toFile(otextfilestream& os);
337
		bool toFile(obinaryfilestream& os);
1 cycrow 338
};
339
 
114 cycrow 340
class bob_material6 : public bob_material
1 cycrow 341
{
342
	public:
343
		class Big
344
		{
345
			public:
346
				static const int flag=0x2000000;
114 cycrow 347
 
1 cycrow 348
				char *effect;
349
				short technique;
114 cycrow 350
 
351
				bob_material6_values values;
352
 
1 cycrow 353
				Big() { effect=0; technique=0; }
354
				~Big() { delete[] effect; }
114 cycrow 355
 
356
				bob_error_codes load(ibinaryfilestream& is);
357
 
358
				bool toFile(otextfilestream& os);
359
				bool toFile(obinaryfilestream& os);
1 cycrow 360
		};
114 cycrow 361
 
1 cycrow 362
		class Small
363
		{
114 cycrow 364
			public:
1 cycrow 365
				struct pair
366
				{
367
					char *texture;
368
					short strength;
114 cycrow 369
 
1 cycrow 370
					pair() { texture=0; }
371
					~pair() { delete[] texture; }
114 cycrow 372
 
373
					pair& operator = (const pair& other)
374
					{
375
						strcreate(texture, other.texture); strength=other.strength; return *this;
1 cycrow 376
					}
377
				};
114 cycrow 378
 
1 cycrow 379
				char *textureFile;
114 cycrow 380
				bob_material1::rgb ambient, diffuse, specular;
1 cycrow 381
				int transparency;
382
				short selfIllumination;
114 cycrow 383
				bob_material1::pair shininess;
1 cycrow 384
				bool destinationBlend;
385
				bool twoSided;
386
				bool wireframe;
387
				short textureValue;
388
				pair enviromentMap;
389
				pair bumpMap;
390
				pair lightMap;
391
				pair map4, map5;
114 cycrow 392
 
393
				Small() {
1 cycrow 394
					textureFile=0; transparency=0; selfIllumination=0; destinationBlend=false; twoSided=false; wireframe=false;
395
					textureValue=0;
396
				}
114 cycrow 397
				~Small()
398
				{
399
					delete[] textureFile;
1 cycrow 400
				}
114 cycrow 401
 
402
				bob_error_codes load(ibinaryfilestream& is, int flags);
403
 
404
				bool toFile(otextfilestream& os);
405
				bool toFile(obinaryfilestream& os);
1 cycrow 406
		};
114 cycrow 407
 
1 cycrow 408
	public:
409
#ifdef small // some fucking definition from RPC (god knows where it's included)
410
	#undef small
411
#endif
412
		int flags;
413
		Small *small;
414
		Big *big;
114 cycrow 415
 
416
		bob_material6() { type=mat6; flags=0; small=0; big=0; }
417
		~bob_material6() { delete small; delete big; }
418
 
419
		bool load(ibinaryfilestream& is);
420
 
421
		bool toFile(obinaryfilestream& os);
422
		bool toFile(otextfilestream& os);
1 cycrow 423
};
424
 
425
inline
114 cycrow 426
ibinaryfilestream& operator >> (ibinaryfilestream& is, bob_material6::Small::pair& right)
1 cycrow 427
{
428
	is >> right.texture >> right.strength;
429
	return is;
430
}
431
 
432
inline
114 cycrow 433
obinaryfilestream& operator << (obinaryfilestream& os, bob_material6::Small::pair& right)
1 cycrow 434
{
435
	static char *empty="";
436
	os << (right.texture ? right.texture : empty) << right.strength;
437
	return os;
438
}
439
 
440
inline
114 cycrow 441
otextfilestream& operator << (otextfilestream& os, bob_material6::Small::pair& right)
1 cycrow 442
{
443
	int old=os.flags();
444
	os << noSemicolons << (*(right.texture)==0 ? "NULL" : right.texture) << ';' << autoSemicolons << right.strength;
445
	os.flags(old);
446
	return os;
447
}
448
 
114 cycrow 449
class bob_materials : public bob_section, public ptr_list<ext::list<bob_material*> >
1 cycrow 450
{
451
	private:
114 cycrow 452
 
1 cycrow 453
	public:
114 cycrow 454
		static const int HDR_MAT6_BEGIN = BOB_SECTION_NAME_MAT6_BEGIN;
455
		static const int HDR_MAT5_BEGIN = BOB_SECTION_NAME_MAT5_BEGIN;
456
		static const int HDR_END = BOB_SECTION_NAME_MAT_END;
457
 
458
		bool toFile(obinaryfilestream& os);
459
		bool toFile(otextfilestream& os);
460
 
461
		bool load(ibinaryfilestream& is);
1 cycrow 462
};
463
 
114 cycrow 464
#include "geometry_bob.h"
465
 
466
class bob_vertex : public vertex
1 cycrow 467
{
468
	public:
114 cycrow 469
		typedef point2d<double> uv_coord;
470
 
471
		static const int FLAG_DEFAULT = 0x19;
472
		static const int FLAG_UV = 2;
473
		static const int FLAG_WEIRD_STUFF = 4;
474
 
475
	private:
476
 
477
	public:
478
		short flags;
1 cycrow 479
		bob_error_codes errorCode;
114 cycrow 480
		uv_coord textureCoords;
481
		point2d<double> weirdCoords;
482
		int sgbits;
483
		normal_vector normalVector;
484
		normal_vector tangentVector;
485
 
486
	public:
487
		bob_vertex() { errorCode=e_noError; flags=0; }
488
		bob_vertex(int x, int y, int z)
489
			: vertex(x,y,z)
1 cycrow 490
		{
114 cycrow 491
			errorCode=e_noError;
492
			flags=0;
1 cycrow 493
		}
114 cycrow 494
 
495
		bool hasTextureCoords() const { return (flags & FLAG_UV) > 0; }
496
 
497
		bool load(ibinaryfilestream& is);
498
 
499
		bool toFile(obinaryfilestream& os);
500
		bool toFile(otextfilestream& os, int idx);
501
 
502
		void getBodCoords(int *coords)
503
		{
504
			coords[0]=conversion::vertex_bob2bod(x);
505
			coords[1]=conversion::vertex_bob2bod(y);
506
			coords[2]=conversion::vertex_bob2bod(z);
507
		}
1 cycrow 508
};
509
 
114 cycrow 510
// must be included AFTER the bob_vertex is defined
511
 
1 cycrow 512
#include "../x2bc_common/bob_point_map.h"
513
 
114 cycrow 514
class bob_vertices : public bob_section
1 cycrow 515
{
516
	public:
114 cycrow 517
		static const int HDR_BEGIN = BOB_SECTION_NAME_POINT_BEGIN;
518
		static const int HDR_END = BOB_SECTION_NAME_POINT_END;
519
 
520
		typedef ptr_list<ext::array<bob_vertex*> > VertexArray;
521
		typedef VertexArray::iterator VertexIterator;
522
 
523
	public:
1 cycrow 524
		bob_point_map map;
114 cycrow 525
		VertexArray new_vertices;
526
 
527
	private:
528
		bool outputRaw(otextfilestream& os);
529
		bool outputBOD(otextfilestream& os);
530
 
531
	public:
532
		bool load(ibinaryfilestream& is);
533
 
534
		bool toFile(obinaryfilestream& os);
535
		bool toFile(otextfilestream& os, const Settings& settings);
1 cycrow 536
};
537
 
114 cycrow 538
class bob_x3vertex_data_record
1 cycrow 539
{
540
	public:
114 cycrow 541
		int pointIndex; // index of BOB point
542
		vector tangent;
543
		vector unk;
544
 
545
		bool load(ibinaryfilestream& is);
546
		bool toFile(obinaryfilestream& os);
1 cycrow 547
};
548
 
114 cycrow 549
class bob_x3vertex_data : public ptr_list<ext::array<bob_x3vertex_data_record*> >
1 cycrow 550
{
551
	public:
114 cycrow 552
		bool load(ibinaryfilestream& is);
553
 
554
		bool toFile(obinaryfilestream& os);
555
 
556
		iterator search(int pointIndex)
1 cycrow 557
		{
114 cycrow 558
			int min=0, mid, res, max=(int)size() - 1;
559
 
560
			if(max==-1) return end();
561
			do {
562
				mid=(max + min) / 2;
563
				res=pointIndex - at(mid)->pointIndex;
564
				if(res <= 0) max=mid - 1;
565
				if(res >= 0) min=mid + 1;
1 cycrow 566
			}
114 cycrow 567
			while(min <= (int)max);
568
			return pointIndex==at(mid)->pointIndex ? (m_first + mid) : end();
1 cycrow 569
		}
570
 
114 cycrow 571
		const_iterator search(int pointIndex) const
1 cycrow 572
		{
573
			int min=0, mid, res, max=(int)size() - 1;
114 cycrow 574
 
1 cycrow 575
			if(max==-1) return end();
576
			do {
114 cycrow 577
				mid=(max + min) / 2;
578
				res=pointIndex - at(mid)->pointIndex;
1 cycrow 579
				if(res <= 0) max=mid - 1;
580
				if(res >= 0) min=mid + 1;
581
			}
582
			while(min <= (int)max);
114 cycrow 583
			return pointIndex==at(mid)->pointIndex ? (m_first + mid) : end();
1 cycrow 584
		}
585
};
586
 
114 cycrow 587
class bob_face
1 cycrow 588
{
589
	public:
114 cycrow 590
		int values[3];
591
		int flags;
1 cycrow 592
		bob_error_codes errorCode;
114 cycrow 593
 
594
		bob_face() { errorCode=e_noError; }
595
		bool load(ibinaryfilestream& is);
596
 
597
		bool toFile(obinaryfilestream& os);
1 cycrow 598
};
599
 
114 cycrow 600
class bob_face_list : public ptr_list<ext::list<bob_face*> >, public bob_with_errors
1 cycrow 601
{
114 cycrow 602
	private:
603
		bool saveVertexTangents(obinaryfilestream& os, const bob_vertices& vertices);
604
 
1 cycrow 605
	public:
606
		int materialIndex;
114 cycrow 607
		bob_x3vertex_data x3vertexData;
1 cycrow 608
 
609
		bob_face_list() { materialIndex=0; }
610
 
114 cycrow 611
		bool load(ibinaryfilestream& is, bool x3data);
612
		bool toFile(obinaryfilestream& os, const bob_vertices& vertices, bool x3data);
613
 
614
		bool outputX3VertexDataRaw(otextfilestream& os);
615
 
616
		//bool computeAndOutputTangents(otextfilestream& os, const bob_point_map& pointMap);
1 cycrow 617
};
618
 
114 cycrow 619
class bob_part_collision_box
1 cycrow 620
{
621
	public:
114 cycrow 622
		point3d<double> sphereOffset;
623
		double sphereDiameter;
624
		point3d<double> boxOffset;
625
		point3d<double> boxSize;
626
 
627
	public:
628
		bob_part_collision_box() 
629
		{ 
630
			sphereDiameter = 0;
631
		}
632
 
633
		bool load(ibinaryfilestream& is);
634
		bool toFile(otextfilestream& os);
635
		bool toFile(obinaryfilestream& os);
1 cycrow 636
};
637
 
114 cycrow 638
class bob_part : public bob_with_errors, public ptr_list<ext::list<bob_face_list*> >
1 cycrow 639
{
640
	public:
114 cycrow 641
		static const int FLAG_X3 = 0x10000000;
642
 
643
		static const int BOD_FLAG_UV = 8;
644
		static const int BOD_FLAG_SGBITS = 16;
645
 
1 cycrow 646
		int flags;
114 cycrow 647
		bob_part_collision_box collisionBox;
1 cycrow 648
 
114 cycrow 649
	private:
650
		bool outputX3VertexData(otextfilestream& os, const bob_point_map& pointMap);
651
		void outputExtraPtInfo(otextfilestream& os, const bob_vertex *points[]);
652
		void outputNormals(otextfilestream& os, const bob_vertex *points[]);
653
		bool outputRaw(otextfilestream& os, const bob_point_map& pointMap, int idx);
654
		bool outputBOD(otextfilestream& os, const Settings& settings, const bob_materials *materials, const bob_point_map& pointMap, int idx);
655
 
656
	public:
657
		bob_part()	{ flags=0; }
658
 
659
		size_t numFaces() const
1 cycrow 660
		{
114 cycrow 661
			size_t count=0;
662
			for(const_iterator &it=begin(); it!=end(); ++it){
663
				count+=it->size();
1 cycrow 664
			}
114 cycrow 665
			return count;
1 cycrow 666
		}
114 cycrow 667
 
1 cycrow 668
		// find the appropriate face list based on material index
669
		bob_face_list * operator[] (int matIdx)
670
		{
671
			for(reverse_iterator &it=rbegin(); it!=rend(); ++it){
672
				if(it->materialIndex==matIdx)
673
					return *it;
674
			}
675
			return NULL;
676
		}
114 cycrow 677
 
1 cycrow 678
		// find or create an appropriate face list based on material index
679
		bob_face_list * facelist(int matIdx)
680
		{
681
			bob_face_list *p=(*this)[matIdx];
682
			if(p==NULL){
683
				p=new bob_face_list();
684
				push_back(p);
685
				p->materialIndex=matIdx;
686
			}
687
			return p;
688
		}
114 cycrow 689
 
690
		bool load(ibinaryfilestream& is);
691
 
692
		bool toFile(obinaryfilestream& os, const bob_vertices& vertices);
693
		bool toFile(otextfilestream& os, const Settings& settings, const bob_materials *materials, const bob_point_map& pointMap, int idx);
694
 
1 cycrow 695
};
696
 
114 cycrow 697
class bob_parts : public bob_section, public ext::list<bob_part*>
1 cycrow 698
{
699
	public:
114 cycrow 700
		static const int HDR_BEGIN = BOB_SECTION_NAME_PART_BEGIN;
701
		static const int HDR_END = BOB_SECTION_NAME_PART_END;
702
 
703
		bool load(ibinaryfilestream& is);
704
 
705
		bool toFile(obinaryfilestream& os, const bob_vertices& vertices);
706
		bool toFile(otextfilestream& os, const Settings& settings, const bob_materials *materials, const bob_point_map *pointMap);
707
 
708
		~bob_parts()
1 cycrow 709
		{
710
			for(iterator &it=begin(); it!=end(); ++it){
711
				delete *it;
712
			}
713
		}
714
};
715
 
114 cycrow 716
class bob_body : public bob_with_errors
1 cycrow 717
{
718
	public:
114 cycrow 719
		bob_bones bones;
720
		bob_vertices vertices;
721
		bob_parts parts;
722
		bob_weights weights;
723
 
1 cycrow 724
		int bodySize;
725
		int bodyFlags;
114 cycrow 726
 
727
		bob_body() { bodySize=0; bodyFlags=0; }
728
 
729
		bool load(ibinaryfilestream& is);
730
 
731
		bool toFile(obinaryfilestream& os);
732
		bool toFile(otextfilestream& os, const Settings& settings, const bob_materials *materials, int idx);
1 cycrow 733
};
734
 
114 cycrow 735
class bob_bodies : public bob_section, public bob_cantainer<bob_body>
1 cycrow 736
{
737
	public:
114 cycrow 738
		static const int HDR_BEGIN = BOB_SECTION_NAME_BODY_BEGIN;
739
		static const int HDR_END = BOB_SECTION_NAME_BODY_END;
740
 
741
		bool load(ibinaryfilestream& is);
742
 
743
		bool toFile(obinaryfilestream& os);
744
		bool toFile(otextfilestream& os, const Settings& settings, const bob_materials *materials);
1 cycrow 745
};
746
 
114 cycrow 747
class bob_dom_bob : public bob_section
1 cycrow 748
{
749
	private:
750
		const Settings *m_settings;
114 cycrow 751
 
1 cycrow 752
	public:
114 cycrow 753
		typedef bob_bodies::iterator BodyIterator;
754
 
755
		bob_info info;
756
		bob_materials materials;
757
		bob_bodies bodies;
758
 
759
		static const int HDR_BEGIN = BOB_SECTION_NAME_BOB_BEGIN;
760
		static const int HDR_END = BOB_SECTION_NAME_BOB_END;
761
 
1 cycrow 762
		bob_dom_bob(const Settings *settings) { m_settings=settings; }
114 cycrow 763
 
764
		bool toFile(obinaryfilestream& os);
765
		bool toFile(otextfilestream& os);
766
 
767
		bool load(ibinaryfilestream& is);
768
 
1 cycrow 769
};
770
 
114 cycrow 771
#endif // !defined(BOB_BOB_INCLUDED)