MCPcopy Create free account
hub / github.com/assimp/assimp / WriteNode

Function WriteNode

code/AssetLib/Assxml/AssxmlFileWriter.cpp:122–165  ·  view source on GitHub ↗

----------------------------------------------------------------------------------- Write a single node as text dump

Source from the content-addressed store, hash-verified

120// -----------------------------------------------------------------------------------
121// Write a single node as text dump
122static void WriteNode(const aiNode *node, IOStream *io, unsigned int depth) {
123 char prefix[512];
124 for (unsigned int i = 0; i < depth; ++i)
125 prefix[i] = '\t';
126 prefix[depth] = '\0';
127
128 const aiMatrix4x4 &m = node->mTransformation;
129
130 aiString name;
131 ConvertName(name, node->mName);
132 ioprintf(io, "%s<Node name=\"%s\"> \n"
133 "%s\t<Matrix4> \n"
134 "%s\t\t%0 6f %0 6f %0 6f %0 6f\n"
135 "%s\t\t%0 6f %0 6f %0 6f %0 6f\n"
136 "%s\t\t%0 6f %0 6f %0 6f %0 6f\n"
137 "%s\t\t%0 6f %0 6f %0 6f %0 6f\n"
138 "%s\t</Matrix4> \n",
139 prefix, name.data, prefix,
140 prefix, m.a1, m.a2, m.a3, m.a4,
141 prefix, m.b1, m.b2, m.b3, m.b4,
142 prefix, m.c1, m.c2, m.c3, m.c4,
143 prefix, m.d1, m.d2, m.d3, m.d4, prefix);
144
145 if (node->mNumMeshes) {
146 ioprintf(io, "%s\t<MeshRefs num=\"%u\">\n%s\t",
147 prefix, node->mNumMeshes, prefix);
148
149 for (unsigned int i = 0; i < node->mNumMeshes; ++i) {
150 ioprintf(io, "%u ", node->mMeshes[i]);
151 }
152 ioprintf(io, "\n%s\t</MeshRefs>\n", prefix);
153 }
154
155 if (node->mNumChildren) {
156 ioprintf(io, "%s\t<NodeList num=\"%u\">\n",
157 prefix, node->mNumChildren);
158
159 for (unsigned int i = 0; i < node->mNumChildren; ++i) {
160 WriteNode(node->mChildren[i], io, depth + 2);
161 }
162 ioprintf(io, "%s\t</NodeList>\n", prefix);
163 }
164 ioprintf(io, "%s</Node>\n", prefix);
165}
166
167// -----------------------------------------------------------------------------------
168// Some chunks of text will need to be encoded for XML

Callers 5

WriteSceneLibraryMethod · 0.85
WriteNodeMethod · 0.85
WriteDumpFunction · 0.85
WriteFileMethod · 0.85
WriteNodeMethod · 0.85

Calls 2

ConvertNameFunction · 0.85
ioprintfFunction · 0.85

Tested by

no test coverage detected