欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android 谷歌推薦的VR實現(xiàn)方式(分享)

 更新時間:2018年01月18日 10:01:31   作者:鍵盤舞者113  
下面小編就為大家分享一篇Android 谷歌推薦的VR實現(xiàn)方式。具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

谷歌有專門的SDK來完成VR,我這次以一個全景圖片的例子來說一下這個SDK實現(xiàn)VR的基本過程,首先全景圖片就是百度地圖里的那樣,能夠看到周圍環(huán)境360的圖片。

添加依賴

compile 'com.google.vr:sdk-panowidget:1.80.0'

添加權(quán)限

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.GET_TASKS"/>

實現(xiàn)代碼

public class GoogleVRActivity extends AppCompatActivity {
 private VrPanoramaView mVrPanoramaView;
 private VrPanoramaView.Options paNormalOptions;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_google_vr);
  initVrPaNormalView();
 }
 @Override
 protected void onPause() {
  super.onPause();
  mVrPanoramaView.pauseRendering();
 }
 @Override
 protected void onResume() {
  super.onResume();
  mVrPanoramaView.resumeRendering();
 }
 @Override
 protected void onDestroy() {
  // Destroy the widget and free memory.
  super.onDestroy();
  mVrPanoramaView.shutdown();
 }

 //初始化VR圖片
 private void initVrPaNormalView() {
  mVrPanoramaView = (VrPanoramaView) findViewById(R.id.mVrPanoramaView);
  paNormalOptions = new VrPanoramaView.Options();
  paNormalOptions.inputType = VrPanoramaView.Options.TYPE_STEREO_OVER_UNDER;
//  mVrPanoramaView.setFullscreenButtonEnabled (false); //隱藏全屏模式按鈕
  mVrPanoramaView.setInfoButtonEnabled(false); //設(shè)置隱藏最左邊信息的按鈕
  mVrPanoramaView.setStereoModeButtonEnabled(false); //設(shè)置隱藏立體模型的按鈕
  mVrPanoramaView.setEventListener(new ActivityEventListener()); //設(shè)置監(jiān)聽
  //加載本地的圖片源
  mVrPanoramaView.loadImageFromBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.andes), paNormalOptions);
  //設(shè)置網(wǎng)絡(luò)圖片源
//  panoWidgetView.loadImageFromByteArray();
 }
 private class ActivityEventListener extends VrPanoramaEventListener {
  @Override
  public void onLoadSuccess() {//圖片加載成功
  }

  @Override
  public void onLoadError(String errorMessage) {//圖片加載失敗
  }
  @Override
  public void onClick() {//當我們點擊了VrPanoramaView 時候觸發(fā)   super.onClick();
  }
  @Override
  public void onDisplayModeChanged(int newDisplayMode) {
   //改變顯示模式時候出發(fā)(全屏模式和紙板模式)
   super.onDisplayModeChanged(newDisplayMode);
  }
 }
}
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:background="@android:color/white">
 <LinearLayout
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:padding="10dip"
  android:id="@+id/main_layout"
  android:orientation="vertical" >
  <TextView
   style="@style/ContentText"
   android:id="@+id/title"
   android:textSize="@dimen/title_text_size"
   android:textStyle="bold"
   android:textColor="@color/colorAccent"
   android:text="第二種谷歌官方VR演示" />
  <TextView
   style="@style/ContentText"
   android:id="@+id/subtitle"
   android:textColor="@color/colorAccent"
   android:textSize="@dimen/caption_text_size"
   android:text="谷歌紙殼子demo" />
  <TextView
   style="@style/ContentText"
   android:id="@+id/paragraph1"
   android:textColor="@color/colorAccent"
   android:textSize="@dimen/paragragh_text_size"
   android:text="魚和熊掌不可兼得" />
  <com.google.vr.sdk.widgets.pano.VrPanoramaView
   android:id="@+id/mVrPanoramaView"
   android:layout_width="match_parent"
   android:layout_height="250dip"/>

 </LinearLayout>
</ScrollView>

VrPanoramaView這個類和Activity有著類似的生命周期,全屏顯示是它自己設(shè)置的,這個VR 的SDK完成度很高,可以多去參考。

以上這篇Android 谷歌推薦的VR實現(xiàn)方式(分享)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論