2013-07-02 08:06:03 +02:00
|
|
|
#pragma once
|
2013-07-02 08:40:43 +02:00
|
|
|
#ifndef _LOADERDFF_HPP_
|
|
|
|
#define _LOADERDFF_HPP_
|
2013-07-02 08:06:03 +02:00
|
|
|
|
|
|
|
#define GLEW_STATIC
|
|
|
|
#include <GL/glew.h>
|
|
|
|
|
|
|
|
#include "../../framework/rwbinarystream.h"
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
class Model
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RW::BSClump clump;
|
|
|
|
|
|
|
|
struct Texture {
|
|
|
|
std::string name;
|
|
|
|
std::string alphaName;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Material {
|
|
|
|
std::vector<Texture> textures;
|
2013-07-04 01:23:12 +02:00
|
|
|
uint32_t colour;
|
2013-07-05 03:15:29 +02:00
|
|
|
|
|
|
|
float diffuseIntensity;
|
|
|
|
float ambientIntensity;
|
2013-07-02 08:06:03 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SubGeometry {
|
|
|
|
GLuint EBO;
|
|
|
|
size_t material;
|
|
|
|
std::vector<uint32_t> indices;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Geometry {
|
|
|
|
GLuint VBO, EBO;
|
|
|
|
|
|
|
|
RW::BSGeometryBounds geometryBounds;
|
|
|
|
|
2013-07-04 01:23:12 +02:00
|
|
|
uint32_t flags;
|
|
|
|
|
2013-07-02 08:06:03 +02:00
|
|
|
std::vector<RW::BSGeometryUV> texcoords;
|
|
|
|
std::vector<RW::BSGeometryTriangle> triangles;
|
2013-07-05 03:15:29 +02:00
|
|
|
std::vector<glm::vec4> colours;
|
2013-07-02 08:06:03 +02:00
|
|
|
std::vector<RW::BSTVector3> vertices;
|
|
|
|
std::vector<RW::BSTVector3> normals;
|
|
|
|
|
|
|
|
std::vector<Material> materials;
|
|
|
|
std::vector<SubGeometry> subgeom;
|
|
|
|
};
|
2013-07-03 20:00:15 +02:00
|
|
|
|
|
|
|
struct Atomic {
|
|
|
|
uint32_t frame;
|
|
|
|
uint32_t geometry;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<std::string> frameNames;
|
2013-07-02 08:06:03 +02:00
|
|
|
|
|
|
|
std::vector<Geometry> geometries;
|
2013-07-03 20:00:15 +02:00
|
|
|
std::vector<Atomic> atomics;
|
|
|
|
std::vector<RW::BSFrameListFrame> frames;
|
2013-07-02 08:06:03 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class LoaderDFF
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
template<class T> T readStructure(char *data, size_t &dataI);
|
|
|
|
RW::BSSectionHeader readHeader(char *data, size_t &dataI);
|
|
|
|
|
|
|
|
public:
|
|
|
|
std::unique_ptr<Model> loadFromMemory(char *data);
|
|
|
|
};
|
2013-07-02 08:40:43 +02:00
|
|
|
|
|
|
|
#endif
|