Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
AugmaDev's avatar
AugmaDev
Explorer
4 years ago
Solved

Editing Cubes in hello_xr Android Studio

How can I change the color of the cubes in hello_xr from Android Studio?

I have very little experience with Android Studio, but I can run hello_xr on on my Quest 2 and I understand OpenGL C++. I tried looking at some of the .c and .cpp files, but Android Studio tells me "This file does not belong to any project target; code insight features might not work properly." 

  • Yes, in the hello_xr demo app, there only one OpenGL resource (vertices and colors) for all the cubes (defines in InitializeResources), so you must refines the source code to create diffrerents resources and manage differents cubes.

     

    The hands cubes are created on the fly in the "openxp_program.cpp" file at the "RenderLayer" function; search for the line with "for (auto hand : {Side::LEFT, Side::RIGHT})".

     

    Cheers

3 Replies

  • Hi,

     

    The cube vertices array contains also the face colors, and is defined in the file geometry.h in the c_cubeVertices array.

     

    Je cube's color is send to the OpenGLES shader in the "graphicsplugin_opengles.cpp" file at the end of the "InitializeResources" function.
     
    Regards

    • AugmaDev's avatar
      AugmaDev
      Explorer

      Great thanks!

      This works, but it ends up changing the color of every cube in the scene. It looks like c_cubeVertices is used several times to create several instances of the cube. Do you happen to know which file has the OpenGL code for creating the cube on the right controller?

      • antoine.emerit's avatar
        antoine.emerit
        Explorer

        Yes, in the hello_xr demo app, there only one OpenGL resource (vertices and colors) for all the cubes (defines in InitializeResources), so you must refines the source code to create diffrerents resources and manage differents cubes.

         

        The hands cubes are created on the fly in the "openxp_program.cpp" file at the "RenderLayer" function; search for the line with "for (auto hand : {Side::LEFT, Side::RIGHT})".

         

        Cheers