Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pano360demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies {
exclude module: "support-v13"
}
annotationProcessor "com.github.hotchemi:permissionsdispatcher-processor:3.1.0"
testCompile 'junit:junit:4.12'
compile project(':filepicker')
compile project(':vrlib')
testImplementation 'junit:junit:4.12'
implementation project(':filepicker')
implementation project(':vrlib')
}
2 changes: 1 addition & 1 deletion pano360demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".HomeActivity"
android:name=".MyHomeActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="portrait">
Expand Down
Binary file added pano360demo/src/main/assets/images/360_pano.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pano360demo/src/main/assets/images/potw1931a.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
package com.martin.ads.pano360demo;

import android.content.pm.ActivityInfo;
import android.graphics.BitmapFactory;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.Toast;

import com.martin.ads.vrlib.PanoramaInteraction;
import com.martin.ads.vrlib.constant.PanoMode;
import com.martin.ads.vrlib.filters.vr.AbsHotspot;
import com.martin.ads.vrlib.filters.vr.ImageHotspot;
import com.martin.ads.vrlib.math.PositionOrientation;
import com.martin.ads.vrlib.ui.Pano360ConfigBundle;
import com.martin.ads.vrlib.ui.PanoPlayerActivity;
import com.martin.ads.vrlib.PanoViewWrapper;

import java.util.List;

/**
* Created by Ads on 2016/6/25.
*/
Expand Down Expand Up @@ -39,12 +48,31 @@ private void init(){
if(configBundle==null){
configBundle=Pano360ConfigBundle.newInstance();
}
configBundle.setRemoveHotspot(true);
GLSurfaceView glSurfaceView=(GLSurfaceView) findViewById(R.id.surface_view);
panoViewWrapper =PanoViewWrapper.with(this)
.setConfig(configBundle)
.setGlSurfaceView(glSurfaceView)
.setPanoramaInteraction(new PanoramaInteraction() {

@Override
public void createHotspot(float yaw, float pinch) {

}

@Override
public void hotspotClicked(ImageHotspot hotspot) {
Toast.makeText(DemoWithGLSurfaceView.this, "Click grabbed", Toast.LENGTH_SHORT).show();
}
})
.init();

panoViewWrapper.getStatusHelper().setPanoDisPlayMode(PanoMode.SINGLE_SCREEN);
panoViewWrapper.getStatusHelper().setPanoInteractiveMode(PanoMode.TOUCH);
panoViewWrapper.addHotspot(ImageHotspot.with(this)
.setPositionOrientation(
PositionOrientation.newInstance().fromTriangularSystem(180,10,3000)//Hotspot distance from camera
).setBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.home_logo)));

glSurfaceView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void onClick(int position) {

//mimeType= MimeType.BITMAP | MimeType.PICTURE;

filePath="images/texture_360_n.jpg";
filePath="images/360_pano.jpg";
mimeType= MimeType.ASSETS | MimeType.PICTURE;
break;
case 4:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
package com.martin.ads.pano360demo;

import android.Manifest;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.BitmapFactory;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.Toast;

import com.martin.ads.vrlib.PanoViewWrapper;
import com.martin.ads.vrlib.PanoramaInteraction;
import com.martin.ads.vrlib.constant.MimeType;
import com.martin.ads.vrlib.constant.PanoMode;
import com.martin.ads.vrlib.filters.vr.ImageHotspot;
import com.martin.ads.vrlib.math.PositionOrientation;
import com.martin.ads.vrlib.ui.Pano360ConfigBundle;
import com.martin.ads.vrlib.ui.PanoPlayerActivity;
import com.martin.ads.vrlib.utils.BitmapUtils;
import com.nbsp.materialfilepicker.ui.FilePickerActivity;

import permissions.dispatcher.NeedsPermission;
import permissions.dispatcher.RuntimePermissions;

@RuntimePermissions
public class MyHomeActivity extends AppCompatActivity {
private static final String TAG = "MyHomeActivity";

private PanoViewWrapper panoViewWrapper;


private boolean USE_DEFAULT_ACTIVITY =true;

private String filePath="~(~ ̄▽ ̄)~";

private int mimeType;


@NeedsPermission({
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.INTERNET
})
void init(){
//fake method to require permissions
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
if(this.getSupportActionBar()!=null)this.getSupportActionBar().hide();

setContentView(R.layout.activity_pano);
MyHomeActivityPermissionsDispatcher.initWithPermissionCheck(this);


//filePath= "android.resource://" + getPackageName() + "/" + R.raw.vr_cinema;
//mimeType= MimeType.RAW | MimeType.PICTURE;

//mimeType= MimeType.BITMAP | MimeType.PICTURE;

filePath="images/360_pano.jpg";
mimeType= MimeType.ASSETS | MimeType.PICTURE;
USE_DEFAULT_ACTIVITY=false;

launch();

WindowManager.LayoutParams params = getWindow().getAttributes();
params.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
getWindow().setAttributes(params);
}

private void launch(){

Pano360ConfigBundle configBundle=Pano360ConfigBundle
.newInstance()
.setFilePath(filePath)
.setMimeType(mimeType)
.setPlaneModeEnabled(false)
//set it false to see default hotspot

.setRemoveHotspot(false);

GLSurfaceView glSurfaceView=(GLSurfaceView) findViewById(R.id.surface_view);

panoViewWrapper =PanoViewWrapper.with(this)
.setConfig(configBundle)
.setGlSurfaceView(glSurfaceView)
.setPanoramaInteraction(new PanoramaInteraction() {

@Override
public void createHotspot(float yaw, float pinch) {

}

@Override
public void hotspotClicked(ImageHotspot hotspot) {
Toast.makeText(MyHomeActivity.this, "Click grabbed", Toast.LENGTH_SHORT).show();
}
})
.init();

panoViewWrapper.getStatusHelper().setPanoDisPlayMode(PanoMode.SINGLE_SCREEN);
panoViewWrapper.getStatusHelper().setPanoInteractiveMode(PanoMode.TOUCH);
panoViewWrapper.addHotspot(ImageHotspot.with(this)
.setPositionOrientation(PositionOrientation.newInstance().fromTriangularSystem(180,10,30))
.setBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.img_58c6f9963d50e)));

glSurfaceView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
//Logger.logTouchEvent(v,event);
return panoViewWrapper.handleTouchEvent(event);
}
});
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1 && resultCode == RESULT_OK) {
filePath = data.getStringExtra(FilePickerActivity.RESULT_FILE_PATH);
mimeType= MimeType.LOCAL_FILE | MimeType.VIDEO;
launch();
}
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
// NOTE: delegate the permission handling to generated method
MyHomeActivityPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
}
}
Binary file added pano360demo/src/main/res/drawable/emoji22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions pano360demo/src/main/res/layout/activity_pano.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="#03A9F4">
<FrameLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.opengl.GLSurfaceView
android:clickable="true"
android:focusable="true"
android:id="@+id/surface_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>


</android.support.design.widget.CoordinatorLayout>
9 changes: 9 additions & 0 deletions pano360demo/src/main/res/layout/player_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.opengl.GLSurfaceView
android:id="@+id/surface_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>

<View
android:background="#ff0000"
android:elevation="10dp"
android:layout_centerInParent="true"
android:layout_width="10dp"
android:layout_height="10dp"/>


</RelativeLayout>
23 changes: 17 additions & 6 deletions vrlib/src/main/java/com/martin/ads/vrlib/PanoViewWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ public class PanoViewWrapper {
private List<AbsHotspot> hotspotList;
private int mimeType;
private Pano360ConfigBundle configBundle;
private PanoramaInteraction panoramaInteraction;
private Bitmap bitmap;

private PanoViewWrapper(Context context) {
this.context=context;
hotspotList =new ArrayList<>();
}

public PanoViewWrapper init(){
Expand All @@ -69,6 +71,10 @@ public PanoViewWrapper setConfig(Pano360ConfigBundle configBundle){
return this;
}

public PanoViewWrapper addHotspot(AbsHotspot absHotspot){
hotspotList.add(absHotspot);
return this;
}
private void init(Context context, Uri uri){
glSurfaceView.setEGLContextClientVersion(2);

Expand Down Expand Up @@ -116,8 +122,8 @@ else if((mimeType & MimeType.RAW)!=0)
.setRenderSizeType(PanoRender.RENDER_SIZE_TEXTURE)
.init();

hotspotList =new ArrayList<>();

/*
if(videoHotspotPath!=null && !videoHotspotPath.isEmpty()){
hotspotList.add(VideoHotspot.with(statusHelper.getContext())
.setPositionOrientation(
Expand All @@ -127,8 +133,8 @@ else if((mimeType & MimeType.RAW)!=0)
.setUri(Uri.parse(videoHotspotPath))
.setAssumedScreenSize(2.0f,1.0f)
);
}else{
hotspotList.add(ImageHotspot.with(statusHelper.getContext())
}else{*/
/* hotspotList.add(ImageHotspot.with(statusHelper.getContext())
.setPositionOrientation(
PositionOrientation.newInstance()
.setY(15).setAngleX(90).setAngleY(-90)
Expand All @@ -153,10 +159,10 @@ else if((mimeType & MimeType.RAW)!=0)
.setY(-15).setAngleX(-90).setAngleY(-90)
)
.setImagePath("imgs/hotspot_logo.png")
);
);*/

mRenderer.getSpherePlugin().setHotspotList(hotspotList);

panoramaInteraction.setHotspotList(hotspotList);
glSurfaceView.setRenderer(mRenderer);
glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);

Expand All @@ -170,7 +176,7 @@ else if((mimeType & MimeType.RAW)!=0)
statusHelper.setPanoDisPlayMode(PanoMode.DUAL_SCREEN);
statusHelper.setPanoInteractiveMode(PanoMode.MOTION);

touchHelper=new TouchHelper(statusHelper,mRenderer);
touchHelper = new TouchHelper(statusHelper,mRenderer,panoramaInteraction);

}

Expand Down Expand Up @@ -256,6 +262,11 @@ public PanoViewWrapper removeDefaultHotSpot(){
return this;
}

public PanoViewWrapper setPanoramaInteraction(PanoramaInteraction panoramaInteraction) {
this.panoramaInteraction = panoramaInteraction;
return this;
}

public static PanoViewWrapper with(Context context){
return new PanoViewWrapper(context);
}
Expand Down
Loading