refactor: move native types to own header, add methods for create/destroy material instance, add priority/layer to load_glb_from_buffer
This commit is contained in:
102
thermion_dart/native/include/APIBoundaryTypes.h
Normal file
102
thermion_dart/native/include/APIBoundaryTypes.h
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef int32_t EntityId;
|
||||||
|
typedef int32_t _ManipulatorMode;
|
||||||
|
typedef struct CameraPtr CameraPtr;
|
||||||
|
typedef struct TMaterialInstance TMaterialInstance;
|
||||||
|
|
||||||
|
struct TMaterialKey {
|
||||||
|
bool doubleSided = 1;
|
||||||
|
bool unlit = 1;
|
||||||
|
bool hasVertexColors = 1;
|
||||||
|
bool hasBaseColorTexture = 1;
|
||||||
|
bool hasNormalTexture = 1;
|
||||||
|
bool hasOcclusionTexture = 1;
|
||||||
|
bool hasEmissiveTexture = 1;
|
||||||
|
bool useSpecularGlossiness = 1;
|
||||||
|
int alphaMode = 4;
|
||||||
|
bool enableDiagnostics = 4;
|
||||||
|
union {
|
||||||
|
#ifdef __cplusplus
|
||||||
|
struct {
|
||||||
|
bool hasMetallicRoughnessTexture;
|
||||||
|
uint8_t metallicRoughnessUV;
|
||||||
|
};
|
||||||
|
struct {
|
||||||
|
bool hasSpecularGlossinessTexture;
|
||||||
|
uint8_t specularGlossinessUV;
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
struct {
|
||||||
|
bool hasMetallicRoughnessTexture = 1;
|
||||||
|
uint8_t metallicRoughnessUV = 7;
|
||||||
|
};
|
||||||
|
struct {
|
||||||
|
bool hasSpecularGlossinessTexture = 1;
|
||||||
|
uint8_t specularGlossinessUV = 7;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
uint8_t baseColorUV;
|
||||||
|
// -- 32 bit boundary --
|
||||||
|
bool hasClearCoatTexture = 1;
|
||||||
|
uint8_t clearCoatUV = 7;
|
||||||
|
bool hasClearCoatRoughnessTexture = 1;
|
||||||
|
uint8_t clearCoatRoughnessUV = 7;
|
||||||
|
bool hasClearCoatNormalTexture = 1;
|
||||||
|
uint8_t clearCoatNormalUV = 7;
|
||||||
|
bool hasClearCoat = 1;
|
||||||
|
bool hasTransmission = 1;
|
||||||
|
bool hasTextureTransforms = 6;
|
||||||
|
// -- 32 bit boundary --
|
||||||
|
uint8_t emissiveUV;
|
||||||
|
uint8_t aoUV;
|
||||||
|
uint8_t normalUV;
|
||||||
|
bool hasTransmissionTexture = 1;
|
||||||
|
uint8_t transmissionUV = 7;
|
||||||
|
// -- 32 bit boundary --
|
||||||
|
bool hasSheenColorTexture = 1;
|
||||||
|
uint8_t sheenColorUV = 7;
|
||||||
|
bool hasSheenRoughnessTexture = 1;
|
||||||
|
uint8_t sheenRoughnessUV = 7;
|
||||||
|
bool hasVolumeThicknessTexture = 1;
|
||||||
|
uint8_t volumeThicknessUV = 7;
|
||||||
|
bool hasSheen = 1;
|
||||||
|
bool hasIOR = 1;
|
||||||
|
bool hasVolume = 1;
|
||||||
|
} ;
|
||||||
|
typedef struct TMaterialKey TMaterialKey;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
float w;
|
||||||
|
} float4;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
double col1[4];
|
||||||
|
double col2[4];
|
||||||
|
double col3[4];
|
||||||
|
double col4[4];
|
||||||
|
} double4x4;
|
||||||
|
|
||||||
|
struct Aabb2 {
|
||||||
|
float minX;
|
||||||
|
float minY;
|
||||||
|
float maxX;
|
||||||
|
float maxY;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct Aabb2 Aabb2;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -46,33 +46,14 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "APIBoundaryTypes.h"
|
||||||
#include "ResourceBuffer.hpp"
|
#include "ResourceBuffer.hpp"
|
||||||
#include "Aabb2.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef int32_t EntityId;
|
|
||||||
typedef int32_t _ManipulatorMode;
|
|
||||||
typedef struct CameraPtr CameraPtr;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
float x;
|
|
||||||
float y;
|
|
||||||
float z;
|
|
||||||
float w;
|
|
||||||
} float4;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
double col1[4];
|
|
||||||
double col2[4];
|
|
||||||
double col3[4];
|
|
||||||
double col4[4];
|
|
||||||
} double4x4;
|
|
||||||
|
|
||||||
EMSCRIPTEN_KEEPALIVE const void *create_filament_viewer(const void *const context, const void *const loader, void *const platform, const char *uberArchivePath);
|
EMSCRIPTEN_KEEPALIVE const void *create_filament_viewer(const void *const context, const void *const loader, void *const platform, const char *uberArchivePath);
|
||||||
EMSCRIPTEN_KEEPALIVE void destroy_filament_viewer(const void *const viewer);
|
EMSCRIPTEN_KEEPALIVE void destroy_filament_viewer(const void *const viewer);
|
||||||
EMSCRIPTEN_KEEPALIVE void *get_scene_manager(const void *const viewer);
|
EMSCRIPTEN_KEEPALIVE void *get_scene_manager(const void *const viewer);
|
||||||
@@ -112,7 +93,7 @@ extern "C"
|
|||||||
EMSCRIPTEN_KEEPALIVE void set_light_position(const void *const viewer, EntityId light, float x, float y, float z);
|
EMSCRIPTEN_KEEPALIVE void set_light_position(const void *const viewer, EntityId light, float x, float y, float z);
|
||||||
EMSCRIPTEN_KEEPALIVE void set_light_direction(const void *const viewer, EntityId light, float x, float y, float z);
|
EMSCRIPTEN_KEEPALIVE void set_light_direction(const void *const viewer, EntityId light, float x, float y, float z);
|
||||||
EMSCRIPTEN_KEEPALIVE EntityId load_glb(void *sceneManager, const char *assetPath, int numInstances, bool keepData);
|
EMSCRIPTEN_KEEPALIVE EntityId load_glb(void *sceneManager, const char *assetPath, int numInstances, bool keepData);
|
||||||
EMSCRIPTEN_KEEPALIVE EntityId load_glb_from_buffer(void *sceneManager, const void *const data, size_t length, bool keepData);
|
EMSCRIPTEN_KEEPALIVE EntityId load_glb_from_buffer(void *sceneManager, const void *const data, size_t length, bool keepData, int priority, int layer);
|
||||||
EMSCRIPTEN_KEEPALIVE EntityId load_gltf(void *sceneManager, const char *assetPath, const char *relativePath, bool keepData);
|
EMSCRIPTEN_KEEPALIVE EntityId load_gltf(void *sceneManager, const char *assetPath, const char *relativePath, bool keepData);
|
||||||
EMSCRIPTEN_KEEPALIVE EntityId create_instance(void *sceneManager, EntityId id);
|
EMSCRIPTEN_KEEPALIVE EntityId create_instance(void *sceneManager, EntityId id);
|
||||||
EMSCRIPTEN_KEEPALIVE int get_instance_count(void *sceneManager, EntityId entityId);
|
EMSCRIPTEN_KEEPALIVE int get_instance_count(void *sceneManager, EntityId entityId);
|
||||||
@@ -160,6 +141,8 @@ extern "C"
|
|||||||
int numMorphTargets,
|
int numMorphTargets,
|
||||||
int numFrames,
|
int numFrames,
|
||||||
float frameLengthInMs);
|
float frameLengthInMs);
|
||||||
|
EMSCRIPTEN_KEEPALIVE TMaterialInstance *create_material_instance(void *const sceneManager, TMaterialKey key);
|
||||||
|
EMSCRIPTEN_KEEPALIVE void destroy_material_instance(void *const sceneManager, TMaterialInstance *instance);
|
||||||
EMSCRIPTEN_KEEPALIVE void clear_morph_animation(
|
EMSCRIPTEN_KEEPALIVE void clear_morph_animation(
|
||||||
void *sceneManager,
|
void *sceneManager,
|
||||||
EntityId entity);
|
EntityId entity);
|
||||||
@@ -262,7 +245,19 @@ extern "C"
|
|||||||
EMSCRIPTEN_KEEPALIVE bool add_animation_component(void *const sceneManager, EntityId entityId);
|
EMSCRIPTEN_KEEPALIVE bool add_animation_component(void *const sceneManager, EntityId entityId);
|
||||||
EMSCRIPTEN_KEEPALIVE void remove_animation_component(void *const sceneManager, EntityId entityId);
|
EMSCRIPTEN_KEEPALIVE void remove_animation_component(void *const sceneManager, EntityId entityId);
|
||||||
|
|
||||||
EMSCRIPTEN_KEEPALIVE EntityId create_geometry(void *const sceneManager, float *vertices, int numVertices, float *normals, int numNormals, float *uvs, int numUvs, uint16_t *indices, int numIndices, int primitiveType, const char *materialPath);
|
EMSCRIPTEN_KEEPALIVE EntityId create_geometry(
|
||||||
|
void *const sceneManager,
|
||||||
|
float *vertices,
|
||||||
|
int numVertices,
|
||||||
|
float *normals,
|
||||||
|
int numNormals,
|
||||||
|
float *uvs,
|
||||||
|
int numUvs,
|
||||||
|
uint16_t *indices,
|
||||||
|
int numIndices,
|
||||||
|
int primitiveType,
|
||||||
|
TMaterialInstance *materialInstance,
|
||||||
|
bool keepData);
|
||||||
EMSCRIPTEN_KEEPALIVE EntityId get_parent(void *const sceneManager, EntityId child);
|
EMSCRIPTEN_KEEPALIVE EntityId get_parent(void *const sceneManager, EntityId child);
|
||||||
EMSCRIPTEN_KEEPALIVE EntityId get_ancestor(void *const sceneManager, EntityId child);
|
EMSCRIPTEN_KEEPALIVE EntityId get_ancestor(void *const sceneManager, EntityId child);
|
||||||
EMSCRIPTEN_KEEPALIVE void set_parent(void *const sceneManager, EntityId child, EntityId parent, bool preserveScaling);
|
EMSCRIPTEN_KEEPALIVE void set_parent(void *const sceneManager, EntityId child, EntityId parent, bool preserveScaling);
|
||||||
@@ -283,7 +278,6 @@ extern "C"
|
|||||||
EMSCRIPTEN_KEEPALIVE void destroy_texture(void *const sceneManager, void *const texture);
|
EMSCRIPTEN_KEEPALIVE void destroy_texture(void *const sceneManager, void *const texture);
|
||||||
EMSCRIPTEN_KEEPALIVE void apply_texture_to_material(void *const sceneManager, EntityId entity, void *const texture, const char *parameterName, int materialIndex);
|
EMSCRIPTEN_KEEPALIVE void apply_texture_to_material(void *const sceneManager, EntityId entity, void *const texture, const char *parameterName, int materialIndex);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user