Play With Billboard
In VR applications there are some elements that needs to always facing the user, such as text, menus.
Here we're going to introduce an easy way to implement it using
Billboard in 3D graphics term is something always facing the camera.
Create a GearVR Framework project by copying the template project
Perform the following steps to make sure your project runs correctly
- (if developing for Gear VR) Copy your Oculus signature file to
- Change the
build.gradleto a unique name to avoid naming conflict when you test the app later
- Change the
res/values/strings.xmlto avoid confusion when you debug the app.
How to use Billboard¶
Make sure to copy both files into
You can learn how to load 3D models with following play with 3D models tutorial, here we'll just highlight the code for billboard
mTrexObj = gvrContext.getAssetLoader().loadModel("trex_mesh.fbx", gvrContext.getMainScene()); mTrexObj.getTransform().setPosition(4,-6,-8); mTrexObj.attachComponent(new GVRBillboard(gvrContext, new Vector3f(0f,1f,0f)));
The second parameter of
GVRBillboard is the up vector of the billboard, it indicates which direction is up so the billboard will rotate accordingly.
Complete Source Code for this sample