add fixes for setting camera
This commit is contained in:
@@ -49,8 +49,8 @@ extern "C" {
|
|||||||
((FilamentViewer*)viewer)->loadGltf(assetPath, relativePath);
|
((FilamentViewer*)viewer)->loadGltf(assetPath, relativePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_camera(void* viewer, const char* nodeName) {
|
bool set_camera(void* viewer, const char* nodeName) {
|
||||||
((FilamentViewer*)viewer)->setCamera(nodeName);
|
return ((FilamentViewer*)viewer)->setCamera(nodeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* filament_viewer_new(
|
void* filament_viewer_new(
|
||||||
@@ -133,10 +133,12 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_pointer(void** ptr, int size) {
|
void free_pointer(char*** ptr, int size) {
|
||||||
|
__android_log_print(ANDROID_LOG_VERBOSE, "filament_api", "Freeing %d char pointers", size);
|
||||||
for(int i = 0; i < size; i++) {
|
for(int i = 0; i < size; i++) {
|
||||||
free(ptr[i]);
|
free((*ptr)[i]);
|
||||||
}
|
}
|
||||||
|
free(*ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void release_source_assets(void* viewer) {
|
void release_source_assets(void* viewer) {
|
||||||
|
|||||||
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"asset" : {
|
"asset" : {
|
||||||
"generator" : "Khronos glTF Blender I/O v1.6.16",
|
"generator" : "Khronos glTF Blender I/O v1.4.40",
|
||||||
"version" : "2.0"
|
"version" : "2.0"
|
||||||
},
|
},
|
||||||
"scene" : 0,
|
"scene" : 0,
|
||||||
@@ -10,7 +10,6 @@
|
|||||||
"nodes" : [
|
"nodes" : [
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
2,
|
|
||||||
3
|
3
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -20,34 +19,6 @@
|
|||||||
"mesh" : 0,
|
"mesh" : 0,
|
||||||
"name" : "Cube"
|
"name" : "Cube"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name" : "Light",
|
|
||||||
"rotation" : [
|
|
||||||
0.16907575726509094,
|
|
||||||
0.7558803558349609,
|
|
||||||
-0.27217137813568115,
|
|
||||||
0.570947527885437
|
|
||||||
],
|
|
||||||
"translation" : [
|
|
||||||
4.076245307922363,
|
|
||||||
5.903861999511719,
|
|
||||||
-1.0054539442062378
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Camera",
|
|
||||||
"rotation" : [
|
|
||||||
0.483536034822464,
|
|
||||||
0.33687159419059753,
|
|
||||||
-0.20870360732078552,
|
|
||||||
0.7804827094078064
|
|
||||||
],
|
|
||||||
"translation" : [
|
|
||||||
7.358891487121582,
|
|
||||||
4.958309173583984,
|
|
||||||
6.925790786743164
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"mesh" : 1,
|
"mesh" : 1,
|
||||||
"name" : "Cone",
|
"name" : "Cone",
|
||||||
@@ -56,12 +27,51 @@
|
|||||||
0,
|
0,
|
||||||
-4.3612141609191895
|
-4.3612141609191895
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"camera" : 0,
|
||||||
|
"name" : "Camera_Orientation",
|
||||||
|
"rotation" : [
|
||||||
|
-0.7071067690849304,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0.7071067690849304
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"children" : [
|
||||||
|
2
|
||||||
|
],
|
||||||
|
"name" : "Camera",
|
||||||
|
"rotation" : [
|
||||||
|
0.5797627568244934,
|
||||||
|
0.0033576595596969128,
|
||||||
|
-0.013425502926111221,
|
||||||
|
0.8146679401397705
|
||||||
|
],
|
||||||
|
"translation" : [
|
||||||
|
0,
|
||||||
|
6.8069868087768555,
|
||||||
|
10.594138145446777
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cameras" : [
|
||||||
|
{
|
||||||
|
"name" : "Camera.001",
|
||||||
|
"perspective" : {
|
||||||
|
"aspectRatio" : 1.7777777777777777,
|
||||||
|
"yfov" : 0.39959652046304894,
|
||||||
|
"zfar" : 1000,
|
||||||
|
"znear" : 0.10000000149011612
|
||||||
|
},
|
||||||
|
"type" : "perspective"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"materials" : [
|
"materials" : [
|
||||||
{
|
{
|
||||||
"doubleSided" : true,
|
"doubleSided" : true,
|
||||||
"name" : "Material",
|
"name" : "Material.001",
|
||||||
"pbrMetallicRoughness" : {
|
"pbrMetallicRoughness" : {
|
||||||
"baseColorFactor" : [
|
"baseColorFactor" : [
|
||||||
0.800000011920929,
|
0.800000011920929,
|
||||||
@@ -88,7 +98,7 @@
|
|||||||
"Key 8"
|
"Key 8"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"name" : "Cube",
|
"name" : "Cube.001",
|
||||||
"primitives" : [
|
"primitives" : [
|
||||||
{
|
{
|
||||||
"attributes" : {
|
"attributes" : {
|
||||||
@@ -207,7 +217,7 @@
|
|||||||
{
|
{
|
||||||
"bufferView" : 0,
|
"bufferView" : 0,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 264,
|
"count" : 276,
|
||||||
"max" : [
|
"max" : [
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
@@ -223,13 +233,13 @@
|
|||||||
{
|
{
|
||||||
"bufferView" : 1,
|
"bufferView" : 1,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 264,
|
"count" : 276,
|
||||||
"type" : "VEC3"
|
"type" : "VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView" : 2,
|
"bufferView" : 2,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 264,
|
"count" : 276,
|
||||||
"type" : "VEC2"
|
"type" : "VEC2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -241,7 +251,7 @@
|
|||||||
{
|
{
|
||||||
"bufferView" : 4,
|
"bufferView" : 4,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 264,
|
"count" : 276,
|
||||||
"max" : [
|
"max" : [
|
||||||
0.14205700159072876,
|
0.14205700159072876,
|
||||||
0.36317670345306396,
|
0.36317670345306396,
|
||||||
@@ -257,13 +267,13 @@
|
|||||||
{
|
{
|
||||||
"bufferView" : 5,
|
"bufferView" : 5,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 264,
|
"count" : 276,
|
||||||
"type" : "VEC3"
|
"type" : "VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView" : 6,
|
"bufferView" : 6,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 264,
|
"count" : 276,
|
||||||
"max" : [
|
"max" : [
|
||||||
0.14205700159072876,
|
0.14205700159072876,
|
||||||
0.6298741102218628,
|
0.6298741102218628,
|
||||||
@@ -279,13 +289,13 @@
|
|||||||
{
|
{
|
||||||
"bufferView" : 7,
|
"bufferView" : 7,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 264,
|
"count" : 276,
|
||||||
"type" : "VEC3"
|
"type" : "VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView" : 8,
|
"bufferView" : 8,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 264,
|
"count" : 276,
|
||||||
"max" : [
|
"max" : [
|
||||||
1.1911587715148926,
|
1.1911587715148926,
|
||||||
0.7055504322052002,
|
0.7055504322052002,
|
||||||
@@ -301,13 +311,13 @@
|
|||||||
{
|
{
|
||||||
"bufferView" : 9,
|
"bufferView" : 9,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 264,
|
"count" : 276,
|
||||||
"type" : "VEC3"
|
"type" : "VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView" : 10,
|
"bufferView" : 10,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 264,
|
"count" : 276,
|
||||||
"max" : [
|
"max" : [
|
||||||
1.0930120944976807,
|
1.0930120944976807,
|
||||||
0.12705659866333008,
|
0.12705659866333008,
|
||||||
@@ -323,13 +333,13 @@
|
|||||||
{
|
{
|
||||||
"bufferView" : 11,
|
"bufferView" : 11,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 264,
|
"count" : 276,
|
||||||
"type" : "VEC3"
|
"type" : "VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView" : 12,
|
"bufferView" : 12,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 264,
|
"count" : 276,
|
||||||
"max" : [
|
"max" : [
|
||||||
1.0931031703948975,
|
1.0931031703948975,
|
||||||
7.137829303741455,
|
7.137829303741455,
|
||||||
@@ -345,13 +355,13 @@
|
|||||||
{
|
{
|
||||||
"bufferView" : 13,
|
"bufferView" : 13,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 264,
|
"count" : 276,
|
||||||
"type" : "VEC3"
|
"type" : "VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView" : 14,
|
"bufferView" : 14,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 264,
|
"count" : 276,
|
||||||
"max" : [
|
"max" : [
|
||||||
0.7663934230804443,
|
0.7663934230804443,
|
||||||
0.12705659866333008,
|
0.12705659866333008,
|
||||||
@@ -367,13 +377,13 @@
|
|||||||
{
|
{
|
||||||
"bufferView" : 15,
|
"bufferView" : 15,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 264,
|
"count" : 276,
|
||||||
"type" : "VEC3"
|
"type" : "VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView" : 16,
|
"bufferView" : 16,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 264,
|
"count" : 276,
|
||||||
"max" : [
|
"max" : [
|
||||||
1.0939359664916992,
|
1.0939359664916992,
|
||||||
0.12705659866333008,
|
0.12705659866333008,
|
||||||
@@ -389,13 +399,13 @@
|
|||||||
{
|
{
|
||||||
"bufferView" : 17,
|
"bufferView" : 17,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 264,
|
"count" : 276,
|
||||||
"type" : "VEC3"
|
"type" : "VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView" : 18,
|
"bufferView" : 18,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 264,
|
"count" : 276,
|
||||||
"max" : [
|
"max" : [
|
||||||
0.9689376950263977,
|
0.9689376950263977,
|
||||||
0.12705659866333008,
|
0.12705659866333008,
|
||||||
@@ -411,13 +421,13 @@
|
|||||||
{
|
{
|
||||||
"bufferView" : 19,
|
"bufferView" : 19,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 264,
|
"count" : 276,
|
||||||
"type" : "VEC3"
|
"type" : "VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView" : 20,
|
"bufferView" : 20,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 128,
|
"count" : 148,
|
||||||
"max" : [
|
"max" : [
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
@@ -433,13 +443,13 @@
|
|||||||
{
|
{
|
||||||
"bufferView" : 21,
|
"bufferView" : 21,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 128,
|
"count" : 148,
|
||||||
"type" : "VEC3"
|
"type" : "VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView" : 22,
|
"bufferView" : 22,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 128,
|
"count" : 148,
|
||||||
"type" : "VEC2"
|
"type" : "VEC2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -451,7 +461,7 @@
|
|||||||
{
|
{
|
||||||
"bufferView" : 24,
|
"bufferView" : 24,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 128,
|
"count" : 148,
|
||||||
"max" : [
|
"max" : [
|
||||||
0,
|
0,
|
||||||
0.5201449394226074,
|
0.5201449394226074,
|
||||||
@@ -467,13 +477,13 @@
|
|||||||
{
|
{
|
||||||
"bufferView" : 25,
|
"bufferView" : 25,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 128,
|
"count" : 148,
|
||||||
"type" : "VEC3"
|
"type" : "VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView" : 26,
|
"bufferView" : 26,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 128,
|
"count" : 148,
|
||||||
"max" : [
|
"max" : [
|
||||||
5.200448989868164,
|
5.200448989868164,
|
||||||
0,
|
0,
|
||||||
@@ -489,13 +499,13 @@
|
|||||||
{
|
{
|
||||||
"bufferView" : 27,
|
"bufferView" : 27,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 128,
|
"count" : 148,
|
||||||
"type" : "VEC3"
|
"type" : "VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView" : 28,
|
"bufferView" : 28,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 128,
|
"count" : 148,
|
||||||
"max" : [
|
"max" : [
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@@ -511,13 +521,13 @@
|
|||||||
{
|
{
|
||||||
"bufferView" : 29,
|
"bufferView" : 29,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 128,
|
"count" : 148,
|
||||||
"type" : "VEC3"
|
"type" : "VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView" : 30,
|
"bufferView" : 30,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 128,
|
"count" : 148,
|
||||||
"max" : [
|
"max" : [
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@@ -533,13 +543,13 @@
|
|||||||
{
|
{
|
||||||
"bufferView" : 31,
|
"bufferView" : 31,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 128,
|
"count" : 148,
|
||||||
"type" : "VEC3"
|
"type" : "VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView" : 32,
|
"bufferView" : 32,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 128,
|
"count" : 148,
|
||||||
"max" : [
|
"max" : [
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@@ -555,13 +565,13 @@
|
|||||||
{
|
{
|
||||||
"bufferView" : 33,
|
"bufferView" : 33,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 128,
|
"count" : 148,
|
||||||
"type" : "VEC3"
|
"type" : "VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView" : 34,
|
"bufferView" : 34,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 128,
|
"count" : 148,
|
||||||
"max" : [
|
"max" : [
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@@ -577,195 +587,195 @@
|
|||||||
{
|
{
|
||||||
"bufferView" : 35,
|
"bufferView" : 35,
|
||||||
"componentType" : 5126,
|
"componentType" : 5126,
|
||||||
"count" : 128,
|
"count" : 148,
|
||||||
"type" : "VEC3"
|
"type" : "VEC3"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bufferViews" : [
|
"bufferViews" : [
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 3168,
|
"byteLength" : 3312,
|
||||||
"byteOffset" : 0
|
"byteOffset" : 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 3168,
|
"byteLength" : 3312,
|
||||||
"byteOffset" : 3168
|
"byteOffset" : 3312
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 2112,
|
"byteLength" : 2208,
|
||||||
"byteOffset" : 6336
|
"byteOffset" : 6624
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 552,
|
"byteLength" : 552,
|
||||||
"byteOffset" : 8448
|
"byteOffset" : 8832
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 3168,
|
"byteLength" : 3312,
|
||||||
"byteOffset" : 9000
|
"byteOffset" : 9384
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 3168,
|
"byteLength" : 3312,
|
||||||
"byteOffset" : 12168
|
"byteOffset" : 12696
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 3168,
|
"byteLength" : 3312,
|
||||||
"byteOffset" : 15336
|
"byteOffset" : 16008
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 3168,
|
"byteLength" : 3312,
|
||||||
"byteOffset" : 18504
|
"byteOffset" : 19320
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 3168,
|
"byteLength" : 3312,
|
||||||
"byteOffset" : 21672
|
"byteOffset" : 22632
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 3168,
|
"byteLength" : 3312,
|
||||||
"byteOffset" : 24840
|
"byteOffset" : 25944
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 3168,
|
"byteLength" : 3312,
|
||||||
"byteOffset" : 28008
|
"byteOffset" : 29256
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 3168,
|
"byteLength" : 3312,
|
||||||
"byteOffset" : 31176
|
"byteOffset" : 32568
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 3168,
|
"byteLength" : 3312,
|
||||||
"byteOffset" : 34344
|
"byteOffset" : 35880
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 3168,
|
"byteLength" : 3312,
|
||||||
"byteOffset" : 37512
|
"byteOffset" : 39192
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 3168,
|
"byteLength" : 3312,
|
||||||
"byteOffset" : 40680
|
"byteOffset" : 42504
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 3168,
|
"byteLength" : 3312,
|
||||||
"byteOffset" : 43848
|
"byteOffset" : 45816
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 3168,
|
"byteLength" : 3312,
|
||||||
"byteOffset" : 47016
|
"byteOffset" : 49128
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 3168,
|
"byteLength" : 3312,
|
||||||
"byteOffset" : 50184
|
"byteOffset" : 52440
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 3168,
|
"byteLength" : 3312,
|
||||||
"byteOffset" : 53352
|
"byteOffset" : 55752
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 3168,
|
"byteLength" : 3312,
|
||||||
"byteOffset" : 56520
|
"byteOffset" : 59064
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 1536,
|
"byteLength" : 1776,
|
||||||
"byteOffset" : 59688
|
"byteOffset" : 62376
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 1536,
|
"byteLength" : 1776,
|
||||||
"byteOffset" : 61224
|
"byteOffset" : 64152
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 1024,
|
"byteLength" : 1184,
|
||||||
"byteOffset" : 62760
|
"byteOffset" : 65928
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 372,
|
"byteLength" : 372,
|
||||||
"byteOffset" : 63784
|
"byteOffset" : 67112
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 1536,
|
"byteLength" : 1776,
|
||||||
"byteOffset" : 64156
|
"byteOffset" : 67484
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 1536,
|
"byteLength" : 1776,
|
||||||
"byteOffset" : 65692
|
"byteOffset" : 69260
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 1536,
|
"byteLength" : 1776,
|
||||||
"byteOffset" : 67228
|
"byteOffset" : 71036
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 1536,
|
"byteLength" : 1776,
|
||||||
"byteOffset" : 68764
|
"byteOffset" : 72812
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 1536,
|
"byteLength" : 1776,
|
||||||
"byteOffset" : 70300
|
"byteOffset" : 74588
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 1536,
|
"byteLength" : 1776,
|
||||||
"byteOffset" : 71836
|
"byteOffset" : 76364
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 1536,
|
"byteLength" : 1776,
|
||||||
"byteOffset" : 73372
|
"byteOffset" : 78140
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 1536,
|
"byteLength" : 1776,
|
||||||
"byteOffset" : 74908
|
"byteOffset" : 79916
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 1536,
|
"byteLength" : 1776,
|
||||||
"byteOffset" : 76444
|
"byteOffset" : 81692
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 1536,
|
"byteLength" : 1776,
|
||||||
"byteOffset" : 77980
|
"byteOffset" : 83468
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 1536,
|
"byteLength" : 1776,
|
||||||
"byteOffset" : 79516
|
"byteOffset" : 85244
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer" : 0,
|
"buffer" : 0,
|
||||||
"byteLength" : 1536,
|
"byteLength" : 1776,
|
||||||
"byteOffset" : 81052
|
"byteOffset" : 87020
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"buffers" : [
|
"buffers" : [
|
||||||
{
|
{
|
||||||
"byteLength" : 82588,
|
"byteLength" : 88796,
|
||||||
"uri" : "cube.bin"
|
"uri" : "cube.bin"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -83,15 +83,21 @@ class _MyAppState extends State<MyApp> {
|
|||||||
_filamentController.zoom(-1.0);
|
_filamentController.zoom(-1.0);
|
||||||
},
|
},
|
||||||
child: const Text('zoom in')),
|
child: const Text('zoom in')),
|
||||||
|
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_filamentController.zoom(1.0);
|
_filamentController.zoom(1.0);
|
||||||
},
|
},
|
||||||
child: const Text('zoom out')),
|
child: const Text('zoom out')),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
_filamentController.setCamera("Camera.001");
|
||||||
|
},
|
||||||
|
child: const Text('Set Camera')),
|
||||||
Builder(builder:(innerCtx) => ElevatedButton(
|
Builder(builder:(innerCtx) => ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final names = await _filamentController
|
final names = await _filamentController
|
||||||
.getTargetNames("Cube");
|
.getTargetNames("Cube.001");
|
||||||
|
|
||||||
await showDialog(
|
await showDialog(
|
||||||
builder: (ctx) {
|
builder: (ctx) {
|
||||||
|
|||||||
@@ -268,10 +268,10 @@ void FilamentViewer::loadGlb(const char* const uri) {
|
|||||||
Log("Loading GLB at URI %s", uri);
|
Log("Loading GLB at URI %s", uri);
|
||||||
|
|
||||||
if(_asset) {
|
if(_asset) {
|
||||||
|
_asset->releaseSourceData();
|
||||||
_resourceLoader->evictResourceData();
|
_resourceLoader->evictResourceData();
|
||||||
_scene->removeEntities(_asset->getEntities(), _asset->getEntityCount());
|
_scene->removeEntities(_asset->getEntities(), _asset->getEntityCount());
|
||||||
_assetLoader->destroyAsset(_asset);
|
_assetLoader->destroyAsset(_asset);
|
||||||
_freeResource(_assetBuffer);
|
|
||||||
}
|
}
|
||||||
_asset = nullptr;
|
_asset = nullptr;
|
||||||
_animator = nullptr;
|
_animator = nullptr;
|
||||||
@@ -339,55 +339,83 @@ void FilamentViewer::loadGltf(const char* const uri, const char* const relativeR
|
|||||||
|
|
||||||
Log("Load complete for GLTF at URI %s", uri);
|
Log("Load complete for GLTF at URI %s", uri);
|
||||||
|
|
||||||
transformToUnitCube();
|
// transformToUnitCube();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilamentViewer::setCamera(const char* cameraName) {
|
bool FilamentViewer::setCamera(const char* cameraName) {
|
||||||
FFilamentAsset* asset = (FFilamentAsset*)_asset;
|
FFilamentAsset* asset = (FFilamentAsset*)_asset;
|
||||||
|
|
||||||
gltfio::NodeMap &sourceNodes = asset->isInstanced() ? asset->mInstances[0]->nodeMap
|
gltfio::NodeMap &sourceNodes = asset->isInstanced() ? asset->mInstances[0]->nodeMap
|
||||||
: asset->mNodeMap;
|
: asset->mNodeMap;
|
||||||
|
Log("Setting camera to %s", cameraName);
|
||||||
for (auto pair : sourceNodes) {
|
for (auto pair : sourceNodes) {
|
||||||
cgltf_node const *node = pair.first;
|
cgltf_node const *node = pair.first;
|
||||||
|
|
||||||
if(node->camera) {
|
if(!node->camera) {
|
||||||
Log("Got camera %s of type %s ", node->camera->name, node->camera->type);
|
if(node->name) {
|
||||||
|
Log("No camera found under node %s", node->name);
|
||||||
|
} else {
|
||||||
|
Log("No camera found under unnamed node.");
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if(strcmp(cameraName, node->camera->name) == 0) {
|
Log("Found camera under node %s", node->name);
|
||||||
filament::math::mat4 mat(
|
|
||||||
node->matrix[0],
|
|
||||||
node->matrix[1],
|
|
||||||
node->matrix[2],
|
|
||||||
node->matrix[3],
|
|
||||||
node->matrix[4],
|
|
||||||
node->matrix[5],
|
|
||||||
node->matrix[6],
|
|
||||||
node->matrix[7],
|
|
||||||
node->matrix[8],
|
|
||||||
node->matrix[9],
|
|
||||||
node->matrix[10],
|
|
||||||
node->matrix[11],
|
|
||||||
node->parent->translation[0],
|
|
||||||
node->parent->translation[1],
|
|
||||||
node->parent->translation[2],
|
|
||||||
1
|
|
||||||
);
|
|
||||||
|
|
||||||
quatf rot1(node->parent->rotation[0],node->parent->rotation[1], node->parent->rotation[2], node->parent->rotation[3]);
|
if(node->camera->name) {
|
||||||
quatf rot2(node->rotation[0],node->rotation[1], node->rotation[2], node->rotation[3]);
|
Log("Checking camera : %s", node->camera->name);
|
||||||
quatf rot3 = rot1 * rot2;
|
}
|
||||||
filament::math::mat4 rotm(rot3);
|
|
||||||
|
if(strcmp(cameraName, node->camera->name) == 0) {
|
||||||
|
Log("Found camera.");
|
||||||
|
filament::math::mat4 mat(
|
||||||
|
node->matrix[0],
|
||||||
|
node->matrix[1],
|
||||||
|
node->matrix[2],
|
||||||
|
node->matrix[3],
|
||||||
|
node->matrix[4],
|
||||||
|
node->matrix[5],
|
||||||
|
node->matrix[6],
|
||||||
|
node->matrix[7],
|
||||||
|
node->matrix[8],
|
||||||
|
node->matrix[9],
|
||||||
|
node->matrix[10],
|
||||||
|
node->matrix[11],
|
||||||
|
node->parent->translation[0],
|
||||||
|
node->parent->translation[1],
|
||||||
|
node->parent->translation[2],
|
||||||
|
1
|
||||||
|
);
|
||||||
|
|
||||||
|
quatf rot1(node->parent->rotation[0],node->parent->rotation[1], node->parent->rotation[2], node->parent->rotation[3]);
|
||||||
|
quatf rot2(node->rotation[0],node->rotation[1], node->rotation[2], node->rotation[3]);
|
||||||
|
quatf rot3 = rot1 * rot2;
|
||||||
|
filament::math::mat4 rotm(rot3);
|
||||||
|
|
||||||
filament::math::mat4 result = mat * rotm;
|
filament::math::mat4 result = mat * rotm;
|
||||||
|
|
||||||
|
Entity cameraEntity = EntityManager::get().create();
|
||||||
|
Camera* cam = _engine->createCamera(cameraEntity);
|
||||||
|
|
||||||
|
const Viewport& vp = _view->getViewport();
|
||||||
|
|
||||||
|
const double aspect = (double)vp.width / vp.height;
|
||||||
|
|
||||||
|
cam->setLensProjection(_cameraFocalLength, aspect, kNearPlane, kFarPlane);
|
||||||
|
|
||||||
|
if(!cam) {
|
||||||
|
Log("Couldn't create camera");
|
||||||
|
} else {
|
||||||
_engine->getTransformManager().setTransform(
|
_engine->getTransformManager().setTransform(
|
||||||
_engine->getTransformManager().getInstance(_mainCamera->getEntity()), result);
|
_engine->getTransformManager().getInstance(cameraEntity), result);
|
||||||
|
|
||||||
}
|
_view->setCamera(cam);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringList FilamentViewer::getTargetNames(const char* meshName) {
|
StringList FilamentViewer::getTargetNames(const char* meshName) {
|
||||||
@@ -404,18 +432,12 @@ StringList FilamentViewer::getTargetNames(const char* meshName) {
|
|||||||
cgltf_node const *node = pair.first;
|
cgltf_node const *node = pair.first;
|
||||||
cgltf_mesh const *mesh = node->mesh;
|
cgltf_mesh const *mesh = node->mesh;
|
||||||
|
|
||||||
if(node->camera) {
|
|
||||||
Log("Got camera %s of type %s", node->camera->name, node->camera->type);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mesh) {
|
if (mesh) {
|
||||||
Log("Mesh : %s ",mesh->name);
|
Log("Mesh : %s ",mesh->name);
|
||||||
if(strcmp(meshName, mesh->name) == 0) {
|
if(strcmp(meshName, mesh->name) == 0) {
|
||||||
return StringList((const char**)mesh->target_names, (int) mesh->target_names_count);
|
return StringList((const char**)mesh->target_names, (int) mesh->target_names_count);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
Log("No mesh attached to node");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return StringList(nullptr, 0);
|
return StringList(nullptr, 0);
|
||||||
}
|
}
|
||||||
@@ -429,7 +451,7 @@ void FilamentViewer::loadSkybox(const char* const skyboxPath, const char* const
|
|||||||
new image::KtxBundle(static_cast<const uint8_t*>(skyboxBuffer.data), static_cast<uint32_t>(skyboxBuffer.size));
|
new image::KtxBundle(static_cast<const uint8_t*>(skyboxBuffer.data), static_cast<uint32_t>(skyboxBuffer.size));
|
||||||
_skyboxTexture = image::ktx::createTexture(_engine, skyboxBundle, false);
|
_skyboxTexture = image::ktx::createTexture(_engine, skyboxBundle, false);
|
||||||
_skybox = filament::Skybox::Builder().environment(_skyboxTexture).build(*_engine);
|
_skybox = filament::Skybox::Builder().environment(_skyboxTexture).build(*_engine);
|
||||||
// _skybox = Skybox::Builder().color({0.1, 0.125, 0.25, 1.0}).build(*_engine);
|
|
||||||
_scene->setSkybox(_skybox);
|
_scene->setSkybox(_skybox);
|
||||||
_freeResource(skyboxBuffer);
|
_freeResource(skyboxBuffer);
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ namespace polyvox {
|
|||||||
// void animateWeights(float* data, int numWeights, int length, float frameRate);
|
// void animateWeights(float* data, int numWeights, int length, float frameRate);
|
||||||
// void animateBones();
|
// void animateBones();
|
||||||
void playAnimation(int index);
|
void playAnimation(int index);
|
||||||
void setCamera(const char* nodeName);
|
bool setCamera(const char* nodeName);
|
||||||
void destroySwapChain();
|
void destroySwapChain();
|
||||||
void createSwapChain(void* surface);
|
void createSwapChain(void* surface);
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ abstract class FilamentController {
|
|||||||
Future<List<String>> getTargetNames(String meshName);
|
Future<List<String>> getTargetNames(String meshName);
|
||||||
Future releaseSourceAssets();
|
Future releaseSourceAssets();
|
||||||
Future playAnimation(int index);
|
Future playAnimation(int index);
|
||||||
|
Future setCamera(String name);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set the weights of all morph targets in the mesh to the specified weights at successive frames (where [framerate] is the number of times per second the weights should be updated).
|
/// Set the weights of all morph targets in the mesh to the specified weights at successive frames (where [framerate] is the number of times per second the weights should be updated).
|
||||||
@@ -121,4 +122,8 @@ class PolyvoxFilamentController extends FilamentController {
|
|||||||
Future playAnimation(int index) async {
|
Future playAnimation(int index) async {
|
||||||
await _channel.invokeMethod("playAnimation", index);
|
await _channel.invokeMethod("playAnimation", index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future setCamera(String name) async {
|
||||||
|
await _channel.invokeMethod("setCamera", name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user