1 /* 2 * Copyright 2011-2013 Arx Libertatis Team (see the AUTHORS file) 3 * 4 * This file is part of Arx Libertatis. 5 * 6 * Arx Libertatis is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * Arx Libertatis is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with Arx Libertatis. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 /* Based on: 20 =========================================================================== 21 ARX FATALIS GPL Source Code 22 Copyright (C) 1999-2010 Arkane Studios SA, a ZeniMax Media company. 23 24 This file is part of the Arx Fatalis GPL Source Code ('Arx Fatalis Source Code'). 25 26 Arx Fatalis Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public 27 License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 28 29 Arx Fatalis Source Code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 30 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 31 32 You should have received a copy of the GNU General Public License along with Arx Fatalis Source Code. If not, see 33 <http://www.gnu.org/licenses/>. 34 35 In addition, the Arx Fatalis Source Code is also subject to certain additional terms. You should have received a copy of these 36 additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Arx 37 Fatalis Source Code. If not, please request a copy in writing from Arkane Studios at the address below. 38 39 If you have questions concerning this license or the applicable additional terms, you may contact in writing Arkane Studios, c/o 40 ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. 41 =========================================================================== 42 */ 43 44 #ifndef ARX_GRAPHICS_GRAPHICSTYPES_H 45 #define ARX_GRAPHICS_GRAPHICSTYPES_H 46 47 #include <cmath> 48 #include <vector> 49 50 #include "audio/AudioTypes.h" 51 #include "graphics/BaseGraphicsTypes.h" 52 #include "graphics/Color.h" 53 #include "graphics/Vertex.h" 54 55 #include "io/resource/ResourcePath.h" 56 57 #include "math/Vector2.h" 58 #include "math/Angle.h" 59 60 #include "platform/Flags.h" 61 62 #include "Configure.h" 63 64 struct EERIE_3DOBJ; 65 class TextureContainer; 66 class Entity; 67 68 struct EERIE_TRI { 69 Vec3f v[3]; 70 }; 71 72 struct EERIE_2D_BBOX { 73 Vec2f min; 74 Vec2f max; 75 }; 76 77 struct EERIE_LIGHT { 78 char exist; 79 char type; 80 char treat; 81 char selected; 82 short extras; 83 short status; // on/off 1/0 84 Vec3f pos; 85 float fallstart; 86 float fallend; 87 float falldiff; 88 float falldiffmul; 89 float precalc; 90 Color3f rgb255; 91 float intensity; 92 Color3f rgb; 93 float i; 94 Vec3f mins; 95 Vec3f maxs; 96 float temp; 97 long ltemp; 98 Color3f ex_flicker; 99 float ex_radius; 100 float ex_frequency; 101 float ex_size; 102 float ex_speed; 103 float ex_flaresize; 104 long tl; 105 unsigned long time_creation; 106 long duration; // will start to fade before the end of duration... 107 audio::SourceId sample; 108 }; 109 110 enum EERIE_TYPES_EXTRAS_MODE 111 { 112 EXTRAS_SEMIDYNAMIC = 0x00000001, 113 EXTRAS_EXTINGUISHABLE = 0x00000002, 114 EXTRAS_STARTEXTINGUISHED = 0x00000004, 115 EXTRAS_SPAWNFIRE = 0x00000008, 116 EXTRAS_SPAWNSMOKE = 0x00000010, 117 EXTRAS_OFF = 0x00000020, 118 EXTRAS_COLORLEGACY = 0x00000040, 119 EXTRAS_NOCASTED = 0x00000080, 120 EXTRAS_FIXFLARESIZE = 0x00000100, 121 EXTRAS_FIREPLACE = 0x00000200, 122 EXTRAS_NO_IGNIT = 0x00000400, 123 EXTRAS_FLARE = 0x00000800 124 }; 125 126 #define TYP_SPECIAL1 1 127 128 129 //************************************************************************************* 130 // EERIE Types 131 //************************************************************************************* 132 133 enum PolyTypeFlag { 134 POLY_NO_SHADOW = (1<<0), 135 POLY_DOUBLESIDED = (1<<1), 136 POLY_TRANS = (1<<2), 137 POLY_WATER = (1<<3), 138 POLY_GLOW = (1<<4), 139 POLY_IGNORE = (1<<5), 140 POLY_QUAD = (1<<6), 141 POLY_TILED = (1<<7), 142 POLY_METAL = (1<<8), 143 POLY_HIDE = (1<<9), 144 POLY_STONE = (1<<10), 145 POLY_WOOD = (1<<11), 146 POLY_GRAVEL = (1<<12), 147 POLY_EARTH = (1<<13), 148 POLY_NOCOL = (1<<14), 149 POLY_LAVA = (1<<15), 150 POLY_CLIMB = (1<<16), 151 POLY_FALL = (1<<17), 152 POLY_NOPATH = (1<<18), 153 POLY_NODRAW = (1<<19), 154 POLY_PRECISE_PATH = (1<<20), 155 POLY_NO_CLIMB = (1<<21), 156 POLY_ANGULAR = (1<<22), 157 POLY_ANGULAR_IDX0 = (1<<23), 158 POLY_ANGULAR_IDX1 = (1<<24), 159 POLY_ANGULAR_IDX2 = (1<<25), 160 POLY_ANGULAR_IDX3 = (1<<26), 161 POLY_LATE_MIP = (1<<27) 162 }; 163 DECLARE_FLAGS(PolyTypeFlag, PolyType); 164 DECLARE_FLAGS_OPERATORS(PolyType); 165 166 struct EERIEPOLY { 167 PolyType type; 168 Vec3f min; 169 Vec3f max; 170 Vec3f norm; 171 Vec3f norm2; 172 TexturedVertex v[4]; 173 TexturedVertex tv[4]; 174 Vec3f nrml[4]; 175 TextureContainer * tex; 176 Vec3f center; 177 float transval; 178 float area; 179 short room; 180 short misc; 181 unsigned short uslInd[4]; 182 }; 183 184 #define IOPOLYVERT 3 185 struct EERIE_FACE { 186 187 PolyType facetype; 188 short texid; //!< index into the objects texture list 189 unsigned short vid[IOPOLYVERT]; 190 float u[IOPOLYVERT]; 191 float v[IOPOLYVERT]; 192 193 float transval; 194 Vec3f norm; 195 Vec3f nrmls[IOPOLYVERT]; 196 float temp; 197 198 short ou[IOPOLYVERT]; 199 short ov[IOPOLYVERT]; 200 Color color[IOPOLYVERT]; 201 202 }; 203 204 205 //*********************************************************************** 206 //* BEGIN EERIE OBJECT STRUCTURES * 207 //*********************************************************************** 208 struct NEIGHBOURS_DATA { 209 short nb_Nvertex; 210 short nb_Nfaces; 211 short * Nvertex; 212 short * Nfaces; 213 }; 214 215 struct PROGRESSIVE_DATA { 216 // ingame data 217 short actual_collapse; // -1 = no collapse 218 short need_computing; 219 float collapse_ratio; 220 // static data 221 float collapse_cost; 222 short collapse_candidate; 223 short padd; 224 }; 225 226 struct EERIE_SPRINGS { 227 short startidx; 228 short endidx; 229 float restlength; 230 float constant; // spring constant 231 float damping; // spring damping 232 long type; 233 }; 234 235 #define CLOTHES_FLAG_NORMAL 0 236 #define CLOTHES_FLAG_FIX 1 237 #define CLOTHES_FLAG_NOCOL 2 238 239 struct CLOTHESVERTEX { 240 241 short idx; 242 unsigned char flags; 243 char coll; 244 Vec3f pos; 245 Vec3f velocity; 246 Vec3f force; 247 float mass; // 1.f/mass 248 249 Vec3f t_pos; 250 Vec3f t_velocity; 251 Vec3f t_force; 252 253 Vec3f lastpos; 254 255 }; 256 257 struct CLOTHES_DATA { 258 259 CLOTHESVERTEX * cvert; 260 CLOTHESVERTEX * backup; 261 short nb_cvert; 262 std::vector<EERIE_SPRINGS> springs; 263 CLOTHES_DATACLOTHES_DATA264 CLOTHES_DATA() : cvert(NULL), backup(NULL), nb_cvert(0) { } 265 }; 266 267 struct COLLISION_SPHERE { 268 short idx; 269 short flags; // TODO not used? 270 float radius; 271 }; 272 273 struct COLLISION_SPHERES_DATA { 274 std::vector<COLLISION_SPHERE> spheres; 275 }; 276 277 struct PHYSVERT 278 { 279 Vec3f initpos; 280 Vec3f temp; 281 Vec3f pos; 282 Vec3f velocity; 283 Vec3f force; 284 Vec3f inertia; 285 float mass; 286 PHYSVERTPHYSVERT287 PHYSVERT() 288 : initpos(Vec3f::ZERO) 289 , temp(Vec3f::ZERO) 290 , pos(Vec3f::ZERO) 291 , velocity(Vec3f::ZERO) 292 , force(Vec3f::ZERO) 293 , inertia(Vec3f::ZERO) 294 , mass(0.f) 295 {} 296 }; 297 298 struct PHYSICS_BOX_DATA 299 { 300 PHYSVERT * vert; 301 long nb_physvert; 302 short active; 303 short stopcount; 304 float radius; //radius around vert[0].pos for spherical collision 305 float storedtiming; 306 }; 307 308 309 struct EERIE_GROUPLIST { 310 std::string name; 311 long origin; 312 std::vector<long> indexes; 313 float siz; 314 EERIE_GROUPLISTEERIE_GROUPLIST315 EERIE_GROUPLIST() : name(), origin(0), indexes(), siz(0.0f) { } 316 }; 317 318 struct EERIE_ACTIONLIST { 319 std::string name; 320 long idx; //index vertex; 321 long act; //action 322 long sfx; //sfx 323 EERIE_ACTIONLISTEERIE_ACTIONLIST324 EERIE_ACTIONLIST() : name(), idx(0), act(0), sfx(0) { } 325 }; 326 327 struct CUB3D 328 { 329 float xmin; 330 float xmax; 331 float ymin; 332 float ymax; 333 float zmin; 334 float zmax; 335 }; 336 337 struct EERIE_MOD_INFO { 338 long link_origin; 339 Vec3f link_position; 340 Vec3f scale; 341 Anglef rot; 342 unsigned long flags; // TODO unused? 343 }; 344 345 struct EERIE_LINKED { 346 long lgroup; //linked to group n° if lgroup=-1 NOLINK 347 long lidx; 348 long lidx2; 349 EERIE_3DOBJ * obj; 350 EERIE_MOD_INFO modinfo; 351 Entity * io; 352 }; 353 354 struct EERIE_SELECTIONS { 355 std::string name; 356 std::vector<long> selected; 357 }; 358 359 #define DRAWFLAG_HIGHLIGHT 1 360 361 struct EERIE_FASTACCESS 362 { 363 short view_attach; 364 short primary_attach; 365 366 short left_attach; 367 short weapon_attach; 368 369 short secondary_attach; 370 short mouth_group; 371 372 short jaw_group; 373 short head_group_origin; 374 375 short head_group; 376 short mouth_group_origin; 377 378 short V_right; 379 short U_right; 380 381 short fire; 382 short sel_head; 383 384 short sel_chest; 385 short sel_leggings; 386 387 short carry_attach; 388 short padding_; 389 }; 390 391 ///////////////////////////////////////////////////////////////////////////////// 392 struct EERIE_BONE 393 { 394 long nb_idxvertices; 395 long * idxvertices; 396 EERIE_GROUPLIST * original_group; 397 long father; 398 EERIE_QUAT quatanim; 399 Vec3f transanim; 400 Vec3f scaleanim; 401 EERIE_QUAT quatlast; 402 Vec3f translast; 403 Vec3f scalelast; 404 EERIE_QUAT quatinit; 405 Vec3f transinit; 406 Vec3f scaleinit; 407 Vec3f transinit_global; 408 }; 409 410 struct EERIE_C_DATA 411 { 412 EERIE_BONE * bones; 413 long nb_bones; 414 }; 415 416 struct EERIE_3DPAD : public Vec3f { 417 float w; 418 }; 419 420 struct EERIE_3DOBJ 421 { EERIE_3DOBJEERIE_3DOBJ422 EERIE_3DOBJ() 423 { 424 point0 = pos = Vec3f::ZERO; 425 angle = Anglef::ZERO; 426 427 origin = 0; 428 ident = 0; 429 nbgroups = 0; 430 drawflags = 0; 431 432 vertexlocal = NULL; 433 434 grouplist = NULL; 435 436 originaltextures = NULL; 437 linked = NULL; 438 439 // TODO Make default constructor possible 440 cub.xmin = 0; 441 cub.xmax = 0; 442 cub.ymin = 0; 443 cub.ymax = 0; 444 cub.zmin = 0; 445 cub.zmax = 0; 446 447 // TODO Default constructor 448 quat.x = quat.y = quat.z = quat.w = 0; 449 nblinked = 0; 450 451 pbox = NULL; 452 pdata = NULL; 453 ndata = NULL; 454 cdata = NULL; 455 sdata = NULL; 456 457 fastaccess.view_attach = 0; 458 fastaccess.primary_attach = 0; 459 fastaccess.left_attach = 0; 460 fastaccess.weapon_attach = 0; 461 fastaccess.secondary_attach = 0; 462 fastaccess.mouth_group = 0; 463 fastaccess.jaw_group = 0; 464 fastaccess.head_group_origin = 0; 465 fastaccess.head_group = 0; 466 fastaccess.mouth_group_origin = 0; 467 fastaccess.V_right = 0; 468 fastaccess.U_right = 0; 469 fastaccess.fire = 0; 470 fastaccess.sel_head = 0; 471 fastaccess.sel_chest = 0; 472 fastaccess.sel_leggings = 0; 473 fastaccess.carry_attach = 0; 474 fastaccess.padding_ = 0; 475 476 c_data = NULL; 477 } 478 479 void clear(); 480 481 ~EERIE_3DOBJ(); 482 483 std::string name; 484 res::path file; 485 Vec3f pos; 486 Vec3f point0; 487 Anglef angle; 488 long origin; 489 long ident; 490 long nbgroups; 491 unsigned long drawflags; 492 EERIE_3DPAD * vertexlocal; 493 std::vector<EERIE_VERTEX> vertexlist; 494 std::vector<EERIE_VERTEX> vertexlist3; 495 496 std::vector<EERIE_FACE> facelist; 497 EERIE_GROUPLIST * grouplist; 498 std::vector<EERIE_ACTIONLIST> actionlist; 499 std::vector<EERIE_SELECTIONS> selections; 500 std::vector<TextureContainer*> texturecontainer; 501 502 char * originaltextures; 503 CUB3D cub; 504 EERIE_QUAT quat; 505 EERIE_LINKED * linked; 506 long nblinked; 507 508 509 PHYSICS_BOX_DATA * pbox; 510 PROGRESSIVE_DATA * pdata; 511 NEIGHBOURS_DATA * ndata; 512 CLOTHES_DATA * cdata; 513 COLLISION_SPHERES_DATA * sdata; 514 EERIE_FASTACCESS fastaccess; 515 EERIE_C_DATA * c_data; 516 517 }; 518 519 520 struct EERIE_3DSCENE { 521 long nbobj; 522 EERIE_3DOBJ ** objs; 523 Vec3f pos; 524 Vec3f point0; 525 long nbtex; 526 TextureContainer ** texturecontainer; 527 long nblight; 528 EERIE_LIGHT ** light; 529 CUB3D cub; 530 }; 531 532 533 #ifdef BUILD_EDIT_LOADSAVE 534 const size_t MAX_SCENES = 64; 535 struct EERIE_MULTI3DSCENE { 536 long nb_scenes; 537 EERIE_3DSCENE * scenes[MAX_SCENES]; 538 CUB3D cub; 539 Vec3f pos; 540 Vec3f point0; 541 }; 542 #endif 543 544 struct EERIE_FRAME 545 { 546 long num_frame; 547 long flag; 548 int master_key_frame; 549 short f_translate; //int 550 short f_rotate; //int 551 float time; 552 Vec3f translate; 553 EERIE_QUAT quat; 554 audio::SampleId sample; 555 }; 556 557 struct EERIE_GROUP 558 { 559 int key; 560 Vec3f translate; 561 EERIE_QUAT quat; 562 Vec3f zoom; 563 }; 564 565 // Animation playing flags 566 #define EA_LOOP 1 // Must be looped at end (indefinitely...) 567 #define EA_REVERSE 2 // Is played reversed (from end to start) 568 #define EA_PAUSED 4 // Is paused 569 #define EA_ANIMEND 8 // Has just finished 570 #define EA_STATICANIM 16 // Is a static Anim (no movement offset returned). 571 #define EA_STOPEND 32 // Must Be Stopped at end. 572 #define EA_FORCEPLAY 64 // User controlled... MUST be played... 573 #define EA_EXCONTROL 128 // ctime externally set, no update. 574 struct EERIE_ANIM 575 { 576 float anim_time; 577 unsigned long flag; 578 long nb_groups; 579 long nb_key_frames; 580 EERIE_FRAME * frames; 581 EERIE_GROUP * groups; 582 unsigned char * voidgroups; 583 }; 584 585 //------------------------------------------------------------------------- 586 //Portal Data; 587 588 struct EERIE_PORTALS 589 { 590 EERIEPOLY poly; 591 long room_1; // facing normal 592 long room_2; 593 short useportal; 594 short paddy; 595 }; 596 597 struct EP_DATA { 598 short px; 599 short py; 600 short idx; 601 short padd; 602 }; 603 604 struct EERIE_ROOM_DATA { 605 long nb_portals; 606 long * portals; 607 long nb_polys; 608 EP_DATA * epdata; 609 Vec3f center; 610 float radius; 611 unsigned short * pussIndice; 612 VertexBuffer<SMY_VERTEX> * pVertexBuffer; 613 unsigned long usNbTextures; 614 TextureContainer ** ppTextureContainer; 615 }; 616 617 struct EERIE_PORTAL_DATA 618 { 619 long nb_rooms; 620 EERIE_ROOM_DATA * room; 621 long nb_total; // of portals 622 EERIE_PORTALS * portals; 623 }; 624 625 struct SMY_ZMAPPINFO 626 { 627 TexturedVertex pVertex[3]; 628 float uv[6]; 629 float color[3]; 630 }; 631 632 struct SMY_ARXMAT 633 { 634 unsigned long uslStartVertex; 635 unsigned long uslNbVertex; 636 637 unsigned long uslStartCull; 638 unsigned long uslNbIndiceCull; 639 640 unsigned long uslStartCull_TNormalTrans; 641 unsigned long uslNbIndiceCull_TNormalTrans; 642 643 unsigned long uslStartCull_TMultiplicative; 644 unsigned long uslNbIndiceCull_TMultiplicative; 645 646 unsigned long uslStartCull_TAdditive; 647 unsigned long uslNbIndiceCull_TAdditive; 648 649 unsigned long uslStartCull_TSubstractive; 650 unsigned long uslNbIndiceCull_TSubstractive; 651 }; 652 653 extern long USE_PORTALS; 654 extern EERIE_PORTAL_DATA * portals; 655 656 #endif // ARX_GRAPHICS_GRAPHICSTYPES_H 657