    

 ## On this page

  

 

 # Test010

 Last update: 16.07.2025 

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

Different types of primitives.

This example demonstrates the different types of primitives that are available. At the moment WebGL is limited to primitives no larger than triangles (3 vertices per primitive).

Most applications generally stick to POINTS, LINES, or TRIANGLES.

/\*

 \* 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;

 

\#include "GLTFWriter.h"

\#include "test.h"

 

using namespace ANSYS::AVZ;

 

namespace {

 void PositionAppend(std::vector&lt;float&gt; &amp;dest,

 const std::vector&lt;float&gt; &amp;src,

 unsigned int srcOffset,

 unsigned int srcCount,

 float offsetX,

 float offsetY,

 float offsetZ)

 {

 unsigned int destOffset = (unsigned int)dest.size();

 dest.resize(destOffset + 3 * srcCount);

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

 dest[destOffset + 3 * i + 0] = src[3 * (srcOffset + i) + 0] + offsetX;

 dest[destOffset + 3 * i + 1] = src[3 * (srcOffset + i) + 1] + offsetY;

 dest[destOffset + 3 * i + 2] = src[3 * (srcOffset + i) + 2] + offsetZ;

 }

 }

};

 

// primitiveTypes

TESTFUNC(PrimitiveTypes)

{

 <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

 <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, "TestScene", "m", 1.0F, GLTFWriter::Scene::BT_TB, 0.42F, 0.55F, 0.871F, 1, 1, 1);

 if (!scene) {

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 

 // LIGHTS

 {

 // LIGHT NODE

 <a id="_a2" name="_a2"></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) *lightNode = GLTFWriter::Node::CreateLight(gltf);

 if (!lightNode || !scene-&gt;<a id="a3" name="a3"></a>[SetLight](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_scene.xhtml#ac92acb916999693ccaaefe8a81962c67)(lightNode)) {

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 

 // LIGHTS

 <a id="_a4" name="_a4"></a>[GLTFWriter::Light](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_light.xhtml) *light1 = GLTFWriter::Light::CreateAmbient(gltf);

 lightNode-&gt;<a id="a5" name="a5"></a>[AppendLight](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a576db36280a02127b5eb662f0566543b)(light1);

 

 [GLTFWriter::Light](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_light.xhtml) *light2 = GLTFWriter::Light::CreateDirectional(gltf, 1, 1, 1, -1, -1, -3);

 lightNode-&gt;[AppendLight](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a576db36280a02127b5eb662f0566543b)(light2);

 }

 

 float x = 0;

 float y = 0;

 float z = 0;

 

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

 locations.push_back(x + 0.0F); locations.push_back(y + 0.0F); locations.push_back(z - 0.0F);

 locations.push_back(x + 1.0F); locations.push_back(y + 0.0F); locations.push_back(z - 0.0F);

 locations.push_back(x + 1.0F); locations.push_back(y + 1.0F); locations.push_back(z - 0.0F);

 locations.push_back(x + 0.0F); locations.push_back(y + 1.0F); locations.push_back(z - 0.0F);

 locations.push_back(x + 0.0F); locations.push_back(y + 0.0F); locations.push_back(z - 1.0F);

 locations.push_back(x + 1.0F); locations.push_back(y + 0.0F); locations.push_back(z - 1.0F);

 locations.push_back(x + 1.0F); locations.push_back(y + 1.0F); locations.push_back(z - 1.0F);

 locations.push_back(x + 0.0F); locations.push_back(y + 1.0F); locations.push_back(z - 1.0F);

 

 // POINTS

 {

 // 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, "Points");

 if (!node || !scene-&gt;<a id="a6" name="a6"></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");

 }

 

 // MESH

 <a id="_a7" name="_a7"></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 || !node-&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_node.xhtml#a68c9eec5fe03405e52b3558a62f8faec)(mesh)) {

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 

 // TECHNIQUE

 <a id="_a9" name="_a9"></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-&gt;<a id="a10" name="a10"></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="_a11" name="_a11"></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="a12" name="a12"></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, "color", 1.0, 0.0, 0.0, 1.0)) || // color name is used to auto-generate a solid colored object

 !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, "pointSize", 50.0))) {

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 

 // VERTICES

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

 PositionAppend(vertices, locations, 0, 8, x, y, z);

 

 // POSITION ATTRIBUTE

 <a id="_a13" name="_a13"></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::CreatePosition(gltf, (unsigned int)vertices.size() / 3, &amp;vertices[0]);

 

 // PRIMITIVE

 <a id="_a14" name="_a14"></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_POINTS, material);

 if (!primitive ||

 !mesh-&gt;<a id="a15" name="a15"></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="a16" name="a16"></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)) {

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 }

 

 y += 2;

 

 // INDEXED POINTS

 {

 // 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, "Indexed Points (Does not make sense)");

 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");

 }

 

 // 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 || !node-&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-&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, "color", 0.5, 0.0, 0.0, 1.0)) || // color name is used to auto-generate a solid colored object

 !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, "pointSize", 50.0))) {

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 

 // VERTICES

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

 PositionAppend(vertices, locations, 0, 8, x, y, z);

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

 

 // POSITION ATTRIBUTE

 [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::CreatePosition(gltf, (unsigned int)vertices.size() / 3, &amp;vertices[0]);

 

 // INDICES

 std::vector&lt;unsigned short&gt; indices;

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

 indices.push_back(i);

 

 // INDEX

 <a id="_a17" name="_a17"></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, (unsigned int)indices.size(), &amp;indices[0]);

 

 // 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_POINTS, 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)) {

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 }

 

 x += 2;

 y -= 2;

 

 // LINES

 {

 // 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, "Lines");

 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");

 }

 

 // 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 || !node-&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-&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, "color", 0.0, 1.0, 0.0, 1.0))) { // color name is used to auto-generate a solid colored object

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 

 // VERTICES

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

 PositionAppend(vertices, locations, 0, 2, x, y, z);

 PositionAppend(vertices, locations, 1, 2, x, y, z);

 PositionAppend(vertices, locations, 2, 2, x, y, z);

 PositionAppend(vertices, locations, 3, 1, x, y, z); PositionAppend(vertices, locations, 0, 1, x, y, z);

 PositionAppend(vertices, locations, 4, 2, x, y, z);

 PositionAppend(vertices, locations, 5, 2, x, y, z);

 PositionAppend(vertices, locations, 6, 2, x, y, z);

 PositionAppend(vertices, locations, 7, 1, x, y, z); PositionAppend(vertices, locations, 4, 1, x, y, z);

 PositionAppend(vertices, locations, 0, 1, x, y, z); PositionAppend(vertices, locations, 4, 1, x, y, z);

 PositionAppend(vertices, locations, 1, 1, x, y, z); PositionAppend(vertices, locations, 5, 1, x, y, z);

 PositionAppend(vertices, locations, 2, 1, x, y, z); PositionAppend(vertices, locations, 6, 1, x, y, z);

 PositionAppend(vertices, locations, 3, 1, x, y, z); PositionAppend(vertices, locations, 7, 1, x, y, z);

 

 // POSITION ATTRIBUTE

 [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::CreatePosition(gltf, (unsigned int)vertices.size() / 3, &amp;vertices[0]);

 

 // 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_LINES, material);

 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)) {

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 }

 

 y += 2;

 

 // INDEXED LINES

 {

 // 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, "Indexed Lines");

 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");

 }

 

 // 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 || !node-&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-&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, "color", 0.0, 0.5, 0.0, 1.0))) { // color name is used to auto-generate a solid colored object

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 

 // VERTICES

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

 PositionAppend(vertices, locations, 0, 8, x, y, z);

 

 // POSITION ATTRIBUTE

 [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::CreatePosition(gltf, (unsigned int)vertices.size() / 3, &amp;vertices[0]);

 

 // INDICES

 std::vector&lt;unsigned short&gt; indices;

 indices.push_back(0); indices.push_back(1);

 indices.push_back(1); indices.push_back(2);

 indices.push_back(2); indices.push_back(3);

 indices.push_back(3); indices.push_back(0);

 indices.push_back(4); indices.push_back(5);

 indices.push_back(5); indices.push_back(6);

 indices.push_back(6); indices.push_back(7);

 indices.push_back(7); indices.push_back(4);

 indices.push_back(0); indices.push_back(4);

 indices.push_back(1); indices.push_back(5);

 indices.push_back(2); indices.push_back(6);

 indices.push_back(3); indices.push_back(7);

 

 // INDEX

 [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, (unsigned int)indices.size(), &amp;indices[0]);

 

 // 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_LINES, 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)) {

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 }

 

 x += 2;

 y -= 2;

 

 // LINE LOOP

 {

 // 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, "Line Loop");

 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");

 }

 

 // 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 || !node-&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-&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, "color", 0.0, 0.0, 1.0, 1.0))) { // color name is used to auto-generate a solid colored object

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 

 // VERTICES

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

 PositionAppend(vertices, locations, 0, 3, x, y, z);

 PositionAppend(vertices, locations, 6, 1, x, y, z);

 PositionAppend(vertices, locations, 5, 1, x, y, z);

 PositionAppend(vertices, locations, 4, 1, x, y, z);

 PositionAppend(vertices, locations, 7, 1, x, y, z);

 PositionAppend(vertices, locations, 3, 1, x, y, z);

 

 // POSITION ATTRIBUTE

 [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::CreatePosition(gltf, (unsigned int)vertices.size() / 3, &amp;vertices[0]);

 

 // 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_LINE_LOOP, material);

 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)) {

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 }

 

 y += 2;

 

 // INDEXED LINE LOOP

 {

 // 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, "Indexed Line Loop");

 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");

 }

 

 // 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 || !node-&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-&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, "color", 0.0, 0.0, 0.5, 1.0))) { // color name is used to auto-generate a solid colored object

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 

 // VERTICES

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

 PositionAppend(vertices, locations, 0, 8, x, y, z);

 

 // POSITION ATTRIBUTE

 [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::CreatePosition(gltf, (unsigned int)vertices.size() / 3, &amp;vertices[0]);

 

 // INDICES

 std::vector&lt;unsigned short&gt; indices;

 indices.push_back(0); indices.push_back(1); indices.push_back(2);

 indices.push_back(6);

 indices.push_back(5);

 indices.push_back(4);

 indices.push_back(7);

 indices.push_back(3);

 

 // INDEX

 [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, (unsigned int)indices.size(), &amp;indices[0]);

 

 // 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_LINE_LOOP, 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)) {

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 }

 

 x += 2;

 y -= 2;

 

 // LINE STRIP

 {

 // 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, "Line Strip");

 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");

 }

 

 // 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 || !node-&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-&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, "color", 0.75, 0.75, 0.0, 1.0))) { // color name is used to auto-generate a solid colored object

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 

 // VERTICES

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

 PositionAppend(vertices, locations, 0, 4, x, y, z);

 PositionAppend(vertices, locations, 0, 1, x, y, z);

 PositionAppend(vertices, locations, 4, 4, x, y, z);

 PositionAppend(vertices, locations, 4, 1, x, y, z);

 

 // POSITION ATTRIBUTE

 [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::CreatePosition(gltf, (unsigned int)vertices.size() / 3, &amp;vertices[0]);

 

 // 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_LINE_LOOP, material);

 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)) {

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 }

 

 y += 2;

 

 // INDEXED LINE STRIP

 {

 // 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, "Indexed Line Strip");

 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");

 }

 

 // 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 || !node-&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-&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, "color", 0.25, 0.25, 0.0, 1.0))) { // color name is used to auto-generate a solid colored object

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 

 // VERTICES

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

 PositionAppend(vertices, locations, 0, 8, x, y, z);

 

 // POSITION ATTRIBUTE

 [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::CreatePosition(gltf, (unsigned int)vertices.size() / 3, &amp;vertices[0]);

 

 // INDICES

 std::vector&lt;unsigned short&gt; indices;

 indices.push_back(0); indices.push_back(1); indices.push_back(2); indices.push_back(3);

 indices.push_back(0);

 indices.push_back(4); indices.push_back(5); indices.push_back(6); indices.push_back(7);

 indices.push_back(4);

 

 // INDEX

 [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, (unsigned int)indices.size(), &amp;indices[0]);

 

 // 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_LINE_LOOP, 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)) {

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 }

 

 x += 2;

 y -= 2;

 

 // TRIANGLES

 {

 // 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, "Triangles");

 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");

 }

 

 // 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 || !node-&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-&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, "color", 0.0, 1.0, 1.0, 1.0))) { // color name is used to auto-generate a solid colored object

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 

 // VERTICES

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

 PositionAppend(vertices, locations, 0, 3, x, y, z);

 PositionAppend(vertices, locations, 0, 1, x, y, z); PositionAppend(vertices, locations, 2, 2, x, y, z);

 PositionAppend(vertices, locations, 1, 1, x, y, z); PositionAppend(vertices, locations, 5, 2, x, y, z);

 PositionAppend(vertices, locations, 1, 1, x, y, z); PositionAppend(vertices, locations, 6, 1, x, y, z); PositionAppend(vertices, locations, 2, 1, x, y, z);

 PositionAppend(vertices, locations, 5, 1, x, y, z); PositionAppend(vertices, locations, 4, 1, x, y, z); PositionAppend(vertices, locations, 7, 1, x, y, z);

 PositionAppend(vertices, locations, 5, 1, x, y, z); PositionAppend(vertices, locations, 7, 1, x, y, z); PositionAppend(vertices, locations, 6, 1, x, y, z);

 PositionAppend(vertices, locations, 4, 1, x, y, z); PositionAppend(vertices, locations, 0, 1, x, y, z); PositionAppend(vertices, locations, 3, 1, x, y, z);

 PositionAppend(vertices, locations, 4, 1, x, y, z); PositionAppend(vertices, locations, 3, 1, x, y, z); PositionAppend(vertices, locations, 7, 1, x, y, z);

 PositionAppend(vertices, locations, 4, 2, x, y, z); PositionAppend(vertices, locations, 1, 1, x, y, z);

 PositionAppend(vertices, locations, 4, 1, x, y, z); PositionAppend(vertices, locations, 1, 1, x, y, z); PositionAppend(vertices, locations, 0, 1, x, y, z);

 PositionAppend(vertices, locations, 3, 1, x, y, z); PositionAppend(vertices, locations, 2, 1, x, y, z); PositionAppend(vertices, locations, 6, 1, x, y, z);

 PositionAppend(vertices, locations, 3, 1, x, y, z); PositionAppend(vertices, locations, 6, 2, x, y, z);

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

 

 // POSITION ATTRIBUTE

 [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::CreatePosition(gltf, (unsigned int)vertices.size() / 3, &amp;vertices[0]);

 

 // NORMALS

 std::vector&lt;float&gt; vertexNormals(3 * numVertices);

 {

 std::vector&lt;unsigned short&gt; indices;

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

 indices.push_back(i);

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

 GLTFWriter::Utils::ComputeVertexNormals3(numVertices, &amp;vertices[0], numTriangles, 3, &amp;indices[0], &amp;vertexNormals[0]);

 }

 

 // NORMAL ATTRIBUTE

 [GLTFWriter::Attribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml) *normal = GLTFWriter::Attribute::CreateNormal(gltf, numVertices, &amp;vertexNormals[0]);

 

 // 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);

 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)(normal)) {

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 }

 

 y += 2;

 

 // INDEXED TRIANGLES

 {

 // 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, "Indexed Triangles");

 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");

 }

 

 // 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 || !node-&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-&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, "color", 0.0, 0.5, 0.5, 1.0))) { // color name is used to auto-generate a solid colored object

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 

 // VERTICES

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

 PositionAppend(vertices, locations, 0, 8, x, y, z);

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

 

 // POSITION ATTRIBUTE

 [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::CreatePosition(gltf, numVertices, &amp;vertices[0]);

 

 // INDICES

 std::vector&lt;unsigned short&gt; indices;

 indices.push_back(0); indices.push_back(1); indices.push_back(2);

 indices.push_back(0); indices.push_back(2); indices.push_back(3);

 indices.push_back(1); indices.push_back(5); indices.push_back(6);

 indices.push_back(1); indices.push_back(6); indices.push_back(2);

 indices.push_back(5); indices.push_back(4); indices.push_back(7);

 indices.push_back(5); indices.push_back(7); indices.push_back(6);

 indices.push_back(4); indices.push_back(0); indices.push_back(3);

 indices.push_back(4); indices.push_back(3); indices.push_back(7);

 indices.push_back(0); indices.push_back(4); indices.push_back(5);

 indices.push_back(0); indices.push_back(5); indices.push_back(1);

 indices.push_back(2); indices.push_back(6); indices.push_back(7);

 indices.push_back(2); indices.push_back(7); indices.push_back(3);

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

 

 // INDEX

 [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, (unsigned int)indices.size(), &amp;indices[0]);

 

 // NORMALS

 std::vector&lt;float&gt; vertexNormals(3 * numVertices);

 GLTFWriter::Utils::ComputeVertexNormals3(numVertices, &amp;vertices[0], numTriangles, 3, &amp;indices[0], &amp;vertexNormals[0]);

 

 // NORMAL ATTRIBUTE

 [GLTFWriter::Attribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml) *normal = GLTFWriter::Attribute::CreateNormal(gltf, numVertices, &amp;vertexNormals[0]);

 

 // 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)(normal)) {

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 }

 

 x += 2;

 y -= 2;

 

 // TRIANGLE STRIP

 {

 // 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, "Triangle Strip");

 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");

 }

 

 // 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 || !node-&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-&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, "color", 1.0, 0.0, 1.0, 1.0))) { // color name is used to auto-generate a solid colored object

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 

 // VERTICES

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

 PositionAppend(vertices, locations, 0, 2, x, y, z); PositionAppend(vertices, locations, 3, 1, x, y, z);

 PositionAppend(vertices, locations, 2, 1, x, y, z);

 PositionAppend(vertices, locations, 7, 1, x, y, z);

 PositionAppend(vertices, locations, 6, 1, x, y, z);

 PositionAppend(vertices, locations, 4, 1, x, y, z);

 PositionAppend(vertices, locations, 5, 1, x, y, z);

 PositionAppend(vertices, locations, 0, 1, x, y, z);

 PositionAppend(vertices, locations, 1, 1, x, y, z);

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

 

 // POSITION ATTRIBUTE

 [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::CreatePosition(gltf, (unsigned int)vertices.size() / 3, &amp;vertices[0]);

 

 // NORMALS

 std::vector&lt;float&gt; vertexNormals(3 * numVertices);

 {

 std::vector&lt;unsigned short&gt; indices;

 indices.push_back(0); indices.push_back(1); indices.push_back(2);

 indices.push_back(2); indices.push_back(1); indices.push_back(3);

 indices.push_back(2); indices.push_back(3); indices.push_back(4);

 indices.push_back(4); indices.push_back(3); indices.push_back(5);

 indices.push_back(4); indices.push_back(5); indices.push_back(6);

 indices.push_back(6); indices.push_back(5); indices.push_back(7);

 indices.push_back(6); indices.push_back(7); indices.push_back(8);

 indices.push_back(8); indices.push_back(7); indices.push_back(9);

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

 GLTFWriter::Utils::ComputeVertexNormals3(numVertices, &amp;vertices[0], numTriangles, 3, &amp;indices[0], &amp;vertexNormals[0]);

 }

 

 // NORMAL ATTRIBUTE

 [GLTFWriter::Attribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml) *normal = GLTFWriter::Attribute::CreateNormal(gltf, numVertices, &amp;vertexNormals[0]);

 

 // 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_TRIANGLE_STRIP, material);

 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)(normal)) {

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 }

 

 y += 2;

 

 // INDEXED TRIANGLE STRIP

 {

 // 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, "Indexed Triangle Strip");

 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");

 }

 

 // 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 || !node-&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-&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, "color", 0.5, 0.0, 0.5, 1.0))) { // color name is used to auto-generate a solid colored object

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 

 // VERTICES

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

 PositionAppend(vertices, locations, 0, 8, x, y, z);

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

 

 // POSITION ATTRIBUTE

 [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::CreatePosition(gltf, numVertices, &amp;vertices[0]);

 

 // INDICES

 std::vector&lt;unsigned short&gt; indices;

 indices.push_back(0); indices.push_back(1); indices.push_back(3);

 indices.push_back(2);

 indices.push_back(7);

 indices.push_back(6);

 indices.push_back(4);

 indices.push_back(5);

 indices.push_back(0);

 indices.push_back(1);

 

 // INDEX

 [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, (unsigned int)indices.size(), &amp;indices[0]);

 

 // NORMALS

 std::vector&lt;float&gt; vertexNormals(3 * numVertices);

 {

 std::vector&lt;unsigned short&gt; indices;

 indices.push_back(0); indices.push_back(1); indices.push_back(3);

 indices.push_back(3); indices.push_back(1); indices.push_back(2);

 indices.push_back(3); indices.push_back(2); indices.push_back(7);

 indices.push_back(7); indices.push_back(2); indices.push_back(6);

 indices.push_back(7); indices.push_back(6); indices.push_back(4);

 indices.push_back(4); indices.push_back(6); indices.push_back(5);

 indices.push_back(4); indices.push_back(5); indices.push_back(0);

 indices.push_back(0); indices.push_back(5); indices.push_back(1);

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

 GLTFWriter::Utils::ComputeVertexNormals3(numVertices, &amp;vertices[0], numTriangles, 3, &amp;indices[0], &amp;vertexNormals[0]);

 }

 

 // NORMAL ATTRIBUTE

 [GLTFWriter::Attribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml) *normal = GLTFWriter::Attribute::CreateNormal(gltf, numVertices, &amp;vertexNormals[0]);

 

 // 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_TRIANGLE_STRIP, 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)(normal)) {

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 }

 

 x += 2;

 y -= 2;

 

 // TRIANGLE FAN

 {

 // 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, "Triangle Fan");

 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");

 }

 

 // 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 || !node-&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-&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, "color", 0.75, 0.0, 0.75, 1.0))) { // color name is used to auto-generate a solid colored object

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 

 // VERTICES

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

 PositionAppend(vertices, locations, 0, 4, x, y, z);

 PositionAppend(vertices, locations, 7, 1, x, y, z);

 PositionAppend(vertices, locations, 4, 2, x, y, z);

 PositionAppend(vertices, locations, 1, 1, x, y, z);

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

 

 // POSITION ATTRIBUTE

 [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::CreatePosition(gltf, (unsigned int)vertices.size() / 3, &amp;vertices[0]);

 

 // NORMALS

 std::vector&lt;float&gt; vertexNormals(3 * numVertices);

 {

 std::vector&lt;unsigned short&gt; indices;

 indices.push_back(0); indices.push_back(1); indices.push_back(2);

 indices.push_back(0); indices.push_back(2); indices.push_back(3);

 indices.push_back(0); indices.push_back(3); indices.push_back(4);

 indices.push_back(0); indices.push_back(4); indices.push_back(5);

 indices.push_back(0); indices.push_back(5); indices.push_back(6);

 indices.push_back(0); indices.push_back(6); indices.push_back(7);

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

 GLTFWriter::Utils::ComputeVertexNormals3(numVertices, &amp;vertices[0], numTriangles, 3, &amp;indices[0], &amp;vertexNormals[0]);

 }

 

 // NORMAL ATTRIBUTE

 [GLTFWriter::Attribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml) *normal = GLTFWriter::Attribute::CreateNormal(gltf, numVertices, &amp;vertexNormals[0]);

 

 // 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_TRIANGLE_FAN, material);

 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)(normal)) {

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 }

 

 y += 2;

 // INDEXED TRIANGLE FAN

 {

 // 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, "Indexed Triangle Fan");

 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");

 }

 

 // 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 || !node-&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-&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, "color", 0.25, 0.0, 0.25, 1.0))) { // color name is used to auto-generate a solid colored object

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 

 // VERTICES

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

 PositionAppend(vertices, locations, 0, 8, x, y, z);

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

 

 // POSITION ATTRIBUTE

 [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::CreatePosition(gltf, numVertices, &amp;vertices[0]);

 

 // INDICES

 std::vector&lt;unsigned short&gt; indices;

 indices.push_back(0); indices.push_back(1); indices.push_back(2);

 indices.push_back(3); 

 indices.push_back(7); 

 indices.push_back(4); 

 indices.push_back(5); 

 indices.push_back(1); 

 

 // INDEX

 [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, (unsigned int)indices.size(), &amp;indices[0]);

 

 // NORMALS

 std::vector&lt;float&gt; vertexNormals(3 * numVertices);

 {

 std::vector&lt;unsigned short&gt; indices;

 indices.push_back(0); indices.push_back(1); indices.push_back(2);

 indices.push_back(0); indices.push_back(2); indices.push_back(3);

 indices.push_back(0); indices.push_back(3); indices.push_back(7);

 indices.push_back(0); indices.push_back(7); indices.push_back(4);

 indices.push_back(0); indices.push_back(4); indices.push_back(5);

 indices.push_back(0); indices.push_back(5); indices.push_back(1);

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

 GLTFWriter::Utils::ComputeVertexNormals3(numVertices, &amp;vertices[0], numTriangles, 3, &amp;indices[0], &amp;vertexNormals[0]);

 }

 

 // NORMAL ATTRIBUTE

 [GLTFWriter::Attribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml) *normal = GLTFWriter::Attribute::CreateNormal(gltf, numVertices, &amp;vertexNormals[0]);

 

 // 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_TRIANGLE_FAN, 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)(normal)) {

 GLTFWriter::GLTF::Destroy(gltf);

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

 }

 }

 

 if (!gltf-&gt;<a id="a18" name="a18"></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="a19" name="a19"></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::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::Light](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_light.xhtml)

Lights define the light objects that can be added to a light node.

**Definition** [GLTFLight.h:31](_g_l_t_f_light_8h_source.xhtml#l00030)



[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::AppendLight](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a576db36280a02127b5eb662f0566543b)

virtual bool AppendLight(Light *light)=0



[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::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::SetLight](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_scene.xhtml#ac92acb916999693ccaaefe8a81962c67)

virtual bool SetLight(Node *light)=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