我从https://github.com/yshrkt/VuforiaSampleSwift下载了带有Swift的示例Vuforia实现。它不能正常工作,但是玩了一点之后我就可以运行它了。 Objective-C
中有一些包装。我有一个问题。值为_objectScale = 0.03175f
。我认为它是针对一台设备进行硬编码的,但是当我在其他设备上运行它时,目标太小或太大。我需要为每个设备手动调整此值。有人可以告诉我这种价值来自何处吗?我能以某种方式在设备上即时计算它还是从Vuforia库中读取它?
- (id)initWithFrame:(CGRect)frame manager:(VuforiaManager *)manager
{
self = [super initWithFrame:frame];
if (self) {
_manager = manager;
// Enable retina mode if available on this device
if (YES == [_manager isRetinaDisplay]) {
[self setContentScaleFactor:[UIScreen mainScreen].nativeScale];
}
// Create the OpenGL ES context
_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
// The EAGLContext must be set for each thread that wishes to use it.
// Set it the first time this method is called (on the main thread)
if (_context != [EAGLContext currentContext]) {
[EAGLContext setCurrentContext:_context];
}
_offTargetTrackingEnabled = NO;
_objectScale = 0.03175f;
_nearPlane = 0.01;
_farPlane = 5;
[self initRendering];
}
return self;
}