generated from asmaloney/GDExtensionTemplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SWBF2 model loading and Godot integration
- Loading branch information
Showing
22 changed files
with
667 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
#pragma once | ||
|
||
#include <godot_cpp/classes/mesh.hpp> | ||
|
||
#include "SWBF2/Model.hpp" | ||
|
||
class ModelMesh : public SWBF2::Model, public godot::Mesh { | ||
GDCLASS(Core, godot::Mesh) | ||
|
||
public: | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include <godot_cpp/variant/utility_functions.hpp> | ||
|
||
#include "StreamReader.hpp" | ||
|
||
#include "ModelChunk.hpp" | ||
#include "ModelSegmentChunk.hpp" | ||
|
||
#include "../Models.hpp" | ||
#include "../Model.hpp" | ||
#include "../ModelSegment.hpp" | ||
|
||
namespace SWBF2 | ||
{ | ||
void ModelChunk::ProcessChunk(StreamReader &streamReader) | ||
{ | ||
Model model; | ||
|
||
auto modelNameReaderChild = streamReader.ReadChildWithHeader<"NAME"_m>(); | ||
|
||
*modelNameReaderChild >> model.m_name; | ||
|
||
auto vertexReaderChild = streamReader.ReadChildWithHeader<"VRTX"_m>(); | ||
|
||
std::vector<std::byte> vertex; | ||
vertex.resize(vertexReaderChild->GetHeader().size); | ||
|
||
*vertexReaderChild >> vertex; | ||
|
||
auto nodeReaderChild = streamReader.ReadChildWithHeader<"NODE"_m>(); | ||
|
||
*nodeReaderChild >> model.m_node; | ||
|
||
auto infoReaderChild = streamReader.ReadChildWithHeader<"INFO"_m>(); | ||
|
||
*infoReaderChild >> model.m_info; | ||
|
||
std::optional<StreamReader> readerChild; | ||
while ((readerChild = streamReader.ReadChild()).has_value()) | ||
{ | ||
switch (readerChild->GetHeader().m_Magic) | ||
{ | ||
case "segm"_m: { | ||
StreamReader r{ *readerChild }; | ||
ModelSegmentChunk::ProcessChunk(r, model); | ||
break; | ||
} | ||
|
||
case "SPHR"_m: | ||
default: | ||
godot::UtilityFunctions::printerr(__FILE__, ":", __LINE__, ": ", readerChild->GetHeader().ToString().c_str(), " not implemented"); | ||
break; | ||
} | ||
} | ||
|
||
Models::m_models.insert_or_assign(model.m_name, model); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
|
||
#include "StreamReader.hpp" | ||
|
||
namespace SWBF2 | ||
{ | ||
class ModelChunk { | ||
public: | ||
static void ProcessChunk(StreamReader &streamReader); | ||
}; | ||
|
||
} |
Oops, something went wrong.