Skip to content

Commit

Permalink
Merge pull request #3 from burninrubber0/filter2
Browse files Browse the repository at this point in the history
Add filtering options
  • Loading branch information
burninrubber0 authored Oct 17, 2023
2 parents 75da001 + 8ed7123 commit 7c4dbd0
Show file tree
Hide file tree
Showing 9 changed files with 584 additions and 602 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set(SOURCES
src/main.cpp
src/converter.cpp
src/trigger-data.cpp
src/types.cpp
src/binary-io/data-stream.cpp
)

Expand Down
7 changes: 4 additions & 3 deletions include/binary-io/data-stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DataStream : public QDataStream
return s;
}

// callocs and reads data from the stream using DataStream's operator>>(DataStream&, T&) method
// callocs and reads data from the stream using DataStream's operator>>(DataStream&, T&)
template <typename T>
void cAllocAndQtRead(T*& entries, int count)
{
Expand All @@ -47,7 +47,7 @@ class DataStream : public QDataStream
*this >> entries[i];
}

// callocs and reads data from the stream using T's read(DataStream&) method
// callocs and reads data from the stream using T's read(DataStream&)
template <typename T>
void cAllocAndCustomRead(T*& entries, int count)
{
Expand All @@ -68,7 +68,8 @@ class DataStream : public QDataStream
// Reads a specified number of bytes from this stream to another stream, writing to a specified
// offset in the other stream. By default, this offset is the current offset of this stream.
// This is most useful for storing unknown data and padding to prevent data loss
void readRawData(DataStream& stream, quint32 length, qint64 position = -1);
// TODO: Come up with a more accurate name for this
void readRawData(DataStream& other, quint32 length, qint64 position = -1);

// Get the current offset the device is reading/writing from
qint64 pos();
Expand Down
105 changes: 62 additions & 43 deletions include/converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

#include <string>

using namespace BrnTrigger;
using namespace tinygltf;

class Converter
{
public:
Expand All @@ -18,89 +21,105 @@ class Converter
int result = 0;

private:
enum class Platform
{
PS3,
X360,
PC,
PS4,
NX
} platform = Platform::PC;

// For file reading
DataStream inStream;
std::string inFileName;
std::string outFileName;
int8_t typeFilter = -1;
std::string profileFileName;

BrnTrigger::TriggerData* triggerData = nullptr;
TriggerData* triggerData = nullptr;
QList<uint64_t> hitTriggerIds;

const int minArgCount = 3;
int getArgs(int argc, char* argv[]);
int checkArgs(int argc, char* argv[]);
void showUsage();

void readTriggerData();
tinygltf::Buffer createGLTFBuffer();
void readProfileTriggers();
void readStuntElements(DataStream& stream, int offset, int count);
void readIslandStuntElements(DataStream& stream, int offset, int count);
Buffer createGLTFBuffer();
void writeBoxRegion(DataStream& stream);
Vector4 EulerToQuatRot(Vector3 euler);
void convertTriggersToGLTF();

bool triggerRegionExists(BrnTrigger::TriggerRegion region, bool checkGenericRegions = true);
void addTriggerRegionFields(BrnTrigger::TriggerRegion region, tinygltf::Value::Object& extras);
bool triggerRegionExists(TriggerRegion region, bool checkGenericRegions = true);
void addTriggerRegionFields(TriggerRegion region, Value::Object& extras);

void convertLandmark(BrnTrigger::Landmark landmark, tinygltf::Node& node, int index);
void convertStartingGrid(BrnTrigger::StartingGrid grid, tinygltf::Node& node, int index);
void convertBlackspot(BrnTrigger::Blackspot blackspot, tinygltf::Node& node, int index);
void convertVfxBoxRegion(BrnTrigger::VFXBoxRegion vfxBoxRegion, tinygltf::Node& node, int index);
void convertSignatureStunt(BrnTrigger::SignatureStunt signatureStunt, tinygltf::Node& node, int index);
void convertKillzone(BrnTrigger::Killzone killzone, tinygltf::Node& node, int index);
void convertGenericRegion(BrnTrigger::GenericRegion region, tinygltf::Node& node, int index);
void convertTriggerRegion(BrnTrigger::TriggerRegion triggerRegion, tinygltf::Node& node, int index);
void convertRoamingLocation(BrnTrigger::RoamingLocation location, tinygltf::Node& node, int index);
void convertSpawnLocation(BrnTrigger::SpawnLocation location, tinygltf::Node& node, int index);
void convertLandmark(Landmark landmark, Node& node, int index);
void convertStartingGrid(StartingGrid grid, Node& node, int index);
void convertBlackspot(Blackspot blackspot, Node& node, int index);
void convertVfxBoxRegion(VFXBoxRegion vfxBoxRegion, Node& node, int index);
void convertSignatureStunt(SignatureStunt signatureStunt, Node& node, int index);
void convertKillzone(Killzone killzone, Node& node, int index);
void convertGenericRegion(GenericRegion region, Node& node, int index);
void convertTriggerRegion(TriggerRegion triggerRegion, Node& node, int index);
void convertRoamingLocation(RoamingLocation location, Node& node, int index);
void convertSpawnLocation(SpawnLocation location, Node& node, int index);

template <typename T>
void addBoxRegionTransform(T entry, tinygltf::Node& node)
void addBoxRegionTransform(T entry, Node& node)
{
node.translation = {
entry.getBoxRegion().getPosX(),
entry.getBoxRegion().getPosY(),
entry.getBoxRegion().getPosZ()
entry.boxRegion.positionX,
entry.boxRegion.positionY,
entry.boxRegion.positionZ
};
Vector4 rotation = EulerToQuatRot({
entry.getBoxRegion().getRotX(),
entry.getBoxRegion().getRotY(),
entry.getBoxRegion().getRotZ()
entry.boxRegion.rotationX,
entry.boxRegion.rotationY,
entry.boxRegion.rotationZ
});
node.rotation = {
rotation.getX(),
rotation.getY(),
rotation.getZ(),
rotation.getW()
rotation.x,
rotation.y,
rotation.z,
rotation.w
};
node.scale = {
entry.getBoxRegion().getDimX(),
entry.getBoxRegion().getDimY(),
entry.getBoxRegion().getDimZ()
entry.boxRegion.dimensionX,
entry.boxRegion.dimensionY,
entry.boxRegion.dimensionZ
};
}

void addPointTransform(Vector3 pos, Vector3 rot, tinygltf::Node& node)
void addPointTransform(Vector3 pos, Vector3 rot, Node& node)
{
node.translation = {
pos.getX(),
pos.getY(),
pos.getZ()
pos.x,
pos.y,
pos.z
};
Vector4 rotation = EulerToQuatRot({
rot.getX(),
rot.getY(),
rot.getZ()
rot.x,
rot.y,
rot.z
});
node.rotation = {
rotation.getX(),
rotation.getY(),
rotation.getZ(),
rotation.getW()
rotation.x,
rotation.y,
rotation.z,
rotation.w
};
}

void addPointTransform(Vector3 pos, tinygltf::Node& node)
void addPointTransform(Vector3 pos, Node& node)
{
node.translation = {
pos.getX(),
pos.getY(),
pos.getZ()
pos.x,
pos.y,
pos.z
};
}
};
Loading

0 comments on commit 7c4dbd0

Please sign in to comment.