137 lines
2.6 KiB
C++
137 lines
2.6 KiB
C++
#pragma once
|
|
#include "IEngine.h"
|
|
#include "IBone.h"
|
|
#include "IRenderCommandNode.h"
|
|
#include "ITexture.h"
|
|
#include "IGeometryBuffer.h"
|
|
#include "IShaderParameterCollection.h"
|
|
#include "ITransformationAnimation.h"
|
|
#include "ITransformation.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;
|
|
string8 m_MaterialName;
|
|
};
|
|
|
|
|
|
struct BluImportedBone
|
|
{
|
|
IBone* m_Bone;
|
|
string8 m_ParentName;
|
|
};
|
|
|
|
struct BluModel
|
|
{
|
|
BluModel()
|
|
: RootTransformation(NULL)
|
|
, RootNode(NULL)
|
|
, BoneController(NULL)
|
|
{}
|
|
IRenderCommandNode* RootNode;
|
|
ITransformation* RootTransformation;
|
|
IBoneController* BoneController;
|
|
};
|
|
|
|
class BluImportResult
|
|
{
|
|
public:
|
|
BluImportResult()
|
|
: m_SuccessfullyLoaded(false)
|
|
, m_BoneController(NULL)
|
|
{}
|
|
|
|
bool m_SuccessfullyLoaded;
|
|
string16 m_FileName;
|
|
std::map<string8, BluImportedGeometryBuffer> m_GeometryBuffers;
|
|
std::map<string8, IShaderParameterCollection*> m_Parameters;
|
|
std::map<string8, IShader*> m_Shaders;
|
|
std::map<string8, BluImportedBone> m_Bones;
|
|
std::map<string8, ITransformationAnimation*> m_Animations;
|
|
|
|
IBoneController* m_BoneController;
|
|
|
|
BluModel GenerateRootCommandNode(IEngine& argEngine);
|
|
};
|
|
|
|
|
|
class BluImporter
|
|
{
|
|
public:
|
|
BluImporter(IEngine& argEngine);
|
|
BluImportResult Load(const string16& argFileName);
|
|
|
|
static BluModel Load(IEngine& argEngine, const string16& argFileName);
|
|
|
|
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;
|
|
}; |