GearVRf - SceneObject not visible with GVSphere Image - android

I am trying to show a dot/pointer on GVRSphereSceneObject in GearVR. But, only the GVRSphereSceneObject is showing where as scene object hides once the texture image becomes visible. If I add both sphere and object using addSceneObject, then image is shown on one side and rest of view is blacked out.
I couldn't find any issue regarding this and tried samples also. Any help will be greatly appreciated.
Here is the code for adding object over sphere.
Future<GVRTexture> texture = gvrContext.loadFutureTexture(new GVRAndroidResource(gvrContext, R.raw.pano));
GVRMaterial material = new GVRMaterial(gvrContext);
material.setMainTexture(texture);
boom = new GVRSphereSceneObject(gvrContext, 18, 36, false, material);
Pointer = new GVRSceneObject(gvrContext,
new FutureWrapper<>(gvrContext.createQuad(0.05f, 0.05f)),
gvrContext.loadFutureTexture(new GVRAndroidResource(this.gvrContext, R.drawable.target)));
Pointer.getRenderData().getMaterial().setColor(Colors.RED[0], Colors.RED[1], Colors.RED[2]);
Pointer.getTransform().setPosition(0.0f, 0.0f, -1.0f);
Pointer.setName("Pointer");
boom.addChildObject(Pointer);
scene.addSceneObject(boom);

If anyone is struggling with this. Please have a look at this issue.
Pointer.getRenderData().setDepthTest(false);
Pointer.getRenderData().setRenderingOrder(SXRRenderData.SXRRenderingOrder.OVERLAY);

Related

Opengl - Creating a mini map from a gl view

I want to create a map from some opengl code that I wrote :
In order to do that I though about taking a screen shot of the upperview of the gl screen.
Yet I cant seem to find how to do that...
any suggestions?
Similar problem has been solved in OSG example code here.
First you need to set your view such that you are looking at center from the TOP VIEW.
osg::Vec3 center = scene->getBound().center();
double radius = scene->getBound().radius();
view->getCamera()->setViewMatrixAsLookAt( center - lookDir*(radius*3.0), center, up );
view->getCamera()->setProjectionMatrixAsPerspective(
30.0f, static_cast<double>(width)/static_cast<double>(height), 1.0f, 10000.0f );
Then, you need to use some OS specific API to do similar to logic below:
osgViewer::ScreenCaptureHandler* scrn = new osgViewer::ScreenCaptureHandler();
osgViewer::ScreenCaptureHandler::WriteToFile* captureOper = new osgViewer::ScreenCaptureHandler::WriteToFile(tmpStr.m_szBuffer, "png");
scrn->setCaptureOperation(captureOper);
scrn->captureNextFrame(*_viewer);
_viewer->frame();
Of course if you are not using OSG then you need to find equivalent APIs (of library you are using) to achieve the same task.

Android OpenGL ES image filters

I found this example and I am making some filters on realtime camera. When I use GlassSphereFilter or SphereRefractionFilter I get sphere on black background, and I want to achieve something like this. Can anyone help me?
Here is part of the code:
view = new FastImageProcessingView(this);
pipeline = new FastImageProcessingPipeline();
view.setPipeline(pipeline);
setContentView(view);
input = new CameraPreviewInput(view);
filter = new SphereRefractionFilter(new PointF(0.43f, 0.5f), 0.25f, 0.71f, 0.5f);
screen = new ScreenEndpoint(pipeline);
input.addTarget(screen);
filter.addTarget(screen);
pipeline.addRootRenderer(input);
pipeline.startRendering();
Is there a way ti show two surfaceViews with camera in same time? One to show normal image and other to show sphere?
I think you should use this library :
https://github.com/CyberAgent/android-gpuimage

AnimatedSprite displays with wrong size

Sorry if this problem was asked before. I have searched around but I didn't find any thread about this, So I post the question here.
I am really new on Andengine. I am trying to load a Tiled Sprite and create an animation with it.
Here are my codes:
public void loadGameResources() {
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/player/");
mSapoTextureAtlas = new BitmapTextureAtlas(mActivity.getTextureManager(),256,178,TextureOptions.DEFAULT);
mPlayerDownITiledTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(mPlayerTextureAtlas, mActivity.getAssets(), "player.png", 0,0,3,1);
mPlayerTextureAtlas.load();
}
What I expect is that the player can do some actions like walking but I don't. Please see the attached screenshots to see the real result. I think that my codes split the original texture into 3 parts rather than just split 3 sprites at first row.
Please take a look and help me to fix this. Thanks a lot!
And here is how I create the animation:
AnimatedSprite player= new AnimatedSprite(100,100,40,40,mResourceManager.mPlayerDownITiledTextureRegion,mVertexBufferObjectManager);
player.animate(500);
player.setZIndex(100);
attachChild(sapo);
What I understood is that you want to animate the player in each direction properly. For that
According to library method
BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(pBitmapTextureAtlas, pAssetManager, pAssetPath, pTextureX, pTextureY, pTileColumns, pTileRows);
Your code will change as below
mSapoTextureAtlas = new BitmapTextureAtlas(mActivity.getTextureManager(),256,256,TextureOptions.DEFAULT);
mPlayerDownITiledTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(mPlayerTextureAtlas, mActivity.getAssets(), "player.png", 0,0,3,4);
To animate player in different directions use this technique
define an array as
long[] ANIMATE_DURATION = new long[] { 200, 200, 200 };
AnimatedSprite player = new AnimatedSprite(x, y, this.mPlayerTextureRegion,this.getVertexBufferObjectManager());
// Down
player.animate(ANIMATE_DURATION, 0, 2, true);
// Up
player.animate(ANIMATE_DURATION, 9, 11, true);
// Right
player.animate(ANIMATE_DURATION, 6, 8, true);
// Left
player.animate(ANIMATE_DURATION, 3, 5, true);
look this Example for more information.
If you have doubt ask me. Hope this helped!
First: Atlas should be in power of two so change it size to 256x256.
Second:
mPlayerDownITiledTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(mPlayerTextureAtlas, mActivity.getAssets(), "player.png", 0,0,3,1);
Last two digits say how many rows and columns you have. You declared 3 columns and 1 row.
Three: Zindex at 100 is needed only if you have so many layers. If not you dont need it.

Sprites attached to scene without intention

I have three TextureRegions that are created like this:
mBackgroundTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(mMenuTextureAtlas, pActivity, "menu_background.png", 0, 0);
mPlayBtnTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(mMenuTextureAtlas, pActivity, "play_btn.png", 50, 100);
mExitBtnTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(mMenuTextureAtlas, pActivity, "exit_btn.png", 50, 200);
I also have corresponding sprites for each TextureRegion which are created like this:
mBackgroundSprite = new Sprite(0, 0, mBackgroundTextureRegion, mBufferObjectManager);
mPlayBtnSprite = new Sprite(0, 0, mPlayBtnTextureRegion, mBufferObjectManager);
mExitBtnSprite = new Sprite(0, 0, mExitBtnTextureRegion, mBufferObjectManager);
When I attach mBackgroundSprite to a scene like this:
mScene.attachChild(mBackgroundSprite);
I would expect only mBackgroundTextureRegion to appear on the scene (i.e. "menu_background.png") but in reality all three TextureRegions appear (i.e. mPlayBtnTextureRegion and mExitBtnTextureRegion appear too in their location as well, (50,100) and (50,200) respectively).
My questions are:
A. Why does this happen? (does it have something to do with using the same Texture for all TextureRegions?)
B. What is the correct way to make only one TextureRegion appear on a scene?
No this has nothing to do with the texture atlas. This is the correct way of doing it more or less. Nothing should be shown on the screen unless they are attached as a child to something (scene or engine). If you need more straightforward help please upload the part of your code that you are loading the sprite.

AndroidPlot: How to render a chart in an AppWidget?

I'm trying to use AndroidPlot to draw a chart in a homescreen widget.
I know that in a normal app, it uses a custom view and from what I've seen (Android: AppWidget with custom view not working), the workaround is to render this as a bitmap in an imageView.
Now I've taken the quickstart code for AndroidPlot and put it into the provider class but it doesn't seem to render anything when I drop it on the homescreen.
The difference between this code and the original quickstart code is that in the quickstart, it leverages the Activity.findViewById but obviously it can't be used here.
Can anyone see something here that I'm doing wrong that may be causing the empty rendering?
Appreciate any help you could provide!
private Bitmap getChartImage(Context context)
{
// initialize our XYPlot reference:
mySimpleXYPlot = new XYPlot(context, "My Simple XYPlot");
mySimpleXYPlot.setDrawingCacheEnabled(true);
// add a new series
mySimpleXYPlot.addSeries(new SimpleXYSeries(), LineAndPointRenderer.class, new LineAndPointFormatter(Color.rgb(0, 200, 0), Color.rgb(200, 0, 0)));
// reduce the number of range labels
mySimpleXYPlot.getGraphWidget().setRangeTicksPerLabel(4);
// reposition the domain label to look a little cleaner:
Widget domainLabelWidget = mySimpleXYPlot.getDomainLabelWidget();
mySimpleXYPlot.position(domainLabelWidget, // the widget to position
45, // x position value, in this case 45 pixels
XLayoutStyle.ABSOLUTE_FROM_LEFT, // how the x position value is applied, in this case from the left
0, // y position value
YLayoutStyle.ABSOLUTE_FROM_BOTTOM, // how the y position is applied, in this case from the bottom
AnchorPosition.LEFT_BOTTOM); // point to use as the origin of the widget being positioned
// get rid of the visual aids for positioning:
mySimpleXYPlot.disableAllMarkup();
//mySimpleXYPlot.measure(150, 150);
//mySimpleXYPlot.layout(0, 0, 150, 150);
Bitmap bmp = mySimpleXYPlot.getDrawingCache();
return bmp;
}
Have you stepped through to see if the bitmap is actually empty? My guess is that the Bitmap is fine and the problem exists outside of this chunk of code. Take a look at this example usage of a widget with AndroidPlot - it's super minimal and it definitely works. Hopefully there's a solution in there for you :)
Nick

Categories

Resources