mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-06-06 08:42:35 +00:00
feat: pathnodes are added through the GLTF file
This commit is contained in:
@@ -91,11 +91,12 @@ namespace gltf
|
|||||||
public:
|
public:
|
||||||
std::optional<std::string> xmodel;
|
std::optional<std::string> xmodel;
|
||||||
std::optional<std::string> spawnpoint;
|
std::optional<std::string> spawnpoint;
|
||||||
|
std::optional<std::string> pathnode;
|
||||||
|
|
||||||
std::optional<std::string> flags;
|
std::optional<std::string> flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonNodeExtras, xmodel, spawnpoint, flags);
|
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonNodeExtras, xmodel, spawnpoint, flags, pathnode);
|
||||||
|
|
||||||
class JsonNode
|
class JsonNode
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -108,6 +108,11 @@ namespace BSP
|
|||||||
BSPSpawnPointType type;
|
BSPSpawnPointType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct BSPPathNode
|
||||||
|
{
|
||||||
|
vec3_t origin;
|
||||||
|
};
|
||||||
|
|
||||||
struct BSPData
|
struct BSPData
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
@@ -118,6 +123,7 @@ namespace BSP
|
|||||||
|
|
||||||
std::vector<BSPLight> lights;
|
std::vector<BSPLight> lights;
|
||||||
std::vector<BSPSpawnPoint> spawnpoints;
|
std::vector<BSPSpawnPoint> spawnpoints;
|
||||||
|
std::vector<BSPPathNode> pathnodes;
|
||||||
};
|
};
|
||||||
|
|
||||||
// BSPGameConstants:
|
// BSPGameConstants:
|
||||||
|
|||||||
@@ -586,6 +586,26 @@ namespace
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool addPathNode_Node(const gltf::JsonNode& node)
|
||||||
|
{
|
||||||
|
assert(node.extras);
|
||||||
|
assert(node.extras->pathnode);
|
||||||
|
|
||||||
|
BSPPathNode pathnode;
|
||||||
|
|
||||||
|
Eigen::Matrix4f nodeMatrix = createNodeMatrix(node);
|
||||||
|
Eigen::Vector4f position(0, 0, 0, 1.0f);
|
||||||
|
Eigen::Vector4f transformedPosition = nodeMatrix * position;
|
||||||
|
pathnode.origin.x = transformedPosition.x();
|
||||||
|
pathnode.origin.y = transformedPosition.y();
|
||||||
|
pathnode.origin.z = transformedPosition.z();
|
||||||
|
RhcToLhcCoordinates(pathnode.origin.v);
|
||||||
|
|
||||||
|
m_bsp->pathnodes.emplace_back(pathnode);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool addSpawnPointNode(const gltf::JsonNode& node)
|
bool addSpawnPointNode(const gltf::JsonNode& node)
|
||||||
{
|
{
|
||||||
assert(node.extras);
|
assert(node.extras);
|
||||||
@@ -641,6 +661,9 @@ namespace
|
|||||||
|
|
||||||
if (m_is_world_gfx && node.extras->spawnpoint)
|
if (m_is_world_gfx && node.extras->spawnpoint)
|
||||||
return addSpawnPointNode(node);
|
return addSpawnPointNode(node);
|
||||||
|
|
||||||
|
if (m_is_world_gfx && node.extras->pathnode)
|
||||||
|
return addPathNode_Node(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.mesh)
|
if (node.mesh)
|
||||||
|
|||||||
@@ -116,6 +116,17 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addPathNodesToEntString(BSP::BSPData* bsp, std::string& entityString)
|
||||||
|
{
|
||||||
|
for (auto& pathnode : bsp->pathnodes)
|
||||||
|
{
|
||||||
|
entityString.append("{\n");
|
||||||
|
entityString.append(std::format("\"origin\" \"{}\"\n", BSP::BSPUtil::convertVec3ToString(pathnode.origin)));
|
||||||
|
entityString.append(std::format("\"classname\" \"{}\"\n", "node_pathnode"));
|
||||||
|
entityString.append("}\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
constexpr const char* DEFAULT_MAP_ENTS_STRING = R"({
|
constexpr const char* DEFAULT_MAP_ENTS_STRING = R"({
|
||||||
"entities": [
|
"entities": [
|
||||||
{
|
{
|
||||||
@@ -167,6 +178,8 @@ namespace BSP
|
|||||||
|
|
||||||
addSpawnsToEntString(bsp, entityString);
|
addSpawnsToEntString(bsp, entityString);
|
||||||
|
|
||||||
|
addPathNodesToEntString(bsp, entityString);
|
||||||
|
|
||||||
MapEnts* mapEnts = m_memory.Alloc<MapEnts>();
|
MapEnts* mapEnts = m_memory.Alloc<MapEnts>();
|
||||||
mapEnts->name = m_memory.Dup(bsp->bspName.c_str());
|
mapEnts->name = m_memory.Dup(bsp->bspName.c_str());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user