Android OpenGL compass - android

Can anyone help me with sample code for a compass needle that points in the direction where the phone is tilted?
I am trying to develop an application to rotate a bitmap in OpenGL from accelerometer values.

Ok so thanks to the comments above we do not have to use OpenGL, and while you could, I personally believe you can make life simpler by using a custom View.
Now in traditional standard StackOverFlow past time I am not going to give you code for this but extrmely large leg up. There is a thermometer example available here http://mindtherobot.com/blog/272/android-custom-ui-making-a-vintage-thermometer/.
Why have I sent you here?
It contains an example that renders a dial exceedingly close to a compass, with a few minor tweeks it could easily become a compass in terms of design. you will just need to remove the temperature related code and use the accelerometers instead.
It is a good intro to custom views and will show you how to get started.
I made a clock after following the tutorial just as another possibility to inspire you.

Related

Mapbox rotate map based on user bearing

I am writing a navigation app and I require rotation of the camera around the user (So rather than just rotating the user icon with the compass the camera rotates around the user giving the impression that the map is rotating in accordance to real life.)
I couldn't seem to find a default mode to do this I have tried the bearing tracking modes (GPS and Compass) as well as the location tracking modes:
mapboxMap.getTrackingSettings().setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
As I was unable to get it working I implemented a custom compass with a basic low pass filter in order to rotate the camera around the user. However as of upgrading from Mapbox 4.1.1 to 4.2.1 my custom implementation has broken (Rotation has become very laggy and very jagged).
I am sure there is a much easier way to do this but I am having a bit of trouble figuring it out. Could someone please advise me as to whether I was going about it the correct way or if there is a much easier solution that I am looking over?
Thank you in advanced!
To track the user location and rotate the map to the orientation is always pointing in the same direction as the user, use these lines combined:
mapboxMap.getTrackingSettings().setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
mapboxMap.getTrackingSettings().setMyBearingTrackingMode(MyBearingTracking.COMPASS);
Note for the full code, i'd recommend checking out this example.
Yes as #SCTaylor says, you absolutely need .setDismissAllTrackingOnGesture(false) to make this work

How does yelp monocle work

I was wondering how the Yelp monocle works. It a cool feature , especially in terms of augmented reality. So I know they access GPS and compass data. And they have data about places nearby like hotels and bars etc. But how do they calculate the orientation w.r.t each other in real time, as I rotate my device. So if my device is pointing east and theres a pizza place to the north. I rotate my device to north. Now how does it know that I'm facing a pizza place here. What is the crucial bit of information being used to calculate this ?
I am thinking of developing similar kind of app for android. Please let me know how I can approach this ..
Well, when you know where you are, you know where you are facing and where your target is, you can calculate the rest. It's basic trigonometry.

3D rotation like credit card in Android

I need to provide some 3D rotation of images, like credit card (please check the video in the link)
I want to know is it feasible or not, in the case of Android. If yes, how can I do that.
The card must have some thickness.
It definitely is feasible, but you will have to do some studying:-).
Start here: http://developer.android.com/guide/topics/graphics/opengl.html
But you may also achieve your goal by just using the video you have posted in your link.
Some context would be useful such as will this be a loading screen? Something in video? etc?
For instance, if you are trying to make a website style layout and have the card up at the top always spinning, I would advice against that on any mobile device as its a waste of performance.
If instead you are using it as a loading screen then again I would advice against it as you are going to spend a lot of time initializing open gl and loading the texture and mesh for the card as well as any lighting you need and then initiate animators and do the spinning etc.
As previously stated OpenGL would be a way of doing this; however, this is not a simple few lines of code. This would be quite the undertaking for someone unfamiliar with OpenGL and 3D modeling to accomplish in a short time frame.
Question: do you require a native Android app, or would it be alright to use Flash Player? You can find tons of interactive 3d geometry demos on http://wonderfl.net - I forked one that had a plane, switched it to a cube, and you can download the results -
3d box on wonderfl
Not OpenGL - the example I found was Papervision3D (which is out of date a couple of years) - but software rendering is fine for 12 triangles. You, of course, would have to import your card faces as texture images if you want to make it look like a credit card.

Make meter in Android

I'm newbie and i'm making small application for Android. I would like to display a meter to show CPU usage.
I already get CPU usage but do NOT know how to make the meter like that: http://vb2.upanh.com/thumbpic/22.878.29891111.asR0/capture.700x0.jpg
Somebody help me! Thanks all.
GeekYouUp's Battery Widget includes a simple example of creating a graph/meter somewhat similar to the example posted. It's code and graphics are available at code.google.com/p/batterywidget/
Where will is the meter graphic to appear? On a main activity screen? In the taskbar? In an app widget? Live wallpaper?

OpenGL model Overlay of Camera Preview

I am trying to display a .md2 model over top of the camera preview on my android phone. I don't need to use the accelerometers or anything. If anyone could even just point me in the right direction as to have to set up an opengl overlay that would be fantastic. If you are able to provide code that shows how to enable this that would be even better! It would be greatly appreciated..
I'm not able to provide code until later this week, but you might want to check out a library called min3d, because I believe they already have a parser written for .md2 files. Then I believe that if you use a GLSurfaceView, the background can be set to be transparent, and you can put a view of the camera behind it. Are you trying to get some kind of augmented reality effect? There are android specific libraries for that too, but they're pretty laggy (at least on my Motorola Droid).

Categories

Resources