#pragma once #ifndef _LOADERDFF_HPP_ #define _LOADERDFF_HPP_ #define GLEW_STATIC #include #include "../../framework/rwbinarystream.h" #include #include #include class Model { public: RW::BSClump clump; struct Texture { std::string name; std::string alphaName; }; struct Material { std::vector textures; uint32_t colour; float diffuseIntensity; float ambientIntensity; }; struct SubGeometry { GLuint EBO; size_t material; std::vector indices; }; struct Geometry { GLuint VBO, EBO; RW::BSGeometryBounds geometryBounds; uint32_t clumpNum; uint32_t flags; std::vector texcoords; std::vector triangles; std::vector colours; std::vector vertices; std::vector normals; std::vector materials; std::vector subgeom; }; struct Atomic { uint32_t frame; uint32_t geometry; }; struct Frame { glm::mat4 matrix; glm::mat3 defaultRotation; glm::vec3 defaultTranslation; int32_t parentFrameIndex; }; std::vector frameNames; std::vector geometries; std::vector atomics; std::vector frames; glm::mat4 getFrameMatrix(int32_t frameIndex) { Frame& frame = frames[frameIndex]; if( frame.parentFrameIndex != -1 ) { return getFrameMatrix(frame.parentFrameIndex) * frame.matrix; } else { return frame.matrix; } } }; class LoaderDFF { private: template T readStructure(char *data, size_t &dataI); RW::BSSectionHeader readHeader(char *data, size_t &dataI); public: Model* loadFromMemory(char *data); }; #endif