mirror of https://github.com/AxioDL/metaforce.git
Additional BlenderConnection::Mesh intermediate fields
This commit is contained in:
parent
daeef99f83
commit
73cb100174
|
@ -579,7 +579,7 @@ void BlenderConnection::PyOutStream::linkBackground(const char* target,
|
|||
|
||||
BlenderConnection::DataStream::Mesh::Mesh
|
||||
(BlenderConnection& conn, HMDLTopology topologyIn, int skinSlotCount, SurfProgFunc& surfProg)
|
||||
: topology(topologyIn), aabbMin(conn), aabbMax(conn)
|
||||
: topology(topologyIn), sceneXf(conn), aabbMin(conn), aabbMax(conn)
|
||||
{
|
||||
uint32_t matSetCount;
|
||||
conn._readBuf(&matSetCount, 4);
|
||||
|
@ -657,6 +657,26 @@ BlenderConnection::DataStream::Mesh::Mesh
|
|||
conn._readBuf(&isSurf, 1);
|
||||
}
|
||||
|
||||
/* Custom properties */
|
||||
uint32_t propCount;
|
||||
conn._readBuf(&propCount, 4);
|
||||
std::string keyBuf;
|
||||
std::string valBuf;
|
||||
for (uint32_t i=0 ; i<propCount ; ++i)
|
||||
{
|
||||
uint32_t kLen;
|
||||
conn._readBuf(&kLen, 4);
|
||||
keyBuf.assign(kLen, '\0');
|
||||
conn._readBuf(&keyBuf[0], kLen);
|
||||
|
||||
uint32_t vLen;
|
||||
conn._readBuf(&vLen, 4);
|
||||
valBuf.assign(vLen, '\0');
|
||||
conn._readBuf(&valBuf[0], vLen);
|
||||
|
||||
customProps[keyBuf] = valBuf;
|
||||
}
|
||||
|
||||
/* Connect skinned verts to bank slots */
|
||||
if (boneNames.size())
|
||||
{
|
||||
|
|
|
@ -354,6 +354,14 @@ public:
|
|||
Vector4f(BlenderConnection& conn) {read(conn);}
|
||||
operator const atVec4f&() const {return val;}
|
||||
};
|
||||
struct Matrix4f
|
||||
{
|
||||
atVec4f val[4];
|
||||
Matrix4f() = default;
|
||||
void read(BlenderConnection& conn) {conn._readBuf(&val, 64);}
|
||||
Matrix4f(BlenderConnection& conn) {read(conn);}
|
||||
const atVec4f& operator[] (size_t idx) const {return val[idx];}
|
||||
};
|
||||
struct Index
|
||||
{
|
||||
uint32_t val;
|
||||
|
@ -368,6 +376,9 @@ public:
|
|||
{
|
||||
HMDLTopology topology;
|
||||
|
||||
/* Object transform in scene */
|
||||
Matrix4f sceneXf;
|
||||
|
||||
/* Cumulative AABB */
|
||||
Vector3f aabbMin;
|
||||
Vector3f aabbMax;
|
||||
|
@ -448,6 +459,8 @@ public:
|
|||
};
|
||||
std::vector<Surface> surfaces;
|
||||
|
||||
std::unordered_map<std::string, std::string> customProps;
|
||||
|
||||
struct SkinBanks
|
||||
{
|
||||
struct Bank
|
||||
|
|
|
@ -52,6 +52,14 @@ def cook(writebuf, mesh_obj, output_mode, max_skin_banks, max_octant_length=None
|
|||
copy_mesh.calc_normals_split()
|
||||
rna_loops = copy_mesh.loops
|
||||
|
||||
# Send scene matrix
|
||||
wmtx = mesh_obj.matrix_world
|
||||
writebuf(struct.pack('ffffffffffffffff',
|
||||
wmtx[0][0], wmtx[0][1], wmtx[0][2], wmtx[0][3],
|
||||
wmtx[1][0], wmtx[1][1], wmtx[1][2], wmtx[1][3],
|
||||
wmtx[2][0], wmtx[2][1], wmtx[2][2], wmtx[2][3],
|
||||
wmtx[3][0], wmtx[3][1], wmtx[3][2], wmtx[3][3]))
|
||||
|
||||
# Filter out useless AABB points and send data
|
||||
pt = copy_obj.bound_box[0]
|
||||
writebuf(struct.pack('fff', pt[0], pt[1], pt[2]))
|
||||
|
@ -182,6 +190,15 @@ def cook(writebuf, mesh_obj, output_mode, max_skin_banks, max_octant_length=None
|
|||
# No more surfaces
|
||||
writebuf(struct.pack('B', 0))
|
||||
|
||||
# Enumerate custom props
|
||||
writebuf(struct.pack('I', len(mesh_obj.keys())))
|
||||
for k in mesh_obj.keys():
|
||||
writebuf(struct.pack('I', len(k)))
|
||||
writebuf(k.encode())
|
||||
val_str = str(mesh_obj[k])
|
||||
writebuf(struct.pack('I', len(val_str)))
|
||||
writebuf(val_str.encode())
|
||||
|
||||
# Delete copied mesh from scene
|
||||
bm_master.free()
|
||||
bpy.context.scene.objects.unlink(copy_obj)
|
||||
|
|
Loading…
Reference in New Issue