- Cardboard VR Projects for Android
- Jonathan Linowes Matt Schoen
- 264字
- 2021-07-16 10:54:10
Creating a new project
If you'd like more details and explanation about these steps, refer to the Creating a new Cardboard project section in Chapter 2, The Skeleton Cardboard Project, and follow along there:
- With Android Studio opened, create a new project. Let's name it
CardboardBox
and target Android 4.4 KitKat (API 19) with an Empty Activity. - Add the Cardboard SDK
common.aar
andcore.aar
library files to your project as new modules, using File | New | New Module.... - Set the library modules as dependencies to the project app, using File | Project Structure.
- Edit the
AndroidManifest.xml
file as explained in Chapter 2, The Skeleton Cardboard Project, being careful to preserve thepackage
name for this project. - Edit the
build.gradle
file as explained in Chapter 2, The Skeleton Cardboard Project, to compile against SDK 22. - Edit the
activity_main.xml
layout file as explained in Chapter 2, The Skeleton Cardboard Project. - Edit the
MainActivity
Java class so that itextends
CardboardActivity
andimplement
s
CardboardView.StereoRenderer
. Modify the class declaration line as follows:public class MainActivity extends CardboardActivity implements CardboardView.StereoRenderer {
- Add the stub method overrides for the interface (using intellisense implement methods or pressing Ctrl + I).
- At the top of the
MainActivity
class, add the following comments as placeholders for variables that we will be creating in this project:CardboardView.StereoRenderer { private static final String TAG = "MainActivity"; // Scene variables // Model variables // Viewing variables // Rendering variables
- Lastly, edit
onCreate()
by adding theCardboadView
instance as follows:@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); CardboardView cardboardView = (CardboardView) findViewById(R.id.cardboard_view); cardboardView.setRenderer(this); setCardboardView(cardboardView); }
推薦閱讀
- Windows phone 7.5 application development with F#
- 龍芯應(yīng)用開發(fā)標(biāo)準(zhǔn)教程
- Effective STL中文版:50條有效使用STL的經(jīng)驗(yàn)(雙色)
- 從零開始學(xué)51單片機(jī)C語言
- 分布式微服務(wù)架構(gòu):原理與實(shí)戰(zhàn)
- 面向?qū)ο蠓治雠c設(shè)計(jì)(第3版)(修訂版)
- 固態(tài)存儲(chǔ):原理、架構(gòu)與數(shù)據(jù)安全
- LPC1100系列處理器原理及應(yīng)用
- Mastering Machine Learning on AWS
- 單片機(jī)原理與技能訓(xùn)練
- UML精粹:標(biāo)準(zhǔn)對(duì)象建模語言簡明指南(第3版)
- Practical Artificial Intelligence and Blockchain
- CPU設(shè)計(jì)實(shí)戰(zhàn):LoongArch版
- 計(jì)算機(jī)組裝與維護(hù)項(xiàng)目化教程(第二版)
- 電腦組裝與維修實(shí)戰(zhàn)