package and namespace changes

This commit is contained in:
Nick Fisher
2021-11-09 22:05:42 +08:00
parent 51ba4b2377
commit bb13d82114
16 changed files with 36 additions and 35 deletions

View File

@@ -1,6 +1,6 @@
# mimetic_filament_example # holovox_filament_example
Demonstrates how to use the mimetic_filament plugin. Demonstrates how to use the holovox_filament plugin.
## Getting Started ## Getting Started

View File

@@ -350,7 +350,7 @@
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES; PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.example.mimeticAvatarExample; PRODUCT_BUNDLE_IDENTIFIER = com.example.holovoxAvatarExample;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
STRIP_INSTALLED_PRODUCT = NO; STRIP_INSTALLED_PRODUCT = NO;
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -489,7 +489,7 @@
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES; PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.example.mimeticAvatarExample; PRODUCT_BUNDLE_IDENTIFIER = com.example.holovoxAvatarExample;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
STRIP_INSTALLED_PRODUCT = NO; STRIP_INSTALLED_PRODUCT = NO;
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -516,7 +516,7 @@
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES; PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.example.mimeticAvatarExample; PRODUCT_BUNDLE_IDENTIFIER = com.example.holovoxAvatarExample;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
STRIP_INSTALLED_PRODUCT = NO; STRIP_INSTALLED_PRODUCT = NO;
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";

View File

@@ -19,7 +19,7 @@ class MyApp extends StatefulWidget {
} }
class _MyAppState extends State<MyApp> { class _MyAppState extends State<MyApp> {
final FilamentController _filamentController = MimeticFilamentController(); final FilamentController _filamentController = HolovoxFilamentController();
bool _rotate = false; bool _rotate = false;
int _primitiveIndex = 0; int _primitiveIndex = 0;

View File

@@ -7,6 +7,6 @@ FilamentNativeViewFactory* factory;
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar { + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
factory = factory =
[[FilamentNativeViewFactory alloc] initWithRegistrar:registrar]; [[FilamentNativeViewFactory alloc] initWithRegistrar:registrar];
[registrar registerViewFactory:factory withId:@"mimetic.app/filament_view"]; [registrar registerViewFactory:factory withId:@"holovox.app/filament_view"];
} }
@end @end

View File

@@ -7,12 +7,12 @@
#include "FilamentViewer.hpp" #include "FilamentViewer.hpp"
static const id VIEW_TYPE = @"mimetic.app/filament_view"; static const id VIEW_TYPE = @"holovox.app/filament_view";
@interface FilamentMethodCallHandler : FlutterMethodChannel @interface FilamentMethodCallHandler : FlutterMethodChannel
- (void)handleMethodCall:(FlutterMethodCall* _Nonnull)call result:( FlutterResult _Nonnull)result; - (void)handleMethodCall:(FlutterMethodCall* _Nonnull)call result:( FlutterResult _Nonnull)result;
- (mimetic::FilamentViewer*) _viewer; - (holovox::FilamentViewer*) _viewer;
- (mimetic::ResourceBuffer)loadResource:(const char* const)path; - (holovox::ResourceBuffer)loadResource:(const char* const)path;
- (void)freeResource:(void*)mem size:(size_t)size misc:(void*)misc; - (void)freeResource:(void*)mem size:(size_t)size misc:(void*)misc;
- (void)ready; - (void)ready;
- (instancetype)initWithController:(FilamentViewController*)controller - (instancetype)initWithController:(FilamentViewController*)controller

View File

@@ -4,7 +4,7 @@
static const FilamentMethodCallHandler* _handler; static const FilamentMethodCallHandler* _handler;
static mimetic::ResourceBuffer loadResourceGlobal(const char* name) { static holovox::ResourceBuffer loadResourceGlobal(const char* name) {
return [_handler loadResource:name]; return [_handler loadResource:name];
} }
@@ -16,7 +16,7 @@ static void* freeResourceGlobal(void* mem, size_t size, void* misc) {
@implementation FilamentMethodCallHandler { @implementation FilamentMethodCallHandler {
FilamentViewController *_controller; FilamentViewController *_controller;
FlutterMethodChannel* _channel; FlutterMethodChannel* _channel;
mimetic::FilamentViewer* _viewer; holovox::FilamentViewer* _viewer;
void* _layer; void* _layer;
NSObject<FlutterPluginRegistrar>* _registrar; NSObject<FlutterPluginRegistrar>* _registrar;
@@ -43,9 +43,9 @@ static void* freeResourceGlobal(void* mem, size_t size, void* misc) {
- (void)handleMethodCall:(FlutterMethodCall* _Nonnull)call result:(FlutterResult _Nonnull )result { - (void)handleMethodCall:(FlutterMethodCall* _Nonnull)call result:(FlutterResult _Nonnull )result {
if([@"initialize" isEqualToString:call.method]) { if([@"initialize" isEqualToString:call.method]) {
if(!call.arguments) if(!call.arguments)
_viewer = new mimetic::FilamentViewer(_layer, nullptr, loadResourceGlobal, freeResourceGlobal); _viewer = new holovox::FilamentViewer(_layer, nullptr, loadResourceGlobal, freeResourceGlobal);
else else
_viewer = new mimetic::FilamentViewer(_layer, [call.arguments UTF8String], loadResourceGlobal, freeResourceGlobal); _viewer = new holovox::FilamentViewer(_layer, [call.arguments UTF8String], loadResourceGlobal, freeResourceGlobal);
[_controller setViewer:_viewer]; [_controller setViewer:_viewer];
[_controller startDisplayLink]; [_controller startDisplayLink];
result(@"OK"); result(@"OK");
@@ -117,7 +117,7 @@ static void* freeResourceGlobal(void* mem, size_t size, void* misc) {
_viewer->playAnimation([call.arguments intValue]); _viewer->playAnimation([call.arguments intValue]);
result(@"OK"); result(@"OK");
} else if([@"getTargetNames" isEqualToString:call.method]) { } else if([@"getTargetNames" isEqualToString:call.method]) {
mimetic::StringList list = _viewer->getTargetNames([call.arguments UTF8String]); holovox::StringList list = _viewer->getTargetNames([call.arguments UTF8String]);
NSMutableArray* asArray = [NSMutableArray arrayWithCapacity:list.count]; NSMutableArray* asArray = [NSMutableArray arrayWithCapacity:list.count];
for(int i = 0; i < list.count; i++) { for(int i = 0; i < list.count; i++) {
asArray[i] = [NSString stringWithFormat:@"%s", list.strings[i]]; asArray[i] = [NSString stringWithFormat:@"%s", list.strings[i]];
@@ -146,7 +146,7 @@ static void* freeResourceGlobal(void* mem, size_t size, void* misc) {
} }
} }
- (mimetic::ResourceBuffer)loadResource:(const char* const)path { - (holovox::ResourceBuffer)loadResource:(const char* const)path {
NSString* p = [NSString stringWithFormat:@"%s", path]; NSString* p = [NSString stringWithFormat:@"%s", path];
NSString* key = [_registrar lookupKeyForAsset:p]; NSString* key = [_registrar lookupKeyForAsset:p];
NSString* nsPath = [[NSBundle mainBundle] pathForResource:key NSString* nsPath = [[NSBundle mainBundle] pathForResource:key
@@ -159,7 +159,7 @@ static void* freeResourceGlobal(void* mem, size_t size, void* misc) {
NSData* buffer = [NSData dataWithContentsOfFile:nsPath]; NSData* buffer = [NSData dataWithContentsOfFile:nsPath];
void* cpy = malloc([buffer length]); void* cpy = malloc([buffer length]);
memcpy(cpy, [buffer bytes], [buffer length]); // can we avoid this copy somehow? memcpy(cpy, [buffer bytes], [buffer length]); // can we avoid this copy somehow?
mimetic::ResourceBuffer rbuf(cpy, [buffer length]); holovox::ResourceBuffer rbuf(cpy, [buffer length]);
return rbuf; return rbuf;
} }

View File

@@ -30,7 +30,7 @@
@implementation FilamentNativeView { @implementation FilamentNativeView {
FilamentView* _view; FilamentView* _view;
FilamentViewController* _controller; FilamentViewController* _controller;
mimetic::FilamentViewer* _viewer; holovox::FilamentViewer* _viewer;
FilamentMethodCallHandler* _handler; FilamentMethodCallHandler* _handler;
void* _layer; void* _layer;
} }

View File

@@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
* *
*/ */
@interface FilamentView : UIView @interface FilamentView : UIView
- (void)setViewer:(mimetic::FilamentViewer*)viewer; - (void)setViewer:(holovox::FilamentViewer*)viewer;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -23,14 +23,14 @@ using namespace std;
@interface FilamentView () @interface FilamentView ()
- (void)initCommon; - (void)initCommon;
- (void)setViewer:(mimetic::FilamentViewer*)viewer; - (void)setViewer:(holovox::FilamentViewer*)viewer;
@end @end
@implementation FilamentView { @implementation FilamentView {
mimetic::FilamentViewer* _viewer; holovox::FilamentViewer* _viewer;
} }
- (void)setViewer:(mimetic::FilamentViewer*)viewer { - (void)setViewer:(holovox::FilamentViewer*)viewer {
_viewer = viewer; _viewer = viewer;
_viewer->updateViewportAndCameraProjection(self.bounds.size.width, self.bounds.size.height, self.contentScaleFactor); _viewer->updateViewportAndCameraProjection(self.bounds.size.width, self.bounds.size.height, self.contentScaleFactor);
} }

View File

@@ -23,7 +23,7 @@
@interface FilamentViewController : UIViewController @interface FilamentViewController : UIViewController
@property(weak, nonatomic) IBOutlet FilamentView* modelView; @property(weak, nonatomic) IBOutlet FilamentView* modelView;
- (void)setViewer:(mimetic::FilamentViewer*)viewer; - (void)setViewer:(holovox::FilamentViewer*)viewer;
- (void)startDisplayLink; - (void)startDisplayLink;
- (void)stopDisplayLink; - (void)stopDisplayLink;

View File

@@ -22,7 +22,7 @@
@implementation FilamentViewController { @implementation FilamentViewController {
CADisplayLink* _displayLink; CADisplayLink* _displayLink;
NSObject<FlutterPluginRegistrar>* _registrar; NSObject<FlutterPluginRegistrar>* _registrar;
mimetic::FilamentViewer* _viewer; holovox::FilamentViewer* _viewer;
FilamentView* _view; FilamentView* _view;
} }
@@ -35,7 +35,7 @@
return self; return self;
} }
- (void)setViewer:(mimetic::FilamentViewer*)viewer { - (void)setViewer:(holovox::FilamentViewer*)viewer {
_viewer = viewer; _viewer = viewer;
[_view setViewer:_viewer]; [_view setViewer:_viewer];
} }

View File

@@ -75,7 +75,7 @@ namespace gltfio {
filament::math::quatf* rotation, filament::math::float3* scale); filament::math::quatf* rotation, filament::math::float3* scale);
} }
namespace mimetic { namespace holovox {
const double kNearPlane = 0.05; // 5 cm const double kNearPlane = 0.05; // 5 cm
const double kFarPlane = 1000.0; // 1 km const double kFarPlane = 1000.0; // 1 km

View File

@@ -40,7 +40,7 @@ using namespace utils;
using namespace camutils; using namespace camutils;
namespace mimetic { namespace holovox {
typedef std::chrono::time_point<std::chrono::high_resolution_clock> time_point_t; typedef std::chrono::time_point<std::chrono::high_resolution_clock> time_point_t;

View File

@@ -25,31 +25,32 @@ abstract class FilamentController {
Future zoom(double z); Future zoom(double z);
} }
class MimeticFilamentController extends FilamentController { class HolovoxFilamentController extends FilamentController {
late int _id; late int _id;
late MethodChannel _channel; late MethodChannel _channel;
final String materialPath; final String materialPath;
final Function(int id)? onFilamentViewCreatedHandler;
MimeticFilamentController( HolovoxFilamentController(
{this.materialPath = "packages/holovox_filament/assets/compiled.mat"}); {this.materialPath = "packages/holovox_filament/assets/compiled.mat",
this.onFilamentViewCreatedHandler});
@override @override
void onFilamentViewCreated(int id) async { void onFilamentViewCreated(int id) async {
_id = id; _id = id;
_channel = MethodChannel("mimetic.app/filament_view_$id"); _channel = MethodChannel("holovox.app/filament_view_$id");
_channel.setMethodCallHandler((call) async { _channel.setMethodCallHandler((call) async {
await Future.delayed(Duration( await Future.delayed(Duration(
seconds: seconds:
1)); // todo - need a better way to know when the GL context is actaully ready 1)); // todo - need a better way to know when the GL context is actually ready
await _initialize(); await _initialize();
onFilamentViewCreatedHandler?.call(_id);
return Future.value(true); return Future.value(true);
}); });
} }
@override @override
Future _initialize() async { Future _initialize() async {
final foo = await rootBundle.load(materialPath);
print("Initializing with material path of size ${foo.lengthInBytes}");
await _channel.invokeMethod("initialize", materialPath); await _channel.invokeMethod("initialize", materialPath);
} }

View File

@@ -8,7 +8,7 @@ import '../../filament_controller.dart';
import 'filament_view_platform.dart'; import 'filament_view_platform.dart';
class FilamentView extends FilamentViewPlatform { class FilamentView extends FilamentViewPlatform {
static const FILAMENT_VIEW_ID = 'mimetic.app/filament_view'; static const FILAMENT_VIEW_ID = 'holovox.app/filament_view';
@override @override
Widget buildView( Widget buildView(