1 #ifndef _chnktype_hpp 2 #define _chnktype_hpp 1 3 4 #include "3dc.h" 5 #include "list_tem.hpp" 6 7 struct ChunkVectorInt; 8 struct ChunkVectorFloat; 9 10 struct ChunkVector 11 { 12 13 double x; 14 double y; 15 double z; 16 17 18 ChunkVector friend operator+(const ChunkVector&, const ChunkVector&); 19 ChunkVector friend operator-(const ChunkVector&, const ChunkVector&); 20 ChunkVector& operator+=(const ChunkVector&); 21 ChunkVector& operator-=(const ChunkVector&); 22 23 ChunkVector friend operator*(const ChunkVector&, const double); 24 ChunkVector friend operator/(const ChunkVector&, const double); 25 26 ChunkVector friend operator*(const ChunkVector&, const ChunkVector&); //cross prod 27 28 29 operator VECTORCH () const; 30 operator ChunkVectorInt () const; 31 operator ChunkVectorFloat () const; 32 33 friend double dot(const ChunkVector&, const ChunkVector&);//dot product 34 friend double mod(const ChunkVector&);//magnitude of vector 35 int norm(); //normalize 36 }; 37 38 struct ChunkVectorInt 39 { 40 41 int x; 42 int y; 43 int z; 44 45 46 ChunkVectorInt friend operator+(const ChunkVectorInt&, const ChunkVectorInt&); 47 ChunkVectorInt friend operator-(const ChunkVectorInt&, const ChunkVectorInt&); 48 ChunkVectorInt& operator+=(const ChunkVectorInt&); 49 ChunkVectorInt& operator-=(const ChunkVectorInt&); 50 51 ChunkVectorInt friend operator*(const ChunkVectorInt&, const double); 52 ChunkVectorInt friend operator/(const ChunkVectorInt&, const double); 53 54 //ChunkVectorInt friend operator*(const ChunkVectorInt&, const ChunkVectorInt&); //cross prod 55 56 operator VECTORCH () const; 57 58 //friend double dot(const ChunkVector&, const ChunkVector&);//dot product 59 friend double mod(const ChunkVectorInt&);//magnitude of vector 60 int norm(); //normalize to 65536 61 }; 62 struct ChunkVectorFloat 63 { 64 65 float x; 66 float y; 67 float z; 68 69 ChunkVectorFloat friend operator+(const ChunkVectorFloat&, const ChunkVectorFloat&); 70 ChunkVectorFloat friend operator-(const ChunkVectorFloat&, const ChunkVectorFloat&); 71 ChunkVectorFloat& operator+=(const ChunkVectorFloat&); 72 ChunkVectorFloat& operator-=(const ChunkVectorFloat&); 73 74 ChunkVectorFloat friend operator*(const ChunkVectorFloat&, const double); 75 ChunkVectorFloat friend operator/(const ChunkVectorFloat&, const double); 76 77 //ChunkVectorInt friend operator*(const ChunkVectorInt&, const ChunkVectorInt&); //cross prod 78 79 operator VECTORCH () const; 80 81 //friend double dot(const ChunkVector&, const ChunkVector&);//dot product 82 friend double mod(const ChunkVectorFloat&);//magnitude of vector 83 int norm(); //normalize to 1 84 }; 85 86 struct ChunkUV 87 { 88 89 float u; 90 float v; 91 92 }; 93 94 // in integers I suppose 95 96 struct ChunkMatrix 97 { 98 99 int mat11; 100 int mat12; 101 int mat13; 102 103 int mat21; 104 int mat22; 105 int mat23; 106 107 int mat31; 108 int mat32; 109 int mat33; 110 111 }; 112 113 114 struct ChunkUV_List 115 { 116 int num_verts; 117 ChunkUV vert[4]; 118 119 // for list iterator 120 friend BOOL operator== (const ChunkUV_List &, const ChunkUV_List &); 121 friend BOOL operator!= (const ChunkUV_List &, const ChunkUV_List &); 122 123 }; 124 125 class ChunkPoly 126 { 127 public: 128 129 int engine_type; 130 int normal_index; 131 int flags; 132 unsigned int colour; 133 134 int num_verts; 135 136 int vert_ind[4]; 137 138 139 //functions for gettings and setting texture and uv indeces in the colour 140 unsigned int GetUVIndex(); 141 unsigned int GetTextureIndex(); 142 143 void SetUVIndex(unsigned int uv_index); 144 void SetTextureIndex(unsigned int texture_index); 145 146 147 }; 148 149 150 struct ChunkShape 151 { 152 ChunkShape(); 153 ~ChunkShape(); 154 155 ChunkShape (const ChunkShape &); 156 ChunkShape& operator=(const ChunkShape &); 157 158 159 float radius; //radius of points about 0,0,0 160 161 ChunkVectorInt max; 162 ChunkVectorInt min; 163 164 ChunkVectorInt centre; //average of min and max 165 float radius_about_centre; 166 167 int num_verts; 168 ChunkVectorInt * v_list; 169 170 //int num_vert_normals; //I don't think num_vert_normals is ever used 171 ChunkVectorFloat * v_normal_list; 172 173 int num_polys; 174 ChunkPoly * poly_list; 175 ChunkVectorFloat * p_normal_list; 176 177 int num_uvs; 178 ChunkUV_List * uv_list; 179 180 int num_texfiles; 181 char ** texture_fns; 182 183 void rescale (double); 184 }; 185 186 struct ChunkQuat 187 { 188 float x,y,z,w; 189 }; 190 191 192 struct ObjectID 193 { 194 int id1; 195 int id2; 196 197 friend BOOL operator== (const ObjectID &, const ObjectID &); 198 friend BOOL operator!= (const ObjectID &, const ObjectID &); 199 friend ObjectID Minimum(const ObjectID &,const ObjectID &); 200 201 }; 202 203 struct ChunkObject 204 { 205 ChunkVectorInt location; 206 207 ChunkQuat orientation; 208 209 BOOL is_base_object; 210 211 char o_name[50]; 212 213 int index_num; //this won't get changed by update_my_chunkobject 214 215 ObjectID ID; 216 }; 217 218 219 struct VMod_Arr_Item 220 { 221 VMod_Arr_Item(); 222 ~VMod_Arr_Item(); 223 224 VMod_Arr_Item(const VMod_Arr_Item & vma); 225 VMod_Arr_Item & operator=(const VMod_Arr_Item & vma); 226 227 int branch_no; 228 int flags; 229 int spare; 230 int object_index; 231 232 friend BOOL operator==(const VMod_Arr_Item &, const VMod_Arr_Item &); 233 friend BOOL operator!=(const VMod_Arr_Item &, const VMod_Arr_Item &); 234 }; 235 236 struct Adjacent_Module 237 { 238 Adjacent_Module(); 239 ~Adjacent_Module(); 240 241 Adjacent_Module(const Adjacent_Module & vma); 242 Adjacent_Module & operator=(const Adjacent_Module & vma); 243 244 int flags; 245 ChunkVectorInt entry_point; 246 int object_index; 247 248 friend BOOL operator==(const Adjacent_Module & am1, const Adjacent_Module & am2); 249 friend BOOL operator!=(const Adjacent_Module & am1, const Adjacent_Module & am2); 250 }; 251 252 class Shape_Chunk; 253 class Shape_Sub_Shape_Chunk; 254 255 struct a_frame 256 { a_framea_frame257 a_frame() 258 : shape1a (0), shape1b(0), shape2a(0), shape2b(0) 259 {} 260 261 Shape_Sub_Shape_Chunk * shape1a; 262 Shape_Chunk * shape1b; 263 Shape_Sub_Shape_Chunk * shape2a; 264 Shape_Chunk * shape2b; 265 int spare; 266 }; 267 268 269 // Data structures for bits and pieces 270 271 struct obinfile 272 { 273 int filepos; 274 char name[50]; 275 size_t length; 276 277 friend BOOL operator==(const obinfile &o1, const obinfile &o2); 278 friend BOOL operator!=(const obinfile &o1, const obinfile &o2); 279 }; 280 281 struct shpinfile 282 { 283 int filepos; 284 int id; 285 size_t length; 286 287 friend BOOL operator==(const shpinfile &s1, const shpinfile &s2); 288 friend BOOL operator!=(const shpinfile &s1, const shpinfile &s2); 289 }; 290 291 292 struct poly_change_info 293 { 294 int poly_num; 295 int vert_num_before; 296 int vert_num_after; 297 298 friend BOOL operator==(poly_change_info const &f1, poly_change_info const &f2); 299 friend BOOL operator!=(poly_change_info const &f1, poly_change_info const &f2); 300 }; 301 302 303 304 #define animframeflag_not_in_psx 0x00000001 305 #define animframeflag_not_in_saturn 0x00000002 306 #define animframeflag_interpolated_frame 0x00000004 307 struct ChunkAnimFrame 308 { 309 ChunkAnimFrame(); 310 ~ChunkAnimFrame(); 311 312 ChunkAnimFrame(const ChunkAnimFrame &); 313 //constructor for interpolated frame 314 //ChunkAnimFrame(ChunkAnimFrame* startframe,ChunkAnimFrame* endframe,int startwt,int endwt,ChunkShape const *cs); 315 ChunkAnimFrame& operator=(const ChunkAnimFrame &); 316 317 318 char* name; 319 320 int num_polys; 321 int num_verts; 322 323 ChunkVectorInt * v_list; 324 ChunkVectorFloat * p_normal_list; 325 326 int flags; 327 int num_interp_frames; 328 int pad3,pad4; 329 }; 330 331 332 #define animseqflag_not_in_psx 0x00000001 333 #define animseqflag_not_in_saturn 0x00000002 334 335 336 struct ChunkAnimSequence 337 { 338 ChunkAnimSequence(); 339 ~ChunkAnimSequence(); 340 341 ChunkAnimSequence (const ChunkAnimSequence &); 342 ChunkAnimSequence& operator=(const ChunkAnimSequence &); 343 344 void DeleteInterpolatedFrames(); 345 void GenerateInterpolatedFrames(ChunkShape const *cs); 346 347 void UpdateNormalsAndExtents(ChunkShape const *cs,List<int>* poly_not_in_bb=0); 348 349 int SequenceNum; 350 char* name; 351 352 int NumFrames; 353 ChunkAnimFrame** Frames; 354 355 int flags; 356 int pad2,pad3,pad4; 357 358 ChunkVectorInt min; 359 ChunkVectorInt max; 360 float radius; 361 362 int num_verts; 363 ChunkVectorFloat* v_normal_list; 364 }; 365 #endif 366