1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-10-06 00:57:19 +02:00
openrw/framework2/include/renderwure/loaders/LoaderIFP.hpp

114 lines
1.8 KiB
C++
Raw Normal View History

#pragma once
#ifndef _LOADERDFF_IFP_
#define _LOADERDFF_IFP_
#include <string>
#include <vector>
#include <map>
#include <glm/glm.hpp>
#include <glm/gtx/quaternion.hpp>
struct AnimationKeyframe
{
glm::quat rotation;
glm::vec3 position;
glm::vec3 scale;
float starttime;
};
struct AnimationBone
{
std::string name;
int32_t previous;
int32_t next;
float duration;
enum Data {
R00,
RT0,
RTS
};
Data type;
std::vector<AnimationKeyframe> frames;
AnimationKeyframe getInterpolatedKeyframe(float time);
};
struct Animation
{
std::string name;
2013-09-11 01:26:13 +02:00
std::map<std::string, AnimationBone*> bones;
2013-08-13 19:42:58 +02:00
float duration;
};
class LoaderIFP
{
template<class T> T* read(char* data, size_t* ofs) {
size_t b = *ofs; *ofs += sizeof(T);
return reinterpret_cast<T*>(data + b);
}
template<class T> T* peek(char* data, size_t* ofs) {
return reinterpret_cast<T*>(data + *ofs);
}
std::string readString(char* data, size_t* ofs);
public:
struct BASE {
char magic[4];
uint32_t size;
};
struct INFO {
BASE base;
int32_t entries;
// null terminated string
// entry data
};
struct ANPK {
BASE base;
INFO info;
};
struct NAME {
BASE base;
};
struct DGAN {
BASE base;
INFO info;
};
struct CPAN {
BASE base;
};
struct ANIM {
BASE base;
char name[28];
int32_t frames;
int32_t unk;
int32_t next;
int32_t prev;
};
struct KFRM {
BASE base;
};
struct Anim {
std::string name;
};
std::map<std::string, Animation*> animations;
bool loadFromMemory(char *data);
};
#endif