    

 ## On this page

  

 

 # Test013

 Last update: 16.07.2025 

 /// &lt;script src="./ansys251/nexus/viewer-loader.js"&gt;&lt;/script&gt; /// ///

Legends

This example demonstrates the use of legends.

Several legends are created demonstrating different options to the legend object.

/\*

 \* Copyright 2018-2021 ANSYS, Inc. Unauthorized use, distribution, or duplication is prohibited.

 \* 

 \* Restricted Rights Legend

 \*

 \* Use, duplication, or disclosure of this

 \* software and its documentation by the

 \* Government is subject to restrictions as

 \* set forth in subdivision \[(b)(3)(ii)\] of

 \* the Rights in Technical Data and Computer

 \* Software clause at 52.227-7013.

 \*/

\#include &lt;vector&gt;

\#include &lt;cmath&gt;

\#ifdef \_WIN32

\#include &lt;codecvt&gt;

\#endif

 

\#include "GLTFWriter.h"

\#include "test.h"

 

using namespace ANSYS::AVZ;

 

namespace {

\#ifdef \_WIN32

 std::string 

 ConvertToUtf8String(const std::wstring&amp; wstr)

 {

 std::wstring_convert&lt;std::codecvt_utf8&lt;wchar_t&gt;&gt; myconv;

 return myconv.to_bytes(wstr);

 }

\#endif

};

 

// Legends

TESTFUNC(Legends)

{

 <a id="_a0" name="_a0"></a>[GLTFWriter::GLTF](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_g_l_t_f.xhtml) *gltf = GLTFWriter::GLTF::Create("MyApp", "1.0", functionName.c_str(), type);

 if (!gltf)

 throw std::runtime_error("Can't create GLTF");

 

 // SCENE

\#ifdef \_WIN32

 <a id="_a1" name="_a1"></a>[GLTFWriter::Scene](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_scene.xhtml) *scene = GLTFWriter::Scene::Create(gltf, ConvertToUtf8String(L"ԎҿșϯϨҁęɳę").c_str(), "", 0, GLTFWriter::Scene::BT_TB, 0.42F, 0.55F, 0.871F, 1, 1, 1);

\#else

 [GLTFWriter::Scene](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_scene.xhtml) *scene = GLTFWriter::Scene::Create(gltf, "Testscene", "m", 1.0F, GLTFWriter::Scene::BT_TB, 0.42F, 0.55F, 0.871F, 1, 1, 1);

\#endif

 if (!scene) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create scene");

 }

 

 // CAMERA

 {

 // CAMERA

 <a id="_a2" name="_a2"></a>[GLTFWriter::Camera](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_camera.xhtml) *camera = GLTFWriter::Camera::CreateOrthographic(gltf);

 // CAMERA NODE

 std::vector&lt;double&gt; mat(16);

 mat[0] = 0;

 mat[1] = 1;

 mat[2] = 0;

 mat[3] = 0;

 mat[4] = 0;

 mat[5] = 0;

 mat[6] = 1;

 mat[7] = 0;

 mat[8] = 1;

 mat[9] = 0;

 mat[10] = 0;

 mat[11] = 0;

 mat[12] = 0;

 mat[13] = 0;

 mat[14] = 0;

 mat[15] = 1;

 <a id="_a3" name="_a3"></a>[GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *cameraNode = GLTFWriter::Node::CreateCamera(gltf, camera, "TestCamera", &amp;mat[0]);

 scene-&gt;<a id="a4" name="a4"></a>[SetCamera](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_scene.xhtml#ae84fba7ea3c00159c2eae7adbfbfa61d)(cameraNode);

 }

 

 // banded texture

 {

 float mn = 1.5;

 float mx = 2.5;

 float range = mx - mn;

 

 // TEXTURE

 std::vector&lt;unsigned char&gt; colors;

 colors.push_back(0); colors.push_back(0); colors.push_back(255); // blue

 colors.push_back(0); colors.push_back(255); colors.push_back(255); // cyan

 colors.push_back(0); colors.push_back(255); colors.push_back(0); // green

 colors.push_back(255); colors.push_back(255); colors.push_back(0); // yellow

 colors.push_back(255); colors.push_back(0); colors.push_back(0); // red

 <a id="_a5" name="_a5"></a>[GLTFWriter::Texture](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_texture.xhtml) *bandedTexture = GLTFWriter::Texture::Create(gltf, GLTFWriter::Texture::TF_RGB, (unsigned int)colors.size() / 3, &amp;colors[0], false);

 

 

 // generate vertices, and texture coordinates for a ball

 std::vector&lt;float&gt; vertices;

 std::vector&lt;unsigned int&gt; lines;

 std::vector&lt;unsigned int&gt; triangles;

 GLTFWriter::Test::MakeSphere(0, -1, 0, 0.5, 64, vertices, lines, triangles);

 const unsigned int numVertices = (unsigned int)vertices.size() / 3;

 const unsigned int numLines = (unsigned int)lines.size() / 2;

 const unsigned int numTriangles = (unsigned int)triangles.size() / 3;

 std::vector&lt;float&gt; textureCoords(numVertices);

 for (unsigned int i = 0; i &lt; numVertices; ++i)

 textureCoords[i] = (vertices[3 * i + 2] + 0.5F) * range + mn; // coordinates go from mn to mx

 

 // NODE

 {

 // LEGEND

 // make this banded colors

 std::vector&lt;float&gt; valueLocation;

 //valueLocation.push\_back(1, mx);

 <a id="_a6" name="_a6"></a>[GLTFWriter::Legend](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_legend.xhtml) *legend = GLTFWriter::Legend::Create(gltf, GLTFWriter::Legend::LO_VERTICAL, 0.75, bandedTexture, mn, mx, GLTFWriter::Legend::LA_X_YCENTER,

\#ifdef _WIN32

 ConvertToUtf8String(L"Z Ƥṏᴤΐṱϊӧת\\nBanded").c_str(), 

\#else

 "Z Position\\nBanded",

\#endif

 "m", "This is an example\\nbanded legend\\nX, Y Center", 6, 0,

 true, false, 0.05F, 0, 0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F, 0.25F);

 

 // BUFFER - combine attributes into a single buffer

 <a id="_a7" name="_a7"></a>[GLTFWriter::Buffer](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_buffer.xhtml) *buffer = GLTFWriter::Buffer::Create(gltf);

 if (!buffer) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create buffer");

 }

 

 // NODE

 [GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *node = GLTFWriter::Node::CreateMesh(gltf, "Banded");

 if (!node || !scene-&gt;<a id="a8" name="a8"></a>[AppendMesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_scene.xhtml#a76e34d4c05fe34dde0fcc4913ad63981)(node)) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create mesh node");

 }

 

 // LEGEND NODE

\#ifdef \_WIN32

 [GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *legendNode = GLTFWriter::Node::CreateLegend(gltf, legend, ConvertToUtf8String(L"Ḷḙḡḗṋḍ").c_str());

\#else

 [GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *legendNode = GLTFWriter::Node::CreateLegend(gltf, legend, "Legend");

\#endif

 node-&gt;<a id="a9" name="a9"></a>[AppendChild](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a86b91dc1bac027fd7a8e59f4d5f0ea05)(legendNode);

 

 

 // MESH NODE

 [GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *meshNode = GLTFWriter::Node::CreateMesh(gltf, "Mesh");

 if (!meshNode || !node-&gt;[AppendChild](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a86b91dc1bac027fd7a8e59f4d5f0ea05)(meshNode)) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create mesh node");

 }

 

 // MESH

 <a id="_a10" name="_a10"></a>[GLTFWriter::Mesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml) *mesh = GLTFWriter::Mesh::Create(gltf);

 if (!mesh || !meshNode-&gt;<a id="a11" name="a11"></a>[AppendMesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a68c9eec5fe03405e52b3558a62f8faec)(mesh)) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create mesh");

 }

 

 // TECHNIQUE

 <a id="_a12" name="_a12"></a>[GLTFWriter::Technique](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_technique.xhtml) *technique = GLTFWriter::Technique::Create(gltf);

 if (!technique ||

 // TECHNIQUE STATES

 !technique-&gt;<a id="a13" name="a13"></a>[AppendState](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_technique.xhtml#a8b2b0766157324d5a2093a3fca36379f)(GLTFWriter::State::Create(gltf, GLTFWriter::State::ST_DEPTHTESTENABLE, 1))) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create technique");

 }

 

 // MATERIAL

 <a id="_a14" name="_a14"></a>[GLTFWriter::Material](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_material.xhtml) *material = GLTFWriter::Material::Create(gltf, technique);

 if (!material ||

 // MATERIAL UNIFORM VALUES

 !material-&gt;<a id="a15" name="a15"></a>[AppendValue](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_material.xhtml#a2f8a41e41af7d9b8cd498506f6510dd7)(GLTFWriter::Value::Create(gltf, "texture0", bandedTexture-&gt;GetID()))) { // texture0 name is auto-generated from Attribute TEXCOORD0

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create material");

 }

 

 // repack unsigned int indices into multiple sets of unsigned short indices

 <a id="_a16" name="_a16"></a>[GLTFWriter::Utils::Repack](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml) *repack = GLTFWriter::Utils::Repack::Create(numTriangles, 3, &amp;triangles[0]);

 if (!repack) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create repack");

 }

 for (unsigned int i = 0; i &lt; repack-&gt;<a id="a17" name="a17"></a>[NumPacks](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a69a383562c62ca71c8a785c96f773fb3)(); ++i) {

 const float *packedData;

 unsigned int numAttributes = repack-&gt;<a id="a18" name="a18"></a>[NumAttributes](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a43a74d90484a85856103c33969eb7107)(i);

 

 // POSITION ATTRIBUTE

 packedData = repack-&gt;<a id="a19" name="a19"></a>[ConstructRepackAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a1487b86e5090019cf7565e144fe11e4f)(&amp;triangles[0], 3, &amp;vertices[0], i);

 <a id="_a20" name="_a20"></a>[GLTFWriter::Attribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml) *vertex = GLTFWriter::Attribute::Create(gltf, "POSITION", GLTFWriter::Attribute::AT_FLOAT_VEC3, numAttributes, packedData, buffer);

 

 // TEXCOORD ATTRIBUTE

 packedData = repack-&gt;[ConstructRepackAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a1487b86e5090019cf7565e144fe11e4f)(&amp;triangles[0], 1, &amp;textureCoords[0], i);

 [GLTFWriter::Attribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml) *texture = GLTFWriter::Attribute::Create(gltf, "TEXCOORD0", GLTFWriter::Attribute::AT_FLOAT, numAttributes, packedData, buffer);

 

 // INDICES

 unsigned int numIndices = 3U * repack-&gt;<a id="a21" name="a21"></a>[NumElements](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a50e2eaf986369c115fe9cae008187cc0)(i);

 const unsigned short *packedIndex = repack-&gt;<a id="a22" name="a22"></a>[ConstructRepackIndex](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#ab3bd7bca7382f17a0c08e144b67d22f2)(&amp;triangles[0], i);

 <a id="_a23" name="_a23"></a>[GLTFWriter::Index](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_index.xhtml) *index = GLTFWriter::Index::Create(gltf, numIndices, packedIndex, buffer);

 

 // PRIMITIVE

 <a id="_a24" name="_a24"></a>[GLTFWriter::Primitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml) *primitive = GLTFWriter::Primitive::Create(gltf, GLTFWriter::Primitive::PT_TRIANGLES, material, index);

 if (!primitive ||

 !mesh-&gt;<a id="a25" name="a25"></a>[AppendPrimitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml#afb99ec25e2eebb4390c17f8770e4c23b)(primitive) ||

 !primitive-&gt;<a id="a26" name="a26"></a>[AppendAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml#ac4144b4cc35eec9c11b07cc7352d209e)(vertex) ||

 !primitive-&gt;[AppendAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml#ac4144b4cc35eec9c11b07cc7352d209e)(texture)) {

 GLTFWriter::Utils::Repack::Destroy(repack);

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create primitive");

 }

 }

 

 GLTFWriter::Utils::Repack::Destroy(repack);

 }

 }

 

 // gradient texture

 {

 float mn = -0.5;

 float mx = 0.5;

 float range = mx - mn;

 

 // TEXTURE

 std::vector&lt;unsigned char&gt; colors;

 colors.push_back(0); colors.push_back(0); colors.push_back(255); // blue

 colors.push_back(0); colors.push_back(255); colors.push_back(255); // cyan

 colors.push_back(0); colors.push_back(255); colors.push_back(0); // green

 colors.push_back(255); colors.push_back(255); colors.push_back(0); // yellow

 colors.push_back(255); colors.push_back(0); colors.push_back(0); // red

 [GLTFWriter::Texture](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_texture.xhtml) *smoothTexture = GLTFWriter::Texture::Create(gltf, GLTFWriter::Texture::TF_RGB, (unsigned int)colors.size() / 3, &amp;colors[0]);

 

 // generate vertices, and texture coordinates for a ball

 std::vector&lt;float&gt; vertices;

 std::vector&lt;unsigned int&gt; lines;

 std::vector&lt;unsigned int&gt; triangles;

 GLTFWriter::Test::MakeSphere(0, 1, 0, 0.5, 64, vertices, lines, triangles);

 const unsigned int numVertices = (unsigned int)vertices.size() / 3;

 const unsigned int numLines = (unsigned int)lines.size() / 2;

 const unsigned int numTriangles = (unsigned int)triangles.size() / 3;

 std::vector&lt;float&gt; textureCoords(numVertices);

 for (unsigned int i = 0; i &lt; numVertices; ++i)

 textureCoords[i] = (vertices[3 * i + 2] + 0.5F) * range + mn; // coordinates go from mn to mx

 

 // NODE

 {

 // LEGEND

 // make this gradient colors

 std::vector&lt;float&gt; valueLocation;

 //valueLocation.push\_back(1, mx);

 [GLTFWriter::Legend](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_legend.xhtml) *legend = GLTFWriter::Legend::Create(gltf, GLTFWriter::Legend::LO_VERTICAL, 0.333F, smoothTexture, mn, mx, GLTFWriter::Legend::LA_XRIGHT_YCENTER,

\#ifdef _WIN32

 ConvertToUtf8String(L"Z Ƥṏᴤΐṱϊӧת\\nSmooth").c_str(),

\#else

 "Z Position\\nSmooth",

\#endif

 "m", "This is an example\\ngradient legend\\nX Right, Y Center", 0, 0,

 false, false);

 

 // BUFFER - combine attributes into a single buffer

 [GLTFWriter::Buffer](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_buffer.xhtml) *buffer = GLTFWriter::Buffer::Create(gltf);

 

 // NODE

 [GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *node = GLTFWriter::Node::CreateMesh(gltf, "Linear");

 if (!node || !scene-&gt;[AppendMesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_scene.xhtml#a76e34d4c05fe34dde0fcc4913ad63981)(node)) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create mesh node");

 }

 

 // LEGEND NODE

\#ifdef \_WIN32

 [GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *legendNode = GLTFWriter::Node::CreateLegend(gltf, legend, ConvertToUtf8String(L"Ḷḙḡḗṋḍ").c_str());

\#else

 [GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *legendNode = GLTFWriter::Node::CreateLegend(gltf, legend, "Legend");

\#endif

 node-&gt;[AppendChild](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a86b91dc1bac027fd7a8e59f4d5f0ea05)(legendNode);

 

 // MESH NODE

 [GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *meshNode = GLTFWriter::Node::CreateMesh(gltf, "Mesh");

 if (!meshNode || !node-&gt;[AppendChild](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a86b91dc1bac027fd7a8e59f4d5f0ea05)(meshNode)) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create mesh node");

 }

 

 // MESH

 [GLTFWriter::Mesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml) *mesh = GLTFWriter::Mesh::Create(gltf);

 if (!mesh || !meshNode-&gt;[AppendMesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a68c9eec5fe03405e52b3558a62f8faec)(mesh)) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create mesh");

 }

 

 // TECHNIQUE

 [GLTFWriter::Technique](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_technique.xhtml) *technique = GLTFWriter::Technique::Create(gltf);

 if (!technique ||

 // TECHNIQUE STATES

 !technique-&gt;[AppendState](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_technique.xhtml#a8b2b0766157324d5a2093a3fca36379f)(GLTFWriter::State::Create(gltf, GLTFWriter::State::ST_DEPTHTESTENABLE, 1))) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create technique");

 }

 

 // MATERIAL

 [GLTFWriter::Material](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_material.xhtml) *material = GLTFWriter::Material::Create(gltf, technique);

 if (!material ||

 // MATERIAL UNIFORM VALUES

 !material-&gt;[AppendValue](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_material.xhtml#a2f8a41e41af7d9b8cd498506f6510dd7)(GLTFWriter::Value::Create(gltf, "texture0", smoothTexture-&gt;GetID()))) { // texture0 name is auto-generated from Attribute TEXCOORD0

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create material");

 }

 

 // repack unsigned int indices into multiple sets of unsigned short indices

 [GLTFWriter::Utils::Repack](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml) *repack = GLTFWriter::Utils::Repack::Create(numTriangles, 3, &amp;triangles[0]);

 if (!repack) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create repack");

 }

 for (unsigned int i = 0; i &lt; repack-&gt;[NumPacks](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a69a383562c62ca71c8a785c96f773fb3)(); ++i) {

 const float *packedData;

 unsigned int numAttributes = repack-&gt;[NumAttributes](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a43a74d90484a85856103c33969eb7107)(i);

 

 // POSITION ATTRIBUTE

 packedData = repack-&gt;[ConstructRepackAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a1487b86e5090019cf7565e144fe11e4f)(&amp;triangles[0], 3, &amp;vertices[0], i);

 [GLTFWriter::Attribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml) *vertex = GLTFWriter::Attribute::Create(gltf, "POSITION", GLTFWriter::Attribute::AT_FLOAT_VEC3, numAttributes, packedData, buffer);

 

 // TEXCOORD ATTRIBUTE

 packedData = repack-&gt;[ConstructRepackAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a1487b86e5090019cf7565e144fe11e4f)(&amp;triangles[0], 1, &amp;textureCoords[0], i);

 [GLTFWriter::Attribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml) *texture = GLTFWriter::Attribute::Create(gltf, "TEXCOORD0", GLTFWriter::Attribute::AT_FLOAT, numAttributes, packedData, buffer);

 

 // INDICES

 unsigned int numIndices = 3U * repack-&gt;[NumElements](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a50e2eaf986369c115fe9cae008187cc0)(i);

 const unsigned short *packedIndex = repack-&gt;[ConstructRepackIndex](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#ab3bd7bca7382f17a0c08e144b67d22f2)(&amp;triangles[0], i);

 [GLTFWriter::Index](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_index.xhtml) *index = GLTFWriter::Index::Create(gltf, numIndices, packedIndex, buffer);

 

 // PRIMITIVE

 [GLTFWriter::Primitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml) *primitive = GLTFWriter::Primitive::Create(gltf, GLTFWriter::Primitive::PT_TRIANGLES, material, index);

 if (!primitive ||

 !mesh-&gt;[AppendPrimitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml#afb99ec25e2eebb4390c17f8770e4c23b)(primitive) ||

 !primitive-&gt;[AppendAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml#ac4144b4cc35eec9c11b07cc7352d209e)(vertex) ||

 !primitive-&gt;[AppendAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml#ac4144b4cc35eec9c11b07cc7352d209e)(texture)) {

 GLTFWriter::Utils::Repack::Destroy(repack);

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create primitive");

 }

 }

 

 GLTFWriter::Utils::Repack::Destroy(repack);

 }

 }

 

 // banded log texture

 {

 float mn = 10;

 float mx = 100;

 float range = mx - mn;

 

 // TEXTURE

 std::vector&lt;unsigned char&gt; colors;

 colors.push_back(0); colors.push_back(0); colors.push_back(255); // blue

 colors.push_back(0); colors.push_back(255); colors.push_back(255); // cyan

 colors.push_back(0); colors.push_back(255); colors.push_back(0); // green

 colors.push_back(255); colors.push_back(255); colors.push_back(0); // yellow

 colors.push_back(255); colors.push_back(0); colors.push_back(0); // red

 

 std::vector&lt;float&gt; bandLocations; // fractions from 0 to 1

 bandLocations.push_back(0);

 bandLocations.push_back(0.064988132F);

 bandLocations.push_back(0.167987381F);

 bandLocations.push_back(0.33123019F);

 bandLocations.push_back(0.589952605F);

 [GLTFWriter::Texture](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_texture.xhtml) *bandedTexture = GLTFWriter::Texture::Create(gltf, GLTFWriter::Texture::TF_RGB, (unsigned int)colors.size() / 3, &amp;colors[0], false, (unsigned int)bandLocations.size(), &amp;bandLocations[0]);

 

 // generate vertices, and texture coordinates for a ball

 std::vector&lt;float&gt; vertices;

 std::vector&lt;unsigned int&gt; lines;

 std::vector&lt;unsigned int&gt; triangles;

 GLTFWriter::Test::MakeSphere(0, 0, -1, 0.5, 64, vertices, lines, triangles);

 const unsigned int numVertices = (unsigned int)vertices.size() / 3;

 const unsigned int numLines = (unsigned int)lines.size() / 2;

 const unsigned int numTriangles = (unsigned int)triangles.size() / 3;

 std::vector&lt;float&gt; textureCoords(numVertices);

 for (unsigned int i = 0; i &lt; numVertices; ++i)

 textureCoords[i] = (vertices[3 * i + 1] + 0.5F) * range + mn; // coordinates go from mn to mx

 

 // NODE

 {

 // LEGEND

 // make this logarithmic with banded colors

 std::vector&lt;float&gt; valueLocations; // pairs of numbers, both of which are fractions from 0 to 1

 valueLocations.push_back(0); valueLocations.push_back(0);

 valueLocations.push_back((15.84893192461114F - mn) / range); valueLocations.push_back(0.2F);

 valueLocations.push_back((25.1188643150958F - mn) / range); valueLocations.push_back(0.4F);

 valueLocations.push_back((39.8107170553498F - mn) / range); valueLocations.push_back(0.6F);

 valueLocations.push_back((63.0957344480194F - mn) / range); valueLocations.push_back(0.8F);

 valueLocations.push_back(1); valueLocations.push_back(1);

 [GLTFWriter::Legend](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_legend.xhtml) *legend = GLTFWriter::Legend::Create(gltf, GLTFWriter::Legend::LO_HORIZONTAL, 0.75, bandedTexture, mn, mx, GLTFWriter::Legend::LA_XCENTER_YBOTTOM,

\#ifdef _WIN32

 ConvertToUtf8String(L"Y Ƥṏᴤΐṱϊӧת\\nBanded").c_str(),

\#else

 "Y Position\\nBanded",

\#endif

 "m", "User specified\\nbanded log legend\\nX Center, Y Bottom", 6, &amp;valueLocations[0],

 false, false, 0, 0, 0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F, 0.25F);

 

 // BUFFER - combine attributes into a single buffer

 [GLTFWriter::Buffer](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_buffer.xhtml) *buffer = GLTFWriter::Buffer::Create(gltf);

 

 // NODE

 [GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *node = GLTFWriter::Node::CreateMesh(gltf, "Banded Log User Specified");

 if (!node || !scene-&gt;[AppendMesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_scene.xhtml#a76e34d4c05fe34dde0fcc4913ad63981)(node)) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create mesh node");

 }

 

 // LEGEND NODE

\#ifdef \_WIN32

 [GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *legendNode = GLTFWriter::Node::CreateLegend(gltf, legend, ConvertToUtf8String(L"Ḷḙḡḗṋḍ").c_str());

\#else

 [GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *legendNode = GLTFWriter::Node::CreateLegend(gltf, legend, "Legend");

\#endif

 node-&gt;[AppendChild](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a86b91dc1bac027fd7a8e59f4d5f0ea05)(legendNode);

 

 // MESH NODE

 [GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *meshNode = GLTFWriter::Node::CreateMesh(gltf, "Mesh");

 if (!meshNode || !node-&gt;[AppendChild](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a86b91dc1bac027fd7a8e59f4d5f0ea05)(meshNode)) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create mesh node");

 }

 

 // MESH

 [GLTFWriter::Mesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml) *mesh = GLTFWriter::Mesh::Create(gltf);

 if (!mesh || !meshNode-&gt;[AppendMesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a68c9eec5fe03405e52b3558a62f8faec)(mesh)) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create mesh");

 }

 

 // TECHNIQUE

 [GLTFWriter::Technique](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_technique.xhtml) *technique = GLTFWriter::Technique::Create(gltf);

 if (!technique ||

 // TECHNIQUE STATES

 !technique-&gt;[AppendState](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_technique.xhtml#a8b2b0766157324d5a2093a3fca36379f)(GLTFWriter::State::Create(gltf, GLTFWriter::State::ST_DEPTHTESTENABLE, 1))) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create technique");

 }

 

 // MATERIAL

 [GLTFWriter::Material](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_material.xhtml) *material = GLTFWriter::Material::Create(gltf, technique);

 if (!material ||

 // MATERIAL UNIFORM VALUES

 !material-&gt;[AppendValue](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_material.xhtml#a2f8a41e41af7d9b8cd498506f6510dd7)(GLTFWriter::Value::Create(gltf, "texture0", bandedTexture-&gt;GetID()))) { // texture0 name is auto-generated from Attribute TEXCOORD0

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create material");

 }

 

 // repack unsigned int indices into multiple sets of unsigned short indices

 [GLTFWriter::Utils::Repack](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml) *repack = GLTFWriter::Utils::Repack::Create(numTriangles, 3, &amp;triangles[0]);

 if (!repack) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create repack");

 }

 for (unsigned int i = 0; i &lt; repack-&gt;[NumPacks](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a69a383562c62ca71c8a785c96f773fb3)(); ++i) {

 const float *packedData;

 unsigned int numAttributes = repack-&gt;[NumAttributes](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a43a74d90484a85856103c33969eb7107)(i);

 

 // POSITION ATTRIBUTE

 packedData = repack-&gt;[ConstructRepackAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a1487b86e5090019cf7565e144fe11e4f)(&amp;triangles[0], 3, &amp;vertices[0], i);

 [GLTFWriter::Attribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml) *vertex = GLTFWriter::Attribute::Create(gltf, "POSITION", GLTFWriter::Attribute::AT_FLOAT_VEC3, numAttributes, packedData, buffer);

 

 // TEXCOORD ATTRIBUTE

 packedData = repack-&gt;[ConstructRepackAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a1487b86e5090019cf7565e144fe11e4f)(&amp;triangles[0], 1, &amp;textureCoords[0], i);

 [GLTFWriter::Attribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml) *texture = GLTFWriter::Attribute::Create(gltf, "TEXCOORD0", GLTFWriter::Attribute::AT_FLOAT, numAttributes, packedData, buffer);

 

 // INDICES

 unsigned int numIndices = 3U * repack-&gt;[NumElements](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a50e2eaf986369c115fe9cae008187cc0)(i);

 const unsigned short *packedIndex = repack-&gt;[ConstructRepackIndex](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#ab3bd7bca7382f17a0c08e144b67d22f2)(&amp;triangles[0], i);

 [GLTFWriter::Index](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_index.xhtml) *index = GLTFWriter::Index::Create(gltf, numIndices, packedIndex, buffer);

 

 // PRIMITIVE

 [GLTFWriter::Primitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml) *primitive = GLTFWriter::Primitive::Create(gltf, GLTFWriter::Primitive::PT_TRIANGLES, material, index);

 if (!primitive ||

 !mesh-&gt;[AppendPrimitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml#afb99ec25e2eebb4390c17f8770e4c23b)(primitive) ||

 !primitive-&gt;[AppendAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml#ac4144b4cc35eec9c11b07cc7352d209e)(vertex) ||

 !primitive-&gt;[AppendAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml#ac4144b4cc35eec9c11b07cc7352d209e)(texture)) {

 GLTFWriter::Utils::Repack::Destroy(repack);

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create primitive");

 }

 }

 

 GLTFWriter::Utils::Repack::Destroy(repack);

 }

 }

 

 // gradient log texture

 // we need to fudge the texture, because auto generated shaders do not support logging of data

 {

 float mn = 10;

 float mx = 100;

 float range = mx - mn;

 

 // TEXTURE

 std::vector&lt;unsigned char&gt; colors;

 colors.push_back(0); colors.push_back(0); colors.push_back(255); // blue

 colors.push_back(0); colors.push_back(255); colors.push_back(255); // cyan

 colors.push_back(0); colors.push_back(255); colors.push_back(0); // green

 colors.push_back(255); colors.push_back(255); colors.push_back(0); // yellow

 colors.push_back(255); colors.push_back(0); colors.push_back(0); // red

 

 // create a gradient texture that is really made up of bands

 const unsigned int numBands = 256;

 std::vector&lt;float&gt; bandLocations; // fractions from 0 to 1

 for (unsigned int i = 0; i &lt; numBands; ++i)

 bandLocations.push_back((float)(pow(10.0, (double)i / numBands) * 10.0 - mn) / range);

 

 [GLTFWriter::Texture](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_texture.xhtml) *smoothTexture = GLTFWriter::Texture::Create(gltf, GLTFWriter::Texture::TF_RGB, (unsigned int)colors.size() / 3, &amp;colors[0], false, (unsigned int)bandLocations.size(), &amp;bandLocations[0]);

 

 // generate vertices, and texture coordinates for a ball

 std::vector&lt;float&gt; vertices;

 std::vector&lt;unsigned int&gt; lines;

 std::vector&lt;unsigned int&gt; triangles;

 GLTFWriter::Test::MakeSphere(0, 0, 1, 0.5, 64, vertices, lines, triangles);

 const unsigned int numVertices = (unsigned int)vertices.size() / 3;

 const unsigned int numLines = (unsigned int)lines.size() / 2;

 const unsigned int numTriangles = (unsigned int)triangles.size() / 3;

 std::vector&lt;float&gt; textureCoords(numVertices);

 for (unsigned int i = 0; i &lt; numVertices; ++i)

 textureCoords[i] = (vertices[3 * i + 1] + 0.5F) * range + mn; // coordinates go from mn to mx

 

 // NODE

 {

 // LEGEND

 [GLTFWriter::Legend](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_legend.xhtml) *legend = GLTFWriter::Legend::Create(gltf, GLTFWriter::Legend::LO_HORIZONTAL, 0.333F, smoothTexture, mn, mx, GLTFWriter::Legend::LA_XCENTER_YTOP,

\#ifdef _WIN32

 ConvertToUtf8String(L"Y Ƥṏᴤΐṱϊӧת\\nGradient").c_str(),

\#else

 "Y Position\\nGradient",

\#endif

 "m", "This is an example\\ngradient log legend\\nX Center, Y Top", 0, 0,

 true, true, 0, 0, 0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F, 0.25F);

 

 // BUFFER - combine attributes into a single buffer

 [GLTFWriter::Buffer](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_buffer.xhtml) *buffer = GLTFWriter::Buffer::Create(gltf);

 

 // NODE

 [GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *node = GLTFWriter::Node::CreateMesh(gltf, "Gradient Log");

 if (!node || !scene-&gt;[AppendMesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_scene.xhtml#a76e34d4c05fe34dde0fcc4913ad63981)(node)) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create mesh node");

 }

 

 // LEGEND NODE

\#ifdef \_WIN32

 [GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *legendNode = GLTFWriter::Node::CreateLegend(gltf, legend, ConvertToUtf8String(L"Ḷḙḡḗṋḍ").c_str());

\#else

 [GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *legendNode = GLTFWriter::Node::CreateLegend(gltf, legend, "Legend");

\#endif

 node-&gt;[AppendChild](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a86b91dc1bac027fd7a8e59f4d5f0ea05)(legendNode);

 

 // MESH NODE

 [GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *meshNode = GLTFWriter::Node::CreateMesh(gltf, "Mesh");

 if (!meshNode || !node-&gt;[AppendChild](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a86b91dc1bac027fd7a8e59f4d5f0ea05)(meshNode)) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create mesh node");

 }

 

 // MESH

 [GLTFWriter::Mesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml) *mesh = GLTFWriter::Mesh::Create(gltf);

 if (!mesh || !meshNode-&gt;[AppendMesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a68c9eec5fe03405e52b3558a62f8faec)(mesh)) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create mesh");

 }

 

 // TECHNIQUE

 [GLTFWriter::Technique](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_technique.xhtml) *technique = GLTFWriter::Technique::Create(gltf);

 if (!technique ||

 // TECHNIQUE STATES

 !technique-&gt;[AppendState](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_technique.xhtml#a8b2b0766157324d5a2093a3fca36379f)(GLTFWriter::State::Create(gltf, GLTFWriter::State::ST_DEPTHTESTENABLE, 1))) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create technique");

 }

 

 // MATERIAL

 [GLTFWriter::Material](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_material.xhtml) *material = GLTFWriter::Material::Create(gltf, technique);

 if (!material ||

 // MATERIAL UNIFORM VALUES

 !material-&gt;[AppendValue](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_material.xhtml#a2f8a41e41af7d9b8cd498506f6510dd7)(GLTFWriter::Value::Create(gltf, "texture0", smoothTexture-&gt;GetID()))) { // texture0 name is auto-generated from Attribute TEXCOORD0

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create material");

 }

 

 // repack unsigned int indices into multiple sets of unsigned short indices

 [GLTFWriter::Utils::Repack](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml) *repack = GLTFWriter::Utils::Repack::Create(numTriangles, 3, &amp;triangles[0]);

 if (!repack) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create repack");

 }

 for (unsigned int i = 0; i &lt; repack-&gt;[NumPacks](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a69a383562c62ca71c8a785c96f773fb3)(); ++i) {

 const float *packedData;

 unsigned int numAttributes = repack-&gt;[NumAttributes](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a43a74d90484a85856103c33969eb7107)(i);

 

 // POSITION ATTRIBUTE

 packedData = repack-&gt;[ConstructRepackAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a1487b86e5090019cf7565e144fe11e4f)(&amp;triangles[0], 3, &amp;vertices[0], i);

 [GLTFWriter::Attribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml) *vertex = GLTFWriter::Attribute::Create(gltf, "POSITION", GLTFWriter::Attribute::AT_FLOAT_VEC3, numAttributes, packedData, buffer);

 

 // TEXCOORD ATTRIBUTE

 packedData = repack-&gt;[ConstructRepackAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a1487b86e5090019cf7565e144fe11e4f)(&amp;triangles[0], 1, &amp;textureCoords[0], i);

 [GLTFWriter::Attribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml) *texture = GLTFWriter::Attribute::Create(gltf, "TEXCOORD0", GLTFWriter::Attribute::AT_FLOAT, numAttributes, packedData, buffer);

 texture-&gt;<a id="a27" name="a27"></a>[SetLogarithmic](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml#a795c8d57e0534017a267ca9511f788ce)(true);

 

 // INDICES

 unsigned int numIndices = 3U * repack-&gt;[NumElements](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a50e2eaf986369c115fe9cae008187cc0)(i);

 const unsigned short *packedIndex = repack-&gt;[ConstructRepackIndex](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#ab3bd7bca7382f17a0c08e144b67d22f2)(&amp;triangles[0], i);

 [GLTFWriter::Index](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_index.xhtml) *index = GLTFWriter::Index::Create(gltf, numIndices, packedIndex, buffer);

 

 // PRIMITIVE

 [GLTFWriter::Primitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml) *primitive = GLTFWriter::Primitive::Create(gltf, GLTFWriter::Primitive::PT_TRIANGLES, material, index);

 if (!primitive ||

 !mesh-&gt;[AppendPrimitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml#afb99ec25e2eebb4390c17f8770e4c23b)(primitive) ||

 !primitive-&gt;[AppendAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml#ac4144b4cc35eec9c11b07cc7352d209e)(vertex) ||

 !primitive-&gt;[AppendAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml#ac4144b4cc35eec9c11b07cc7352d209e)(texture)) {

 GLTFWriter::Utils::Repack::Destroy(repack);

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create primitive");

 }

 }

 

 GLTFWriter::Utils::Repack::Destroy(repack);

 }

 }

 

 if (!gltf-&gt;<a id="a28" name="a28"></a>[Write](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_g_l_t_f.xhtml#a0bf3a4ec615dc8810776dd82a65eba91)()) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Error creating file");

 }

 

 [GLTFWriter::GLTF::GLTFError](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_g_l_t_f.xhtml#a5b8141dc8536bc10d1a72996ad6f98b4) error = gltf-&gt;<a id="a29" name="a29"></a>[GetError](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_g_l_t_f.xhtml#a63295f8f31619517e94cf27d3a8b9ea8)();

 

 GLTFWriter::GLTF::Destroy(gltf);

 

 if (error != GLTFWriter::GLTF::GLTF_ERROR_NONE)

 throw std::runtime_error("Error creating file");

}

[ANSYS::AVZ::GLTFWriter::Attribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml)

Attributes define the per element index values for elements defined by Index.

**Definition** [GLTFAttribute.h:32](_g_l_t_f_attribute_8h_source.xhtml#l00031)



[ANSYS::AVZ::GLTFWriter::Attribute::SetLogarithmic](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml#a795c8d57e0534017a267ca9511f788ce)

virtual void SetLogarithmic(bool log)=0



[ANSYS::AVZ::GLTFWriter::Buffer](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_buffer.xhtml)

Buffers define files that are used to contain attribute and index data.

**Definition** [GLTFBuffer.h:36](_g_l_t_f_buffer_8h_source.xhtml#l00035)



[ANSYS::AVZ::GLTFWriter::Camera](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_camera.xhtml)

Cameras define an orthographic or perspective projection of the scene.

**Definition** [GLTFCamera.h:28](_g_l_t_f_camera_8h_source.xhtml#l00027)



[ANSYS::AVZ::GLTFWriter::GLTF](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_g_l_t_f.xhtml)

This is the main class of the GLTFWriter.

**Definition** [GLTFGLTF.h:32](_g_l_t_f_g_l_t_f_8h_source.xhtml#l00031)



[ANSYS::AVZ::GLTFWriter::GLTF::Write](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_g_l_t_f.xhtml#a0bf3a4ec615dc8810776dd82a65eba91)

virtual bool Write(bool formatJSON=false)=0



[ANSYS::AVZ::GLTFWriter::GLTF::GLTFError](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_g_l_t_f.xhtml#a5b8141dc8536bc10d1a72996ad6f98b4)

GLTFError

**Definition** [GLTFGLTF.h:35](_g_l_t_f_g_l_t_f_8h_source.xhtml#l00035)



[ANSYS::AVZ::GLTFWriter::GLTF::GetError](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_g_l_t_f.xhtml#a63295f8f31619517e94cf27d3a8b9ea8)

virtual GLTFError GetError()=0



[ANSYS::AVZ::GLTFWriter::Index](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_index.xhtml)

Indexes define elements within primitives.

**Definition** [GLTFIndex.h:29](_g_l_t_f_index_8h_source.xhtml#l00028)



[ANSYS::AVZ::GLTFWriter::Legend](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_legend.xhtml)

Legends are colored bars with numbers at intervals along bar.

**Definition** [GLTFLegend.h:27](_g_l_t_f_legend_8h_source.xhtml#l00026)



[ANSYS::AVZ::GLTFWriter::Material](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_material.xhtml)

Materials describe how primitives are rendered.

**Definition** [GLTFMaterial.h:30](_g_l_t_f_material_8h_source.xhtml#l00029)



[ANSYS::AVZ::GLTFWriter::Material::AppendValue](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_material.xhtml#a2f8a41e41af7d9b8cd498506f6510dd7)

virtual bool AppendValue(Value *value)=0



[ANSYS::AVZ::GLTFWriter::Mesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml)

Meshes define the renderable objects that can be added to a node.

**Definition** [GLTFMesh.h:104](_g_l_t_f_mesh_8h_source.xhtml#l00103)



[ANSYS::AVZ::GLTFWriter::Mesh::AppendPrimitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml#afb99ec25e2eebb4390c17f8770e4c23b)

virtual bool AppendPrimitive(Primitive *primitive)=0



[ANSYS::AVZ::GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml)

Nodes are the GLTFWriter class that contain the data that is defined in the GLTF file.

**Definition** [GLTFNode.h:31](_g_l_t_f_node_8h_source.xhtml#l00030)



[ANSYS::AVZ::GLTFWriter::Node::AppendMesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a68c9eec5fe03405e52b3558a62f8faec)

virtual bool AppendMesh(Mesh *mesh)=0



[ANSYS::AVZ::GLTFWriter::Node::AppendChild](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a86b91dc1bac027fd7a8e59f4d5f0ea05)

virtual bool AppendChild(Node *node)=0



[ANSYS::AVZ::GLTFWriter::Primitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml)

Primitives are the renderable parts of meshes.

**Definition** [GLTFMesh.h:30](_g_l_t_f_mesh_8h_source.xhtml#l00029)



[ANSYS::AVZ::GLTFWriter::Primitive::AppendAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml#ac4144b4cc35eec9c11b07cc7352d209e)

virtual bool AppendAttribute(Attribute *attribute)=0



[ANSYS::AVZ::GLTFWriter::Scene](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_scene.xhtml)

Scenes are the GLTFWriter class that create the view of the data that is defined in the GLTF file.

**Definition** [GLTFScene.h:29](_g_l_t_f_scene_8h_source.xhtml#l00028)



[ANSYS::AVZ::GLTFWriter::Scene::AppendMesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_scene.xhtml#a76e34d4c05fe34dde0fcc4913ad63981)

virtual bool AppendMesh(Node *mesh)=0



[ANSYS::AVZ::GLTFWriter::Scene::SetCamera](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_scene.xhtml#ae84fba7ea3c00159c2eae7adbfbfa61d)

virtual bool SetCamera(Node *camera)=0



[ANSYS::AVZ::GLTFWriter::Technique](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_technique.xhtml)

Techniques performs the rendering of primitives.

**Definition** [GLTFTechnique.h:240](_g_l_t_f_technique_8h_source.xhtml#l00239)



[ANSYS::AVZ::GLTFWriter::Technique::AppendState](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_technique.xhtml#a8b2b0766157324d5a2093a3fca36379f)

virtual bool AppendState(State *state)=0



[ANSYS::AVZ::GLTFWriter::Texture](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_texture.xhtml)

Textures are images that can be used to color a primitive.

**Definition** [GLTFTexture.h:28](_g_l_t_f_texture_8h_source.xhtml#l00027)



[ANSYS::AVZ::GLTFWriter::Utils::Repack](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml)

Manages repacking of indices from unsigned int type to unsigned short type. This only works for POINT...

**Definition** [GLTFUtils.h:106](_g_l_t_f_utils_8h_source.xhtml#l00105)



[ANSYS::AVZ::GLTFWriter::Utils::Repack::ConstructRepackAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a1487b86e5090019cf7565e144fe11e4f)

virtual const int * ConstructRepackAttribute(const unsigned int *indices, unsigned int attributeSize, const int *attributeData, unsigned int packNum)=0



[ANSYS::AVZ::GLTFWriter::Utils::Repack::NumAttributes](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a43a74d90484a85856103c33969eb7107)

virtual unsigned int NumAttributes(unsigned int packNum) const =0



[ANSYS::AVZ::GLTFWriter::Utils::Repack::NumElements](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a50e2eaf986369c115fe9cae008187cc0)

virtual unsigned int NumElements(unsigned int packNum) const =0



[ANSYS::AVZ::GLTFWriter::Utils::Repack::NumPacks](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#a69a383562c62ca71c8a785c96f773fb3)

virtual unsigned int NumPacks() const =0



[ANSYS::AVZ::GLTFWriter::Utils::Repack::ConstructRepackIndex](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.xhtml#ab3bd7bca7382f17a0c08e144b67d22f2)

virtual const unsigned short * ConstructRepackIndex(const unsigned int *indices, unsigned int packNum)=0