mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 15:40:45 +01:00
Tools: Fixed build in MeshExtractor (almost)
This commit is contained in:
@@ -22,7 +22,7 @@ endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
add_subdirectory(acelite)
|
||||
if(SERVERS AND USE_MYSQL_SOURCES)
|
||||
if(USE_MYSQL_SOURCES)
|
||||
add_subdirectory(mysqllite)
|
||||
endif()
|
||||
if(TOOLS)
|
||||
|
||||
@@ -30,5 +30,6 @@ if( SERVERS )
|
||||
else()
|
||||
if( TOOLS )
|
||||
add_subdirectory(collision)
|
||||
add_subdirectory(shared)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
53
src/tools/mesh_extractor/ADT.cpp
Normal file
53
src/tools/mesh_extractor/ADT.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "ADT.h"
|
||||
#include "DoodadHandler.h"
|
||||
#include "LiquidHandler.h"
|
||||
#include "WorldModelHandler.h"
|
||||
|
||||
ADT::ADT( std::string file ) : ObjectData(NULL), Data(NULL), _DoodadHandler(NULL), _WorldModelHandler(NULL), _LiquidHandler(NULL), HasObjectData(false)
|
||||
{
|
||||
Data = new ChunkedData(file);
|
||||
ObjectData = new ChunkedData(Utils::Replace(file, ".adt", "_obj0.adt"));
|
||||
if (ObjectData->Stream)
|
||||
HasObjectData = true;
|
||||
else
|
||||
ObjectData = NULL;
|
||||
}
|
||||
|
||||
ADT::~ADT()
|
||||
{
|
||||
delete ObjectData;
|
||||
delete Data;
|
||||
|
||||
for (std::vector<MapChunk*>::iterator itr = MapChunks.begin(); itr != MapChunks.end(); ++itr)
|
||||
delete *itr;
|
||||
|
||||
MapChunks.clear();
|
||||
delete _DoodadHandler;
|
||||
delete _WorldModelHandler;
|
||||
delete _LiquidHandler;
|
||||
}
|
||||
|
||||
void ADT::Read()
|
||||
{
|
||||
Header.Read(Data->GetChunkByName("MHDR")->GetStream());
|
||||
MapChunks.reserve(16 * 16);
|
||||
int mapChunkIndex = 0;
|
||||
|
||||
for (std::vector<Chunk*>::iterator itr = Data->Chunks.begin(); itr != Data->Chunks.end(); ++itr)
|
||||
if ((*itr)->Name == "MCNK")
|
||||
MapChunks.push_back(new MapChunk(this, *itr));
|
||||
|
||||
_LiquidHandler = new LiquidHandler(this);
|
||||
|
||||
// do this separate from map chunk initialization to access liquid data
|
||||
for (std::vector<MapChunk*>::iterator itr = MapChunks.begin(); itr != MapChunks.end(); ++itr)
|
||||
(*itr)->GenerateTriangles();
|
||||
|
||||
_DoodadHandler = new DoodadHandler(this);
|
||||
for (std::vector<MapChunk*>::iterator itr = MapChunks.begin(); itr != MapChunks.end(); ++itr)
|
||||
_DoodadHandler->ProcessMapChunk(*itr);
|
||||
|
||||
_WorldModelHandler = new WorldModelHandler(this);
|
||||
for (std::vector<MapChunk*>::iterator itr = MapChunks.begin(); itr != MapChunks.end(); ++itr)
|
||||
_WorldModelHandler->ProcessMapChunk(*itr);
|
||||
}
|
||||
@@ -2,9 +2,10 @@
|
||||
#define ADT_H
|
||||
#include "ChunkedData.h"
|
||||
#include "MapChunk.h"
|
||||
#include "DoodadHandler.h"
|
||||
#include "WorldModelHandler.h"
|
||||
#include "LiquidHandler.h"
|
||||
|
||||
class DoodadHandler;
|
||||
class WorldModelHandler;
|
||||
class LiquidHandler;
|
||||
|
||||
class ADT
|
||||
{
|
||||
|
||||
@@ -45,9 +45,14 @@ add_executable(MeshExtractor
|
||||
)
|
||||
|
||||
target_link_libraries(MeshExtractor
|
||||
shared
|
||||
g3dlib
|
||||
mpq
|
||||
Recast
|
||||
Detour
|
||||
${MYSQL_LIBRARY}
|
||||
${OPENSSL_LIBRARIES}
|
||||
${OPENSSL_EXTRA_LIBRARIES}
|
||||
${BZIP2_LIBRARIES}
|
||||
${ZLIB_LIBRARIES}
|
||||
${ACE_LIBRARY}
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
{
|
||||
if (_items.size() > FlushLimit)
|
||||
Clear();
|
||||
_items.insert(key, val);
|
||||
_items[key] = val;
|
||||
}
|
||||
|
||||
T* Get(std::string key)
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
static const float UnitSize;
|
||||
static const float Origin[];
|
||||
static const float PI;
|
||||
static const float MaxStandableHeight;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -88,7 +88,7 @@ void DoodadHandler::ReadDoodadPaths( Chunk* id, Chunk* data )
|
||||
}
|
||||
}
|
||||
|
||||
void DoodadHandler::InsertModelGeometry(DoodadDefinition def, Model* model)
|
||||
void DoodadHandler::InsertModelGeometry(const DoodadDefinition def, Model* model)
|
||||
{
|
||||
G3D::Matrix4 transformation = Utils::GetTransformation(def);
|
||||
uint32 vertOffset = Vertices.size();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
class DoodadDefinition : IDefinition
|
||||
class DoodadDefinition : public IDefinition
|
||||
{
|
||||
public:
|
||||
uint32 MmidIndex;
|
||||
@@ -43,7 +43,7 @@ protected:
|
||||
private:
|
||||
void ReadDoodadDefinitions(Chunk* chunk);
|
||||
void ReadDoodadPaths(Chunk* id, Chunk* data);
|
||||
void InsertModelGeometry(DoodadDefinition def, Model* model);
|
||||
void InsertModelGeometry(const DoodadDefinition def, Model* model);
|
||||
std::set<uint32> _drawn;
|
||||
std::vector<DoodadDefinition>* _definitions;
|
||||
std::vector<std::string>* _paths;
|
||||
|
||||
@@ -43,7 +43,7 @@ void LiquidHandler::HandleNewLiquid()
|
||||
fseek(stream, chunk->Offset + information.OffsetMask2, SEEK_SET);
|
||||
uint32 size = ceil(information.Width * information.Height / 8.0f);
|
||||
uint8* altMask = new uint8[size];
|
||||
fread(altMax, sizeof(uint8), size, stream);
|
||||
fread(altMask, sizeof(uint8), size, stream);
|
||||
|
||||
for (int mi = 0; mi < size; mi++)
|
||||
renderMask.Mask[mi + information.OffsetY] |= altMask[mi];
|
||||
@@ -84,8 +84,8 @@ void LiquidHandler::HandleNewLiquid()
|
||||
uint32 vertOffset = Vertices.size();
|
||||
Vertices.push_back(location);
|
||||
Vertices.push_back(Vector3(location.x - Constants::UnitSize, location.y, location.z));
|
||||
Vertices.push_back(new Vector3(location.x, location.y - Constants::UnitSize, location.z));
|
||||
Vertices.push_back(new Vector3(location.x - Constants::UnitSize, location.y - Constants::UnitSize, location.z));
|
||||
Vertices.push_back(Vector3(location.x, location.y - Constants::UnitSize, location.z));
|
||||
Vertices.push_back(Vector3(location.x - Constants::UnitSize, location.y - Constants::UnitSize, location.z));
|
||||
|
||||
Triangles.push_back(Triangle<uint32>(Constants::TRIANGLE_TYPE_WATER, vertOffset, vertOffset+2, vertOffset + 1));
|
||||
Triangles.push_back(Triangle<uint32>(Constants::TRIANGLE_TYPE_WATER, vertOffset + 2, vertOffset + 3, vertOffset + 1));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "MapChunk.h"
|
||||
#include "ADT.h"
|
||||
#include "LiquidHandler.h"
|
||||
|
||||
MapChunk::MapChunk( ADT* _adt, Chunk* chunk ) : Adt(_adt), Source(chunk), Vertices(NULL)
|
||||
{
|
||||
@@ -25,7 +26,7 @@ void MapChunk::GenerateTriangles()
|
||||
uint32 bottomRight = (17 * (y + 1)) + x + 1;
|
||||
uint32 center = (17 * y) + 9 + x;
|
||||
|
||||
uint8 triangleType = Constants::TRIANGLE_TYPE_TERRAIN;
|
||||
Constants::TriangleType triangleType = Constants::TRIANGLE_TYPE_TERRAIN;
|
||||
if (Adt->_LiquidHandler && !Adt->_LiquidHandler->MCNKData.empty())
|
||||
{
|
||||
MCNKLiquidData& data = Adt->_LiquidHandler->MCNKData[Index];
|
||||
@@ -37,10 +38,10 @@ void MapChunk::GenerateTriangles()
|
||||
triangleType = Constants::TRIANGLE_TYPE_WATER;
|
||||
}
|
||||
|
||||
Triangles.push_back(new Triangle<uint8>(triangleType, topRight, topLeft, center));
|
||||
Triangles.push_back(new Triangle<uint8>(triangleType, topLeft, bottomLeft, center));
|
||||
Triangles.push_back(new Triangle<uint8>(triangleType, bottomLeft, bottomRight, center));
|
||||
Triangles.push_back(new Triangle<uint8>(triangleType, bottomRight, topRight, center));
|
||||
Triangles.push_back(Triangle<uint8>(triangleType, topRight, topLeft, center));
|
||||
Triangles.push_back(Triangle<uint8>(triangleType, topLeft, bottomLeft, center));
|
||||
Triangles.push_back(Triangle<uint8>(triangleType, bottomLeft, bottomRight, center));
|
||||
Triangles.push_back(Triangle<uint8>(triangleType, bottomRight, topRight, center));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,11 +27,10 @@ TileBuilder::TileBuilder(std::string world, int x, int y) : _Geometry(NULL), Wor
|
||||
|
||||
void TileBuilder::CalculateTileBounds( float*& bmin, float*& bmax )
|
||||
{
|
||||
float origin[3] = Constants::Origin;
|
||||
bmin = new float[3];
|
||||
bmax = new float[3];
|
||||
bmin[0] = origin[0] + (Constants::TileSize * X);
|
||||
bmin[2] = origin[2] + (Constants::TileSize * Y);
|
||||
bmax[0] = origin[0] + (Constants::TileSize * (X + 1));
|
||||
bmax[2] = origin[2] + (Constants::TileSize * (Y + 1));
|
||||
bmin[0] = Constants::Origin[0] + (Constants::TileSize * X);
|
||||
bmin[2] = Constants::Origin[2] + (Constants::TileSize * Y);
|
||||
bmax[0] = Constants::Origin[0] + (Constants::TileSize * (X + 1));
|
||||
bmax[2] = Constants::Origin[2] + (Constants::TileSize * (Y + 1));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "Utils.h"
|
||||
#include "WorldModelHandler.h"
|
||||
#include "Constants.h"
|
||||
#include <cstring>
|
||||
#include "g3d/Matrix4.h"
|
||||
#include "g3d/Quat.h"
|
||||
|
||||
const float Constants::TileSize = 533.0f + (1/3.0f);
|
||||
const float Constants::MaxXY = 32.0f * Constants::TileSize;
|
||||
@@ -9,6 +11,7 @@ const float Constants::ChunkSize = Constants::TileSize / 16.0f;
|
||||
const float Constants::UnitSize = Constants::ChunkSize / 8.0f;
|
||||
const float Constants::Origin[] = { -Constants::MaxXY, 0.0f, -Constants::MaxXY };
|
||||
const float Constants::PI = 3.1415926f;
|
||||
const float Constants::MaxStandableHeight = 1.5f;
|
||||
|
||||
void Utils::Reverse(char word[])
|
||||
{
|
||||
@@ -60,14 +63,7 @@ std::string Utils::GetAdtPath( std::string world, int x, int y )
|
||||
|
||||
std::string Utils::FixModelPath( std::string path )
|
||||
{
|
||||
std::string::size_type idx = path.rfind(".");
|
||||
// Bizarre way of changing extension but...
|
||||
if (idx != std::string::npos)
|
||||
{
|
||||
path[idx + 1] = "M";
|
||||
path[idx + 2] = "2";
|
||||
}
|
||||
return path;
|
||||
return Utils::GetPathBase(path) + ".M2";
|
||||
}
|
||||
|
||||
G3D::Matrix4 Utils::RotationX(float angle)
|
||||
@@ -139,7 +135,7 @@ std::string Utils::GetPathBase( std::string path )
|
||||
{
|
||||
int lastIndex = path.find_last_of(".");
|
||||
if (lastIndex != std::string::npos)
|
||||
return path.substr(0, lastindex);
|
||||
return path.substr(0, lastIndex);
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -172,3 +168,15 @@ std::string Utils::Replace( std::string str, const std::string& oldStr, const st
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
G3D::Matrix4 Utils::GetWmoDoodadTransformation( DoodadInstance inst, WorldModelDefinition root )
|
||||
{
|
||||
G3D::Matrix4 rootTransformation = Utils::GetTransformation(root);
|
||||
G3D::Matrix4 translation = G3D::Matrix4::translation(inst.Position.x, inst.Position.y, inst.Position.z);
|
||||
G3D::Matrix4 scale = G3D::Matrix4::scale(inst.Scale);
|
||||
G3D::Matrix4 rotation = Utils::RotationY(Constants::PI);
|
||||
G3D::Quat quat(-inst.QuatY, inst.QuatZ, -inst.QuatX, inst.QuatW);
|
||||
G3D::Matrix4 quatRotation = quat.toRotationMatrix();
|
||||
|
||||
return scale * rotation * quatRotation ** translation * rootTransformation;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
#include "Common.h"
|
||||
#include "Constants.h"
|
||||
|
||||
struct WorldModelDefinition;
|
||||
class DoodadInstance;
|
||||
|
||||
struct Vector3
|
||||
{
|
||||
Vector3() {}
|
||||
@@ -35,6 +38,7 @@ struct TilePos
|
||||
template<typename T>
|
||||
struct Triangle
|
||||
{
|
||||
Triangle() {}
|
||||
Triangle(Constants::TriangleType type, T v0, T v1, T v2) : Type(type), V0(v0), V1(v1), V2(v2) {}
|
||||
T V0;
|
||||
T V1;
|
||||
@@ -444,7 +448,6 @@ public:
|
||||
MCNKLiquidData() {}
|
||||
MCNKLiquidData(float** heights, H2ORenderMask mask) : Heights(heights), Mask(mask) {}
|
||||
|
||||
static const float MaxStandableHeight = 1.5f;
|
||||
float** Heights;
|
||||
H2ORenderMask Mask;
|
||||
|
||||
@@ -452,10 +455,10 @@ public:
|
||||
{
|
||||
if (!Heights)
|
||||
return false;
|
||||
if (!Mask->ShouldRender(x, y))
|
||||
if (!Mask.ShouldRender(x, y))
|
||||
return false;
|
||||
float diff = Heights[x][y] - height;
|
||||
if (diff > MaxStandableHeight)
|
||||
if (diff > Constants::MaxStandableHeight)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -517,7 +520,7 @@ class IDefinition
|
||||
public:
|
||||
Vector3 Position;
|
||||
Vector3 Rotation;
|
||||
virtual float Scale() const = 0;
|
||||
virtual float Scale() const { return 1.0f; };
|
||||
};
|
||||
|
||||
class Utils
|
||||
@@ -555,6 +558,6 @@ public:
|
||||
return true;
|
||||
}
|
||||
static std::string Utils::Replace( std::string str, const std::string& oldStr, const std::string& newStr );
|
||||
|
||||
static G3D::Matrix4 GetWmoDoodadTransformation( DoodadInstance inst, WorldModelDefinition root );
|
||||
};
|
||||
#endif
|
||||
@@ -33,7 +33,7 @@ void WorldModelGroup::ReadNormals()
|
||||
return;
|
||||
|
||||
uint32 normalCount = chunk->Length / 12;
|
||||
ASSERT(normalCount == Vertices.size(), "normalCount is different than the Vertices count");
|
||||
ASSERT(normalCount == Vertices.size() && "normalCount is different than the Vertices count");
|
||||
Normals.reserve(normalCount);
|
||||
FILE* stream = chunk->GetStream();
|
||||
for (int i = 0; i < normalCount; i++)
|
||||
@@ -48,8 +48,8 @@ void WorldModelGroup::ReadLiquid()
|
||||
|
||||
HasLiquidData = true;
|
||||
FILE* stream = chunk->GetStream();
|
||||
LiquidDataHeader = LiquidHeader.Read(stream);
|
||||
LiquidDataGeometry = LiquidData.Read(stream, LiquidDataHeader);
|
||||
LiquidDataHeader = LiquidHeader::Read(stream);
|
||||
LiquidDataGeometry = LiquidData::Read(stream, LiquidDataHeader);
|
||||
}
|
||||
|
||||
void WorldModelGroup::ReadVertices()
|
||||
@@ -72,7 +72,7 @@ void WorldModelGroup::ReadTriangles()
|
||||
return;
|
||||
|
||||
uint32 triangleCount = chunk->Length / 6;
|
||||
ASSERT(triangleCount == TriangleFlags.size(), "triangleCount != TriangleFlags.size()");
|
||||
ASSERT(triangleCount == TriangleFlags.size() && "triangleCount != TriangleFlags.size()");
|
||||
FILE* stream = chunk->GetStream();
|
||||
Triangles.reserve(triangleCount);
|
||||
for (int i = 0; i < triangleCount; i++)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "WorldModelHandler.h"
|
||||
#include "WorldModelRoot.h"
|
||||
#include "Chunk.h"
|
||||
#include "Cache.h"
|
||||
#include "Model.h"
|
||||
#include "Common.h"
|
||||
#include "g3d/Matrix4.h"
|
||||
#include <cstdio>
|
||||
@@ -15,7 +17,7 @@ WorldModelDefinition WorldModelDefinition::Read( FILE* file )
|
||||
ret.UpperExtents = Vector3::Read(file);
|
||||
ret.LowerExtents = Vector3::Read(file);
|
||||
fread(&ret.Flags, sizeof(uint16), 1, file);
|
||||
fread(&ret.DooadSet, sizeof(uint16), 1, file);
|
||||
fread(&ret.DoodadSet, sizeof(uint16), 1, file);
|
||||
uint32 discard;
|
||||
fread(&discard, sizeof(uint32), 1, file);
|
||||
return ret;
|
||||
@@ -39,7 +41,7 @@ void WorldModelHandler::ProcessInternal( ChunkedData* subChunks )
|
||||
return;
|
||||
FILE* stream = wmoReferencesChunk->GetStream();
|
||||
uint32 refCount = wmoReferencesChunk->Length / 4;
|
||||
for (int i = 0; i < refCount; i++)
|
||||
for (uint32 i = 0; i < refCount; i++)
|
||||
{
|
||||
int32 index;
|
||||
fread(&index, sizeof(int32), 1, stream);
|
||||
@@ -56,7 +58,7 @@ void WorldModelHandler::ProcessInternal( ChunkedData* subChunks )
|
||||
if (wmo.MwidIndex >= _paths->size())
|
||||
continue;
|
||||
|
||||
std::string path = _paths[(int) wmo.MwidIndex];
|
||||
std::string path = (*_paths)[wmo.MwidIndex];
|
||||
WorldModelRoot* model = Cache->WorldModelCache.Get(path);
|
||||
if (!model)
|
||||
{
|
||||
@@ -71,16 +73,16 @@ void WorldModelHandler::ProcessInternal( ChunkedData* subChunks )
|
||||
}
|
||||
}
|
||||
|
||||
void WorldModelHandler::InsertModelGeometry( std::vector<Vector3> verts, std::vector<Triangle<uint32> > tris, WorldModelDefinition& def, WorldModelRoot* root )
|
||||
void WorldModelHandler::InsertModelGeometry( std::vector<Vector3>& verts, std::vector<Triangle<uint32> >& tris, WorldModelDefinition& def, WorldModelRoot* root )
|
||||
{
|
||||
G3D::Matrix4 transformation = Utils::GetTransformation();
|
||||
G3D::Matrix4 transformation = Utils::GetTransformation(def);
|
||||
for (std::vector<WorldModelGroup>::iterator group = root->Groups.begin(); group != root->Groups.end(); ++group)
|
||||
{
|
||||
uint32 vertOffset = verts.size();
|
||||
for (std::vector<Vector3>::iterator itr2 = group->Vertices.begin(); itr2 != group->Vertices.end(); ++itr2)
|
||||
verts.push_back(Utils::VectorTransform(*itr2, transformation));
|
||||
|
||||
for (int i = 0; i < group->Triangles.size(); ++i)
|
||||
for (uint32 i = 0; i < group->Triangles.size(); ++i)
|
||||
{
|
||||
// only include collidable tris
|
||||
if ((group->TriangleFlags[i] & 0x04) != 0 && group->TriangleMaterials[i] != 0xFF)
|
||||
@@ -93,7 +95,7 @@ void WorldModelHandler::InsertModelGeometry( std::vector<Vector3> verts, std::ve
|
||||
if (def.DoodadSet >= 0 && def.DoodadSet < root->DoodadSets.size())
|
||||
{
|
||||
DoodadSet set = root->DoodadSets[def.DoodadSet];
|
||||
std::vector<DoodadInstance> instances = new std::vector<DoodadInstance>;
|
||||
std::vector<DoodadInstance> instances;
|
||||
instances.reserve(set.CountInstances);
|
||||
for (uint32 i = set.FirstInstanceIndex; i < (set.CountInstances + set.FirstInstanceIndex); i++)
|
||||
{
|
||||
@@ -104,16 +106,16 @@ void WorldModelHandler::InsertModelGeometry( std::vector<Vector3> verts, std::ve
|
||||
|
||||
for (std::vector<DoodadInstance>::iterator instance = instances.begin(); instance != instances.end(); ++instance)
|
||||
{
|
||||
Model* model = Cache.ModelCache.Get(instance->File);
|
||||
Model* model = Cache->ModelCache.Get(instance->File);
|
||||
if (!model)
|
||||
{
|
||||
model = new Model(instance->File);
|
||||
Cache.ModelCache.Insert(instance->File, model);
|
||||
Cache->ModelCache.Insert(instance->File, model);
|
||||
}
|
||||
|
||||
if (!model.IsCollidable)
|
||||
if (!model->IsCollidable)
|
||||
continue;
|
||||
G3D::Matrix4 doodadTransformation = Utils::GetWmoDoodadTransformation(instance, def);
|
||||
G3D::Matrix4 doodadTransformation = Utils::GetWmoDoodadTransformation(*instance, def);
|
||||
int vertOffset = verts.size();
|
||||
for (std::vector<Vector3>::iterator itr2 = model->Vertices.begin(); itr2 != model->Vertices.end(); ++itr2)
|
||||
verts.push_back(Utils::VectorTransform(*itr2, doodadTransformation));
|
||||
@@ -126,9 +128,9 @@ void WorldModelHandler::InsertModelGeometry( std::vector<Vector3> verts, std::ve
|
||||
if (!group->HasLiquidData)
|
||||
continue;
|
||||
|
||||
for (int y = 0; y < group->LiquidDataHeader.Height; y++)
|
||||
for (uint32 y = 0; y < group->LiquidDataHeader.Height; y++)
|
||||
{
|
||||
for (int x = 0; x < group->LiquidDataHeader.Width; x++)
|
||||
for (uint32 x = 0; x < group->LiquidDataHeader.Width; x++)
|
||||
{
|
||||
if (!group->LiquidDataGeometry.ShouldRender(x, y))
|
||||
continue;
|
||||
@@ -144,7 +146,7 @@ void WorldModelHandler::InsertModelGeometry( std::vector<Vector3> verts, std::ve
|
||||
group->LiquidDataGeometry.HeightMap[x + 1][y + 1], x + 1, y + 1));
|
||||
|
||||
tris.push_back(Triangle<uint32>(Constants::TRIANGLE_TYPE_WATER, vertOffset, vertOffset + 2, vertOffset + 1));
|
||||
tris.push_back(new Triangle<uint32>(Constants::TRIANGLE_TYPE_WATER, vertOffset + 2, vertOffset + 3, vertOffset + 1));
|
||||
tris.push_back(Triangle<uint32>(Constants::TRIANGLE_TYPE_WATER, vertOffset + 2, vertOffset + 3, vertOffset + 1));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -163,7 +165,7 @@ void WorldModelHandler::ReadDefinitions()
|
||||
_definitions = new std::vector<WorldModelDefinition>;
|
||||
_definitions->reserve(definitionCount);
|
||||
FILE* stream = chunk->GetStream();
|
||||
for (int i = 0; i < definitionCount; i++)
|
||||
for (uint32 i = 0; i < definitionCount; i++)
|
||||
_definitions->push_back(WorldModelDefinition::Read(stream));
|
||||
}
|
||||
|
||||
@@ -177,7 +179,7 @@ void WorldModelHandler::ReadModelPaths()
|
||||
uint32 paths = mwid->Length / 4;
|
||||
_paths = new std::vector<std::string>;
|
||||
_paths->reserve(paths);
|
||||
for (int i = 0; i < paths; i++)
|
||||
for (uint32 i = 0; i < paths; i++)
|
||||
{
|
||||
FILE* stream = mwid->GetStream();
|
||||
fseek(stream, i * 4, SEEK_CUR);
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
#define WMODEL_HNDL_H
|
||||
#include "Common.h"
|
||||
#include "Utils.h"
|
||||
#include "WorldModelRoot.h"
|
||||
#include "ObjectDataHandler.h"
|
||||
#include "ADT.h"
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
struct WorldModelDefinition : IDefinition
|
||||
class ADT;
|
||||
|
||||
struct WorldModelDefinition : public IDefinition
|
||||
{
|
||||
public:
|
||||
WorldModelDefinition() {}
|
||||
@@ -20,8 +22,6 @@ public:
|
||||
uint16 Flags;
|
||||
uint16 DoodadSet;
|
||||
|
||||
virtual float Scale() const { return 1.0f; }
|
||||
|
||||
static WorldModelDefinition Read(FILE* file);
|
||||
};
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
std::vector<Vector3> Vertices;
|
||||
std::vector<Triangle<uint32> > Triangles;
|
||||
bool IsSane() { return _definitions && _paths; }
|
||||
void InsertModelGeometry(std::vector<Vector3> verts, std::vector<Triangle<uint32> > tris, WorldModelDefinition& def, WorldModelRoot* root);
|
||||
void InsertModelGeometry(std::vector<Vector3>& verts, std::vector<Triangle<uint32> >& tris, WorldModelDefinition& def, WorldModelRoot* root);
|
||||
protected:
|
||||
void ProcessInternal(ChunkedData* data);
|
||||
private:
|
||||
|
||||
@@ -33,7 +33,7 @@ void WorldModelRoot::ReadDoodadSets()
|
||||
return;
|
||||
|
||||
FILE* stream = chunk->GetStream();
|
||||
ASSERT(chunk->Length / 32 == Header.CountSets, "chunk.Length / 32 == Header.CountSets");
|
||||
ASSERT(chunk->Length / 32 == Header.CountSets && "chunk.Length / 32 == Header.CountSets");
|
||||
DoodadSets.reserve(Header.CountSets);
|
||||
for (int i = 0; i < Header.CountSets; i++)
|
||||
DoodadSets.push_back(DoodadSet::Read(stream));
|
||||
|
||||
Reference in New Issue
Block a user