AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
VMAP::GroupModel_Raw Struct Reference

#include "TileAssembler.h"

Public Member Functions

 GroupModel_Raw ()
 
 ~GroupModel_Raw ()
 
bool Read (FILE *f)
 

Public Attributes

uint32 mogpflags {0}
 
uint32 GroupWMOID {0}
 
G3D::AABox bounds
 
uint32 liquidflags {0}
 
std::vector< MeshTriangletriangles
 
std::vector< G3D::Vector3 > vertexArray
 
class WmoLiquidliquid
 

Detailed Description

Constructor & Destructor Documentation

◆ GroupModel_Raw()

VMAP::GroupModel_Raw::GroupModel_Raw ( )
inline
77: liquid(nullptr) { }
class WmoLiquid * liquid
Definition: TileAssembler.h:75

◆ ~GroupModel_Raw()

VMAP::GroupModel_Raw::~GroupModel_Raw ( )
565 {
566 delete liquid;
567 }

References liquid.

Member Function Documentation

◆ Read()

bool VMAP::GroupModel_Raw::Read ( FILE *  f)
468 {
469 char blockId[5];
470 blockId[4] = 0;
471 int blocksize;
472 int readOperation = 0;
473
476
477 Vector3 vec1, vec2;
478 READ_OR_RETURN(&vec1, sizeof(Vector3));
479
480 READ_OR_RETURN(&vec2, sizeof(Vector3));
481 bounds.set(vec1, vec2);
482
484
485 // will this ever be used? what is it good for anyway??
486 uint32 branches;
487 READ_OR_RETURN(&blockId, 4);
488 CMP_OR_RETURN(blockId, "GRP ");
489 READ_OR_RETURN(&blocksize, sizeof(int));
490 READ_OR_RETURN(&branches, sizeof(uint32));
491 for (uint32 b = 0; b < branches; ++b)
492 {
493 uint32 indexes;
494 // indexes for each branch (not used jet)
495 READ_OR_RETURN(&indexes, sizeof(uint32));
496 }
497
498 // ---- indexes
499 READ_OR_RETURN(&blockId, 4);
500 CMP_OR_RETURN(blockId, "INDX");
501 READ_OR_RETURN(&blocksize, sizeof(int));
502 uint32 nindexes;
503 READ_OR_RETURN(&nindexes, sizeof(uint32));
504 if (nindexes > 0)
505 {
506 uint16* indexarray = new uint16[nindexes];
507 READ_OR_RETURN_WITH_DELETE(indexarray, nindexes * sizeof(uint16));
508 triangles.reserve(nindexes / 3);
509 for (uint32 i = 0; i < nindexes; i += 3)
510 {
511 triangles.push_back(MeshTriangle(indexarray[i], indexarray[i + 1], indexarray[i + 2]));
512 }
513
514 delete[] indexarray;
515 }
516
517 // ---- vectors
518 READ_OR_RETURN(&blockId, 4);
519 CMP_OR_RETURN(blockId, "VERT");
520 READ_OR_RETURN(&blocksize, sizeof(int));
521 uint32 nvectors;
522 READ_OR_RETURN(&nvectors, sizeof(uint32));
523
524 if (nvectors > 0)
525 {
526 float* vectorarray = new float[nvectors * 3];
527 READ_OR_RETURN_WITH_DELETE(vectorarray, nvectors * sizeof(float) * 3);
528 for (uint32 i = 0; i < nvectors; ++i)
529 {
530 vertexArray.push_back( Vector3(vectorarray + 3 * i));
531 }
532
533 delete[] vectorarray;
534 }
535 // ----- liquid
536 liquid = nullptr;
537 if (liquidflags & 3)
538 {
539 READ_OR_RETURN(&blockId, 4);
540 CMP_OR_RETURN(blockId, "LIQU");
541 READ_OR_RETURN(&blocksize, sizeof(int));
542 uint32 liquidType;
543 READ_OR_RETURN(&liquidType, sizeof(uint32));
544 if (liquidflags & 1)
545 {
546 WMOLiquidHeader hlq;
547 READ_OR_RETURN(&hlq, sizeof(WMOLiquidHeader));
548 liquid = new WmoLiquid(hlq.xtiles, hlq.ytiles, Vector3(hlq.pos_x, hlq.pos_y, hlq.pos_z), liquidType);
549 uint32 size = hlq.xverts * hlq.yverts;
550 READ_OR_RETURN(liquid->GetHeightStorage(), size * sizeof(float));
551 size = hlq.xtiles * hlq.ytiles;
553 }
554 else
555 {
556 liquid = new WmoLiquid(0, 0, Vector3::zero(), liquidType);
557 liquid->GetHeightStorage()[0] = bounds.high().z;
558 }
559 }
560
561 return true;
562 }
#define READ_OR_RETURN_WITH_DELETE(V, S)
Definition: TileAssembler.cpp:462
#define READ_OR_RETURN(V, S)
Definition: TileAssembler.cpp:460
#define CMP_OR_RETURN(V, S)
Definition: TileAssembler.cpp:464
std::uint32_t uint32
Definition: Define.h:107
std::uint16_t uint16
Definition: Define.h:108
uint32 mogpflags
Definition: TileAssembler.h:68
G3D::AABox bounds
Definition: TileAssembler.h:71
uint32 GroupWMOID
Definition: TileAssembler.h:69
uint32 liquidflags
Definition: TileAssembler.h:72
std::vector< G3D::Vector3 > vertexArray
Definition: TileAssembler.h:74
std::vector< MeshTriangle > triangles
Definition: TileAssembler.h:73
float * GetHeightStorage()
Definition: WorldModel.h:54
uint8 * GetFlagsStorage()
Definition: WorldModel.h:55
Definition: wmo.h:100
float pos_z
Definition: wmo.h:104
float pos_y
Definition: wmo.h:103
int ytiles
Definition: wmo.h:101
int xverts
Definition: wmo.h:101
int yverts
Definition: wmo.h:101
float pos_x
Definition: wmo.h:102
int xtiles
Definition: wmo.h:101

References bounds, CMP_OR_RETURN, VMAP::WmoLiquid::GetFlagsStorage(), VMAP::WmoLiquid::GetHeightStorage(), GroupWMOID, liquid, liquidflags, mogpflags, VMAP::WMOLiquidHeader::pos_x, VMAP::WMOLiquidHeader::pos_y, VMAP::WMOLiquidHeader::pos_z, READ_OR_RETURN, READ_OR_RETURN_WITH_DELETE, triangles, vertexArray, VMAP::WMOLiquidHeader::xtiles, VMAP::WMOLiquidHeader::xverts, VMAP::WMOLiquidHeader::ytiles, and VMAP::WMOLiquidHeader::yverts.

Member Data Documentation

◆ bounds

G3D::AABox VMAP::GroupModel_Raw::bounds

◆ GroupWMOID

uint32 VMAP::GroupModel_Raw::GroupWMOID {0}

◆ liquid

class WmoLiquid* VMAP::GroupModel_Raw::liquid

◆ liquidflags

uint32 VMAP::GroupModel_Raw::liquidflags {0}

Referenced by Read().

◆ mogpflags

uint32 VMAP::GroupModel_Raw::mogpflags {0}

◆ triangles

std::vector<MeshTriangle> VMAP::GroupModel_Raw::triangles

◆ vertexArray

std::vector<G3D::Vector3> VMAP::GroupModel_Raw::vertexArray