    

 ## On this page

  

 

 # GLTFUtils

 Last update: 16.07.2025 

<a id="l00001" name="l00001"></a> 1/\*

<a id="l00002" name="l00002"></a> 2 \* Copyright 2018-2021 ANSYS, Inc. Unauthorized use, distribution, or duplication is prohibited.

<a id="l00003" name="l00003"></a> 3 \* 

<a id="l00004" name="l00004"></a> 4 \* Restricted Rights Legend

<a id="l00005" name="l00005"></a> 5 \*

<a id="l00006" name="l00006"></a> 6 \* Use, duplication, or disclosure of this

<a id="l00007" name="l00007"></a> 7 \* software and its documentation by the

<a id="l00008" name="l00008"></a> 8 \* Government is subject to restrictions as

<a id="l00009" name="l00009"></a> 9 \* set forth in subdivision \[(b)(3)(ii)\] of

<a id="l00010" name="l00010"></a> 10 \* the Rights in Technical Data and Computer

<a id="l00011" name="l00011"></a> 11 \* Software clause at 52.227-7013.

<a id="l00012" name="l00012"></a> 12 \*/

<a id="l00013" name="l00013"></a> 13\#ifndef \_\_INCLUDED\_GLTF\_GLTFUTILS\_\_

<a id="l00014" name="l00014"></a> 14\#define \_\_INCLUDED\_GLTF\_GLTFUTILS\_\_

<a id="l00015" name="l00015"></a> 15 

<a id="l00016" name="l00016"></a> 16\#include "GLTFCommon.h"

<a id="l00017" name="l00017"></a> 17 

<a id="l00018" name="l00018"></a> 18namespace [ANSYS](namespace_a_n_s_y_s.html) { namespace AVZ { namespace GLTFWriter {

<a id="l00022" name="l00022"></a>[ 22](namespace_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils.html) namespace Utils {

<a id="l00025" name="l00025"></a>[ 25](namespace_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils.html#a0577a4549c5f1819d12668849229a6dc) GLTFWRITERSPEC void [ComputeElementNormals3](namespace_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils.html#a0577a4549c5f1819d12668849229a6dc)(const unsigned int numVertices, 

<a id="l00026" name="l00026"></a> 26 const float *vertices, 

<a id="l00027" name="l00027"></a> 27 const unsigned int numElements, 

<a id="l00028" name="l00028"></a> 28 const unsigned int elementSize, 

<a id="l00029" name="l00029"></a> 29 const unsigned short *indices, 

<a id="l00030" name="l00030"></a> 30 float *normals 

<a id="l00031" name="l00031"></a> 31 );

<a id="l00034" name="l00034"></a>[ 34](namespace_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils.html#acb2012b094a30a5b6c1df2fa55b5f4d1) GLTFWRITERSPEC void [ComputeElementNormals3](namespace_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils.html#a0577a4549c5f1819d12668849229a6dc)(const unsigned int numVertices, 

<a id="l00035" name="l00035"></a> 35 const float *vertices, 

<a id="l00036" name="l00036"></a> 36 const unsigned int numElements, 

<a id="l00037" name="l00037"></a> 37 const unsigned int elementSize, 

<a id="l00038" name="l00038"></a> 38 const unsigned int *indices, 

<a id="l00039" name="l00039"></a> 39 float *normals 

<a id="l00040" name="l00040"></a> 40 );

<a id="l00041" name="l00041"></a> 41 

<a id="l00045" name="l00045"></a>[ 45](namespace_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils.html#afa344d6cb377a0f47fe35f3bb82343f7) GLTFWRITERSPEC void [ComputeVertexNormals3](namespace_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils.html#afa344d6cb377a0f47fe35f3bb82343f7)(const unsigned int numVertices, 

<a id="l00046" name="l00046"></a> 46 const float *vertices, 

<a id="l00047" name="l00047"></a> 47 const unsigned int numElements, 

<a id="l00048" name="l00048"></a> 48 const unsigned int elementSize, 

<a id="l00049" name="l00049"></a> 49 const unsigned short *indices, 

<a id="l00050" name="l00050"></a> 50 float *normals 

<a id="l00051" name="l00051"></a> 51 );

<a id="l00055" name="l00055"></a>[ 55](namespace_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils.html#aa5e70ea966a4606e34c640e4ed1e0815) GLTFWRITERSPEC void [ComputeVertexNormals3](namespace_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils.html#afa344d6cb377a0f47fe35f3bb82343f7)(const unsigned int numVertices, 

<a id="l00056" name="l00056"></a> 56 const float *vertices, 

<a id="l00057" name="l00057"></a> 57 const unsigned int numElements, 

<a id="l00058" name="l00058"></a> 58 const unsigned int elementSize, 

<a id="l00059" name="l00059"></a> 59 const unsigned int *indices, 

<a id="l00060" name="l00060"></a> 60 float *normals 

<a id="l00061" name="l00061"></a> 61 );

<a id="l00062" name="l00062"></a> 62 

<a id="l00063" name="l00063"></a> 63\#if 0

<a id="l00066" name="l00066"></a> 66 GLTFWRITERSPEC unsigned int CreateVectors(unsigned int resolution, 

<a id="l00067" name="l00067"></a> 67 float offset, 

<a id="l00068" name="l00068"></a> 68 unsigned int numLocations, 

<a id="l00069" name="l00069"></a> 69 const float *locations, 

<a id="l00070" name="l00070"></a> 70 const float *lengths, 

<a id="l00071" name="l00071"></a> 71 const float *directions, 

<a id="l00072" name="l00072"></a> 72 std::vector&lt;float&gt; &amp;vertices, 

<a id="l00073" name="l00073"></a> 73 std::vector&lt;unsigned int&gt; &amp;indices, 

<a id="l00074" name="l00074"></a> 74 std::vector&lt;unsigned int&gt; &amp;newToOld 

<a id="l00075" name="l00075"></a> 75 );

<a id="l00077" name="l00077"></a> 77 GLTFWRITERSPEC void CreateStreamTubes(unsigned int resolution, 

<a id="l00078" name="l00078"></a> 78 float diameter, 

<a id="l00079" name="l00079"></a> 79 unsigned int numLines, 

<a id="l00080" name="l00080"></a> 80 const unsigned int *lineLengths, 

<a id="l00081" name="l00081"></a> 81 const float *locations, 

<a id="l00082" name="l00082"></a> 82 std::vector&lt;float&gt; &amp;vertices, 

<a id="l00083" name="l00083"></a> 83 std::vector&lt;unsigned int&gt; &amp;indices, 

<a id="l00084" name="l00084"></a> 84 std::vector&lt;unsigned int&gt; &amp;newToOld 

<a id="l00085" name="l00085"></a> 85 );

<a id="l00086" name="l00086"></a> 86\#endif

<a id="l00087" name="l00087"></a> 87 

<a id="l00105" name="l00105"></a>[ 105](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.html) class [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.html) 

<a id="l00106" name="l00106"></a> 106 {

<a id="l00107" name="l00107"></a> 107 protected:

<a id="l00108" name="l00108"></a> 108 virtual [~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.html)() {}

<a id="l00109" name="l00109"></a> 109 

<a id="l00110" name="l00110"></a> 110 public:

<a id="l00112" name="l00112"></a>[ 112](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.html#aac5034c27c24bb12676c465abf4163ab) static GLTFWRITERSPEC [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.html) *[Create](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.html#aac5034c27c24bb12676c465abf4163ab)(unsigned int elementCount, 

<a id="l00113" name="l00113"></a> 113 unsigned int elementSize, 

<a id="l00114" name="l00114"></a> 114 const unsigned int *indices 

<a id="l00115" name="l00115"></a> 115 );

<a id="l00117" name="l00117"></a>[ 117](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.html#ad07982f15ab3f57fd454d7e2c7f621a0) static GLTFWRITERSPEC void [Destroy](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.html#ad07982f15ab3f57fd454d7e2c7f621a0)([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.html) *packer);

<a id="l00118" name="l00118"></a> 118 

<a id="l00121" name="l00121"></a>[ 121](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.html#a69a383562c62ca71c8a785c96f773fb3) GLTFWRITERSPEC virtual unsigned int [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.html#a69a383562c62ca71c8a785c96f773fb3)() const = 0;

<a id="l00123" name="l00123"></a>[ 123](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.html#a43a74d90484a85856103c33969eb7107) GLTFWRITERSPEC virtual unsigned int [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.html#a43a74d90484a85856103c33969eb7107)(unsigned int packNum 

<a id="l00124" name="l00124"></a> 124 ) const = 0;

<a id="l00127" name="l00127"></a>[ 127](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.html#a1487b86e5090019cf7565e144fe11e4f) GLTFWRITERSPEC virtual const int *[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.html#a1487b86e5090019cf7565e144fe11e4f)(const unsigned int *indices, 

<a id="l00128" name="l00128"></a> 128 unsigned int attributeSize, 

<a id="l00129" name="l00129"></a> 129 const int *attributeData, 

<a id="l00130" name="l00130"></a> 130 unsigned int packNum 

<a id="l00131" name="l00131"></a> 131 ) = 0;

<a id="l00134" name="l00134"></a>[ 134](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.html#ad414f449c9db7ed809688409ca2481d1) GLTFWRITERSPEC virtual const float *[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.html#ad414f449c9db7ed809688409ca2481d1)(const unsigned int *indices, 

<a id="l00135" name="l00135"></a> 135 unsigned int attributeSize, 

<a id="l00136" name="l00136"></a> 136 const float *attributeData, 

<a id="l00137" name="l00137"></a> 137 unsigned int packNum 

<a id="l00138" name="l00138"></a> 138 ) = 0;

<a id="l00141" name="l00141"></a>[ 141](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.html#a50e2eaf986369c115fe9cae008187cc0) GLTFWRITERSPEC virtual unsigned int [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.html#a50e2eaf986369c115fe9cae008187cc0)(unsigned int packNum 

<a id="l00142" name="l00142"></a> 142 ) const = 0;

<a id="l00145" name="l00145"></a>[ 145](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.html#ab3bd7bca7382f17a0c08e144b67d22f2) GLTFWRITERSPEC virtual const unsigned short *[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.html#ab3bd7bca7382f17a0c08e144b67d22f2)(const unsigned int *indices, 

<a id="l00146" name="l00146"></a> 146 unsigned int packNum 

<a id="l00147" name="l00147"></a> 147 ) = 0;

<a id="l00148" name="l00148"></a> 148 };



<a id="l00149" name="l00149"></a> 149 };



<a id="l00150" name="l00150"></a> 150 

<a id="l00151" name="l00151"></a> 151} } } 

<a id="l00152" name="l00152"></a> 152 

<a id="l00153" name="l00153"></a> 153\#endif

[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.html)

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

**Definition** [GLTFUtils.h:106](#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.html#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.html#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.html#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.html#a69a383562c62ca71c8a785c96f773fb3)

virtual unsigned int NumPacks() const =0



[ANSYS::AVZ::GLTFWriter::Utils::Repack::Create](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.html#aac5034c27c24bb12676c465abf4163ab)

static Repack * Create(unsigned int elementCount, unsigned int elementSize, const unsigned int *indices)



[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.html#ab3bd7bca7382f17a0c08e144b67d22f2)

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



[ANSYS::AVZ::GLTFWriter::Utils::Repack::Destroy](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils_1_1_repack.html#ad07982f15ab3f57fd454d7e2c7f621a0)

static void Destroy(Repack *packer)



[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.html#ad414f449c9db7ed809688409ca2481d1)

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



[ANSYS::AVZ::GLTFWriter::Utils::ComputeElementNormals3](namespace_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils.html#a0577a4549c5f1819d12668849229a6dc)

void ComputeElementNormals3(const unsigned int numVertices, const float *vertices, const unsigned int numElements, const unsigned int elementSize, const unsigned short *indices, float *normals)



[ANSYS::AVZ::GLTFWriter::Utils::ComputeVertexNormals3](namespace_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_utils.html#afa344d6cb377a0f47fe35f3bb82343f7)

void ComputeVertexNormals3(const unsigned int numVertices, const float *vertices, const unsigned int numElements, const unsigned int elementSize, const unsigned short *indices, float *normals)



[ANSYS](namespace_a_n_s_y_s.html)

GLTFWriter API Documentation.

**Definition** [GLTFAnimation.h:19](_g_l_t_f_animation_8h_source.html#l00019)