2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-18 13:25:25 +00:00

Added HMDL outputting from blender intermediate

This commit is contained in:
Jack Andersen
2015-11-13 16:26:06 -10:00
parent 7c0206bd39
commit db335e5d98
8 changed files with 347 additions and 38 deletions

View File

@@ -7,6 +7,7 @@ if(WIN32)
list(APPEND PLAT_SRCS winsupport.cpp ../include/HECL/winsupport.hpp)
endif()
atdna(atdna_HMDLMeta.cpp ../include/HECL/HMDLMeta.hpp)
atdna(atdna_Frontend.cpp ../include/HECL/Frontend.hpp)
atdna(atdna_Runtime.cpp ../include/HECL/Runtime.hpp)
@@ -15,6 +16,7 @@ add_library(HECLCommon
ProjectPath.cpp
WideStringConvert.cpp
../include/HECL/HECL.hpp
../include/HECL/HMDLMeta.hpp
../include/HECL/Backend/Backend.hpp
../include/HECL/Backend/GX.hpp
../include/HECL/Backend/ProgrammableCommon.hpp
@@ -22,6 +24,7 @@ add_library(HECLCommon
../include/HECL/Frontend.hpp
../include/HECL/Database.hpp
../include/HECL/Runtime.hpp
atdna_HMDLMeta.cpp
atdna_Frontend.cpp
atdna_Runtime.cpp
${PLAT_SRCS})

View File

@@ -1,12 +1,58 @@
#include "HECL/HMDLMeta.hpp"
#include "HECL/Runtime.hpp"
#include <Athena/MemoryReader.hpp>
namespace HECL
{
namespace Runtime
{
static LogVisor::LogModule Log("HMDL");
HMDLData::HMDLData(boo::IGraphicsDataFactory* factory, const void *data)
HMDLData::HMDLData(boo::IGraphicsDataFactory* factory,
const void* metaData, const void* vbo, const void* ibo)
{
HMDLMeta meta;
{
Athena::io::MemoryReader r((atUint8*)metaData, HECL_HMDL_META_SZ);
meta.read(r);
}
if (meta.magic != FOURCC('TACO'))
Log.report(LogVisor::FatalError, "invalid HMDL magic");
m_vbo = factory->newStaticBuffer(boo::BufferUseVertex, vbo, meta.vertStride, meta.vertCount);
m_ibo = factory->newStaticBuffer(boo::BufferUseIndex, ibo, 4, meta.indexCount);
size_t elemCount = 2 + meta.colorCount + meta.uvCount + meta.weightCount;
std::unique_ptr<boo::VertexElementDescriptor[]> vdescs(new boo::VertexElementDescriptor[elemCount]);
for (size_t i=0 ; i<elemCount ; ++i)
{
vdescs[i].vertBuffer = m_vbo;
vdescs[i].indexBuffer = m_ibo;
}
vdescs[0].semantic = boo::VertexSemanticPosition;
vdescs[1].semantic = boo::VertexSemanticNormal;
size_t e = 2;
for (size_t i=0 ; i<meta.colorCount ; ++i, ++e)
{
vdescs[e].semantic = boo::VertexSemanticColor;
vdescs[e].semanticIdx = i;
}
for (size_t i=0 ; i<meta.uvCount ; ++i, ++e)
{
vdescs[e].semantic = boo::VertexSemanticUV;
vdescs[e].semanticIdx = i;
}
for (size_t i=0 ; i<meta.weightCount ; ++i, ++e)
{
vdescs[e].semantic = boo::VertexSemanticWeight;
vdescs[e].semanticIdx = i;
}
m_vtxFmt = factory->newVertexFormat(elemCount, vdescs.get());
}
}