Prior to this development, if I wanted to load multiple different models I had to load each one in the
onSurfaceCreated method and then pass the vertices, normals and indices to a
GenericGameObject, there is nothing majorly wrong with this but I wanted to make the process a bit easier.
First I created a dto class (data transfer object) called
ModelData which is used to pass the vertices, normals, UVs and indices for a 3D model between other classes. I changed the
ObjectFileParser to return the parser data as a
ModelData object and similarly I changed the
GenericGameObject to take in a
To load the model data I created a
ModelLoader class which parses all the available models object files in its
init function and puts the resulting
ModelData objects into a
HashMap with the file name as the key.
ModelLoader class can then be used to get the
ModelData object for any already parsed model.
In the event that a requested model is not in the
HashMap then a default cube is returned.
I create an instance of the
ModelLoader class in the
onCreate method and pass it via the
VrGlSurgaceView to the
VrRenderer so I can generate
GenericGameObjects with any of the parsed model data.
In anticipation of adding a tile based system into the game in future, I created a few basic 20x20 tiles which I added to the
ModelLoader to be used in the game.
This development is a stepping stone to implementing a tile map style world and as such is only a small change from the previous version.
Now that I have a basic environment in the game, I have the following observations:
- The SKyBox texture does not make sense with the scene now being all above 0.0 on the y axis.
- Each "tile"s are one single colour each which is not ideal.
- Similarly the floor is as reflective as the other parts of the models, again this is not what I want.
- The specular lighting on the models is in a very different place from one eyes camera to the other, this indicates to me that the distance between each camera is too great, but I shall need to trial this in my VR headset to confirm.
- A small observation is that the light is currently coming from directly above the player at the moment and it would be nice to have this orbiting the scene and maybe changing colour at "Dusk" and "Dawn".
Until next time, the source code at this point in the project can be found here.