From 0666884a04787db0f5d2e79aebe7d1a52b4fda35 Mon Sep 17 00:00:00 2001 From: devZoGok Date: Thu, 7 Dec 2023 20:48:33 +0200 Subject: [PATCH] wrting and reading child node transforms --- script.py | 13 +++++++++++++ xmlModelReader.cpp | 8 ++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/script.py b/script.py index 9aeaca6..55a2147 100644 --- a/script.py +++ b/script.py @@ -151,6 +151,19 @@ def export(node, parentTag): nodeTag = ET.SubElement(parentTag, 'node') nodeTag.set('name', node.name) + nodeTag.set('px', str(node.location[0])) + nodeTag.set('py', str(node.location[2])) + nodeTag.set('pz', str(-node.location[1])) + + nodeTag.set('rw', str(node.rotation_quaternion[0])) + nodeTag.set('rx', str(node.rotation_quaternion[1])) + nodeTag.set('ry', str(node.rotation_quaternion[2])) + nodeTag.set('rz', str(node.rotation_quaternion[3])) + + nodeTag.set('sx', str(node.scale[0])) + nodeTag.set('sy', str(node.scale[1])) + nodeTag.set('sz', str(node.scale[2])) + if node.type == 'MESH': mesh = node.data numFaces = len(mesh.polygons) diff --git a/xmlModelReader.cpp b/xmlModelReader.cpp index 2855925..011c6ca 100644 --- a/xmlModelReader.cpp +++ b/xmlModelReader.cpp @@ -276,8 +276,12 @@ namespace vb01{ ((Bone*)node)->setIkChainLength(ikChainLength); } } - else - node = new Node(Vector3::VEC_ZERO, Quaternion::QUAT_W, Vector3::VEC_IJK, name); + else{ + Vector3 pos = Vector3(atof(xmlEl->Attribute("px")), atof(xmlEl->Attribute("py")), atof(xmlEl->Attribute("pz"))); + Quaternion rot = Quaternion(atof(xmlEl->Attribute("rw")), atof(xmlEl->Attribute("rx")), atof(xmlEl->Attribute("ry")), atof(xmlEl->Attribute("rz"))); + Vector3 scale = Vector3(atof(xmlEl->Attribute("sx")), atof(xmlEl->Attribute("sy")), atof(xmlEl->Attribute("sz"))); + node = new Node(pos, rot, scale, name); + } XMLElement *skeletonTag = xmlEl->FirstChildElement("skeleton");