119 lines
2.2 KiB
C++
119 lines
2.2 KiB
C++
#pragma once
|
|
#include "../Bone/BoneController.h"
|
|
|
|
|
|
struct BluSectionType
|
|
{
|
|
enum Enumeration
|
|
{
|
|
Mesh = 0,
|
|
Material = 1,
|
|
Bone = 2,
|
|
Animation = 3,
|
|
LastKnownType = 3
|
|
};
|
|
};
|
|
|
|
|
|
template < typename T >
|
|
struct ScopedBuffer
|
|
{
|
|
ScopedBuffer(T* argData)
|
|
{
|
|
m_Data = argData;
|
|
}
|
|
|
|
ScopedBuffer(unsigned int argCount)
|
|
{
|
|
m_Data = new T[argCount];
|
|
}
|
|
|
|
~ScopedBuffer()
|
|
{
|
|
if (m_Data != NULL)
|
|
delete [] m_Data;
|
|
}
|
|
|
|
T* Detach()
|
|
{
|
|
T* l_Tmp_ = m_Data;
|
|
m_Data = NULL;
|
|
return l_Tmp_;
|
|
}
|
|
|
|
T* get_Data() const
|
|
{
|
|
return m_Data;
|
|
}
|
|
|
|
operator const T* () { return m_Data; }
|
|
|
|
T* m_Data;
|
|
};
|
|
|
|
|
|
struct BluImportedGeometryBuffer
|
|
{
|
|
IGeometryBuffer* m_GeometryBuffer;
|
|
string16 m_MaterialName;
|
|
};
|
|
|
|
|
|
struct BluImportedBone
|
|
{
|
|
IBone* m_Bone;
|
|
string16 m_ParentName;
|
|
};
|
|
|
|
|
|
class BluImportResult
|
|
{
|
|
public:
|
|
BluImportResult()
|
|
: m_SuccessfullyLoaded(false)
|
|
, m_BoneController(NULL)
|
|
{}
|
|
|
|
bool m_SuccessfullyLoaded;
|
|
string16 m_FileName;
|
|
std::map<string16, BluImportedGeometryBuffer> m_GeometryBuffers;
|
|
std::map<string16, IMaterial*> m_Materials;
|
|
std::map<string16, BluImportedBone> m_Bones;
|
|
std::map<string16, ITransformationAnimation*> m_Animations;
|
|
|
|
BoneController* m_BoneController;
|
|
|
|
IRenderable* GenerateRootRenderable(IEngine* argEngine, IMaterial* argOverrideMaterial);
|
|
};
|
|
|
|
|
|
class BluImporter
|
|
{
|
|
public:
|
|
BluImporter(IEngine& argEngine);
|
|
BluImportResult Load(const string16& argFileName);
|
|
|
|
static IRenderable* Load(IEngine* argEngine, const string16& argFileName, IMaterial* argOverrideMaterial = NULL);
|
|
|
|
protected:
|
|
void ImportMesh(IFile* argFile, string8 argObjectName, BluImportResult& argResult);
|
|
void ImportMaterial(IFile* argFile, string8 argObjectName, BluImportResult& argResult);
|
|
void ImportBone(IFile* argFile, string8 argObjectName, BluImportResult& argResult);
|
|
void ImportAnimation(IFile* argFile, string8 argObjectName, BluImportResult& argResult);
|
|
|
|
string16 ConvertPath(const string8& argOrignal)
|
|
{
|
|
if (argOrignal.empty())
|
|
return std::to_string16(argOrignal);
|
|
|
|
int li_Pos = argOrignal.rfind("\\");
|
|
if (li_Pos >= 0)
|
|
return m_CurrentPath + std::to_string16(argOrignal.substr(li_Pos + 1, argOrignal.size() - li_Pos));
|
|
|
|
return m_CurrentPath + std::to_string16(argOrignal);
|
|
}
|
|
|
|
private:
|
|
IEngine& m_Engine;
|
|
string16 m_CurrentPath;
|
|
}; |