GLVis  v4.2
Accurate and flexible finite element visualization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Types | Static Protected Member Functions | Protected Attributes | List of all members
glTF_Builder Class Reference

#include <gltf.hpp>

Collaboration diagram for glTF_Builder:
[legend]

Classes

struct  accessor_id
 
struct  buffer_id
 
struct  buffer_view_id
 
struct  image_id
 
struct  material_id
 
struct  mesh_id
 
struct  node_id
 
struct  node_type
 
struct  pbr_matallic_roughness
 
struct  sampler_id
 
struct  struct_accessor
 
struct  struct_attributes
 
struct  struct_buffer
 
struct  struct_buffer_view
 
struct  struct_image
 
struct  struct_material
 
struct  struct_mesh
 
struct  struct_node
 
struct  struct_pbrMetallicRoughness
 
struct  struct_primitive
 
struct  struct_sampler
 
struct  struct_texture
 
struct  struct_texture_info
 
struct  texture_id
 

Public Types

enum  target_type { target_type::ARRAY_BUFFER = 34962, target_type::ELEMENT_ARRAY_BUFFER = 34963 }
 
enum  component_type {
  component_type::BYTE = 5120, component_type::UNSIGNED_BYTE = 5121, component_type::SHORT = 5122, component_type::UNSIGNED_SHORT = 5123,
  component_type::UNSIGNED_INT = 5125, component_type::FLOAT = 5126
}
 
enum  tensor_type {
  tensor_type::SCALAR = 0, tensor_type::VEC2, tensor_type::VEC3, tensor_type::VEC4,
  tensor_type::MAT2, tensor_type::MAT3, tensor_type::MAT4
}
 
enum  mag_filter { mag_filter::NEAREST = 9728, mag_filter::LINEAR = 9729 }
 
enum  min_filter {
  min_filter::NEAREST = 9728, min_filter::LINEAR = 9729, min_filter::NEAREST_MIPMAP_NEAREST = 9984, min_filter::LINEAR_MIPMAP_NEAREST = 9985,
  min_filter::NEAREST_MIPMAP_LINEAR = 9986, min_filter::LINEAR_MIPMAP_LINEAR = 9987
}
 
enum  wrap_type { wrap_type::CLAMP_TO_EDGE = 33071, wrap_type::MIRRORED_REPEAT = 33648, wrap_type::REPEAT = 10497 }
 
typedef std::array< float, 2 > vec2f
 
typedef std::array< float, 3 > vec3f
 
typedef std::array< float, 4 > color4f
 
typedef std::vector< float > vecnf
 

Public Member Functions

 glTF_Builder (const std::string &filePrefix)
 
buffer_id addBuffer (const std::string &bufferName)
 
buffer_view_id addBufferView (buffer_id buffer, const void *data, size_t byteLength, size_t byteStride, size_t byteAlign, target_type target)
 
void appendToBufferView (buffer_view_id bufferView, const void *data, size_t byteLength)
 
accessor_id addAccessor (buffer_view_id bufferView, size_t byteOffset, component_type componentType, size_t count, tensor_type tensorType)
 
accessor_id addAccessorVec2f (buffer_view_id bufferView, size_t byteOffset, size_t count, vec2f min, vec2f max)
 
accessor_id addAccessorVec3f (buffer_view_id bufferView, size_t byteOffset, size_t count, vec3f min, vec3f max)
 
image_id addImage (const std::string &imageName, int width, int height, const color4f *pixels)
 
sampler_id addSampler (mag_filter magFilter=mag_filter::NEAREST, min_filter minFilter=min_filter::NEAREST, wrap_type wrapS=wrap_type::CLAMP_TO_EDGE, wrap_type wrapT=wrap_type::CLAMP_TO_EDGE)
 
texture_id addTexture (sampler_id sampler, image_id source)
 
material_id addMaterial (const std::string &materialName, const pbr_matallic_roughness &pbrMetallicRoughness, bool doubleSided=false)
 
mesh_id addMesh (const std::string &meshName)
 
void addMeshTriangles (mesh_id mesh, accessor_id vertexPositions, accessor_id vertexNormals, accessor_id vertexTexCoords0, accessor_id vertexIndices, material_id material)
 
void addMeshLines (mesh_id mesh, accessor_id vertexPositions, accessor_id vertexTexcoords0, accessor_id vertexColors0, material_id material)
 
node_id addNode (const std::string &nodeName)
 
void addNodeMesh (node_id node, mesh_id mesh)
 
void addNodeScale (node_id node, vec3f scale)
 
void addNodeTranslation (node_id node, vec3f translation)
 
void getMaterialPBRMR (material_id material, pbr_matallic_roughness &pbr_mr_copy)
 
int writeFile ()
 

Static Public Attributes

static constexpr unsigned INVALID_ID = std::numeric_limits<unsigned>::max()
 
static const char * tensorTypes []
 

Protected Types

typedef node_type< bool > node_bool
 
typedef node_type< unsigned > node_unsigned
 
typedef node_type< float > node_float
 
typedef node_type< std::string > node_string
 
typedef node_type< vec3fnode_vec3f
 
typedef node_type< color4fnode_color4f
 
typedef node_type< vecnfnode_vecnf
 

Static Protected Member Functions

static const char * sep (size_t i)
 
template<typename T >
static void print_node (std::ostream &out, int &pfx_counter, const std::string &pfx, const node_type< T > &n)
 
static void print (std::ostream &out, const bool &v)
 
static void print (std::ostream &out, const unsigned &v)
 
static void print (std::ostream &out, const float &v)
 
static void print (std::ostream &out, const std::string &v)
 
template<typename T , size_t s>
static void print (std::ostream &out, const std::array< T, s > &v)
 
template<typename T >
static void print (std::ostream &out, const std::vector< T > &v)
 
static void print (std::ostream &out, const struct_attributes &a)
 
static void print (std::ostream &out, const struct_texture_info &ti)
 
static void print (std::ostream &out, const struct_pbrMetallicRoughness &pbr)
 

Protected Attributes

const std::string file_prefix
 
std::vector< struct_bufferbuffers
 
std::vector< struct_buffer_viewbuffer_views
 
std::vector< struct_accessoraccessors
 
std::vector< struct_imageimages
 
std::vector< struct_samplersamplers
 
std::vector< struct_texturetextures
 
std::vector< struct_materialmaterials
 
std::vector< struct_meshmeshes
 
std::vector< struct_nodenodes
 

Detailed Description

Definition at line 24 of file gltf.hpp.

Member Typedef Documentation

typedef std::array<float,4> glTF_Builder::color4f

Definition at line 29 of file gltf.hpp.

typedef node_type<bool> glTF_Builder::node_bool
protected

Definition at line 41 of file gltf.hpp.

Definition at line 46 of file gltf.hpp.

typedef node_type<float> glTF_Builder::node_float
protected

Definition at line 43 of file gltf.hpp.

typedef node_type<std::string> glTF_Builder::node_string
protected

Definition at line 44 of file gltf.hpp.

typedef node_type<unsigned> glTF_Builder::node_unsigned
protected

Definition at line 42 of file gltf.hpp.

Definition at line 45 of file gltf.hpp.

Definition at line 47 of file gltf.hpp.

typedef std::array<float,2> glTF_Builder::vec2f

Definition at line 27 of file gltf.hpp.

typedef std::array<float,3> glTF_Builder::vec3f

Definition at line 28 of file gltf.hpp.

typedef std::vector<float> glTF_Builder::vecnf

Definition at line 30 of file gltf.hpp.

Member Enumeration Documentation

Enumerator
BYTE 
UNSIGNED_BYTE 
SHORT 
UNSIGNED_SHORT 
UNSIGNED_INT 
FLOAT 

Definition at line 237 of file gltf.hpp.

Enumerator
NEAREST 
LINEAR 

Definition at line 255 of file gltf.hpp.

Enumerator
NEAREST 
LINEAR 
NEAREST_MIPMAP_NEAREST 
LINEAR_MIPMAP_NEAREST 
NEAREST_MIPMAP_LINEAR 
LINEAR_MIPMAP_LINEAR 

Definition at line 257 of file gltf.hpp.

Enumerator
ARRAY_BUFFER 
ELEMENT_ARRAY_BUFFER 

Definition at line 230 of file gltf.hpp.

Enumerator
SCALAR 
VEC2 
VEC3 
VEC4 
MAT2 
MAT3 
MAT4 

Definition at line 247 of file gltf.hpp.

Enumerator
CLAMP_TO_EDGE 
MIRRORED_REPEAT 
REPEAT 

Definition at line 264 of file gltf.hpp.

Constructor & Destructor Documentation

glTF_Builder::glTF_Builder ( const std::string &  filePrefix)
inline

Definition at line 279 of file gltf.hpp.

Member Function Documentation

glTF_Builder::accessor_id glTF_Builder::addAccessor ( buffer_view_id  bufferView,
size_t  byteOffset,
component_type  componentType,
size_t  count,
tensor_type  tensorType 
)

Definition at line 97 of file gltf.cpp.

glTF_Builder::accessor_id glTF_Builder::addAccessorVec2f ( buffer_view_id  bufferView,
size_t  byteOffset,
size_t  count,
vec2f  min,
vec2f  max 
)

Definition at line 140 of file gltf.cpp.

glTF_Builder::accessor_id glTF_Builder::addAccessorVec3f ( buffer_view_id  bufferView,
size_t  byteOffset,
size_t  count,
vec3f  min,
vec3f  max 
)

Definition at line 165 of file gltf.cpp.

glTF_Builder::buffer_id glTF_Builder::addBuffer ( const std::string &  bufferName)

Definition at line 24 of file gltf.cpp.

glTF_Builder::buffer_view_id glTF_Builder::addBufferView ( buffer_id  buffer,
const void *  data,
size_t  byteLength,
size_t  byteStride,
size_t  byteAlign,
target_type  target 
)

Definition at line 38 of file gltf.cpp.

glTF_Builder::image_id glTF_Builder::addImage ( const std::string &  imageName,
int  width,
int  height,
const color4f pixels 
)

Definition at line 190 of file gltf.cpp.

glTF_Builder::material_id glTF_Builder::addMaterial ( const std::string &  materialName,
const pbr_matallic_roughness pbrMetallicRoughness,
bool  doubleSided = false 
)

Definition at line 276 of file gltf.cpp.

glTF_Builder::mesh_id glTF_Builder::addMesh ( const std::string &  meshName)

Definition at line 322 of file gltf.cpp.

void glTF_Builder::addMeshLines ( mesh_id  mesh,
accessor_id  vertexPositions,
accessor_id  vertexTexcoords0,
accessor_id  vertexColors0,
material_id  material 
)

Definition at line 379 of file gltf.cpp.

void glTF_Builder::addMeshTriangles ( mesh_id  mesh,
accessor_id  vertexPositions,
accessor_id  vertexNormals,
accessor_id  vertexTexCoords0,
accessor_id  vertexIndices,
material_id  material 
)

Definition at line 333 of file gltf.cpp.

glTF_Builder::node_id glTF_Builder::addNode ( const std::string &  nodeName)

Definition at line 422 of file gltf.cpp.

void glTF_Builder::addNodeMesh ( node_id  node,
mesh_id  mesh 
)

Definition at line 433 of file gltf.cpp.

void glTF_Builder::addNodeScale ( node_id  node,
vec3f  scale 
)

Definition at line 441 of file gltf.cpp.

void glTF_Builder::addNodeTranslation ( node_id  node,
vec3f  translation 
)

Definition at line 449 of file gltf.cpp.

Definition at line 232 of file gltf.cpp.

glTF_Builder::texture_id glTF_Builder::addTexture ( sampler_id  sampler,
image_id  source 
)

Definition at line 256 of file gltf.cpp.

void glTF_Builder::appendToBufferView ( buffer_view_id  bufferView,
const void *  data,
size_t  byteLength 
)

Definition at line 81 of file gltf.cpp.

void glTF_Builder::getMaterialPBRMR ( material_id  material,
pbr_matallic_roughness pbr_mr_copy 
)

Definition at line 457 of file gltf.cpp.

static void glTF_Builder::print ( std::ostream &  out,
const bool &  v 
)
inlinestaticprotected

Definition at line 156 of file gltf.hpp.

static void glTF_Builder::print ( std::ostream &  out,
const unsigned &  v 
)
inlinestaticprotected

Definition at line 157 of file gltf.hpp.

static void glTF_Builder::print ( std::ostream &  out,
const float &  v 
)
inlinestaticprotected

Definition at line 158 of file gltf.hpp.

static void glTF_Builder::print ( std::ostream &  out,
const std::string &  v 
)
inlinestaticprotected

Definition at line 159 of file gltf.hpp.

template<typename T , size_t s>
static void glTF_Builder::print ( std::ostream &  out,
const std::array< T, s > &  v 
)
inlinestaticprotected

Definition at line 162 of file gltf.hpp.

template<typename T >
static void glTF_Builder::print ( std::ostream &  out,
const std::vector< T > &  v 
)
inlinestaticprotected

Definition at line 169 of file gltf.hpp.

static void glTF_Builder::print ( std::ostream &  out,
const struct_attributes a 
)
inlinestaticprotected

Definition at line 175 of file gltf.hpp.

static void glTF_Builder::print ( std::ostream &  out,
const struct_texture_info ti 
)
inlinestaticprotected

Definition at line 185 of file gltf.hpp.

static void glTF_Builder::print ( std::ostream &  out,
const struct_pbrMetallicRoughness pbr 
)
inlinestaticprotected

Definition at line 193 of file gltf.hpp.

template<typename T >
static void glTF_Builder::print_node ( std::ostream &  out,
int &  pfx_counter,
const std::string &  pfx,
const node_type< T > &  n 
)
inlinestaticprotected

Definition at line 144 of file gltf.hpp.

static const char* glTF_Builder::sep ( size_t  i)
inlinestaticprotected

Definition at line 142 of file gltf.hpp.

int glTF_Builder::writeFile ( )

Definition at line 472 of file gltf.cpp.

Member Data Documentation

std::vector<struct_accessor> glTF_Builder::accessors
protected

Definition at line 209 of file gltf.hpp.

std::vector<struct_buffer_view> glTF_Builder::buffer_views
protected

Definition at line 208 of file gltf.hpp.

std::vector<struct_buffer> glTF_Builder::buffers
protected

Definition at line 207 of file gltf.hpp.

const std::string glTF_Builder::file_prefix
protected

Definition at line 205 of file gltf.hpp.

std::vector<struct_image> glTF_Builder::images
protected

Definition at line 210 of file gltf.hpp.

constexpr unsigned glTF_Builder::INVALID_ID = std::numeric_limits<unsigned>::max()
static

Definition at line 218 of file gltf.hpp.

std::vector<struct_material> glTF_Builder::materials
protected

Definition at line 213 of file gltf.hpp.

std::vector<struct_mesh> glTF_Builder::meshes
protected

Definition at line 214 of file gltf.hpp.

std::vector<struct_node> glTF_Builder::nodes
protected

Definition at line 215 of file gltf.hpp.

std::vector<struct_sampler> glTF_Builder::samplers
protected

Definition at line 211 of file gltf.hpp.

const char * glTF_Builder::tensorTypes
static
Initial value:
=
{
"SCALAR", "VEC2", "VEC3", "VEC4", "MAT2", "MAT3", "MAT4"
}

Definition at line 252 of file gltf.hpp.

std::vector<struct_texture> glTF_Builder::textures
protected

Definition at line 212 of file gltf.hpp.


The documentation for this class was generated from the following files: