com.metaio.sdk
Class MetaioSurfaceView

java.lang.Object
  extended by GLSurfaceView
      extended by com.metaio.sdk.MetaioSurfaceView

public final class MetaioSurfaceView
extends GLSurfaceView

This class encapsulates metaio SDK renderer's view. It manages tracking, touch events, loading and rendering geometries. This view should be overlayed on top of camera view to experience the augmentation, because rendered does not renders camera image


Nested Class Summary
static interface MetaioSurfaceView.Callback
          Implement this callback to load/unload geometries, transform geometries and handle geometries selection through touch event and receive animation events.
 
Constructor Summary
MetaioSurfaceView(Context context)
          Creates GLSurfaceView for rendering
MetaioSurfaceView(Context context, GLSurfaceView.EGLConfigChooser chooser)
          Creates GLSurfaceView for rendering
 
Method Summary
 AudioRenderer getAudioRenderer()
           
static GLSurfaceView.EGLConfigChooser getEGLConfigChooser(int r, int g, int b, int a, int depth, int stencil, int samples)
          Returns
 FrameLayout.LayoutParams getLayoutParams(Vector2di cameraResolution, boolean fullScreen)
          Helper method to determine best layout parameters for this view This method assumes that Activity is in landscape mode.
 FrameLayout.LayoutParams getLayoutParams(Vector2di cameraResolution, boolean fullScreen, boolean portrait)
          Helper method to determine best layout parameters for this view
 FrameLayout.LayoutParams getLayoutParams(Vector2di cameraResolution, Rect visibleFrame, boolean fullView)
          Helper method to determine best layout parameters for this view This method assumes that Activity is in landscape mode.
 FrameLayout.LayoutParams getLayoutParams(Vector2di cameraResolution, Rect visibleFrame, boolean fullView, boolean portrait)
          Helper method to determine best layout parameters for this view
 PointF globalToLocalViewCoordinates(MotionEvent event, Rect visibleFrame)
          This transforms onTouch global screen coordinates into local view coordinate system, while compensating for the visible window frame and local view dimensions.
 void onDrawFrame(GL10 gl)
           
 void onPause()
           
 void onResume()
           
 void onSurfaceChanged(GL10 gl, int w, int h)
           
 void onSurfaceCreated(GL10 gl, EGLConfig config)
           
 void registerCallback(MetaioSurfaceView.Callback callback)
          Register a callback class to load/unload geometries, transform geometries and handle selection of geometries through touch event.
 void surfaceChanged(SurfaceHolder holder, int format, int w, int h)
           
 void surfaceCreated(SurfaceHolder holder)
           
 void surfaceDestroyed(SurfaceHolder holder)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetaioSurfaceView

public MetaioSurfaceView(Context context)
Creates GLSurfaceView for rendering

Parameters:
context - Application context

MetaioSurfaceView

public MetaioSurfaceView(Context context,
                         GLSurfaceView.EGLConfigChooser chooser)
Creates GLSurfaceView for rendering

Parameters:
context - Application context
chooser - Customized GLSurfaceView.EGLConfigChooser instance
Method Detail

getEGLConfigChooser

public static GLSurfaceView.EGLConfigChooser getEGLConfigChooser(int r,
                                                                 int g,
                                                                 int b,
                                                                 int a,
                                                                 int depth,
                                                                 int stencil,
                                                                 int samples)
Returns

Parameters:
r - int redSize
g - int greenSize
b - int blueSize
a - int alphaSize
depth - int depthSize
stencil - int stencilSize
samples - int samples 0/2/4 for multisampling
Returns:
pointer to GLSurfaceView.EGLConfigChooser to be used

getLayoutParams

public FrameLayout.LayoutParams getLayoutParams(Vector2di cameraResolution,
                                                boolean fullScreen)
Helper method to determine best layout parameters for this view This method assumes that Activity is in landscape mode.

Parameters:
cameraResolution - Camera image resolution
fullScreen - camera view will be stretched to full screen if true, else it will be stretched to best fit keeping the aspect ratio
Returns:
Layout params that can be applies to the camera view
See Also:
getLayoutParams(Vector2di, boolean, boolean)

getLayoutParams

public FrameLayout.LayoutParams getLayoutParams(Vector2di cameraResolution,
                                                Rect visibleFrame,
                                                boolean fullView)
Helper method to determine best layout parameters for this view This method assumes that Activity is in landscape mode.

Parameters:
cameraResolution - Camera image resolution
visibleFrame - Visible window frame in which this view should fit in
fullView - true to fill entire parent view, false to best fit
Returns:
LayoutParams

getLayoutParams

public FrameLayout.LayoutParams getLayoutParams(Vector2di cameraResolution,
                                                Rect visibleFrame,
                                                boolean fullView,
                                                boolean portrait)
Helper method to determine best layout parameters for this view

Parameters:
cameraResolution - Camera image resolution
visibleFrame - Visible window frame in which this view should fit in
fullView - true to fill entire parent view, false to best fit
portrait - true if the Activity is in portrait orientation
Returns:
LayoutParams

getLayoutParams

public FrameLayout.LayoutParams getLayoutParams(Vector2di cameraResolution,
                                                boolean fullScreen,
                                                boolean portrait)
Helper method to determine best layout parameters for this view

Parameters:
cameraResolution - Camera image resolution
fullScreen - camera view will be stretched to full screen if true, else it will be stretched to best fit keeping the aspect ratio
portrait - if the Activity is in portrait orientation
Returns:
Layout params that can be applies to the camera view

globalToLocalViewCoordinates

public PointF globalToLocalViewCoordinates(MotionEvent event,
                                           Rect visibleFrame)
This transforms onTouch global screen coordinates into local view coordinate system, while compensating for the visible window frame and local view dimensions.

Parameters:
event - MotionEvent
visibleFrame - Visible window frame
Returns:
PointF containing touch event coordinates in local view

surfaceCreated

public void surfaceCreated(SurfaceHolder holder)

surfaceChanged

public void surfaceChanged(SurfaceHolder holder,
                           int format,
                           int w,
                           int h)

surfaceDestroyed

public void surfaceDestroyed(SurfaceHolder holder)

registerCallback

public void registerCallback(MetaioSurfaceView.Callback callback)
Register a callback class to load/unload geometries, transform geometries and handle selection of geometries through touch event.

Parameters:
callback - a class which implements MetaioSurfaceView.Callback interface
See Also:
MetaioSurfaceView.Callback

onPause

public void onPause()

onResume

public void onResume()

getAudioRenderer

public AudioRenderer getAudioRenderer()

onSurfaceCreated

public void onSurfaceCreated(GL10 gl,
                             EGLConfig config)

onSurfaceChanged

public void onSurfaceChanged(GL10 gl,
                             int w,
                             int h)

onDrawFrame

public void onDrawFrame(GL10 gl)