Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

QTR.h

Go to the documentation of this file.
00001 /*
00002  * QTR.h
00003  *
00004  * Part of Fly! Legacy project
00005  *
00006  * Copyright 2003 Chris Wallace
00007  *
00008  * Fly! Legacy is free software; you can redistribute it and/or modify
00009  *   it under the terms of the GNU General Public License as published by
00010  *   the Free Software Foundation; either version 2 of the License, or
00011  *   (at your option) any later version.
00012  *
00013  * Fly! Legacy is distributed in the hope that it will be useful,
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  *   GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  *   along with Fly! Legacy; if not, write to the Free Software
00020  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  */
00023 
00029 #ifndef QTR_H
00030 #define QTR_H
00031 
00032 typedef struct {
00033   unsigned short numNodes;
00034   unsigned long  magic;
00035   unsigned long  width;
00036   unsigned long  height;
00037   unsigned long  rasterBytes;
00038   short          elev[4];
00039 } SQTRHeader;
00040 
00041 #define SIZEOF_QTR_HEADER   24
00042 
00043 
00044 typedef struct {
00045   unsigned char   type;
00046   short           center;
00047   union {
00048     struct {
00049       unsigned short  nwNode;
00050       unsigned short  neNode;
00051       unsigned short  swNode;
00052       unsigned short  seNode;
00053     } branchData;
00054     struct {
00055       short           nwElevation;
00056       short           neElevation;
00057       short           swElevation;
00058       short           seElevation;
00059     } leafData;
00060     struct {
00061       unsigned long offset;
00062       unsigned long dummy;
00063     } rasterData;
00064   };
00065 } SQTRNode;
00066 
00067 #define SIZEOF_QTR_NODE     11
00068 
00069 
00070 #define QTR_NODE_BRANCH     0x00
00071 #define QTR_NODE_LEAF       0x01
00072 #define QTR_NODE_TYPE03     0x03
00073 #define QTR_NODE_RASTER_ABS 0x03
00074 #define QTR_NODE_TYPE85     0x85
00075 #define QTR_NODE_RASTER_REL 0x85
00076 
00077 //
00078 // CQTRFile class
00079 //
00080 class CQTRFile {
00081 public:
00082   CQTRFile (void);
00083   CQTRFile (int index);
00084   CQTRFile (const char* qtrFilename);
00085   ~CQTRFile (void);
00086 
00087   bool           Load (const char* qtrFilename);
00088   bool           Save (const char* qtrFilename);
00089 
00090   unsigned short NumQuadtreeNodes (void);
00091   SQTRNode       *GetQuadtreeNode (unsigned short i);
00092   char           *GetRasterData (unsigned long offset);
00093   float          ExtractRelativeData (char* data, int x, int z);
00094   float          ExtractAbsoluteData (short* data, int x, int z);
00095   float          Search (int level, unsigned short node, int x, int z);
00096   void           Dump (const char* txtFilename);
00097 
00098 public:
00099   SQTRHeader  header;
00100   SQTRNode    *qtreenode;
00101   char        *raster;
00102 };
00103 
00104 #endif // QTR_H
00105 
SourceForge.net Logo Documentation generated by doxygen