Support for 32-bit vertex indices in BTG files

This commit is contained in:
James Turner 2011-10-04 14:04:59 +01:00
parent 6485ea4051
commit d9a281c493
2 changed files with 662 additions and 796 deletions

File diff suppressed because it is too large Load Diff

View File

@ -27,29 +27,24 @@
#ifndef _SG_BINOBJ_HXX #ifndef _SG_BINOBJ_HXX
#define _SG_BINOBJ_HXX #define _SG_BINOBJ_HXX
#include <zlib.h> // for gzFile
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/math/sg_types.hxx> #include <simgear/math/sg_types.hxx>
#include <simgear/bucket/newbucket.hxx> #include <simgear/math/SGMath.hxx>
#include <stdio.h> #include <vector>
#include <time.h>
#include <list>
#include <string> #include <string>
/** STL Structure used to store object information */ /** STL Structure used to store object information */
typedef std::vector < int_list > group_list; typedef std::vector < int_list > group_list;
typedef group_list::iterator group_list_iterator; typedef group_list::iterator group_list_iterator;
typedef group_list::const_iterator const_group_list_iterator; typedef group_list::const_iterator const_group_list_iterator;
// forward decls
/** Magic Number for our file format */ class SGBucket;
#define SG_FILE_MAGIC_NUMBER ( ('S'<<24) + ('G'<<16) + SG_BINOBJ_VERSION ) class SGPath;
/** /**
* A class to manipulate the simgear 3d object format. * A class to manipulate the simgear 3d object format.
@ -85,6 +80,7 @@ typedef group_list::const_iterator const_group_list_iterator;
* - vertex: FLOAT, FLOAT, FLOAT * - vertex: FLOAT, FLOAT, FLOAT
*/ */
class SGBinObject { class SGBinObject {
private:
unsigned short version; unsigned short version;
SGVec3d gbs_center; SGVec3d gbs_center;
@ -119,6 +115,24 @@ class SGBinObject {
group_list fans_tc; // fans texture coordinate index group_list fans_tc; // fans texture coordinate index
string_list fan_materials; // fans materials string_list fan_materials; // fans materials
void read_properties(gzFile fp, int nproperties);
void read_object( gzFile fp,
int obj_type,
int nproperties,
int nelements,
group_list& vertices,
group_list& normals,
group_list& colors,
group_list& texCoords,
string_list& materials);
void write_header(gzFile fp, int type, int nProps, int nElements);
void write_objects(gzFile fp, int type, const group_list& verts,
const group_list& normals, const group_list& colors,
const group_list& texCoords, const string_list& materials);
unsigned int count_objects(const string_list& materials);
public: public:
inline unsigned short get_version() const { return version; } inline unsigned short get_version() const { return version; }
@ -207,6 +221,9 @@ public:
*/ */
bool write_bin( const std::string& base, const std::string& name, const SGBucket& b ); bool write_bin( const std::string& base, const std::string& name, const SGBucket& b );
bool write_bin_file(const SGPath& file);
/** /**
* Write out the structures to an ASCII file. We assume that the * Write out the structures to an ASCII file. We assume that the
* groups come to us sorted by material property. If not, things * groups come to us sorted by material property. If not, things