1#ifndef __JBXL_CPP_GLTF_TOOL_H_
2#define __JBXL_CPP_GLTF_TOOL_H_
24#define JBXL_GLTF_COPYRIGHT "glTF/glb"
25#define JBXL_GLTF_GENERATOR "JBXL glTF/glb Tool Library (C) 2024 v1.0 by Fumi.Iseki and Austin Tate"
26#define JBXL_GLTF_VERSION "2.0"
28#define JBXL_GLB_HEADER "glTF"
29#define JBXL_GLB_VERSION 2.0
30#define JBXL_GLB_TYPE_JSON "JSON"
31#define JBXL_GLB_TYPE_BIN "BIN\0"
33#define JBXL_GLTF_BIN_AOS 1
34#define JBXL_GLTF_BIN_SOA 2
38#define JBXL_GLB_ACCESSORS_PNG_IMAGE "{\"bufferView\":%d,\"mimeType\":\"image/png\"}"
39#define JBXL_GLB_ACCESSORS_JPEG_IMAGE "{\"bufferView\":%d,\"mimeType\":\"image/jpeg\"}"
41#define JBXL_GLTF_BUFFERS_BIN "{\"uri\":\"%s\",\"byteLength\":%u}"
42#define JBXL_GLTF_BUFFERS_B64 "{\"uri\":\"data:application/octet-stream;base64,%s\",\"byteLength\":%u}"
44#define JBXL_GLTF_VIEWS "{\"buffer\":%d,\"byteOffset\":%u,\"byteLength\":%u,\"byteStride\":%u,\"target\":34962}"
45#define JBXL_GLTF_VIEWS_ELEMENT "{\"buffer\":%d,\"byteOffset\":%u,\"byteLength\":%u,\"target\":34963}"
47#define JBXL_GLTF_VIEWS_DATA "{\"buffer\":%d,\"byteOffset\":%u,\"byteLength\":%u}"
49#define JBXL_GLTF_ACCESSORS "{\"bufferView\":%d,\"byteOffset\":%u,\"componentType\":%d,\"count\":%d,\"type\":\"%s\"}"
50#define JBXL_GLTF_ACCESSORS_S "{\"bufferView\":%d,\"byteOffset\":%u,\"componentType\":%d,\"count\":%d,\"type\":\"%s\",\"max\":[%d],\"min\":[%d]}"
51#define JBXL_GLTF_ACCESSORS_V2 "{\"bufferView\":%d,\"byteOffset\":%u,\"componentType\":%d,\"count\":%d,\"type\":\"%s\",\"max\":[%f,%f],\"min\":[%f,%f]}"
52#define JBXL_GLTF_ACCESSORS_V3 "{\"bufferView\":%d,\"byteOffset\":%u,\"componentType\":%d,\"count\":%d,\"type\":\"%s\",\"max\":[%f,%f,%f],\"min\":[%f,%f,%f]}"
54#define JBXL_GLTF_NODES_ROOT "{\"name\":\"Root\"}"
55#define JBXL_GLTF_NODES_ARMATURE "{\"name\":\"Armature\"}"
56#define JBXL_GLTF_NODES_MESH "{\"name\":\"%s\",\"mesh\":%d}"
57#define JBXL_GLTF_NODES_SKIN "{\"skin\":%d}"
58#define JBXL_GLTF_NODES_SKLTN "{\"name\":%s}"
60#define JBXL_GLTF_MESHES_PRIM "{\"indices\":%d,\"attributes\":{\"POSITION\":%d,\"NORMAL\":%d,\"TEXCOORD_0\":%d},\"material\":%d,\"mode\":4}"
61#define JBXL_GLTF_MESHES_PRIM_JW "{\"indices\":%d,\"attributes\":{\"POSITION\":%d,\"NORMAL\":%d,\"TEXCOORD_0\":%d,\"JOINTS_0\":%d,\"WEIGHTS_0\":%d},\"material\":%d,\"mode\":4}"
62#define JBXL_GLTF_SKINS "{\"inverseBindMatrices\":%d,\"skeleton\":%d}"
65#define JBXL_GLTF_TEXTURES "{\"source\":%d}"
67#define JBXL_GLTF_IMAGES "{\"uri\":\"%s\"}"
69#define JBXL_GLTF_MTLS_NAME_PBR "{\"name\":\"%s\",\"pbrMetallicRoughness\":{\"baseColorTexture\":{\"index\":%d,\"texCoord\":0}}}"
70#define JBXL_GLTF_MTLS_BCOLORF "{\"baseColorFactor\":[%f,%f,%f,%f]}"
71#define JBXL_GLTF_MTLS_METALF "{\"metallicFactor\":%f}"
72#define JBXL_GLTF_MTLS_ROUGHF "{\"roughnessFactor\":%f}"
74#define JBXL_GLTF_MTLS_CUTOFF "{\"alphaCutoff\":%f}"
75#define JBXL_GLTF_MTLS_EMISSIVE "{\"emissiveFactor\":[%f,%f,%f]}"
79typedef struct _gltf_facet_min_max {
101typedef struct _glb_file_header {
108typedef struct _glb_data_chunk {
116typedef struct _glb_texture_info {
121 struct _glb_texture_info*
next;
247 void setUE(
bool b) { this->forUE = b;}
290 void outputFile (
const char* fn,
const char* out_dirn,
const char* tex_dirn,
const char* bin_dirn);
291 void output_gltf(
char* fn,
char* out_dirn,
char* tex_dirn,
char* bin_dirn);
292 void output_glb (
char* fn,
char* out_dirn,
char* tex_dirn,
char* bin_dirn);
三角Contour(Facet)用ライブラリ ヘッダ for BREP
void addRootNode(AffineTrans< double > *affine)
void createBinDataSeqSoA(MeshFacetNode *facet, int shell_indexes, int shell_vertexes)
GLTFShellNode * shellNode
void addShell(MeshObjectData *meshdata, bool collider, SkinJointData *skin_joint=NULL, tList *joints_info=NULL)
AffineTrans< double > affineRoot
glbTextureInfo * getGLBTextureInfo(const char *tex_dirn)
void freeGLBTextureInfo(glbTextureInfo *tex_info)
void addMeshes(MeshFacetNode *facet)
AffineTrans< double > getAffineBaseTrans4Engine(void)
void execAffineUVMap(MeshFacetNode *facet, AffineTrans< double > *affine)
void addAccessorsAoS(MeshFacetNode *facet)
uDWord convertJson_gltf2glb(glbTextureInfo *tex_info)
void createBinDataAoS(void)
void addAccessorsSoA(MeshFacetNode *facet)
void createBinDataIBM(SkinJointData *skin_joint, AffineTrans< double > *ue_trans=NULL)
gltfFacetMinMax getFacetMinMax(MeshFacetNode *facet)
void convertJson_TexturePath(char *tex_dirn)
unsigned int mesh_prim_no
void outputFile(const char *fn, const char *out_dirn, const char *tex_dirn, const char *bin_dirn)
void addMaterials(MeshFacetNode *facet)
void createShellGeometryData(MeshFacetNode *facet, int shell_indexes, int shell_vertexes, SkinJointData *skin_joint=NULL, AffineTrans< double > *ue_trans=NULL)
void addTextures(MeshFacetNode *facet)
void addMaterialParameters(tJson *pbr, MeshFacetNode *facet)
unsigned int joint_offset
void addBufferViewsIBM(void)
void addBufferViewsSoA(MeshFacetNode *facet)
void createBinDataSoA(void)
void output_glb(char *fn, char *out_dirn, char *tex_dirn, char *bin_dirn)
void createBinDataSeqAoS(MeshFacetNode *facet, int shell_indexes, int shell_vertexes)
void addNodes(AffineTrans< double > *affine)
void addBufferViewsAoS(MeshFacetNode *facet)
void addAccessorsIBM(void)
void addSkeletonNodes(SkinJointData *skin_joint, AffineTrans< double > *affin)
void output_gltf(char *fn, char *out_dirn, char *tex_dirn, char *bin_dirn)
unsigned int shell_vertexes
unsigned int shell_indexes
unsigned int * facet_index
Vector4< short unsigned > * vj
unsigned int * facet_vertex
virtual ~GLTFShellNode(void)
MeshObject の Polygonデータ(1面)を格納するクラス.リスト構造を取る.
void freeGLTFData(GLTFData *gltf)
struct _glb_texture_info * next