PanicAR Framework 1.04
Ready-to-go AR functionality for any existing iOS App
Public Member Functions | Static Public Member Functions

ARController Class Reference

main controller of AR functionality More...

List of all members.

Public Member Functions

(Mesh) - defaultMarkerMesh
(ARMarkerTemplate *) - defaultMarkerTemplate
(Mesh) - radarMesh
(uint) - radarDot
(uint) - radarBG
(ARMarker *) - lastTappedMarker
(BOOL) - inRadarMode
(void) - setDelegate:
(id) - initWithNibName:bundle:
(id) - initWithNibName:bundle:delegate:
(void) - suspendToBackground
(void) - resumeFromBackground
(void) - freeMemory
(BOOL) - startLocationServicesIfNeccessary
(void) - stopLocationServices:
(void) - addObject:
(ARMarker *) - addMarker:
(ARMarker *) - addMarkerAtLocation:atLocation:
(void) - addMarkers:
(void) - removeMarker:
(void) - clearMarkers
(int) - numberOfMarkers
(void) - setViewport:
(BOOL) - showController:showStatusBar:
(BOOL) - showController:showStatusBar:
(void) - hideController
(void) - showRadar
(void) - hideRadar

Static Public Member Functions

(void) + setAPIKey:
(void) + setEnableAccelerometer:
(void) + setEnableCameraView:
(void) + setEnableMovieCapture:
(void) + setEnableRadar:
(void) + setEnableAutoswitchToRadar:
(void) + setEnableViewOrientationUpdate:
(void) + setEnableInteraction:
(void) + setEnableLoadingView:
(void) + setEnableContinuousGPS:
(void) + setDefaultOrientation:
(void) + setFadeInAnim:
(void) + setFadeOutAnim:
(void) + setCameraTransform:y:
(void) + setCameraTint:g:b:a:
(void) + setRadarPosition:y:
(void) + setRange:Maximum:
(BOOL) + deviceSupportsAR
(BOOL) + locationServicesAvailable
(BOOL) + locationServicesAvailable:delayError:
(BOOL) + loadMesh:mesh:
(uint) + loadTexture:
(double) + bearingTowardsLocation:to:
(ARController *) + sharedController

Detailed Description

main controller of AR functionality

the ARController creates and controls the CameraView, the OpenGL 3D View and the LocationManager it will handle all Augmented Reality calculations and the drawing of the markers


Member Function Documentation

- (ARMarker*) addMarker: (ARMarker *)  marker

adds an ARMarker to the controller Marker needs to have location!

- (ARMarker*) addMarkerAtLocation: (ARMarker *)  marker
atLocation: (CLLocation *)  cllocation 

adds the ARMarker at the given location

Parameters:
atLocation,:set this location to the marker and add it to the controller
- (void) addMarkers: (NSArray *)  array

adds an array of ARMarker-type objects to the controller Markers need to have locations assign, markers without will be omitted!

- (void) addObject: (id< ARObjectDelegate >)  object

adds an ARMarker to the controller Marker needs to have location!

+ (double) bearingTowardsLocation: (CLLocation *)  fromLocation
to: (CLLocation *)  towardsLocation 

calculates the direction towards a location, heads-up line isthe north

pole at 0 degrees does not take into account the earth's curve and therefore

will grow more inaccurate the farther the locations are apart

- (void) clearMarkers

remove all ARMarkers from the controller

- (Mesh) defaultMarkerMesh

INTERNAL: default marker mesh

- (ARMarkerTemplate*) defaultMarkerTemplate

INTERNAL: default marker template

+ (BOOL) deviceSupportsAR

checks if the device supports Augmented Reality functionality

Returns YES if GPS, Compass and Camera are available i.e. if the hardware model is iPhone 3Gs or later

will always return YES if running iOS 3.x: cannot check for AR availability automatically, use an instance of CLLocationManager and 'headingAvailable' to check for compass availability

- (void) freeMemory

free as much memory as possible (mainly by releasing OGL memory occupied by ARMarker textures)

- (void) hideController

hide the ARController view

- (void) hideRadar

hide the radar view within the ARController view

- (id) initWithNibName: (NSString *)  nibNameOrNil
bundle: (NSBundle *)  nibBundleOrNil 

create ARController with startup parameters

initinitWithNibName:

Parameters:
nibNameOrNilname of Interface File (nib or xib) without extension
nibBundleOrNilbundle to load Interface File from

allocates and initializes a new ARController instance with previously defined settings. The instance will be returned and will be available in the class field 'sharedController'

- (id) initWithNibName: (NSString *)  nibNameOrNil
bundle: (NSBundle *)  nibBundleOrNil
delegate: (id< ARControllerDelegate >)  _delegate 

create ARController with startup parameters, pass a custom delegate object

initWithNibName:

Parameters:
nibNameOrNilname of Interface File (nib or xib) without extension
nibBundleOrNilbundle to load Interface File from
delegatethe delegate instance to receive events from the ARController

allocates and initializes a new ARController instance with previously defined settings. The instance will be returned and will be available in the class field 'sharedController'

- (BOOL) inRadarMode

is ARView in Radar Mode?

- (ARMarker*) lastTappedMarker

last tapped marker

+ (BOOL) loadMesh: (NSString *)  meshFilename
mesh: (Mesh &)  mesh 

load a mesh for use in the AR view (pass mesh as pointer to Mesh struct)

supports loading of OBJ-files, specs: triangulated, single UV set, need to have material please note that popular 3d model tools may export OBJ without UVs when using materials without textures

make sure mesh file is added to XCode first

Returns:
YES if mesh successfully loaded, otherwise NO
+ (uint) loadTexture: (NSString *)  textureFilename

load a texture into OpenGL for use in the AR view

loads all image formats supported by the SDK and creates a OpenGL texture name for it

Returns:
the OpenGL texture name (uint)
+ (BOOL) locationServicesAvailable

checks if location services are available/allowed for the device/user

only checks if location services are turned on and the app is authorized to use them will not take into account if Airplane Mode is turned on

use deviceSupportsAR to check if device supports camera and location services in general

Returns YES if location services are available to app

will always return YES if running iOS 3.x: locationServicesAvailable: cannot check for availability on iOS 3.x, check manually for locationManager locationServicesAvailable

+ (BOOL) locationServicesAvailable: (BOOL)  raiseError
delayError: (BOOL)  delayError 

checks if location services are available/allowed for the device/user

Parameters:
raiseError,:if YES a error will be dispatched to the delegate using arDidReceiveError
delayError,:if YES a error will be dispatched to the delegate the next time the ARView becomes visible

only checks if location services are turned on and the app is authorized to use them will not take into account if Airplane Mode is turned on

use deviceSupportsAR to check if device supports camera and location services in general

Returns YES if location services are available to app

will always return YES if running iOS 3.x: locationServicesAvailable: cannot check for availability on iOS 3.x, check manually for locationManager locationServicesAvailable

- (int) numberOfMarkers

returns the number of ARMarkers currently added to the Controller

- (uint) radarBG

INTERNAL: radar background texture

- (uint) radarDot

INTERNAL: radar marker texture

- (Mesh) radarMesh

INTERNAL: radar base mesh

- (void) removeMarker: (ARMarker *)  marker

remove a ARMarker object

- (void) resumeFromBackground

resume ARController

+ (void) setAPIKey: (NSString *)  key

CONFIGURATION: set API key

the Framework will run in DEMO Mode unless it receives a valid API key can only be set before ARController is initialized

contact sales@dopanic.com for a valid API key

default: ""

+ (void) setCameraTint: (float)  r
g: (float)  g
b: (float)  b
a: (float)  a 

CONFIGURATION: set a background color for the OpenGL view (rendered above the Camera's live feed)

Parameters:
rred component of background color
ggreen component of background color
bblue component of background color
aalpha component of background color

can be used to increased contrast (when set to black with low alpha-value

default: (0,0,0,0)

+ (void) setCameraTransform: (float)  x
y: (float)  y 

CONFIGURATION: set the camera's live view transformation (to achieve full screen camera view)

Parameters:
xthe width transformation of the camera's live view
ythe height transformation of the camera's live view

default for iPhone4: (1.25,1.25)

+ (void) setDefaultOrientation: (UIDeviceOrientation)  orientation

CONFIGURATION: the default orientation of the ARController's view

Parameters:
orientationthe default device orientation

set to Landscape if default view is landscape, otherwise set to portrait

default: UIDeviceOrientationPortrait

- (void) setDelegate: (id< ARControllerDelegate >)  _delegate

set the delegate object to handle all ARController events

Parameters:
_delegatethe delegate you want to use
+ (void) setEnableAccelerometer: (BOOL)  state

CONFIGURATION: use movie capture mode of camera for better image (but with ipod playback interruption while ARView is visible)

Parameters:
stateset to YES or NO

can only be set before ARController is initialized

disabling will also disable EnableAutoswitchToRadar and EnableViewOrientationUpdate

default: NO

+ (void) setEnableAutoswitchToRadar: (BOOL)  state

CONFIGURATION: switch to radar based on device orientation (OrientationFaceUp)

Parameters:
stateset to YES or NO

can only be set before ARController is initialized

default: NO

+ (void) setEnableCameraView: (BOOL)  state

CONFIGURATION: use live camera view

Parameters:
stateset to YES or NO

can be disabled for special use cases

can only be set before ARController is initialized

disabling will also disable EnableMovieCapture

default: YES

+ (void) setEnableContinuousGPS: (BOOL)  state

CONFIGURATION: by default locationManager does not do updates when ARView not shown, set this setting to YES to update the locationManager continuosly

Parameters:
stateset to YES or NO

default: NO

+ (void) setEnableInteraction: (BOOL)  state

CONFIGURATION: enable touch events on Markers and scrolling through marker-stacks

Parameters:
stateset to YES or NO

default: YES

+ (void) setEnableLoadingView: (BOOL)  state

CONFIGURATION: enable screens to cover up AR view transitions (e.g. iris animation of UIImagePickerController)

Parameters:
stateset to YES or NO

not yet supported on iOS 5

default: NO

+ (void) setEnableMovieCapture: (BOOL)  state

CONFIGURATION: use movie capture mode of UIImagePickerController

Parameters:
stateset to YES or NO

needs EnableCameraView to be YES

can only be set before ARController is initialized

if enabled, UIImagePickerController will use movie capture mode which will create a better preview image of the camera, but will cause iPod playback to be interrupted as soon as the ARController is shown

default: NO

+ (void) setEnableRadar: (BOOL)  state

CONFIGURATION: use the top-down radar-style rendering of the camera view

Parameters:
stateset to YES or NO

can only be set before ARController is initialized

default: NO

+ (void) setEnableViewOrientationUpdate: (BOOL)  state

CONFIGURATION: update ARController's view orientation to device' orientation

Parameters:
stateset to YES or NO

needs EnableAccelerometer to be YES

will only change the content of the OpenGL-rendered view, not the orientation of any view in the controller or of the controller itself

default: NO

+ (void) setFadeInAnim: (UIViewAnimationTransition)  anim

CONFIGURATION: set the fade in animation transition used when displaying the ARController as a modal view

Parameters:
animthe animation style used for showing the AR View

default: UIViewAnimationTransitionFlipFromLeft

+ (void) setFadeOutAnim: (UIViewAnimationTransition)  anim

CONFIGURATION: set the fade out animation transition used when displaying the ARController as a modal view

Parameters:
animthe animation style used for hiding the AR View

default: UIViewAnimationTransitionFlipFromRight

+ (void) setRadarPosition: (float)  x
y: (float)  y 

CONFIGURATION: set the center of the radar on screen

Parameters:
xthe sideways offset of the radar screen
ythe up-down offset of the radar screen

default: (0,0)

+ (void) setRange: (float)  min
Maximum: (float)  max 

CONFIGURATION: set the min range and max range for markers to be displayed

Parameters:
minmarkers closer to the device than min are not shown on screen
maxmarkers farther away than max are not shown on screen

set to -1 to remove limit

default: (5,20000)

- (void) setViewport: (CGRect)  rect

set the viewport area of the Augmented Reality view

Parameters:
rectnew viewport area
+ (ARController*) sharedController

returns the current AR controller

- (BOOL) showController: (BOOL)  asModal
showStatusBar: (BOOL)  showStatusBar 

show the ARController view

Parameters:
asModalshow as modal view?
showStatusBarshow statusbar?
- (BOOL) showController: (BOOL)  asModal
showStatusBar: (BOOL)  showStatusBar 

show the ARController view

Parameters:
asModalshow as modal view?
showStatusBarshow statusbar?
displayErrorshow alert for errors that occur?
Returns:
YES if controller can be shown, NO if error occured (e.g. location not available)
- (void) showRadar

show the radar view within the ARController view

- (BOOL) startLocationServicesIfNeccessary

manually start location service update, only needed if stopped before, see: stopLocationServices

- (void) stopLocationServices: (BOOL)  force

manually stop location service update

- (void) suspendToBackground

suspend ARController

 All Classes Functions