With the Solar System project implemented and our code stabilized, you might realize that we've built some code that is not necessarily specific to this application, which can be reused in other projects, and ought to make its way back to the RenderBox
library. That's what we'll do now.
We recommend you do this directly within Android Studio, selecting and copying from this project's hierarchy view to the other's. Perform the following steps:
.shader
files from the Solar System's res/raw/
directory into the res/raw/
directory of the RenderBox
lib's RenderBox
module. If you've been following along, there will be eight files for the vertex and fragment .shader
files for day_night
, diffuse_lighting
, solid_color_lighting
, and unilt_tex
.Component
and Material
.java
files from the Solar System's RenderBoxExt
module folder to the corresponding folders in RenderBox
lib's RenderBox
module. Remove all invalid references to MainActivity
in the source code.loadTexture
in MainActivity
. It rightfully belongs to the RenderBox
library. Find the declaration for loadTexture
in the Solar System's MainActivity.java
file, and cut the code. Then, open the RenderObject.java
file in RenderBox
lib and paste the definition into the RenderObject
class.RenderBox
lib, replace (refactor) all the instances of MainActivity.loadTexture
with RenderObject.loadTexture
. These will be found in several Material
Java files, where we load material textures.RenderBox.java
, the reset()
method destroys the handles of any materials. Add the calls for the new materials that we just introduced:DayNightMaterial.destroy()
DiffuseLightingMaterial.destroy()
SolidColorLightingMaterial.destroy()
UnlitTexMaterial.destroy()
solarsystem
throughout.Now, you should be able to successfully rebuild the library (Build | Make Module 'renderbox') to generate an updated renderbox[-debug].aar
library file.
Lastly, the Solar System project can now use the new .aar
library. Copy the renderbox[-debug].aar
file from the RenderBoxLib
project's renderbox/build/output
folder into the SolarSystem renderbox/
folder, replacing the older version of the same file with the newly built one. Build and run the Solar System project with this version of the library.