Android 360度全景图片 源码

先上张效果图


Google官方写了一个包,专门用来作全景图片的:PanoramaGL.jar。 可自己下载 http://download.csdn.net/detail/wuf1023/8073707

   设置显示图片有两种试,第一种是一整张鱼眼式的全景图片;第二种是6张图片合成

  不多说,直接上代码

public class HelloPanorama extends PLView
{
	@Override
	protected void onGLContextCreated(GL10 gl)
	{
        super.onGLContextCreated(gl);
      //If you want to use setDeviceOrientationEnabled(true), activity orientation only must be portrait. Eg. android:screenOrientation="portrait"
    	this.setDeviceOrientationEnabled(false);
    	
      //You can use accelerometer你可以用加速计
    	//this.setAccelerometerEnabled(true);
    	//this.setAccelerometerUpDownEnabled(true);
    	//this.setAccelerometerSensitivity(0.5f);
    	//this.setAccelerometerLeftRightEnabled(true);

    	//充许滚动
    	this.setScrollingEnabled(true);
    	//充许惯性
    	this.setInertiaEnabled(true);
    	//惯性灵敏度
    	this.setInertiaInterval(0.2f);

    	//旋转灵敏度
    	this.getCamera().setRotateSensitivity(100f);
    	//缩放灵敏度
    	this.getCamera().setFovSensitivity(2000);
    	//缩放范围
    	this.getCamera().setFovRange(PLRange.PLRangeMake(-5.0f, 5.0f));
    	//初始缩放
    	this.getCamera().setFov(-5f);
    	
        try
        {
        	/*
        	 * Important Note: You must edit AndroidManifest.xml and put android:configChanges="keyboardHidden|orientation" attribute in activity else you have memory problems
        	 */
	    	
	    	
	    	//Example with Sphere type (you need one image)
	    	this.setType(PLViewType.PLViewTypeSpherical);
	    	this.addTextureAndRelease(PLTexture.textureWithImage(this.getImageWithResouce(R.drawable.p01)));
	    	
	    	/*
	    	//Example with Cube Faces type (you need an image for each cube face)
	    	this.setType(PLViewType.PLViewTypeCubeFaces);
	    	this.addTextureAndRelease(PLTexture.textureWithImage(this.getImageWithResouce(R.drawable.front)));
	    	this.addTextureAndRelease(PLTexture.textureWithImage(this.getImageWithResouce(R.drawable.back)));
	    	this.addTextureAndRelease(PLTexture.textureWithImage(this.getImageWithResouce(R.drawable.left)));
	    	this.addTextureAndRelease(PLTexture.textureWithImage(this.getImageWithResouce(R.drawable.right)));
	    	this.addTextureAndRelease(PLTexture.textureWithImage(this.getImageWithResouce(R.drawable.top)));
	    	this.addTextureAndRelease(PLTexture.textureWithImage(this.getImageWithResouce(R.drawable.bottom)));
	    	*/
        }
        catch(Throwable ex)
        {
        	Log.e("HelloPanorama::onGLContextCreated", "Error:" + ex.getMessage());
        }
	}
}



评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值