注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

姑射道人的博客

博客新地址:nixuchen.com

 
 
 

日志

 
 

360度全景图 panoramaGL 使用0.1版本  

2013-10-25 15:02:46|  分类: android |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
package cn.net.brisc.museum.demo;

import javax.microedition.khronos.opengles.GL10;

import com.panoramagl.PLIPanorama;
import com.panoramagl.PLImage;
import com.panoramagl.PLSpherical2Panorama;
import com.panoramagl.PLSphericalPanorama;
import com.panoramagl.PLView;

import com.panoramagl.utils.PLUtils;

import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.ToggleButton;

import cn.net.brisc.expo.constant.Variable;
import cn.net.brisc.expo.db.PanoramaBean;
import cn.net.brisc.expo.utils.AsyncImageLoader;


public class PanoramaActivity extends PLView {

PanoramaBean bean;
private String TAG = "PanoramaActivity";
private boolean sign=true;

/** init methods */

/** init methods */

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.loadPanorama(0);

}
 /**
     * This event is fired when OpenGL renderer was created
     * @param gl Current OpenGL context
     */
    @Override
protected void onGLContextCreated(GL10 gl)
{
    super.onGLContextCreated(gl);
   
    //Add layout
    View mainView = this.getLayoutInflater().inflate(R.layout.activity_panorama, null);
        this.addContentView(mainView, new LinearLayout.LayoutParams(Variable.ScreenHeight,Variable.ScreenWidth));
        
      
//取消放大缩小
this.getCamera().setFovEnabled(false);
        
//        //Spinner control
//        Spinner panoramaTypeSpinner = (Spinner)mainView.findViewById(R.id.spinner_panorama_type);
//        ArrayAdapter<?> adapter = ArrayAdapter.createFromResource(this, R.array.panorama_types, android.R.layout.simple_spinner_item);
//        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
//        panoramaTypeSpinner.setAdapter(adapter);
//        panoramaTypeSpinner.setOnItemSelectedListener(new OnItemSelectedListener()
//        {
// @Override
// public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id)
// {
//// loadPanoramaFromJSON(position);
// loadPanorama(position);
// }
//
// @Override
// public void onNothingSelected(AdapterView<?> parentView)
// {
// }
// });
        
//        //Zoom controls
//        ZoomControls zoomControls = (ZoomControls)mainView.findViewById(R.id.zoomControls);
//        zoomControls.setOnZoomInClickListener(new OnClickListener()
//        {
// @Override
// public void onClick(View view)
// {
// getCamera().zoomIn(true);
// }
// });
//        zoomControls.setOnZoomOutClickListener(new OnClickListener()
//        {
// @Override
// public void onClick(View view)
// {
// getCamera().zoomOut(true);
// }
// });
}

 /**load methods*/
    
    /**
     * Load panorama image manually
     * @param index Spinner position where 0 = spherical, 1 = spherical2, 2 = cubic, 3 = cylindrical
     */
    private void loadPanorama(int index)
    {
    GL10 gl = this.getCurrentGL();
    PLIPanorama panorama = null;
    //Lock panoramic view
    this.setBlocked(true);
    //Spherical panorama example (supports up 1024x512 texture)
        if(index == 0)
        {
            panorama = new PLSphericalPanorama();
            ((PLSphericalPanorama)panorama).setImage(gl, PLImage.imageWithBitmap(PLUtils.getBitmap(this, R.raw.demo), false));
//            ((PLSphericalPanorama)panorama).setImage(gl, PLImage.imageWithBitmap(PLUtils.getBitmap(this, R.raw.pano_sphere), false)); + GetURL.SDCARD + imageid
        }
        //Spherical2 panorama example (only support 2048x1024 texture)
//        if(index == 0)
//        {
//         panorama = new PLSpherical2Panorama();
////            ((PLSpherical2Panorama)panorama).setImage(gl, PLImage.imageWithBitmap(PLUtils.getBitmap(this, R.raw.pano_sphere2), false));
//         ((PLSpherical2Panorama)panorama).setImage(gl, PLImage.imageWithBitmap(PLUtils.getBitmap(this, "file://"+GetURL.SDCARD+imageid), false));
//        }
//        //Cubic panorama example (supports up 1024x1024 texture per face)
//        else if(index == 2)
//        {
//         PLCubicPanorama cubicPanorama = new PLCubicPanorama();
//         cubicPanorama.setImage(gl, PLImage.imageWithBitmap(PLUtils.getBitmap(this, R.raw.pano_f), false), PLCubeFaceOrientation.PLCubeFaceOrientationFront);
//         cubicPanorama.setImage(gl, PLImage.imageWithBitmap(PLUtils.getBitmap(this, R.raw.pano_b), false), PLCubeFaceOrientation.PLCubeFaceOrientationBack);
//         cubicPanorama.setImage(gl, PLImage.imageWithBitmap(PLUtils.getBitmap(this, R.raw.pano_l), false), PLCubeFaceOrientation.PLCubeFaceOrientationLeft);
//         cubicPanorama.setImage(gl, PLImage.imageWithBitmap(PLUtils.getBitmap(this, R.raw.pano_r), false), PLCubeFaceOrientation.PLCubeFaceOrientationRight);
//         cubicPanorama.setImage(gl, PLImage.imageWithBitmap(PLUtils.getBitmap(this, R.raw.pano_u), false), PLCubeFaceOrientation.PLCubeFaceOrientationUp);
//         cubicPanorama.setImage(gl, PLImage.imageWithBitmap(PLUtils.getBitmap(this, R.raw.pano_d), false), PLCubeFaceOrientation.PLCubeFaceOrientationDown);
//            panorama = cubicPanorama;
//        }
        //Cylindrical panorama example (supports up 1024x1024 texture)
//        else if(index == 1)
//        {
//         PLCylindricalPanorama cylindricalPanorama = new PLCylindricalPanorama();
//         cylindricalPanorama.setHeightCalculated(false);
//         cylindricalPanorama.getCamera().setPitchRange(0.0f, 0.0f);
////         cylindricalPanorama.setImage(gl, PLImage.imageWithBitmap(PLUtils.getBitmap(this, R.raw.pano_sphere), false));
//         cylindricalPanorama.setImage(gl, PLImage.imageWithBitmap(PLUtils.getBitmap(this, "file://"+ GetURL.SDCARD + imageid), false));
//            panorama = cylindricalPanorama;
//        }
        //Add a hotspot
//        panorama.addHotspot(new PLHotspot((kHotspotIdMin + Math.abs(random.nextInt()) % ((kHotspotIdMax + 1) - kHotspotIdMin)), PLImage.imageWithBitmap(PLUtils.getBitmap(this, R.raw.hotspot), false), 0.0f, 0.0f, 0.08f, 0.08f));
        //Load panorama
//        this.activateOrientation();
//        this.startSensorialRotation();
        
        this.reset();
        this.setPanorama(panorama);
        
        if(sign){
       this.startSensorialRotation();        
//        this.activateOrientation();
       this.activateAccelerometer();
//        this.activateMagnetometer();
//        this.activateGyroscope();
this.setAccelerometerEnabled(true);
    this.setAccelerometerInterval(0.033f);
    this.setAccelerometerSensitivity(10.0f);
    this.setAccelerometerLeftRightEnabled(true);
    this.setAccelerometerUpDownEnabled(false);
    }else{
    this.setAccelerometerEnabled(false);
    }

        //Unlock panoramic view
        this.setBlocked(false);
    }
}

  评论这张
 
阅读(1141)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017