Labeling parts of 3D model with Android and OpenGL ES/Rajawali

medonja

I have imported a model (e.g. a teapot) using Rajawali into my scene. What I would like is to label parts of the model (e.g. the lid, body, foot, handle and the spout) using plain Android views, but I have no idea how this could be achieved. Specifically, positioning the labels on the right place seems challenging. The idea is that when I transform my model's position in the scene, the tips of the labels are still correctly positioned

Rajawali tutorial show how Android views can be placed on top of the scene here https://github.com/Rajawali/Rajawali/wiki/Tutorial-08-Adding-User-Interface-Elements . I also understand how using the transformation matrices a 3D coordinate on the model can be transformed into a 2D coordinate on the screen, but I have no idea how to determine the exact 3D coordinates on the model itself. The model is exported to OBJ format using Blender, so I assume there is some clever way of determining the coordinates in Blender and exporting them to a separate file or include them somehow in the OBJ file (but not render those points, only include them as metadata), but I have no idea how I could do that.

Any ideas are very appreciated! :)

Dominic Cerisano

I would use a screenquad, not a view. This is a general GL solution, and will also work with iOS.

You must determine the indices of the desired model vertices. Using the text rendering algo below, you can just fiddle them until you hit the right ones.

  1. Create a reasonable ARGB bitmap with same aspect ratio as the screen.
  2. Create the screenquad texture using this bitmap
  3. Create a canvas using this bitmap
  4. The rest happens in onDrawFrame(). Clear the canvas using clear paint.
  5. Use the MVP matrix to convert desired model vertices to canvas coordinates.
  6. Draw your desired text at the canvas coordinates
  7. Update the texture.

  • Your text will render very precisely at the vertices you specfied. The GL thread will double-buffer and loop you back to #4. Super smooth 3D text animation!
  • Use double floating point math to avoid loss of precision during coordinate conversion, which results in wobbly text. You could even use the z value of the vertex to scale the text. Fancy!
  • The performance bottleneck is #7 since the entire bitmap must be copied to GL texture memory, every frame. Try to keep the bitmap as small as possible, maintaining aspect ratio. Maybe let the user toggle the labels.

  • Note that the copy to GL texture memory is redundant since in OpenGL-ES, GL memory is just regular memory. For compatibility reasons, a redundant chunk of regular memory is reserved to artificially enforce the copy.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Smooth model movement in OpenGL 3D

From Dev

OpenGL 3D model texturing

From Dev

How to detect clicks (touch) on specific parts of 3d model?

From Dev

How to animate a 3d model (mesh) in OpenGL?

From Dev

OpenGL Java Get Properties of 3D OBJ Model

From Dev

Creating 3D cube using Android OpenGL ES 2.0

From Dev

How to Load a 3D Object in OpenGL ES 2.0 for Android?

From Dev

Android OpenGL: DrawElements for large, complex 3d objects

From Dev

Android OpenGL ES 2.0 - Cannot see 3D Obect

From Dev

Some parts are missing when render 3D object in android(java) using OpenGLES 2

From Dev

Android white labeling

From Dev

Android App White Labeling

From Dev

OpenGL, screen doesn't update after adding Assimp 3D model

From Dev

3D plot of Meshgrid vs. Labeling Matrix

From Dev

Labeling certain points in 3D parametric graph

From Dev

Opengl hide parts of the screen

From Dev

3D Picking in OpenGL

From Dev

Model not visible android OpenGL ES 2.0

From Java

how to use JOML to simulate OpenGL like Model, View Matrices on 3D projection to 2D plane?

From Dev

Android - How to renderer video texture on 3D cube with opengl-es?

From Dev

Can we split the window in to 3 parts in android

From Dev

I want to change 3d model in vuforia Augmented Reality in android

From Dev

Android White Labeling using Android Studio Flavors

From Dev

D3 - Labeling of x axis are links

From Dev

Drawing cube 3D using Opengl

From Dev

Opengl 3d laser beam

From Dev

OpenGL - 3D texturing - conceptual questions

From Dev

OpenGL 3D transparency in voxels

From Dev

3D intersection (Radiosity) - OpenGl