By little
on Wed, 06/20/2012 - 17:10
Hello.
I want integrate vuforia sdk with [URL=http://isgl3d.com/]Isgl3d[/URL] framework.
I changed ImageTarget example from the vuforia sdk samples. In
ImageTargetAppDelegate.mm add isgl view with transparent
background over the arParentController.view but I get a black screen.
When I commented out this:
[CODE]//[[Isgl3dDirector sharedInstance] run] [/CODE]
then I normaly see my video camera image.
May be something wrong with cleaning background? But I set the transparency:
[CODE][Isgl3dDirector sharedInstance].backgroundColorString = @"00000000";
..
..
_viewController.view.backgroundColor = [UIColor clearColor];
_viewController.view.opaque = NO;[/CODE]
This is my ImageTargetAppDelegate.mm:
[CODE]#import "ImageTargetsAppDelegate.h"
#import "ARParentViewController.h"
#import "QCARutils.h"
#import "Isgl3d.h"
#import "Isgl3dViewController.h"
#import "GWViewManager.h"
#import "GWPlayersListViewController.h"
@implementation ImageTargetsAppDelegate
static BOOL firstTime = YES;
// test to see if the screen has hi-res mode
- (BOOL) isRetinaEnabled{
return ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)]
&&
([UIScreen mainScreen].scale == 2.0));
}
// Setup a continuation of the splash screen until the camera is initialised
- (void) setupSplashContinuation{
CGRect screenBounds = [[UIScreen mainScreen] bounds];
// first get the splash screen continuation in place
NSString *splashImageName = @"Default.png";
if (screenBounds.size.width == 768)
splashImageName = @"Default-Portrait~ipad.png";
else if ((screenBounds.size.width == 320) && [self isRetinaEnabled])
splashImageName = @"Default@2x.png";
UIImage *image = [UIImage imageNamed:splashImageName];
splashV = [[UIImageView alloc] initWithImage:image];
splashV.frame = screenBounds;
[window addSubview:splashV];
// poll to see if the camera video stream has started and if so remove the splash screen.
[NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(removeSplash:) userInfo:nil repeats:YES];
}
// this is the application entry point
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
QCARutils *qUtils = [QCARutils getInstance];
CGRect screenBounds = [[UIScreen mainScreen] bounds];
window = [[UIWindow alloc] initWithFrame: screenBounds];
[self setupSplashContinuation];
// Provide a list of targets we're expecting - the first in the list is the default
[qUtils addTargetName:@"Stones & Chips" atPath:@"StonesAndChips.xml"];
[qUtils addTargetName:@"Tarmac" atPath:@"Tarmac.xml"];
// Add the EAGLView and the overlay view to the window
arParentViewController = [[ARParentViewController alloc] init];
arParentViewController.arViewRect = screenBounds;
[window insertSubview:arParentViewController.view atIndex:0];
//[window addSubview:arParentViewController.view];
[window makeKeyAndVisible];
// Set the background transparent
[Isgl3dDirector sharedInstance].backgroundColorString = @"00000000";
// Create the UIViewController
_viewController = [[Isgl3dViewController alloc] init];
_viewController.wantsFullScreenLayout = YES;
// Create OpenGL view (here for OpenGL ES 1.1)
Isgl3dEAGLView * glView = [Isgl3dEAGLView viewWithFrameForES1:[window bounds]];
// Set view in director
[Isgl3dDirector sharedInstance].openGLView = glView;
// Enable retina display : uncomment if desired
[[Isgl3dDirector sharedInstance] enableRetinaDisplay:YES];
// Enables anti aliasing (MSAA) : uncomment if desired (note may not be available on all devices and can have performance cost)
[Isgl3dDirector sharedInstance].antiAliasingEnabled = YES;
// Set the animation frame rate
[[Isgl3dDirector sharedInstance] setAnimationInterval:1.0/60];
// Add the OpenGL view to the view controller
_viewController.view = glView;
// Make the opengl view transparent
_viewController.view.backgroundColor = [UIColor clearColor];
_viewController.view.opaque = NO;
// Add view to window and make visible
[window addSubview:_viewController.view];
[window makeKeyAndVisible];
[_viewController.view addSubview:[GWViewManager instance].playersList.view];
// Creates the view(s) and adds them to the director
//Isgl3dView *sceneView = [GWViewManager instance].helloWorldView;
//[[Isgl3dDirector sharedInstance] addView:sceneView];
//Isgl3dView *uiView = [GWViewManager instance].interfaceView;
//[[Isgl3dDirector sharedInstance] addView:uiView];
//Isgl3dView *toolPanelView = [GWViewManager instance].toolPanelView;
//[[Isgl3dDirector sharedInstance] addView:toolPanelView];
// Run the director
[[Isgl3dDirector sharedInstance] run];
return YES;
}
- (void) removeSplash:(NSTimer *)theTimer{
// poll to see if the camera video stream has started and if so remove the splash screen.
if ([QCARutils getInstance].videoStreamStarted == YES)
{
[splashV removeFromSuperview];
[theTimer invalidate];
}
}
- (void)applicationDidBecomeActive:(UIApplication *)application{
// don't do this straight after startup - the view controller will do it
if (firstTime == NO)
{
// do the same as when the view is shown
[arParentViewController viewDidAppear:NO];
}
firstTime = NO;
[[Isgl3dDirector sharedInstance] resume];
}
- (void)applicationWillResignActive:(UIApplication *)application{
// do the same as when the view has dissappeared
[arParentViewController viewDidDisappear:NO];
[[Isgl3dDirector sharedInstance] pause];
}
- (void)applicationWillTerminate:(UIApplication *)application{
// Remove the OpenGL view from the view controller
[[Isgl3dDirector sharedInstance].openGLView removeFromSuperview];
// End and reset the director
[Isgl3dDirector resetInstance];
// Release
[_viewController release];
_viewController = nil;
[window release];
window = nil;
}
- (void) applicationDidEnterBackground:(UIApplication *)application {
[[Isgl3dDirector sharedInstance] stopAnimation];
}
- (void) applicationWillEnterForeground:(UIApplication *)application {
[[Isgl3dDirector sharedInstance] startAnimation];
}
- (void) applicationDidReceiveMemoryWarning:(UIApplication *)application {
[[Isgl3dDirector sharedInstance] onMemoryWarning];
}
- (void) applicationSignificantTimeChange:(UIApplication *)application {
[[Isgl3dDirector sharedInstance] onSignificantTimeChange];
}
- (void)dealloc{
if(arParentViewController){
[arParentViewController release];
}
if (_viewController) {
[_viewController release];
}
if (window) {
[window release];
}
[GWViewManager destroy];
[super dealloc];
}
@end
[/CODE]
Re: Isgl3d and vuforia sdk
Re: Isgl3d and vuforia sdk
Re: Isgl3d and vuforia sdk
Re: Isgl3d and vuforia sdk