全景图(PanoramaGL)

可加入QQ群397178710交流

细节

1如何导入PanoramaGL类库?

1.1从源代码中导入

(1)下载PanoramaGL_0.1.zip或从代码仓库下载源代码
(2)如果你下载zip文件然后解压该文件
(3)在Eclipse中导入PanoramaGL项目:
    点击“File”选择“Import”菜单;
    选择“General”目录中的“Existing Projects into Workspace”,点击“Next”按钮;
    点击“Browse”按钮,选择PanoramaGL项目文件夹
    点击“Finish”按钮。
(4)右键单击你的项目并选择“Properties”选项
(5)选择左侧面板“Android”选项
(6)找到右侧面板“Library”部分,点击“Add...”按钮
(7)选择“PanoramaGL”类库,点击“OK”按钮
(8)在属性窗口的右下角选择“OK”按钮表示接受更改

1.2从编译后的文件中导入

(1)下载libglues.zip
(2)解压zip文件并复制到你的项目的“libs”文件夹中
(3)下载PanoramaGL 0.1.jar
(4)复制jar文件到你的项目的“libs”文件夹中
(5)在你的项目中导入jar文件:
    右键单击你的项目并选择“Properties”选项;
    选择左侧面板“Java Build Path”选项;
    选择“Libraries”选项卡;
    点击“Add JARs”按钮;
    在你的项目中选择“libs/PanoramaGL_0.1.jar”文件;
    点击“OK”按钮;
    在属性窗口的右下角选择“OK”按钮表示接受更改。

2在应用程序中如何使用PanoramaGL?

(1)如前面描述那样导入类库
(2)在“res/raw”文件夹中导入一个球面图像(如:pano_sphere.jpg)
(3)在Activity中,你需要构建一个全景图像的查看器,具体做法如下:
继承PLView类
[java]

      1. public class YourActivity extends PLView  
在onCreate()方法中加载全景图像
[java]
      1.  @Override  
      2. public void onCreate(Bundle savedInstanceState) {  
      3.     super.onCreate(savedInstanceState);  
      4.     PLSphericalPanorama panorama = new PLSphericalPanorama();  
      5.     panorama.setImage(this.getCurrentGL(), PLImage.imageWithBitmap(PLUtils.getBitmap(this, R.raw.pano_sphere)));  
      6.     this.setPanorama(panorama);  
      7. }  
注意:如果有必要的话,你也可以从其他方法中加载全景图像或事件。

3简单JSON协议

同样,你可以使用JSON协议加载全景图像。
注意:在该版本中,JSON协议被限制只处理本地文件。

3.1源代码

[java]

      1. this.load(new PLJSONLoader(this"res://raw/json_spherical"));  
注意:在我的应用程序的“res/raw”文件夹中有一个名为“json_spherical.data”的文件,可以使用这段代码加载。或
[java]
      1. this.load(new PLJSONLoader(this"file:///sdcard/files/json_spherical.data"));  
注意:在Android设备的“/sdcard/files”文件夹中有一个名为“json_spherical.data”的文件,可以使用这段代码加载。

3.2JSON协议

[java]

      1. {  
      2.     "urlBase""file:///sdcard/files",  //URL base where the files are  
      3.                                         //The options are res:// for application resources and file:// for file system (this feature will be improved to support the http protocol)  
      4.     "type""spherical",                //Panorama type: [spherical, spherical2, cubic, cylindrical]  
      5.     "sensorialRotation"false,         //Automatic rotation using sensors [true, false] <Optional>  
      6.     "scrolling":                        //Scrolling section <Optional>  
      7.     {  
      8.         "enabled"false                //Enable scrolling feature [true, false] <Optional>  
      9.     },  
      10.     "inertia":                          //Inertia section <Optional>  
      11.     {  
      12.         "enabled"false,               //Enable inertia feature [true, false] <Optional>  
      13.         "interval"3                   //Inertia's interval in seconds <Optional>  
      14.     },  
      15.     "accelerometer":                    //Accelerometer section <Optional>  
      16.     {  
      17.         "enabled"false,               //Enable the accelerometer feature [true, false] <Optional>  
      18.         "interval"0.033,              //Update interval of accelerometer (this value must be calculated as 1/frequency) <Optional>  
      19.         "sensitivity"10.0,            //Sensitivity of the accelerometer <Optional>  
      20.         "leftRightEnabled"true,       //Enable the direction of movement with the accelerometer (left/right) <Optional>  
      21.         "upDownEnabled"false          //Enable the direction of movement with the accelerometer (up/down) <Optional>  
      22.     },  
      23.     "images":                           //Panoramic images section  
      24.                                         //A property can be a name e.g. preview.jpg, preview or URL e.g. file:///sdcard/files/preview.jpg, res://raw/preview  
      25.                                         //if a property only have a name, the real path will be the urlBase + image name  
      26.     {  
      27.         "preview""preview.jpg",       //Preview image name or URL (this option will be used with http protocol) <Optional>  
      28.         "image""pano.jpg"             //Panoramic image name or URL for spherical, spherical2 and cylindrical panoramas  
      29.         "front""front.jpg",           //Front image name or URL for cubic panorama (only use with cubic panorama)  
      30.         "back""back.jpg",             //Back image name or URL for cubic panorama (only use with cubic panorama)  
      31.         "left""left.jpg",             //Left image name or URL for cubic panorama (only use with cubic panorama)  
      32.         "right""right.jpg",           //Right image name or URL for cubic panorama (only use with cubic panorama)  
      33.         "up""up.jpg",                 //Up image name or URL for cubic panorama (only use with cubic panorama)  
      34.         "down""down.jpg"              //Down image name or URL for cubic panorama (only use with cubic panorama)  
      35.     },  
      36.     "camera":                           //Camera settings section <Optional>  
      37.     {  
      38.         "vlookat"0,                   //Initial vertical position [-90, 90]  
      39.         "hlookat"0,                   //Initial horizontal position [-180, 180]  
      40.         "atvmin": -90,                  //Min vertical position [-90, 90]  
      41.         "atvmax"90,                   //Max vertical position [-90, 90]  
      42.         "athmin": -180,                 //Min horizontal position [-180, 180]  
      43.         "athmax"180                   //Max horizontal position [-180, 180]  
      44.     },  
      45.     "hotspots": [                       //Hotspots section (this section is an array of hotspots) <Optional>  
      46.                  {  
      47.                  "id"1,               //Hotspot identifier (long)  
      48.                  "atv"0,              //Vertical position [-90, 90]  
      49.                  "ath"0,              //Horizontal position [-180, 180]  
      50.                  "width"0.08,         //Width  
      51.                  "height"0.08,        //Height  
      52.                  "image""hotspot.png" //Image name or URL  
      53.                  }  
      54.                 ]  
      55. }  

3.3看到

PLJSONLoader类和PLView加载方法。
json_spherical.data、json_spherical2、json_cylindrical.data和json_cubic.data都位于 HelloPanoramaGL 示例的“res/raw”文件夹中。



个人心得:
panorama
.addHotspot  //添加展向热点
panorama
.getCamera().lookAt(0.0f, -25.0f);
 //设置初始角度
panorama
.getCamera().setPitchMax(0.0f);
panorama
.getCamera().setPitchMin(0.0f); //设置最大角度



//横向偏转角度回调
public
void  onDidRotateCamera(PLIView view, Object sender,
                                 
PLICamera  camera,  float  pitch,  float  yaw,  float  roll) {

                           
super .onDidRotateCamera(view, sender, camera, pitch, yaw, roll);

                           Log.
d ( "pitch" , String. valueOf(pitch));

                           
// Message msg = new Message();
                           
// if (45.0f <= yaw && yaw <= 135.0f) {
                           
//
                           
// if (y) {
                           
// msg.what = 1;
                           
// } else {
                           
// msg.what = 2;
                           
// }
                           
// Log.d("yaw ", "右");
                           
//
                           
// // id = "8d979af7-ba10-429f-b0f5-a49e26447f79";
                           
// } else if (-45.0f <= yaw && yaw <= 45.0f) {
                           
//
                           
// if (q) {
                           
// msg.what = 1;
                           
// } else {
                           
// msg.what = 2;
                           
// }
                           
// Log.d("yaw ", "前");
                           
//
                           
// } else if (135.0f <= yaw || yaw <= -135.0f) {
                           
//
                           
// if (h) {
                           
// msg.what = 1;
                           
// } else {
                           
// msg.what = 2;
                           
// }
                           
// Log.d("yaw ", "后");
                           
//
                           
// } else if (-135.0f <= yaw && yaw <= -45.0f) {
                           
//
                           
// if (z) {
                           
// msg.what = 1;
                           
// } else {
                           
// msg.what = 2;
                           
// }
                           
// Log.d("yaw ", "左");
                           
//
                           
// }
                           
// handler.sendMessage(msg);

                    }

             });


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值