Unity3d Vuforia与Mobile Movie Texture插件结合

Mobile Movie Texture插件(以下统称MMT)重要是为播放视频,此中包含透明通道视频,尤其是AR中播放透底视频。
(一般只须要融会这个就可以,由于Xcode只会执行一个.mm文件,之所以会呈现扫描不播放视频的情形,重要是由于这个原因)。

 

整合到VuforiaNativeRendererController.mm

/*============================================================================
Copyright (c) 2014 Qualcomm Connected Experiences, Inc.
All Rights Reserved.
============================================================================*/
#import <UIKit/UIKit.h>
#import "UnityAppController.h"
#import "VuforiaRenderDelegate.h"


// Unity native rendering callback plugin mechanism is only supported
// from version 4.5 onwards
#if UNITY_VERSION>434

// Exported methods for native rendering callback
extern "C" void VuforiaSetGraphicsDevice(void* device, int deviceType, int eventType);
extern "C" void VuforiaRenderEvent(int marker);


extern "C" void MMTUnitySetGraphicsDevice(void* device, int deviceType, int eventType);
extern "C" void MMTUnityRenderEvent(int marker);

extern "C" void VuforiaSetGraphicsDeviceMerge(void* device, int deviceType, int eventType)
{
VuforiaSetGraphicsDevice(device, deviceType, eventType);
MMTUnitySetGraphicsDevice(device, deviceType, eventType);
}

extern "C" void VuforiaRenderEventMerge(int marker)
{
VuforiaRenderEvent(marker);
MMTUnityRenderEvent(marker);
}

#endif

// Controller to support native rendering callback
@interface VuforiaNativeRendererController : UnityAppController
{
}
- (void)shouldAttachRenderDelegate;
@end

@implementation VuforiaNativeRendererController

- (void)shouldAttachRenderDelegate
{
self.renderDelegate = [[VuforiaRenderDelegate alloc] init];

// Unity native rendering callback plugin mechanism is only supported
// from version 4.5 onwards
#if UNITY_VERSION>434
UnityRegisterRenderingPlugin(&VuforiaSetGraphicsDeviceMerge, &VuforiaRenderEventMerge);
#endif
}
@end


IMPL_APP_CONTROLLER_SUBCLASS(VuforiaNativeRendererController)

posted @ 2017-05-12 15:17  laugher  阅读(885)  评论(0编辑  收藏  举报