Skip to content

Commit

Permalink
rework mod for new gltf
Browse files Browse the repository at this point in the history
  • Loading branch information
PredatorCZ committed Apr 21, 2024
1 parent a8b7854 commit c277566
Show file tree
Hide file tree
Showing 7 changed files with 1,665 additions and 2,023 deletions.
2 changes: 1 addition & 1 deletion 3rd_party/spike
47 changes: 39 additions & 8 deletions include/revil/mod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@

#pragma once
#include "revil/platform.hpp"
#include "spike/gltf_attribute.hpp"
#include "spike/io/bincore_fwd.hpp"
#include "spike/type/matrix44.hpp"
#include <memory>
#include <span>
#include <string>
#include <vector>

namespace revil {

Expand Down Expand Up @@ -64,14 +68,36 @@ struct alignas(8) BoneIndex {
operator size_t() const { return reinterpret_cast<const size_t &>(*this); }
};

struct alignas(8) LODIndex {
bool lod1, lod2, lod3;
struct MODPrimitive {
bool triStrips;
bool lod1;
bool lod2;
bool lod3;
uint32 skinIndex = 0;
uint32 materialIndex = 0;
uint32 indexIndex;
uint32 vertexIndex;
std::string name;
};

LODIndex() = default;
LODIndex(size_t input)
: lod1(input & 0xff), lod2((input >> 8) & 0xff),
lod3((input >> 16) & 0xff) {}
operator size_t() const { return reinterpret_cast<const size_t &>(*this); }
struct MODSkin {
std::span<const uint8> remaps;
std::span<const es::Matrix44> poses;
};

struct MODVertexSpan {
char *buffer;
uint32 numVertices;
uint32 stride;
std::vector<Attribute> attrs;
std::vector<std::unique_ptr<AttributeCodec>> codecs;
};

using MODIndexSpan = std::span<uint16>;

struct MODMaterial {
std::string name;
Reflector *refl;
};

class ES_EXPORT MOD {
Expand All @@ -82,13 +108,18 @@ class ES_EXPORT MOD {
~MOD();
/* Castable into:
uni::Element<const uni::Skeleton>
uni::Element<const unk::Model>
*/
template <class C> C As() const;
void Load(const std::string &fileName);
void Load(BinReaderRef_e rd);
void Save(BinWritterRef wr);

std::span<const MODVertexSpan> Vertices() const;
std::span<const MODIndexSpan> Indices() const;
std::span<const MODPrimitive> Primitives() const;
std::span<const MODSkin> Skins() const;
std::span<const MODMaterial> Materials() const;

private:
std::unique_ptr<MODImpl> pi;
};
Expand Down
Loading

0 comments on commit c277566

Please sign in to comment.