:orphan:

###########
glTF Reader
###########

.. rst-class:: format-title-block

+--------------------------------------------------------------------------+
|                        **gl Transmission Format**                        |
+-----------------------------------------+--------------------------------+
| **File Extension**                      | glTF, GLB                      |
+-----------------------------------------+--------------------------------+
| **Supported Versions**                  | Version 2.0 only               |
+-----------------------------------------+--------------------------------+
| **Platforms**                           | |wy| |ly| |my| |ay| |iy|       | 
+-----------------------------------------+--------------------------------+
| **Tessellation**                        | |t_green| Supported            | 
+-----------------------------------------+--------------------------------+
| :ref:`gltf_rd_brep`                     | |c_grey| Unsupported by format | 
+-----------------------------------------+--------------------------------+
| :ref:`gltf_rd_pmi`                      | |c_grey| Unsupported by format | 
+-----------------------------------------+--------------------------------+

glTF (GL Transmission Format) is an open standard for efficient transmission 
of 3D scenes and models, storing meshes, materials, textures, and scene hierarchy 
for visualization and rendering.

When read by HOOPS Exchange, glTF files provide access to tessellated 3D data and 
associated visualization information, including materials and textures as defined 
in the file.
CAD-specific data such as B-rep, PMI, and exact model definitions are unsupported 
by the format.

A file does not need to have a particular extension to be read correctly by 
HOOPS Exchange. 
However, the file extensions of glTF files that you can expect to be loaded by 
HOOPS Exchange include:

* `.gltf`
* `.glb`

.. note:: 
   
   Experimentally, Draco compressed glTF files are supported.

How to Import From glTF 
=======================

Reading ``glTF`` files follows the same pattern as other formats: configure load parameters, then call the standard load function.

To load a glTF file, use :cpp:func:`A3DAsmModelFileLoadFromFile`.
The :cpp:struct:`A3DParamsLoadData` structure is used to customize the loading behavior:

.. code-block:: c

   A3DAsmModelFile* pModelFile = 0;

   A3DRWParamsLoadData sReadParam = A3D_MAKE_DATA(A3DRWParamsLoadData);
   sReadParam.m_sGeneral.m_bReadSolids = true;

   // ... set other A3DRWParamsLoadData fields as necessary

   A3DAsmModelFileLoadFromFile("path/to/file.gltf", &sReadParam, &pModelFile);

See :doc:`/guide/basic_operations/load_model` for more about loading model files.

.. _gltf_rd_brep: 

Boundary Representation (B-rep)
===============================

Boundary Representation is unsupported by glTF.

.. _gltf_rd_pmi: 

Product and Manufacturing Information (PMI)
=======================================

Product and Manufacturing Information (PMI) is unsupported by glTF.

The detailed description of the material data format is included in the documentation of the :struct:`A3DGraphMaterialData` structure.

For more information about accessing textures and attributes, please read the documentation for the :struct:`A3DGlobalData`,
:struct:`A3DGraphMaterialData`,
:struct:`A3DGraphTextureApplicationData` and
:struct:`A3DMiscAttributeData` structures.

Assembly
========

This concept is unsupported by glTF.

Views
=====

Views are unsupported by glTF.

Physically-Based Rendering Material
===================================

As of version 2019, HOOPS Exchange supports physically based rendering (PBR) materials with :struct:`A3DGraphMaterialData` structure.
PBR related information are read from glTF formats.

Miscellaneous
=============

Supported
*********

* Version 2.0 files only (tinygltf limitation; only "asset" data is correctly parsed from 1.0 files)
* Vertex position, normal, color, texture coordinate sets 0 and 1
* Triangles
* Full texture support and material data: normal, occlusion, emissive
* Physically Based Rendering (PBR) textures and constants: base color, metallness, roughness
* Texture file formats: JPEG, PNG, BMP, GIF (handled by tinygltf)
* Cameras

Unsupported
***********

* Version 1.0 files
* Vertex tangents
* Animations
* Skins
* Extensions
* Shaders
* Sparse accessors (currently not supported by tinygltf)
* Byte-swapping for Big-Endian platforms

Limitations
***********

* Compressed .glb files are currently unsupported.
* Reading glTF is supported only on Windows, Linux, and MacOS platforms.
