add (very rough) gizmo, restructure Dart package into library, add EntityListWidget
This commit is contained in:
@@ -138,7 +138,7 @@ namespace flutter_filament
|
||||
void setAntiAliasing(bool msaaEnabled, bool fxaaEnabled, bool taaEnabled);
|
||||
void setDepthOfField();
|
||||
|
||||
EntityId createGeometry(float* vertices, uint32_t numVertices, uint16_t* indices, uint32_t numIndices, const char* materialPath);
|
||||
EntityId createGeometry(float* vertices, uint32_t numVertices, uint16_t* indices, uint32_t numIndices, filament::RenderableManager::PrimitiveType primitiveType = RenderableManager::PrimitiveType::TRIANGLES, const char* materialPath = nullptr);
|
||||
|
||||
SceneManager *const getSceneManager()
|
||||
{
|
||||
|
||||
@@ -197,9 +197,11 @@ extern "C"
|
||||
FLUTTER_PLUGIN_EXPORT void remove_collision_component(void *const sceneManager, EntityId entityId);
|
||||
FLUTTER_PLUGIN_EXPORT void add_animation_component(void *const sceneManager, EntityId entityId);
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT EntityId create_geometry(void *const viewer, float* vertices, int numVertices, uint16_t* indices, int numIndices, const char* materialPath);
|
||||
FLUTTER_PLUGIN_EXPORT EntityId create_geometry(void *const viewer, float* vertices, int numVertices, uint16_t* indices, int numIndices, int primitiveType, const char* materialPath);
|
||||
FLUTTER_PLUGIN_EXPORT void set_parent(void *const sceneManager, EntityId child, EntityId parent);
|
||||
FLUTTER_PLUGIN_EXPORT void test_collisions(void *const sceneManager, EntityId entity);
|
||||
FLUTTER_PLUGIN_EXPORT void set_priority(void *const sceneManager, EntityId entityId, int priority);
|
||||
FLUTTER_PLUGIN_EXPORT void get_gizmo(void *const sceneManager, EntityId* out);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ extern "C"
|
||||
FLUTTER_PLUGIN_EXPORT void set_post_processing_ffi(void *const viewer, bool enabled);
|
||||
FLUTTER_PLUGIN_EXPORT void reset_to_rest_pose_ffi(void *const sceneManager, EntityId entityId);
|
||||
FLUTTER_PLUGIN_EXPORT void ios_dummy_ffi();
|
||||
FLUTTER_PLUGIN_EXPORT void create_geometry_ffi(void *const viewer, float *vertices, int numVertices, uint16_t *indices, int numIndices, const char *materialPath, void (*callback)(EntityId));
|
||||
FLUTTER_PLUGIN_EXPORT void create_geometry_ffi(void *const viewer, float *vertices, int numVertices, uint16_t *indices, int numIndices, int primitiveType, const char *materialPath, void (*callback)(EntityId));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
#include <gltfio/FilamentInstance.h>
|
||||
#include <gltfio/ResourceLoader.h>
|
||||
|
||||
#include <filament/IndexBuffer.h>
|
||||
#include <filament/InstanceBuffer.h>
|
||||
|
||||
#include "material/gizmo.h"
|
||||
#include "utils/NameComponentManager.h"
|
||||
#include "ResourceBuffer.hpp"
|
||||
#include "components/CollisionComponentManager.hpp"
|
||||
@@ -141,6 +145,19 @@ namespace flutter_filament
|
||||
/// @param entityId
|
||||
void getInstances(EntityId entityId, EntityId* out);
|
||||
|
||||
///
|
||||
/// Sets the draw priority for the given entity. See RenderableManager.h for more details.
|
||||
///
|
||||
void setPriority(EntityId entity, int priority);
|
||||
|
||||
|
||||
/// @brief returns the gizmo entity, used to manipulate the global transform for entities
|
||||
/// @param out a pointer to an array of three EntityId {x, y, z}
|
||||
/// @return
|
||||
///
|
||||
void getGizmo(EntityId* out);
|
||||
|
||||
|
||||
friend class FilamentViewer;
|
||||
|
||||
|
||||
@@ -154,6 +171,7 @@ namespace flutter_filament
|
||||
gltfio::TextureProvider *_stbDecoder = nullptr;
|
||||
gltfio::TextureProvider *_ktxDecoder = nullptr;
|
||||
std::mutex _mutex;
|
||||
Material* _gizmoMaterial;
|
||||
|
||||
utils::NameComponentManager* _ncm;
|
||||
|
||||
@@ -173,5 +191,10 @@ namespace flutter_filament
|
||||
const gltfio::FilamentInstance* instance,
|
||||
const char *entityName);
|
||||
|
||||
EntityId addGizmo();
|
||||
utils::Entity _gizmoX;
|
||||
utils::Entity _gizmoY;
|
||||
utils::Entity _gizmoZ;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -115,6 +115,8 @@ namespace flutter_filament {
|
||||
{
|
||||
auto now = high_resolution_clock::now();
|
||||
|
||||
// Log("animation component count : %d", )
|
||||
|
||||
for(auto it = begin(); it < end(); it++) {
|
||||
const auto& entity = getEntity(it);
|
||||
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
#ifndef FILE_MATERIAL_PROVIDER
|
||||
#define FILE_MATERIAL_PROVIDER
|
||||
|
||||
#include <filament/gltfio/MaterialProvider.h>
|
||||
#include <filament/Texture.h>
|
||||
#include <filament/TextureSampler.h>
|
||||
#include <math/mat4.h>
|
||||
#include <math/vec3.h>
|
||||
#include <math/vec4.h>
|
||||
#include <math/mat3.h>
|
||||
#include <math/norm.h>
|
||||
#include "Log.hpp"
|
||||
|
||||
namespace flutter_filament {
|
||||
|
||||
|
||||
class FileMaterialProvider : public filament::gltfio::MaterialProvider {
|
||||
|
||||
filament::Material* _m;
|
||||
const filament::Material* _ms[1];
|
||||
filament::Texture* mDummyTexture = nullptr;
|
||||
|
||||
public:
|
||||
FileMaterialProvider(filament::Engine* engine, const void* const data, const size_t size) {
|
||||
_m = filament::Material::Builder()
|
||||
.package(data, size)
|
||||
.build(*engine);
|
||||
_ms[0] = _m;
|
||||
unsigned char texels[4] = {};
|
||||
mDummyTexture = filament::Texture::Builder()
|
||||
.width(1).height(1)
|
||||
.format(filament::Texture::InternalFormat::RGBA8)
|
||||
.build(*engine);
|
||||
filament::Texture::PixelBufferDescriptor pbd(texels, sizeof(texels), filament::Texture::Format::RGBA,
|
||||
filament::Texture::Type::UBYTE);
|
||||
mDummyTexture->setImage(*engine, 0, std::move(pbd));
|
||||
}
|
||||
|
||||
filament::MaterialInstance* createMaterialInstance(filament::gltfio::MaterialKey* config, filament::gltfio::UvMap* uvmap,
|
||||
const char* label = "material", const char* extras = nullptr) {
|
||||
|
||||
auto getUvIndex = [uvmap](uint8_t srcIndex, bool hasTexture) -> int {
|
||||
return hasTexture ? int(uvmap->at(srcIndex)) - 1 : -1;
|
||||
};
|
||||
|
||||
auto instance = _m->createInstance();
|
||||
filament::math::mat3f identity;
|
||||
instance->setParameter("baseColorUvMatrix", identity);
|
||||
instance->setParameter("normalUvMatrix", identity);
|
||||
|
||||
instance->setParameter("baseColorIndex", getUvIndex(config->baseColorUV, config->hasBaseColorTexture));
|
||||
instance->setParameter("normalIndex", getUvIndex(config->normalUV, config->hasNormalTexture));
|
||||
if(config->hasNormalTexture) {
|
||||
filament::TextureSampler sampler;
|
||||
instance->setParameter("normalMap", mDummyTexture, sampler);
|
||||
instance->setParameter("baseColorMap", mDummyTexture, sampler);
|
||||
} else {
|
||||
Log("No normal texture for specified material.");
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates or fetches a compiled Filament material corresponding to the given config.
|
||||
*/
|
||||
virtual filament::Material* getMaterial(filament::gltfio::MaterialKey* config, filament::gltfio::UvMap* uvmap, const char* label = "material") {
|
||||
return _m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a weak reference to the array of cached materials.
|
||||
*/
|
||||
const filament::Material* const* getMaterials() const noexcept {
|
||||
return _ms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of cached materials.
|
||||
*/
|
||||
size_t getMaterialsCount() const noexcept {
|
||||
return (size_t)1;
|
||||
}
|
||||
|
||||
void destroyMaterials() {
|
||||
|
||||
}
|
||||
|
||||
bool needsDummyData(filament::VertexAttribute attrib) const noexcept {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
12
ios/include/material/gizmo.S
Normal file
12
ios/include/material/gizmo.S
Normal file
@@ -0,0 +1,12 @@
|
||||
.global GIZMO_GIZMO_OFFSET;
|
||||
.global GIZMO_GIZMO_SIZE;
|
||||
|
||||
.global GIZMO_PACKAGE
|
||||
.section .rodata
|
||||
GIZMO_PACKAGE:
|
||||
.incbin "gizmo.bin"
|
||||
GIZMO_GIZMO_OFFSET:
|
||||
.int 0
|
||||
GIZMO_GIZMO_SIZE:
|
||||
.int 36751
|
||||
|
||||
12
ios/include/material/gizmo.apple.S
Normal file
12
ios/include/material/gizmo.apple.S
Normal file
@@ -0,0 +1,12 @@
|
||||
.global _GIZMO_GIZMO_OFFSET;
|
||||
.global _GIZMO_GIZMO_SIZE;
|
||||
|
||||
.global _GIZMO_PACKAGE
|
||||
.section __TEXT,__const
|
||||
_GIZMO_PACKAGE:
|
||||
.incbin "gizmo.bin"
|
||||
_GIZMO_GIZMO_OFFSET:
|
||||
.int 0
|
||||
_GIZMO_GIZMO_SIZE:
|
||||
.int 36751
|
||||
|
||||
3
ios/include/material/gizmo.bin
Normal file
3
ios/include/material/gizmo.bin
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bbb413c69ac6f77243a02049d2ccf494a1f20ea88fb8ca159b22c5bc0a4fdd95
|
||||
size 36751
|
||||
1847
ios/include/material/gizmo.c
Normal file
1847
ios/include/material/gizmo.c
Normal file
File diff suppressed because it is too large
Load Diff
13
ios/include/material/gizmo.h
Normal file
13
ios/include/material/gizmo.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef GIZMO_H_
|
||||
#define GIZMO_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern "C" {
|
||||
extern const uint8_t GIZMO_PACKAGE[];
|
||||
extern int GIZMO_GIZMO_OFFSET;
|
||||
extern int GIZMO_GIZMO_SIZE;
|
||||
}
|
||||
#define GIZMO_GIZMO_DATA (GIZMO_PACKAGE + GIZMO_GIZMO_OFFSET)
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user