Fork me
BeyondAR
Augmented Reality Framework for Android
 All Classes Functions Variables
com.beyondar.android.opengl.renderer.ARRenderer Class Reference

Renderer for drawing the World with OpenGL. More...

Inheritance diagram for com.beyondar.android.opengl.renderer.ARRenderer:
Collaboration diagram for com.beyondar.android.opengl.renderer.ARRenderer:

Classes

interface  FpsUpdatable
 
interface  GLSnapshotCallback
 Callback to get notified when the snapshot of the OpenGL view is taken. More...
 

Public Member Functions

 ARRenderer ()
 ARRenderer constructor.
 
void rotateView (int surfaceRotation)
 Set the rotation of the device:
Surface.ROTATION_0
Surface.ROTATION_90
Surface.ROTATION_180
Surface.ROTATION_270
More...
 
void setWorld (World world)
 Define the world where the objects are stored. More...
 
World getWorld ()
 Get the World used for by the ARRenderer. More...
 
void setCameraPosition (Point3 newCameraPos)
 Change the camera position. More...
 
void restoreCameraPosition ()
 Restore the camera position.
 
Point3 getCameraPosition ()
 Get the camera position. More...
 
void onDrawFrame (GL10 gl)
 
void setPullCloserDistance (float maxDistanceSize)
 When a GeoObject is rendered according to its position it could look very small if it is far away. More...
 
float getPullCloserDistance ()
 Get the max distance which a GeoObject will be rendered. More...
 
void setPushAwayDistance (float minDistanceSize)
 When a GeoObject is rendered according to its position it could look very big if it is too close. More...
 
float getPushAwayDistance ()
 Get the minimum distance which a GeoObject will be rendered. More...
 
void setFpsUpdatable (FpsUpdatable fpsUpdatable)
 Set the FpsUpdatable to get notified about the frames per seconds. More...
 
void setOnBeyondarObjectRenderedListener (OnBeyondarObjectRenderedListener rendererTracker)
 
void fillBeyondarObjectScreenPositions (BeyondarObject beyondarObject)
 Use this method to fill all the screen positions of the BeyondarObject. More...
 
void tackePicture (GLSnapshotCallback callBack)
 Take an snapshot of the view. More...
 
void onSurfaceChanged (GL10 gl, int width, int height)
 
void onSurfaceCreated (GL10 gl, EGLConfig config)
 
void loadBeyondarObjectTexture (GL10 gl, BeyondarObject geoObject)
 Load the textures of the specified geoObject. More...
 
Texture loadBitmapTexture (GL10 gl, Bitmap btm, String uri)
 Load the Texture from a Bitmap. More...
 
boolean isTextureLoaded (Bitmap bitmap)
 Check if the bitmap texture object is loaded. More...
 
boolean isTextureObjectLoaded (String uri)
 Check if the image URI has been loaded as a texture. More...
 
Texture getTexture (String uri)
 Get a copy of the texture pointer for the specified URI. More...
 
Texture load2DTexture (GL10 gl, Bitmap bitmap)
 Create the texture for the specified Bitmap. More...
 
void onSensorChanged (float[] filteredValues, SensorEvent event)
 
void getViewRay (float x, float y, Ray ray)
 Get a view Ray for the screen position (x,y). More...
 
void getScreenCoordinates (Point3 position, Point3 outPoint)
 Get the screen position of a given Point3. More...
 
void getScreenCoordinates (Point3 position, Point3 outPoint, float[] eye)
 Get the screen position of a given Point3. More...
 
void getScreenCoordinates (float x, float y, float z, Point3 outPoint, float[] eye)
 Get the screen position of a given Point3. More...
 
void setRendering (boolean render)
 Specify if the ARRenderer should render the world. More...
 
boolean isRendering ()
 Get known if the ARRenderer is rendering the world. More...
 
void onExternalBitmapLoaded (BitmapCache cache, String url, Bitmap btm)
 This method is called when an external image (such as a network image) is loaded and stored in the cache. More...
 
void forceFillBeyondarObjectPositions (boolean fill)
 Use this method to fill all the screen positions of the BeyondarObject when a object is rendered. More...
 
void addPlugin (GLPlugin plugin)
 
boolean removePlugin (GLPlugin plugin)
 
void removeAllPlugins ()
 
GLPlugin getFirstPlugin (Class<?extends GLPlugin > pluginClass)
 
boolean containsAnyPlugin (Class<?extends GLPlugin > pluginClass)
 
boolean containsPlugin (GLPlugin plugin)
 
List< GLPlugingetAllPlugins (Class<?extends GLPlugin > pluginClass, List< GLPlugin > result)
 
List< GLPlugingetAllPugins (Class<?extends GLPlugin > pluginClass)
 
List< GLPlugingetAllPlugins ()
 
void onPause ()
 Called when the application is paused.
 
void onResume ()
 Called when the application is resumed.
 
void setMaxDistanceToRender (float meters)
 Set the distance (in meters) which the app will draw the objects. More...
 
float getMaxDistanceToRender ()
 Get the distance (in meters) which the AR view will draw the objects. More...
 
void setDistanceFactor (float factor)
 Set the distance factor for rendering all the objects. More...
 
float getDistanceFactor ()
 Get the distance factor. More...
 

Static Public Attributes

static final float DEFAULT_MAX_AR_VIEW_DISTANCE = 100
 The default maximum distance that the object will be displayed (meters) in the AR view.
 
static final float DEFAULT_DISTANCE_FACTOR = 2
 
static float Z_FAR = 400.0f
 Specifies the distance from the viewer to the far clipping plane. More...
 
static final double TIMEOUT_LOAD_TEXTURE = 1500
 

Protected Member Functions

Bitmap savePixels (GL10 gl)
 Generate a new bitmap from the gl. More...
 
void convertGPStoPoint3 (GeoObject geoObject, Point3 out)
 Convert the geolocation to gl points representation. More...
 
void renderWorld (GL10 gl, long time)
 Render the World. More...
 
void renderList (GL10 gl, BeyondarObjectList list, long time)
 Render a specific list. More...
 
void renderBeyondarObject (GL10 gl, BeyondarObject beyondarObject, Texture defaultTexture, long time)
 Render a specific BeyondarObject. More...
 
void loadAdditionalTextures (GL10 gl)
 Override this method to load additional textures. More...
 

Protected Attributes

List< GLPluginplugins
 List of loaded plugins. More...
 
Object lockPlugins = new Object()
 Lock to synchronize the access to the plugins. More...
 

Detailed Description

Renderer for drawing the World with OpenGL.

Member Function Documentation

void com.beyondar.android.opengl.renderer.ARRenderer.convertGPStoPoint3 ( GeoObject  geoObject,
Point3  out 
)
protected

Convert the geolocation to gl points representation.

Parameters
geoObjectThe GeoObject to be processed.
outWhere the results be stored.

Here is the call graph for this function:

Here is the caller graph for this function:

void com.beyondar.android.opengl.renderer.ARRenderer.fillBeyondarObjectScreenPositions ( BeyondarObject  beyondarObject)

Use this method to fill all the screen positions of the BeyondarObject.

After this method is called you can use the following:
BeyondarObject.getScreenPositionBottomLeft()
BeyondarObject.getScreenPositionBottomRight()
BeyondarObject.getScreenPositionTopLeft()
BeyondarObject.getScreenPositionTopRight()

Parameters
beyondarObjectThe BeyondarObject to compute

Here is the call graph for this function:

Here is the caller graph for this function:

void com.beyondar.android.opengl.renderer.ARRenderer.forceFillBeyondarObjectPositions ( boolean  fill)

Use this method to fill all the screen positions of the BeyondarObject when a object is rendered.

Remember that the information is filled when the object is rendered, so it is asynchronous.

After this method is called you can use the following:
BeyondarObject.getScreenPositionBottomLeft()
BeyondarObject.getScreenPositionBottomRight()
BeyondarObject.getScreenPositionTopLeft()
BeyondarObject.getScreenPositionTopRight()

Important Enabling this feature will reduce the FPS, use only when is needed.

Parameters
fillEnable or disable this feature.
Point3 com.beyondar.android.opengl.renderer.ARRenderer.getCameraPosition ( )

Get the camera position.

Returns
float com.beyondar.android.opengl.renderer.ARRenderer.getDistanceFactor ( )

Get the distance factor.

Returns
Distance factor
float com.beyondar.android.opengl.renderer.ARRenderer.getMaxDistanceToRender ( )

Get the distance (in meters) which the AR view will draw the objects.

Returns
meters
float com.beyondar.android.opengl.renderer.ARRenderer.getPullCloserDistance ( )

Get the max distance which a GeoObject will be rendered.

Returns
The current max distance. 0 is the default behavior
float com.beyondar.android.opengl.renderer.ARRenderer.getPushAwayDistance ( )

Get the minimum distance which a GeoObject will be rendered.

Returns
The current minimum distance. 0 is the default behavior
void com.beyondar.android.opengl.renderer.ARRenderer.getScreenCoordinates ( Point3  position,
Point3  outPoint 
)

Get the screen position of a given Point3.

Parameters
positionThe 3D position to transform to a screen coordinates.
outPointThe object where the result will be stored.

Here is the caller graph for this function:

void com.beyondar.android.opengl.renderer.ARRenderer.getScreenCoordinates ( Point3  position,
Point3  outPoint,
float[]  eye 
)

Get the screen position of a given Point3.

Parameters
positionThe 3D position to transform to a screen coordinates.
outPointThe object where the result will be stored.
eyeArray where the eye position will be stored to do the calculations.

Here is the call graph for this function:

void com.beyondar.android.opengl.renderer.ARRenderer.getScreenCoordinates ( float  x,
float  y,
float  z,
Point3  outPoint,
float[]  eye 
)

Get the screen position of a given Point3.

Parameters
xThe 3D position (x) to transform to a screen coordinates.
yThe 3D position (y) to transform to a screen coordinates.
zThe 3D position (z) to transform to a screen coordinates.
outPointThe object where the result will be stored.
eyeArray where the eye position will be stored to do the calculations.
Texture com.beyondar.android.opengl.renderer.ARRenderer.getTexture ( String  uri)

Get a copy of the texture pointer for the specified URI.

Parameters
uri
Returns

Here is the caller graph for this function:

void com.beyondar.android.opengl.renderer.ARRenderer.getViewRay ( float  x,
float  y,
Ray  ray 
)

Get a view Ray for the screen position (x,y).

Use this to object to check if there are any GeoObject that collide.

Parameters
x
y
ray
World com.beyondar.android.opengl.renderer.ARRenderer.getWorld ( )

Get the World used for by the ARRenderer.

Returns
boolean com.beyondar.android.opengl.renderer.ARRenderer.isRendering ( )

Get known if the ARRenderer is rendering the world.

Returns
boolean com.beyondar.android.opengl.renderer.ARRenderer.isTextureLoaded ( Bitmap  bitmap)

Check if the bitmap texture object is loaded.

To check if the Texture has been loaded with a pointer, use Texture.isLoaded()

Parameters
bitmap
Returns
true if it is already loaded, false otherwise.
boolean com.beyondar.android.opengl.renderer.ARRenderer.isTextureObjectLoaded ( String  uri)

Check if the image URI has been loaded as a texture.

To check if the Texture has any GL texture pointer use Texture.isLoaded()

Parameters
uri
Returns
true if it is already loaded, false otherwise.
Texture com.beyondar.android.opengl.renderer.ARRenderer.load2DTexture ( GL10  gl,
Bitmap  bitmap 
)

Create the texture for the specified Bitmap.


Important The method will recycle the bitmap after being used.

Parameters
gl
bitmap
Returns
A new texture for the bitmap.

Here is the call graph for this function:

Here is the caller graph for this function:

void com.beyondar.android.opengl.renderer.ARRenderer.loadAdditionalTextures ( GL10  gl)
protected

Override this method to load additional textures.

Use the following code to help you:
loadTexture(gl, yourBitmap)
This method is called when the surface is created.

Parameters
gl
void com.beyondar.android.opengl.renderer.ARRenderer.loadBeyondarObjectTexture ( GL10  gl,
BeyondarObject  geoObject 
)

Load the textures of the specified geoObject.

Parameters
gl
geoObjectThe object to load the textures.

Here is the call graph for this function:

Here is the caller graph for this function:

Texture com.beyondar.android.opengl.renderer.ARRenderer.loadBitmapTexture ( GL10  gl,
Bitmap  btm,
String  uri 
)

Load the Texture from a Bitmap.

Parameters
gl
btmThe Bitmap to load.
uriThe unique id of the bitmap.
Returns
The Texture object.

Here is the call graph for this function:

Here is the caller graph for this function:

void com.beyondar.android.opengl.renderer.ARRenderer.onExternalBitmapLoaded ( BitmapCache  cache,
String  url,
Bitmap  btm 
)

This method is called when an external image (such as a network image) is loaded and stored in the cache.

Parameters
cacheThe cache that contains this bitmap.
urlThe URL that identify the bitmap
btmThe Bitmap loaded

Implements com.beyondar.android.util.cache.BitmapCache.OnExternalBitmapLoadedCacheListener.

void com.beyondar.android.opengl.renderer.ARRenderer.renderBeyondarObject ( GL10  gl,
BeyondarObject  beyondarObject,
Texture  defaultTexture,
long  time 
)
protected

Render a specific BeyondarObject.

Parameters
gl
beyondarObjectBeyondarObject to render.
defaultTextureIf the texture from the BeyondarObject is not available the defaultTexure will be used.

Here is the call graph for this function:

Here is the caller graph for this function:

void com.beyondar.android.opengl.renderer.ARRenderer.renderList ( GL10  gl,
BeyondarObjectList  list,
long  time 
)
protected

Render a specific list.

Parameters
gl
listList to render.
timeTime mark to be used for drawing the frame.

Here is the call graph for this function:

Here is the caller graph for this function:

void com.beyondar.android.opengl.renderer.ARRenderer.renderWorld ( GL10  gl,
long  time 
)
protected

Render the World.

Parameters
gl
timeTime mark to be used for drawing the frame.

Here is the call graph for this function:

void com.beyondar.android.opengl.renderer.ARRenderer.rotateView ( int  surfaceRotation)

Set the rotation of the device:
Surface.ROTATION_0
Surface.ROTATION_90
Surface.ROTATION_180
Surface.ROTATION_270

Parameters
surfaceRotation
Bitmap com.beyondar.android.opengl.renderer.ARRenderer.savePixels ( GL10  gl)
protected

Generate a new bitmap from the gl.

Parameters
gl
Returns
A new Bitmap of the last frame.
void com.beyondar.android.opengl.renderer.ARRenderer.setCameraPosition ( Point3  newCameraPos)

Change the camera position.

It is independent to the GPS position.

Parameters
newCameraPosThe new camera position

Here is the caller graph for this function:

void com.beyondar.android.opengl.renderer.ARRenderer.setDistanceFactor ( float  factor)

Set the distance factor for rendering all the objects.

As bigger the factor the closer the objects.

Parameters
factornumber bigger than 0.
void com.beyondar.android.opengl.renderer.ARRenderer.setFpsUpdatable ( FpsUpdatable  fpsUpdatable)

Set the FpsUpdatable to get notified about the frames per seconds.

Parameters
fpsUpdatableThe event listener. Use null to remove the FpsUpdatable
void com.beyondar.android.opengl.renderer.ARRenderer.setMaxDistanceToRender ( float  meters)

Set the distance (in meters) which the app will draw the objects.

Parameters
meters
void com.beyondar.android.opengl.renderer.ARRenderer.setPullCloserDistance ( float  maxDistanceSize)

When a GeoObject is rendered according to its position it could look very small if it is far away.

Use this method to render far objects as if there were closer.
For instance if there is an object at 100 meters and we want to have everything at least at 25 meters, we could use this method for that purpose.
To set it to the default behavior just set it to 0

Parameters
maxDistanceSizeThe top far distance (in meters) which we want to draw a GeoObject , 0 to set again the default behavior
void com.beyondar.android.opengl.renderer.ARRenderer.setPushAwayDistance ( float  minDistanceSize)

When a GeoObject is rendered according to its position it could look very big if it is too close.

Use this method to render near objects as if there were farther.
For instance if there is an object at 1 meters and we want to have everything at least at 10 meters, we could use this method for that purpose.
To set it to the default behavior just set it to 0

Parameters
minDistanceSizeThe top near distance (in meters) which we want to draw a GeoObject , 0 to set again the default behavior
void com.beyondar.android.opengl.renderer.ARRenderer.setRendering ( boolean  render)

Specify if the ARRenderer should render the world.

Parameters
render

Here is the caller graph for this function:

void com.beyondar.android.opengl.renderer.ARRenderer.setWorld ( World  world)

Define the world where the objects are stored.

Parameters
world
void com.beyondar.android.opengl.renderer.ARRenderer.tackePicture ( GLSnapshotCallback  callBack)

Take an snapshot of the view.

The callback will be notified when the picture is ready.

Parameters
callBack

Member Data Documentation

Object com.beyondar.android.opengl.renderer.ARRenderer.lockPlugins = new Object()
protected

Lock to synchronize the access to the plugins.

Use it to modify the loaded plugins.

List<GLPlugin> com.beyondar.android.opengl.renderer.ARRenderer.plugins
protected

List of loaded plugins.

float com.beyondar.android.opengl.renderer.ARRenderer.Z_FAR = 400.0f
static

Specifies the distance from the viewer to the far clipping plane.

Used for the GLU.gluPerspective


The documentation for this class was generated from the following file: