mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-28 15:17:46 +00:00
more pcb_reader things
This commit is contained in:
parent
2f02b5c850
commit
e540dbca47
3 changed files with 63 additions and 38 deletions
|
@ -8,9 +8,9 @@ file(GLOB SERVER_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}*.c*")
|
||||||
add_executable(pcb_reader2 ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES})
|
add_executable(pcb_reader2 ${SERVER_PUBLIC_INCLUDE_FILES} ${SERVER_SOURCE_FILES})
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
target_link_libraries( pcb_reader2 common xivdat pthread mysqlclient dl z stdc++fs Recast Detour )
|
target_link_libraries( pcb_reader2 common xivdat pthread mysqlclient dl z stdc++fs Recast Detour DetourTileCache )
|
||||||
else()
|
else()
|
||||||
target_link_libraries( pcb_reader2 common xivdat mysql zlib Recast Detour )
|
target_link_libraries( pcb_reader2 common xivdat mysql zlib Recast Detour DetourTileCache )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories( pcb_reader2
|
target_include_directories( pcb_reader2
|
||||||
|
|
|
@ -9,6 +9,10 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
#include "matrix4.h"
|
#include "matrix4.h"
|
||||||
#include "vec3.h"
|
#include "vec3.h"
|
||||||
#include "sgb.h"
|
#include "sgb.h"
|
||||||
|
@ -238,6 +242,47 @@ public:
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct LGB_COLLISION_BOX_HEADER :
|
||||||
|
public LGB_ENTRY_HEADER
|
||||||
|
{
|
||||||
|
uint8_t unk[100];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LGB_COLLISION_BOX_ENTRY :
|
||||||
|
public LGB_ENTRY
|
||||||
|
{
|
||||||
|
LGB_COLLISION_BOX_HEADER header;
|
||||||
|
std::string name;
|
||||||
|
|
||||||
|
LGB_COLLISION_BOX_ENTRY( char* buf, uint32_t offset ) :
|
||||||
|
LGB_ENTRY( buf, offset )
|
||||||
|
{
|
||||||
|
header = *reinterpret_cast< LGB_COLLISION_BOX_HEADER* >( buf + offset );
|
||||||
|
header.type = LgbEntryType::CollisionBox;
|
||||||
|
name = std::string( buf + offset + header.nameOffset );
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "\nName: " << name << "Id: " << header.unknown << "\n";
|
||||||
|
ss << "Pos: " << header.translation.x << " " << header.translation.y << " " << header.translation.z << "\n";
|
||||||
|
ss << "Rot?: " << header.rotation.x << " " << header.rotation.y << " " << header.rotation.z << "\n";
|
||||||
|
ss << "Scale?: " << header.scale.x << " " << header.scale.y << " " << header.scale.z << "\n";
|
||||||
|
ss << "00 01 02 03 04 05 06 07 | 08 09 0A 0B 0C 0D 0E 0F\n";
|
||||||
|
ss << "-------------------------------------------------\n";
|
||||||
|
ss << std::hex;
|
||||||
|
ss << std::setw( 2 );
|
||||||
|
ss << std::setfill( '0' );
|
||||||
|
|
||||||
|
for( auto i = 1; i < sizeof( header.unk ); ++i )
|
||||||
|
if( i % 16 == 0 )
|
||||||
|
ss << std::setw(2) << (int)header.unk[i - 1] << "\n";
|
||||||
|
else if( i % 8 == 0 )
|
||||||
|
ss << std::setw(2) << (int)header.unk[i - 1] << " | ";
|
||||||
|
else
|
||||||
|
ss << std::setw(2) << (int)header.unk[i - 1] << " ";
|
||||||
|
ss << "\n";
|
||||||
|
std::cout << ss.str();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct LGB_GROUP_HEADER
|
struct LGB_GROUP_HEADER
|
||||||
{
|
{
|
||||||
uint32_t unknown;
|
uint32_t unknown;
|
||||||
|
@ -289,7 +334,11 @@ struct LGB_GROUP
|
||||||
case LgbEntryType::EventObject:
|
case LgbEntryType::EventObject:
|
||||||
entries.push_back( std::make_shared< LGB_EOBJ_ENTRY >( buf, entryOffset ) );
|
entries.push_back( std::make_shared< LGB_EOBJ_ENTRY >( buf, entryOffset ) );
|
||||||
break;
|
break;
|
||||||
|
case LgbEntryType::CollisionBox:
|
||||||
|
entries.push_back( std::make_shared< LGB_COLLISION_BOX_ENTRY >( buf, entryOffset ) );
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
|
//std::cout << "\t\tUnknown SGB entry! Group: " << name << " type: " << ( int )type << " index: " << i << " entryOffset: " << entryOffset << "\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,17 +11,15 @@
|
||||||
#include "exporter.h"
|
#include "exporter.h"
|
||||||
#include "obj_exporter.h"
|
#include "obj_exporter.h"
|
||||||
|
|
||||||
/*
|
//*
|
||||||
#include <recastnavigation/Recast/Include/Recast.h>
|
#include <recastnavigation/Recast/Include/Recast.h>
|
||||||
#include <recastnavigation/Recast/Include/RecastAlloc.h>
|
#include <recastnavigation/Recast/Include/RecastAlloc.h>
|
||||||
#include <recastnavigation/Detour/Include/DetourNavMesh.h>
|
#include <recastnavigation/Detour/Include/DetourNavMesh.h>
|
||||||
#include <recastnavigation/Detour/Include/DetourNavMeshBuilder.h>
|
#include <recastnavigation/Detour/Include/DetourNavMeshBuilder.h>
|
||||||
#include <recastnavigation/DetourTileCache/Include/DetourTileCache.h>
|
#include <recastnavigation/DetourTileCache/Include/DetourTileCache.h>
|
||||||
#include <recastnavigation/DetourTileCache/Include/DetourTileCacheBuilder.h>
|
#include <recastnavigation/DetourTileCache/Include/DetourTileCacheBuilder.h>
|
||||||
#include <recastnavigation/RecastDemo/Include/ChunkyTriMesh.h>
|
|
||||||
#include <recastnavigation/RecastDemo/Include/InputGeom.h>
|
//*/
|
||||||
#include <recastnavigation/RecastDemo/Include/Sample.h>
|
|
||||||
*/
|
|
||||||
class NavmeshExporter
|
class NavmeshExporter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -33,7 +31,8 @@ public:
|
||||||
|
|
||||||
auto fileName = currPath + "/" + zone.name + "/" + zone.name + ".nav";
|
auto fileName = currPath + "/" + zone.name + "/" + zone.name + ".nav";
|
||||||
exportZoneCommandline( zone, deleteObj );
|
exportZoneCommandline( zone, deleteObj );
|
||||||
|
//for( auto& group : zone.groups )
|
||||||
|
//buildTileMesh(group.second, 0, 0);
|
||||||
auto end = std::chrono::high_resolution_clock::now();
|
auto end = std::chrono::high_resolution_clock::now();
|
||||||
printf( "[Navmesh] Finished exporting %s in %u ms\n",
|
printf( "[Navmesh] Finished exporting %s in %u ms\n",
|
||||||
fileName.c_str(),
|
fileName.c_str(),
|
||||||
|
@ -133,13 +132,15 @@ private:
|
||||||
for( const auto& mesh : model.second.meshes )
|
for( const auto& mesh : model.second.meshes )
|
||||||
{
|
{
|
||||||
auto size = mesh.verts.size();
|
auto size = mesh.verts.size();
|
||||||
|
if (!size)
|
||||||
|
continue;
|
||||||
rcCalcBounds( mesh.verts.data(), size / 3, &cfg.bmin[0], &cfg.bmax[0] );
|
rcCalcBounds( mesh.verts.data(), size / 3, &cfg.bmin[0], &cfg.bmax[0] );
|
||||||
verts.reserve( verts.size() + size );
|
verts.resize( verts.size() + size );
|
||||||
memcpy( &verts[i], mesh.verts.data(), size );
|
memcpy( &verts[i], mesh.verts.data(), size );
|
||||||
i += size;
|
i += size;
|
||||||
|
|
||||||
size = mesh.indices.size();
|
size = mesh.indices.size();
|
||||||
indices.reserve( indices.size() + size );
|
indices.resize( indices.size() + size );
|
||||||
for( auto j = 0; j < mesh.indices.size(); j += 3 )
|
for( auto j = 0; j < mesh.indices.size(); j += 3 )
|
||||||
{
|
{
|
||||||
indices[j] = mesh.indices[j] + numIndices;
|
indices[j] = mesh.indices[j] + numIndices;
|
||||||
|
@ -150,8 +151,7 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto chunkyMesh = new rcChunkyTriMesh;
|
|
||||||
rcCreateChunkyTriMesh( &verts[0], &indices[0], verts.size() / 3, 256, chunkyMesh );
|
|
||||||
if( !rcCreateHeightfield( &ctx, *hf, cfg.width, cfg.height, cfg.bmin, cfg.bmax, cfg.cs, cfg.ch ) )
|
if( !rcCreateHeightfield( &ctx, *hf, cfg.width, cfg.height, cfg.bmin, cfg.bmax, cfg.cs, cfg.ch ) )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -162,33 +162,10 @@ private:
|
||||||
tbmax[0] = cfg.bmax[0];
|
tbmax[0] = cfg.bmax[0];
|
||||||
tbmax[1] = cfg.bmax[2];
|
tbmax[1] = cfg.bmax[2];
|
||||||
int cid[512];// TODO: Make grow when returning too many items.
|
int cid[512];// TODO: Make grow when returning too many items.
|
||||||
const int ncid = rcGetChunksOverlappingRect(chunkyMesh, tbmin, tbmax, cid, 512);
|
|
||||||
if (!ncid)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
auto tileTriCount = 0;
|
auto tileTriCount = 0;
|
||||||
auto triareas = new unsigned char[chunkyMesh->maxTrisPerChunk];
|
|
||||||
for (int i = 0; i < ncid; ++i)
|
|
||||||
{
|
|
||||||
const rcChunkyTriMeshNode& node = chunkyMesh->nodes[cid[i]];
|
|
||||||
const int* ctris = &chunkyMesh->tris[node.i*3];
|
|
||||||
const int nctris = node.n;
|
|
||||||
|
|
||||||
tileTriCount += nctris;
|
|
||||||
|
|
||||||
memset(triareas, 0, nctris*sizeof(unsigned char));
|
|
||||||
rcMarkWalkableTriangles(&ctx, cfg.walkableSlopeAngle,
|
|
||||||
&verts[0], verts.size() / 3, ctris, nctris, triareas);
|
|
||||||
|
|
||||||
if (!rcRasterizeTriangles(&ctx, &verts[0], verts.size() / 3, ctris, triareas, nctris, *hf, cfg.walkableClimb))
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
delete [] triareas;
|
|
||||||
triareas = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Once all geometry is rasterized, we do initial pass of filtering to
|
// Once all geometry is rasterized, we do initial pass of filtering to
|
||||||
// remove unwanted overhangs caused by the conservative rasterization
|
// remove unwanted overhangs caused by the conservative rasterization
|
||||||
// as well as filter spans where the character cannot possibly stand.
|
// as well as filter spans where the character cannot possibly stand.
|
||||||
|
@ -343,7 +320,6 @@ private:
|
||||||
cs = 0;
|
cs = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* navData = 0;
|
|
||||||
int navDataSize = 0;
|
int navDataSize = 0;
|
||||||
if (cfg.maxVertsPerPoly <= DT_VERTS_PER_POLYGON)
|
if (cfg.maxVertsPerPoly <= DT_VERTS_PER_POLYGON)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue