Java Code Examples for com.panoramagl.utils.PLUtils

The following examples show how to use com.panoramagl.utils.PLUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: PanoramaGL   Source File: PLTexture.java    License: Apache License 2.0 6 votes vote down vote up
protected void recycleTexture(GL10 gl)
{
	if(gl != null && mTextureId != null && mTextureId[0] != 0)
	{
		if(PLUtils.getAndroidVersion() < 3f)
		{
			gl.glDeleteTextures(1, mTextureId, 0);
			mTextureId[0] = 0;
			mGLWrapper = null;
			mIsValid = false;
		}
		else if(mGLWrapper != null)
		{
			GLSurfaceView glSurfaceView = mGLWrapper.getGLSurfaceView();
			if(glSurfaceView != null)
				glSurfaceView.queueEvent(new PLRecycleTextureRunnable(this));
		}
	}
}
 
Example 2
Source Project: panoramagl   Source File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void changePanorama(int index) {
    if (currentIndex == index) return;

    PLSphericalPanorama panorama = new PLSphericalPanorama();
    panorama.setImage(new PLImage(PLUtils.getBitmap(this, resourceIds[index]), false));
    float pitch = 5f;
    float yaw = 0f;
    float zoomFactor = 0.8f;

    if (currentIndex != -1) {
        PLICamera camera = plManager.getPanorama().getCamera();
        pitch = camera.getPitch();
        yaw = camera.getYaw();
        zoomFactor = camera.getZoomFactor();
    }

    panorama.getCamera().lookAtAndZoomFactor(pitch, yaw, zoomFactor, false);
    plManager.setPanorama(panorama);
    currentIndex = index;
}
 
Example 3
Source Project: PanoramaGL   Source File: PanoramaGLActivity.java    License: Apache License 2.0 5 votes vote down vote up
/**init methods*/

@Override
protected void onCreate(Bundle savedInstanceState)
{
	super.onCreate(savedInstanceState);
	//Load panorama
	PLSpherical2Panorama panorama = new PLSpherical2Panorama();
	panorama.getCamera().lookAt(30.0f, 90.0f);
       panorama.setImage(new PLImage(PLUtils.getBitmap(this, R.raw.spherical_pano), false));
       this.setPanorama(panorama);
}
 
Example 4
Source Project: PanoramaGL   Source File: PLTexture.java    License: Apache License 2.0 5 votes vote down vote up
protected PLIImage convertImage(PLIImage image, PLTextureColorFormat colorFormat)
{
	if(colorFormat != PLTextureColorFormat.PLTextureColorFormatUnknown)
	{
		Bitmap newBitmap = PLUtils.convertBitmap(image.getBitmap(), colorFormat);
		if(newBitmap != image.getBitmap())
			return new PLImage(newBitmap);
	}
	return image;
}
 
Example 5
Source Project: PanoramaGL   Source File: PLHotspot.java    License: Apache License 2.0 5 votes vote down vote up
protected void calculateCoords(GL10 gl)
{
	if(!hasChangedCoordProperty)
		return;
	
	hasChangedCoordProperty = false;
	
	float textureCoords[] = new float[8];
	
	List<PLPosition> positions = this.calculatePoints(gl);
	PLPosition pos1 = positions.get(0);
	PLPosition pos2 = positions.get(1);
	PLPosition pos3 = positions.get(2);
	PLPosition pos4 = positions.get(3);
	
	this.array
	(
		mVertexs, 12,
		pos1.x, pos1.y, pos1.z,
		pos2.x, pos2.y, pos2.z,
		pos3.x, pos3.y, pos3.z,
		pos4.x, pos4.y, pos4.z
	);
	this.array
	(
		textureCoords, 8,
		1.0f, 1.0f,	
		0.0f, 1.0f,
		1.0f, 0.0f,
		0.0f, 0.0f
	);
	
	mVertexsBuffer = PLUtils.makeFloatBuffer(mVertexs);
	mTextureCoordsBuffer = PLUtils.makeFloatBuffer(textureCoords);
}
 
Example 6
Source Project: PanoramaGL   Source File: PLImage.java    License: Apache License 2.0 5 votes vote down vote up
/**delete methods*/

protected void deleteImage()
{
	if(mBitmap != null)
	{
		if(PLUtils.getAndroidVersion() < 3.0f && !mBitmap.isRecycled())
			mBitmap.recycle();
		mBitmap = null;
		mIsRecycled = true;
		mIsLoaded = false;
	}
}
 
Example 7
Source Project: PanoramaGL   Source File: PLCamera.java    License: Apache License 2.0 5 votes vote down vote up
protected void setInternalFovSensitivity(float fovSensitivity)
{
	if(mFovSensitivity != fovSensitivity)
	{
		mFovSensitivity = fovSensitivity;
		mFovSensitivityByDisplayPPI = PLConstants.kDisplayPPIBaseline / PLUtils.getDisplayPPI() * fovSensitivity;
	}
}
 
Example 8
Source Project: PanoramaGL   Source File: PLCamera.java    License: Apache License 2.0 5 votes vote down vote up
protected void setInternalRotationSensitivity(float rotationSensitivity)
{
	if(mRotationSensitivity != rotationSensitivity)
	{
		mRotationSensitivity = rotationSensitivity;
		mRotationSensitivityByDisplayPPI = PLConstants.kDisplayPPIBaseline / PLUtils.getDisplayPPI() * rotationSensitivity;
	}
}
 
Example 9
Source Project: PanoramaGL   Source File: PLJSONLoader.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void didEndDownload(String url, byte[] data, long elapsedTime)
{
	PLIImage image = new PLImage(PLUtils.getBitmap(data, mColorFormat), false);
	if(mPanorama instanceof PLCubicPanorama)
		((PLCubicPanorama)mPanorama).setImage(image, mIndex);
	else if(mPanorama instanceof PLIQuadricPanorama)
		((PLIQuadricPanorama)mPanorama).setImage(image);
}
 
Example 10
Source Project: SimplePanorama   Source File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    bitmaps[0] = PLUtils.getBitmap(this, R.raw.sunset_at_pier);
    bitmaps[1] = PLUtils.getBitmap(this, R.raw.sunset_at_pier_grey);

    sphericalView = (SphericalView) findViewById(R.id.spherical_view);
    sphericalView.setPanorama(bitmaps[0], true);

    findViewById(R.id.button1).setOnClickListener(buttonClickListener);
    findViewById(R.id.button2).setOnClickListener(buttonClickListener);
}
 
Example 11
Source Project: panoramagl   Source File: PLTexture.java    License: Apache License 2.0 5 votes vote down vote up
protected PLIImage convertImage(PLIImage image, PLTextureColorFormat colorFormat) {
    if (colorFormat != PLTextureColorFormat.PLTextureColorFormatUnknown) {
        Bitmap newBitmap = PLUtils.convertBitmap(image.getBitmap(), colorFormat);
        if (newBitmap != image.getBitmap())
            return new PLImage(newBitmap);
    }
    return image;
}
 
Example 12
Source Project: panoramagl   Source File: PLTexture.java    License: Apache License 2.0 5 votes vote down vote up
protected void recycleTexture(GL10 gl) {
    if (gl != null && mTextureId != null && mTextureId[0] != 0) {
        if (PLUtils.getAndroidVersion() < 3f) {
            gl.glDeleteTextures(1, mTextureId, 0);
            mTextureId[0] = 0;
            mGLWrapper = null;
            mIsValid = false;
        } else if (mGLWrapper != null) {
            GLSurfaceView glSurfaceView = mGLWrapper.getGLSurfaceView();
            if (glSurfaceView != null)
                glSurfaceView.queueEvent(new PLRecycleTextureRunnable(this));
        }
    }
}
 
Example 13
Source Project: panoramagl   Source File: PLHotspot.java    License: Apache License 2.0 5 votes vote down vote up
protected void calculateCoords(GL10 gl) {
    if (!hasChangedCoordProperty)
        return;

    hasChangedCoordProperty = false;

    float textureCoords[] = new float[8];

    List<PLPosition> positions = this.calculatePoints(gl);
    PLPosition pos1 = positions.get(0);
    PLPosition pos2 = positions.get(1);
    PLPosition pos3 = positions.get(2);
    PLPosition pos4 = positions.get(3);

    this.array
            (
                    mVertexs, 12,
                    pos1.x, pos1.y, pos1.z,
                    pos2.x, pos2.y, pos2.z,
                    pos3.x, pos3.y, pos3.z,
                    pos4.x, pos4.y, pos4.z
            );
    this.array
            (
                    textureCoords, 8,
                    1.0f, 1.0f,
                    0.0f, 1.0f,
                    1.0f, 0.0f,
                    0.0f, 0.0f
            );

    mVertexsBuffer = PLUtils.makeFloatBuffer(mVertexs);
    mTextureCoordsBuffer = PLUtils.makeFloatBuffer(textureCoords);
}
 
Example 14
Source Project: panoramagl   Source File: PLImage.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * delete methods
 */

protected void deleteImage() {
    if (mBitmap != null) {
        if (PLUtils.getAndroidVersion() < 3.0f && !mBitmap.isRecycled())
            mBitmap.recycle();
        mBitmap = null;
        mIsRecycled = true;
        mIsLoaded = false;
    }
}
 
Example 15
Source Project: panoramagl   Source File: PLJSONLoader.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void didEndDownload(String url, byte[] data, long elapsedTime) {
    PLIImage image = new PLImage(PLUtils.getBitmap(data, mColorFormat), false);
    if (mPanorama instanceof PLCubicPanorama)
        ((PLCubicPanorama) mPanorama).setImage(image, mIndex);
    else if (mPanorama instanceof PLIQuadricPanorama)
        ((PLIQuadricPanorama) mPanorama).setImage(image);
}
 
Example 16
Source Project: PanoramaGL   Source File: PLJSONLoader.java    License: Apache License 2.0 4 votes vote down vote up
protected PLIImage getLocalImage(String url, PLTextureColorFormat colorFormat)
{
	Bitmap bitmap = PLUtils.getBitmap(mView.getActivity().getApplicationContext(), url, colorFormat);
	return (bitmap != null ? new PLImage(bitmap, false) : null);
}
 
Example 17
Source Project: PanoramaGL   Source File: PLJSONLoader.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void didEndDownload(String url, byte[] data, long elapsedTime)
{
	mImage.assign(PLUtils.getBitmap(data, mColorFormat), false);
}
 
Example 18
Source Project: panoramagl   Source File: PLCamera.java    License: Apache License 2.0 4 votes vote down vote up
protected void setInternalFovSensitivity(float fovSensitivity) {
    if (mFovSensitivity != fovSensitivity) {
        mFovSensitivity = fovSensitivity;
        mFovSensitivityByDisplayPPI = PLConstants.kDisplayPPIBaseline / PLUtils.getDisplayPPI() * fovSensitivity;
    }
}
 
Example 19
Source Project: panoramagl   Source File: PLCamera.java    License: Apache License 2.0 4 votes vote down vote up
protected void setInternalRotationSensitivity(float rotationSensitivity) {
    if (mRotationSensitivity != rotationSensitivity) {
        mRotationSensitivity = rotationSensitivity;
        mRotationSensitivityByDisplayPPI = PLConstants.kDisplayPPIBaseline / PLUtils.getDisplayPPI() * rotationSensitivity;
    }
}
 
Example 20
Source Project: panoramagl   Source File: PLJSONLoader.java    License: Apache License 2.0 4 votes vote down vote up
protected PLIImage getLocalImage(String url, PLTextureColorFormat colorFormat) {
    Bitmap bitmap = PLUtils.getBitmap(mView.getContext().getApplicationContext(), url, colorFormat);
    return (bitmap != null ? new PLImage(bitmap, false) : null);
}
 
Example 21
Source Project: panoramagl   Source File: PLJSONLoader.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void didEndDownload(String url, byte[] data, long elapsedTime) {
    mImage.assign(PLUtils.getBitmap(data, mColorFormat), false);
}