2016-03-04 23:02:44 +00:00
|
|
|
#include "hecl/HMDLMeta.hpp"
|
|
|
|
#include "hecl/Runtime.hpp"
|
|
|
|
#include <athena/MemoryReader.hpp>
|
2015-11-13 02:12:09 +00:00
|
|
|
|
2017-12-29 07:56:31 +00:00
|
|
|
namespace hecl::Runtime
|
2015-11-13 02:12:09 +00:00
|
|
|
{
|
2017-12-29 07:56:31 +00:00
|
|
|
static logvisor::Module HMDL_Log("HMDL");
|
2015-11-13 02:12:09 +00:00
|
|
|
|
2016-03-30 19:15:08 +00:00
|
|
|
HMDLData::HMDLData(boo::IGraphicsDataFactory::Context& ctx,
|
2015-11-14 02:26:06 +00:00
|
|
|
const void* metaData, const void* vbo, const void* ibo)
|
2015-11-13 02:12:09 +00:00
|
|
|
{
|
2015-11-14 02:26:06 +00:00
|
|
|
HMDLMeta meta;
|
|
|
|
{
|
2016-03-04 23:02:44 +00:00
|
|
|
athena::io::MemoryReader r((atUint8*)metaData, HECL_HMDL_META_SZ);
|
2015-11-14 02:26:06 +00:00
|
|
|
meta.read(r);
|
|
|
|
}
|
2015-11-14 23:40:32 +00:00
|
|
|
if (meta.magic != 'TACO')
|
2017-12-29 07:56:31 +00:00
|
|
|
HMDL_Log.report(logvisor::Fatal, "invalid HMDL magic");
|
2015-11-14 02:26:06 +00:00
|
|
|
|
2016-03-30 19:15:08 +00:00
|
|
|
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, vbo, meta.vertStride, meta.vertCount);
|
|
|
|
m_ibo = ctx.newStaticBuffer(boo::BufferUse::Index, ibo, 4, meta.indexCount);
|
2015-11-14 02:26:06 +00:00
|
|
|
|
|
|
|
size_t elemCount = 2 + meta.colorCount + meta.uvCount + meta.weightCount;
|
2018-10-07 02:53:57 +00:00
|
|
|
m_vtxFmtData.reset(new boo::VertexElementDescriptor[elemCount]);
|
2015-11-14 02:26:06 +00:00
|
|
|
|
2018-10-07 02:53:57 +00:00
|
|
|
m_vtxFmtData[0].semantic = boo::VertexSemantic::Position3;
|
|
|
|
m_vtxFmtData[1].semantic = boo::VertexSemantic::Normal3;
|
2015-11-14 02:26:06 +00:00
|
|
|
size_t e = 2;
|
|
|
|
|
|
|
|
for (size_t i=0 ; i<meta.colorCount ; ++i, ++e)
|
|
|
|
{
|
2018-10-07 02:53:57 +00:00
|
|
|
m_vtxFmtData[e].semantic = boo::VertexSemantic::ColorUNorm;
|
|
|
|
m_vtxFmtData[e].semanticIdx = i;
|
2015-11-14 02:26:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i=0 ; i<meta.uvCount ; ++i, ++e)
|
|
|
|
{
|
2018-10-07 02:53:57 +00:00
|
|
|
m_vtxFmtData[e].semantic = boo::VertexSemantic::UV2;
|
|
|
|
m_vtxFmtData[e].semanticIdx = i;
|
2015-11-14 02:26:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i=0 ; i<meta.weightCount ; ++i, ++e)
|
|
|
|
{
|
2018-10-07 02:53:57 +00:00
|
|
|
m_vtxFmtData[e].semantic = boo::VertexSemantic::Weight;
|
|
|
|
m_vtxFmtData[e].semanticIdx = i;
|
2015-11-18 06:16:08 +00:00
|
|
|
}
|
|
|
|
|
2018-10-07 02:53:57 +00:00
|
|
|
m_vtxFmt = boo::VertexFormatInfo(elemCount, m_vtxFmtData.get());
|
2015-11-13 02:12:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|