aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/scripts/Commands/cs_mmaps.cpp108
-rw-r--r--src/tools/mesh_extractor/Cache.h4
-rw-r--r--src/tools/mesh_extractor/DoodadHandler.cpp12
-rw-r--r--src/tools/mesh_extractor/DoodadHandler.h2
-rw-r--r--src/tools/mesh_extractor/Geometry.cpp6
-rw-r--r--src/tools/mesh_extractor/TileBuilder.cpp2
-rw-r--r--src/tools/mesh_extractor/Utils.cpp10
-rw-r--r--src/tools/mesh_extractor/Utils.h22
-rw-r--r--src/tools/mesh_extractor/WorldModelGroup.cpp14
-rw-r--r--src/tools/mesh_extractor/WorldModelHandler.cpp6
-rw-r--r--src/tools/mesh_extractor/WorldModelHandler.h6
-rw-r--r--src/tools/mesh_extractor/WorldModelRoot.cpp2
12 files changed, 101 insertions, 93 deletions
diff --git a/src/server/scripts/Commands/cs_mmaps.cpp b/src/server/scripts/Commands/cs_mmaps.cpp
index c1fc4d1a5e9..e4a0ebf7f24 100644
--- a/src/server/scripts/Commands/cs_mmaps.cpp
+++ b/src/server/scripts/Commands/cs_mmaps.cpp
@@ -60,60 +60,58 @@ public:
static bool HandleMmapPathCommand(ChatHandler* handler, char const* args)
{
- if (!MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId()))
- {
- handler->PSendSysMessage("NavMesh not loaded for current map.");
- return true;
- }
-
- handler->PSendSysMessage("mmap path:");
-
- // units
- Player* player = handler->GetSession()->GetPlayer();
- Unit* target = handler->getSelectedUnit();
- if (!player || !target)
- {
- handler->PSendSysMessage("Invalid target/source selection.");
- return true;
- }
-
- char* para = strtok((char*)args, " ");
-
- bool useStraightPath = false;
- if (para && strcmp(para, "true") == 0)
- useStraightPath = true;
-
- // unit locations
- float x, y, z;
- player->GetPosition(x, y, z);
-
- // path
- PathGenerator path(target);
- path.SetUseStraightPath(useStraightPath);
- path.CalculatePath(x, y, z);
-
- PointsArray pointPath = path.GetPath();
- handler->PSendSysMessage("%s's path to %s:", target->GetName(), player->GetName());
- handler->PSendSysMessage("Building %s", useStraightPath ? "StraightPath" : "SmoothPath");
- handler->PSendSysMessage("length %i type %u", pointPath.size(), path.GetPathType());
-
- Vector3 start = path.GetStartPosition();
- Vector3 end = path.GetEndPosition();
- Vector3 actualEnd = path.GetActualEndPosition();
-
- handler->PSendSysMessage("start (%.3f, %.3f, %.3f)", start.x, start.y, start.z);
- handler->PSendSysMessage("end (%.3f, %.3f, %.3f)", end.x, end.y, end.z);
- handler->PSendSysMessage("actual end (%.3f, %.3f, %.3f)", actualEnd.x, actualEnd.y, actualEnd.z);
-
- if (!player->isGameMaster())
- handler->PSendSysMessage("Enable GM mode to see the path points.");
-
- // this entry visible only to GM's with "gm on"
- static const uint32 WAYPOINT_NPC_ENTRY = 1;
- for (uint32 i = 0; i < pointPath.size(); ++i)
- player->SummonCreature(WAYPOINT_NPC_ENTRY, pointPath[i].x, pointPath[i].y, pointPath[i].z, 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
-
- return true;
+ if (!MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId()))
+ {
+ handler->PSendSysMessage("NavMesh not loaded for current map.");
+ return true;
+ }
+
+ handler->PSendSysMessage("mmap path:");
+
+ // units
+ Player* player = handler->GetSession()->GetPlayer();
+ Unit* target = handler->getSelectedUnit();
+ if (!player || !target)
+ {
+ handler->PSendSysMessage("Invalid target/source selection.");
+ return true;
+ }
+
+ char* para = strtok((char*)args, " ");
+
+ bool useStraightPath = false;
+ if (para && strcmp(para, "true") == 0)
+ useStraightPath = true;
+
+ // unit locations
+ float x, y, z;
+ player->GetPosition(x, y, z);
+
+ // path
+ PathGenerator path(target);
+ path.SetUseStraightPath(useStraightPath);
+ bool result = path.CalculatePath(x, y, z);
+
+ PointsArray pointPath = path.GetPath();
+ handler->PSendSysMessage("%s's path to %s:", target->GetName(), player->GetName());
+ handler->PSendSysMessage("Building: %s", useStraightPath ? "StraightPath" : "SmoothPath");
+ handler->PSendSysMessage("Result: %s - Length: %i - Type: %u", (result ? "true" : "false"), pointPath.size(), path.GetPathType());
+
+ Vector3 start = path.GetStartPosition();
+ Vector3 end = path.GetEndPosition();
+ Vector3 actualEnd = path.GetActualEndPosition();
+
+ handler->PSendSysMessage("StartPosition (%.3f, %.3f, %.3f)", start.x, start.y, start.z);
+ handler->PSendSysMessage("EndPosition (%.3f, %.3f, %.3f)", end.x, end.y, end.z);
+ handler->PSendSysMessage("ActualEndPosition (%.3f, %.3f, %.3f)", actualEnd.x, actualEnd.y, actualEnd.z);
+
+ if (!player->isGameMaster())
+ handler->PSendSysMessage("Enable GM mode to see the path points.");
+
+ for (uint32 i = 0; i < pointPath.size(); ++i)
+ player->SummonCreature(VISUAL_WAYPOINT, pointPath[i].x, pointPath[i].y, pointPath[i].z, 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
+
+ return true;
}
static bool HandleMmapLocCommand(ChatHandler* handler, const char* args)
@@ -290,4 +288,4 @@ public:
void AddSC_mmaps_commandscript()
{
new mmaps_commandscript();
-} \ No newline at end of file
+}
diff --git a/src/tools/mesh_extractor/Cache.h b/src/tools/mesh_extractor/Cache.h
index 186a7870af1..bc2ea6a2883 100644
--- a/src/tools/mesh_extractor/Cache.h
+++ b/src/tools/mesh_extractor/Cache.h
@@ -11,7 +11,8 @@ class GenericCache
{
public:
GenericCache() {}
- const int32 FlushLimit = 1000;
+
+ static const int32 FlushLimit = 1000;
void Insert(std::string key, T* val)
{
@@ -35,6 +36,7 @@ private:
class CacheClass
{
+public:
CacheClass() {}
GenericCache<Model> ModelCache;
GenericCache<WorldModelRoot> WorldModelCache;
diff --git a/src/tools/mesh_extractor/DoodadHandler.cpp b/src/tools/mesh_extractor/DoodadHandler.cpp
index 4a7707753c4..71ca1974b81 100644
--- a/src/tools/mesh_extractor/DoodadHandler.cpp
+++ b/src/tools/mesh_extractor/DoodadHandler.cpp
@@ -27,7 +27,7 @@ void DoodadHandler::ProcessInternal( ChunkedData* subChunks )
return;
FILE* stream = doodadReferencesChunk->GetStream();
uint32 refCount = doodadReferencesChunk->Length / 4;
- for (int i = 0; i < refCount; i++)
+ for (uint32 i = 0; i < refCount; i++)
{
int32 index;
fread(&index, sizeof(int32), 1, stream);
@@ -41,11 +41,11 @@ void DoodadHandler::ProcessInternal( ChunkedData* subChunks )
continue;
std::string path = (*_paths)[doodad.MmidIndex];
- Model* model = Cache.ModelCache.Get(path);
+ Model* model = Cache->ModelCache.Get(path);
if (!model)
{
model = new Model(path);
- Cache.ModelCache.Insert(path, model);
+ Cache->ModelCache.Insert(path, model);
}
if (!model->IsCollidable)
continue;
@@ -92,8 +92,10 @@ void DoodadHandler::InsertModelGeometry(DoodadDefinition def, Model* model)
{
G3D::Matrix4 transformation = Utils::GetTransformation(def);
uint32 vertOffset = Vertices.size();
+
for (std::vector<Vector3>::iterator itr = model->Vertices.begin(); itr != model->Vertices.end(); ++itr)
Vertices.push_back(Utils::VectorTransform(*itr, transformation));
+
for (std::vector<Triangle<uint16> >::iterator itr = model->Triangles.begin(); itr != model->Triangles.end(); ++itr)
- Triangles.push_back(Triangle<uint16>(Constants::TRIANGLE_TYPE_DOODAD, itr->V0 + vertOffset, itr->V1 + vertOffset, itr->V2 + vertOffset));
-} \ No newline at end of file
+ Triangles.push_back(Triangle<uint32>(Constants::TRIANGLE_TYPE_DOODAD, itr->V0 + vertOffset, itr->V1 + vertOffset, itr->V2 + vertOffset));
+}
diff --git a/src/tools/mesh_extractor/DoodadHandler.h b/src/tools/mesh_extractor/DoodadHandler.h
index c62584ca1f1..d38ee723bef 100644
--- a/src/tools/mesh_extractor/DoodadHandler.h
+++ b/src/tools/mesh_extractor/DoodadHandler.h
@@ -15,7 +15,7 @@ public:
uint16 DecimalScale;
uint16 Flags;
- float Scale() { return DecimalScale / 1024.0f; }
+ virtual float Scale() const { return DecimalScale / 1024.0f; }
void Read(FILE* stream)
{
diff --git a/src/tools/mesh_extractor/Geometry.cpp b/src/tools/mesh_extractor/Geometry.cpp
index 8e417af4c73..130258b6908 100644
--- a/src/tools/mesh_extractor/Geometry.cpp
+++ b/src/tools/mesh_extractor/Geometry.cpp
@@ -68,7 +68,7 @@ void Geometry::AddData( std::vector<Vector3>& verts, std::vector<Triangle<uint32
void Geometry::GetRawData( float*& verts, int*& tris, uint8*& areas )
{
verts = new float[Vertices.size() * 3];
- for (int i = 0; i < Vertices.size(); ++i)
+ for (uint32 i = 0; i < Vertices.size(); ++i)
{
Vector3& vert = Vertices[i];
verts[(i * 3) + 0] = vert.x;
@@ -77,7 +77,7 @@ void Geometry::GetRawData( float*& verts, int*& tris, uint8*& areas )
}
tris = new int[Triangles.size() * 3];
- for (int i = 0; i < Triangles.size(); ++i)
+ for (uint32 i = 0; i < Triangles.size(); ++i)
{
Triangle<uint32>& tri = Triangles[i];
tris[(i * 3) + 0] = (int)tri.V0;
@@ -86,7 +86,7 @@ void Geometry::GetRawData( float*& verts, int*& tris, uint8*& areas )
}
areas = new uint8[Triangles.size()];
- for (int i = 0; i < Triangles.size(); i++)
+ for (uint32 i = 0; i < Triangles.size(); i++)
{
switch (Triangles[i].Type)
{
diff --git a/src/tools/mesh_extractor/TileBuilder.cpp b/src/tools/mesh_extractor/TileBuilder.cpp
index 070b9d70050..36e71730c34 100644
--- a/src/tools/mesh_extractor/TileBuilder.cpp
+++ b/src/tools/mesh_extractor/TileBuilder.cpp
@@ -34,4 +34,4 @@ void TileBuilder::CalculateTileBounds( float*& bmin, float*& bmax )
bmin[2] = origin[2] + (Constants::TileSize * Y);
bmax[0] = origin[0] + (Constants::TileSize * (X + 1));
bmax[2] = origin[2] + (Constants::TileSize * (Y + 1));
-} \ No newline at end of file
+}
diff --git a/src/tools/mesh_extractor/Utils.cpp b/src/tools/mesh_extractor/Utils.cpp
index 0b92dab267f..ef24a8017bd 100644
--- a/src/tools/mesh_extractor/Utils.cpp
+++ b/src/tools/mesh_extractor/Utils.cpp
@@ -74,7 +74,7 @@ G3D::Matrix4 Utils::RotationX(float angle)
{
float _cos = cos(angle);
float _sin = sin(angle);
- Matrix4 ret = G3D::Matrix4::identity();
+ G3D::Matrix4 ret = G3D::Matrix4::identity();
ret[2][2] = _cos;
ret[2][3] = _sin;
ret[3][2] = -_sin;
@@ -82,7 +82,7 @@ G3D::Matrix4 Utils::RotationX(float angle)
return ret;
}
-G3D::Matrix4 Utils::GetTransformation( IDefinition def )
+G3D::Matrix4 Utils::GetTransformation(IDefinition def)
{
G3D::Matrix4 translation;
if (def.Position.x == 0.0f && def.Position.y == 0.0f && def.Position.z == 0.0f)
@@ -101,7 +101,7 @@ G3D::Matrix4 Utils::RotationY( float angle )
{
float _cos = cos(angle);
float _sin = sin(angle);
- Matrix4 ret = G3D::Matrix4::identity();
+ G3D::Matrix4 ret = G3D::Matrix4::identity();
ret[1][1] = _cos;
ret[1][3] = -_sin;
ret[3][1] = _sin;
@@ -113,7 +113,7 @@ G3D::Matrix4 Utils::RotationZ( float angle )
{
float _cos = cos(angle);
float _sin = sin(angle);
- Matrix4 ret = G3D::Matrix4::identity();
+ G3D::Matrix4 ret = G3D::Matrix4::identity();
ret[1][1] = _cos;
ret[1][2] = _sin;
ret[2][1] = -_sin;
@@ -126,7 +126,7 @@ float Utils::ToRadians( float degrees )
return Constants::PI * degrees / 180.0f;
}
-Vector3 Utils::VectorTransform( Vector3 vec, G3D::Matrix matrix )
+Vector3 Utils::VectorTransform( Vector3 vec, G3D::Matrix4 matrix )
{
Vector3 ret;
ret.x = vec.x * matrix[1][1] + vec.y * matrix[2][1] + vec.z * matrix[3][1] + matrix[4][1];
diff --git a/src/tools/mesh_extractor/Utils.h b/src/tools/mesh_extractor/Utils.h
index aa73db173a7..ec333d80f8c 100644
--- a/src/tools/mesh_extractor/Utils.h
+++ b/src/tools/mesh_extractor/Utils.h
@@ -16,10 +16,12 @@ struct Vector3
float x;
float y;
float z;
+
Vector3 operator +(Vector3 const& other)
{
return Vector3(x + other.x, y + other.y, z + other.z);
}
+
static Vector3 Read(FILE* file);
};
@@ -342,7 +344,7 @@ public:
fread(&ret.UnknownZero, sizeof(uint32), 1, stream);
return ret;
}
-}
+};
class LiquidHeader
{
@@ -384,16 +386,16 @@ public:
{
LiquidData ret;
ret.HeightMap = new float*[header.CountXVertices];
- for (int i = 0; i < header.CountXVertices; ++i)
+ for (uint32 i = 0; i < header.CountXVertices; ++i)
ret.HeightMap[i] = new float[header.CountYVertices];
ret.RenderFlags = new uint8*[header.Width];
- for (int i = 0; i < header.Width; ++i)
+ for (uint32 i = 0; i < header.Width; ++i)
ret.RenderFlags[i] = new uint8[header.Height];
- for (int y = 0; y < header.CountYVertices; y++)
+ for (uint32 y = 0; y < header.CountYVertices; y++)
{
- for (int x = 0; x < header.CountXVertices; x++)
+ for (uint32 x = 0; x < header.CountXVertices; x++)
{
uint32 discard;
fread(&discard, sizeof(uint32), 1, stream);
@@ -403,9 +405,9 @@ public:
}
}
- for (int y = 0; y < header.Height; y++)
+ for (uint32 y = 0; y < header.Height; y++)
{
- for (int x = 0; x < header.Width; x++)
+ for (uint32 x = 0; x < header.Width; x++)
{
uint8 tmp;
fread(&tmp, sizeof(uint8), 1, stream);
@@ -441,8 +443,8 @@ class MCNKLiquidData
public:
MCNKLiquidData() {}
MCNKLiquidData(float** heights, H2ORenderMask mask) : Heights(heights), Mask(mask) {}
- const float MaxStandableHeight = 1.5f;
+ static const float MaxStandableHeight = 1.5f;
float** Heights;
H2ORenderMask Mask;
@@ -515,7 +517,7 @@ class IDefinition
public:
Vector3 Position;
Vector3 Rotation;
- virtual float Scale() = 0;
+ virtual float Scale() const = 0;
};
class Utils
@@ -540,7 +542,7 @@ public:
static G3D::Matrix4 RotationY(float angle);
static G3D::Matrix4 RotationZ(float angle);
static float ToRadians(float degrees);
- static Vector3 VectorTransform(Vector3 vec, G3D::Matrix matrix);
+ static Vector3 VectorTransform(Vector3 vec, G3D::Matrix4 matrix);
static std::string GetPathBase(std::string path);
static Vector3 GetLiquidVert(G3D::Matrix4 transformation, Vector3 basePosition, float height, int x, int y);
static float Distance(float x, float y);
diff --git a/src/tools/mesh_extractor/WorldModelGroup.cpp b/src/tools/mesh_extractor/WorldModelGroup.cpp
index 308c7ff7b86..5039eb56381 100644
--- a/src/tools/mesh_extractor/WorldModelGroup.cpp
+++ b/src/tools/mesh_extractor/WorldModelGroup.cpp
@@ -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++)
@@ -58,7 +58,7 @@ void WorldModelGroup::ReadVertices()
if (!chunk)
return;
- uint32 verticeCount = chunk.Length / 12;
+ uint32 verticeCount = chunk->Length / 12;
Vertices.reserve(verticeCount);
FILE* stream = chunk->GetStream();
for (int i = 0; i < verticeCount; i++)
@@ -71,9 +71,9 @@ void WorldModelGroup::ReadTriangles()
if (!chunk)
return;
- uint32 triangleCount = chunk.Length / 6;
- Assert(triangleCount == TriangleFlags.size(), "triangleCount != TriangleFlags.size()");
- FILE* stream = chunk.GetStream();
+ uint32 triangleCount = chunk->Length / 6;
+ ASSERT(triangleCount == TriangleFlags.size(), "triangleCount != TriangleFlags.size()");
+ FILE* stream = chunk->GetStream();
Triangles.reserve(triangleCount);
for (int i = 0; i < triangleCount; i++)
{
@@ -94,7 +94,7 @@ void WorldModelGroup::ReadMaterials()
return;
FILE* stream = chunk->GetStream();
- uint32 triangleCount = chunk.Length / 2;
+ uint32 triangleCount = chunk->Length / 2;
TriangleFlags.reserve(triangleCount);
TriangleMaterials.reserve(triangleCount);
for (int i = 0; i < triangleCount; i++)
@@ -115,7 +115,7 @@ void WorldModelGroup::ReadBoundingBox()
return;
FILE* stream = chunk->GetStream();
- fseek(stream, 8, SEEK_CUR):
+ fseek(stream, 8, SEEK_CUR);
fread(&Flags, sizeof(uint32), 1, stream);
BoundingBox[0] = Vector3::Read(stream);
BoundingBox[1] = Vector3::Read(stream);
diff --git a/src/tools/mesh_extractor/WorldModelHandler.cpp b/src/tools/mesh_extractor/WorldModelHandler.cpp
index e895e2bfde8..cb8ac6d8e5d 100644
--- a/src/tools/mesh_extractor/WorldModelHandler.cpp
+++ b/src/tools/mesh_extractor/WorldModelHandler.cpp
@@ -159,8 +159,8 @@ void WorldModelHandler::ReadDefinitions()
return;
const int32 definitionSize = 64;
- uint32 definitionCount = chunk.Length / definitionSize;
- _definitions = new new std::vector<WorldModelDefinition>;
+ uint32 definitionCount = chunk->Length / definitionSize;
+ _definitions = new std::vector<WorldModelDefinition>;
_definitions->reserve(definitionCount);
FILE* stream = chunk->GetStream();
for (int i = 0; i < definitionCount; i++)
@@ -174,7 +174,7 @@ void WorldModelHandler::ReadModelPaths()
if (!mwid || !mwmo)
return;
- uint32 paths = mwid.Length / 4;
+ uint32 paths = mwid->Length / 4;
_paths = new std::vector<std::string>;
_paths->reserve(paths);
for (int i = 0; i < paths; i++)
diff --git a/src/tools/mesh_extractor/WorldModelHandler.h b/src/tools/mesh_extractor/WorldModelHandler.h
index 2236339de9d..81e6eab1c4b 100644
--- a/src/tools/mesh_extractor/WorldModelHandler.h
+++ b/src/tools/mesh_extractor/WorldModelHandler.h
@@ -10,14 +10,18 @@
struct WorldModelDefinition : IDefinition
{
+public:
WorldModelDefinition() {}
+
uint32 MwidIndex;
uint32 UniqueId;
Vector3 UpperExtents;
Vector3 LowerExtents;
uint16 Flags;
uint16 DoodadSet;
- float Scale() { return 1.0f; }
+
+ virtual float Scale() const { return 1.0f; }
+
static WorldModelDefinition Read(FILE* file);
};
diff --git a/src/tools/mesh_extractor/WorldModelRoot.cpp b/src/tools/mesh_extractor/WorldModelRoot.cpp
index 9764e339242..18b3fd8586d 100644
--- a/src/tools/mesh_extractor/WorldModelRoot.cpp
+++ b/src/tools/mesh_extractor/WorldModelRoot.cpp
@@ -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));