现在准备在我的应用里面加一个增强现实的功能。
所以希望能在这里集思广益。感兴趣的朋友都来说说吧。
做过的,希望你能跟大家分享下经验,没做过的,遇到什么难题了,可以说出来,大家谈论,没做的,想做的,可以过来看看热闹。谢谢大家的捧场。我这有些网站与大家分享。
http://www.devx.com/wireless/Article/42482/1954
http://stackoverflow.com/questions/1939318/augmented-reality-framework
http://stackoverflow.com/questions/1870278/how-to-start-writing-an-augmented-reality-application
http://www.androidkit.com/developing-augmented-reality-applications-for-android
http://mobile.tutsplus.com/tutorials/android/android_augmented-reality/
https://github.com/haseman/Android-AR-Kit
所以希望能在这里集思广益。感兴趣的朋友都来说说吧。
做过的,希望你能跟大家分享下经验,没做过的,遇到什么难题了,可以说出来,大家谈论,没做的,想做的,可以过来看看热闹。谢谢大家的捧场。我这有些网站与大家分享。
http://www.devx.com/wireless/Article/42482/1954
http://stackoverflow.com/questions/1939318/augmented-reality-framework
http://stackoverflow.com/questions/1870278/how-to-start-writing-an-augmented-reality-application
http://www.androidkit.com/developing-augmented-reality-applications-for-android
http://mobile.tutsplus.com/tutorials/android/android_augmented-reality/
https://github.com/haseman/Android-AR-Kit
我们一起研究. [email protected]
我找到一些有用的资料
比如说layer
最近找到一个API 叫做wikitude,手机下载一个WIKITUDE 的MODULE,然后再在自己的类 里调用方法就可以了。
但问题是如果不付费就只能用BETA 版的。
现在也没想到什么其他的好办法。一下是实现自己跟着学做的。
几个坐标的点可以随意改,我只是随便加的。
import java.util.ArrayList;
import java.util.Collection;
import org.openintents.intents.WikitudeARIntent;
import org.openintents.intents.WikitudePOI;import android.app.Activity;
import android.app.Application;
import android.content.ActivityNotFoundException;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;public class RAugmente extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b = (Button)findViewById(R.id.reality);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
// lance intent de realite augmente
startARViewBasic();
}
/*
* vue réalité augmenté
*/
private void startARViewBasic() {
// TODO Auto-generated method stub
// Creation d'un intent basic AR
WikitudeARIntent intent = prepareIntent();
// Titre de mon application
intent.addTitleText("AR application");
// lancement de RA
try{
//lecontext.startActivity(intent);
startActivity(intent);
}
catch(ActivityNotFoundException e){
//Toast.makeText(this, "Rien trouvé"+e.getMessage(), Toast.LENGTH_SHORT).show();
//email.setText(e.getMessage()+"/"+intent.toString());
}
}
private WikitudeARIntent prepareIntent() {
// TODO Auto-generated method stub
// create the intent
WikitudeARIntent intent = new WikitudeARIntent(RAugmente.this.getApplication(), null, null);
// add the POIs
this.addPoint(intent);
return intent;
}
// ajouter les point ce qu'on va dessiner
private void addPoint(WikitudeARIntent intent) {
// première point de la fac (maurienne)
WikitudePOI point1 = new WikitudePOI(45640910, 5869453);
// deuxième point (belledonne)
WikitudePOI point2 = new WikitudePOI(45641997, 5869011);
// troisième point (entremont)
WikitudePOI point3 = new WikitudePOI(45640421, 5870406); // quatrième point (4 canton)
WikitudePOI point4 = new WikitudePOI(45640523, 5870991); // cinquième point (Bauge)
WikitudePOI point5 = new WikitudePOI(45640155, 5870867); // ma collection de point
Collection<WikitudePOI> points = new ArrayList<WikitudePOI>();
points.add(point1);
points.add(point2);
points.add(point3);
points.add(point4);
points.add(point5);
intent.addPOIs(points);
}
});
}
}
WikitudeARIntent intent = new WikitudeARIntent(RAugmente.this.getApplication(), null, null)祝大家能在编程愉快!
private static final String CALLBACK_INTENT = "wikitudeapi.mycallbackactivity";
/** the id of the dialog which will be created when the modelfile cannot be located */
private static final int DIALOG_NO_MODEL_FILE_ON_SD = 1;
/** the model ile name */
private static final String modelFileName = Environment.getExternalStorageDirectory() + "/wtc_old_triang.obj";
/** the latitude of the origin (0/0/0) of the model */
private static final float modelCenterLatitude = 47.822f;
/** the longitude of the origin (0/0/0) of the model */
private static final float modelCenterLongitude = 13.045f;
/** the altitude of the origin (0/0/0) of the model */
private static final float modelCenterAltitude = 470; /**
* {@inheritDoc}
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.main); // We hook up 3 different buttons.
Button b = (Button) findViewById(R.id.button1);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
BasicOpenARDemoActivity.this.startARViewBasic();
}
}); b = (Button) findViewById(R.id.button2);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
BasicOpenARDemoActivity.this.startARViewWithIcons();
}
}); b = (Button) findViewById(R.id.button3);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
BasicOpenARDemoActivity.this.startARViewWithCustomTitle();
}
}); b = (Button) findViewById(R.id.button4);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
BasicOpenARDemoActivity.this.start3dARView();
}
});
} /**
* starts the basic AR view
*/
private void startARViewBasic() { // Create the basic intent
WikitudeARIntent intent = prepareIntent(); // And launch the intent
try {
intent.startIntent(this);
} catch (ActivityNotFoundException e) {
AbstractWikitudeARIntent.handleWikitudeNotFound(this);
}
} /**
* does the same as the basic AR view above, but adds custom icons to the POIs
*/
void startARViewWithIcons() { // Create the basic intent
WikitudeARIntent intent = prepareIntent(); // Optionally add a title
intent.addTitleText("AR app with custom icons");
intent.setPrintMarkerSubText(false); // Optionally: Add icons
addIcons(intent); // And launch the intent
try {
intent.startIntent(this);
} catch (ActivityNotFoundException e) {
AbstractWikitudeARIntent.handleWikitudeNotFound(this);
}
} /**
* does the same as the basic AR view above, but adds custom icons to the POIs and a graphical title image
*/
void startARViewWithCustomTitle() {
// Create the basic intent
WikitudeARIntent intent = prepareIntent(); intent.setPrintMarkerSubText(false); // Optionally: Add icons
addIcons(intent); // Optionally: Put a custom graphical title:
intent.addTitleImageResource(this.getResources().getResourceName(R.drawable.custom_title_bar)); // Optionally, one could set URIs:
// Use Android's content provider or create your own
// to host your custom images.
// intent.addTitleImageUri("content://com.IconCP/ANY_ICON_PATH.jpeg"); // And launch the intent
try {
intent.startIntent(this);
} catch (ActivityNotFoundException e) {
AbstractWikitudeARIntent.handleWikitudeNotFound(this);
}
} /**
* starts the 3D AR view
*/
private void start3dARView() { // Create the basic intent
Wikitude3dARIntent intent = new Wikitude3dARIntent(this.getApplication(), null, null); File file = new File(modelFileName);
if (!file.exists()) {
this.showDialog(BasicOpenARDemoActivity.DIALOG_NO_MODEL_FILE_ON_SD);
} else {
intent.setModelPathFileSystem(modelFileName);
intent.setModelOrigin(modelCenterLatitude, modelCenterLongitude, modelCenterAltitude);
intent.setMetersWorth1000Points(1); // And launch the intent
try {
intent.startIntent(this);
} catch (ActivityNotFoundException e) {
AbstractWikitudeARIntent.handleWikitudeNotFound(this);
}
}
} /**
* prepares a Wikitude AR Intent (e.g. adds the POIs to the view)
*
* @return the prepared intent
*/
private WikitudeARIntent prepareIntent() {
// create the intent
WikitudeARIntent intent = new WikitudeARIntent(this.getApplication(), null, null);
// add the POIs
this.addPois(intent);
// add one menu item
intent.setMenuItem1("My menu item", BasicOpenARDemoActivity.CALLBACK_INTENT);
intent.setPrintMarkerSubText(true);
return intent;
} /**
* adds hard-coded POIs to the intent
*
* @param intent
* the intent
*/
private void addPois(WikitudeARIntent intent) {
WikitudePOI poi1 = new WikitudePOI(35.683333, 139.766667, 36, "Tokyo", "Tokyo is the capital of Japan.");
poi1.setLink("http://www.tourism.metro.tokyo.jp/");
poi1.setDetailAction(BasicOpenARDemoActivity.CALLBACK_INTENT);
WikitudePOI poi2 = new WikitudePOI(41.9, 12.5, 14, "Rome",
"Rome is the capital of Italy and the country's largest and most populous city, with over 2.7 million residents.");
poi2.setDetailAction(BasicOpenARDemoActivity.CALLBACK_INTENT);
WikitudePOI poi3 = new WikitudePOI(40.716667, -74, 1, "New York",
"New York is the most populous city in the United States, and the center of the New York metropolitan area.");
poi3.setDetailAction(BasicOpenARDemoActivity.CALLBACK_INTENT);
WikitudePOI poi4 = new WikitudePOI(48.208333, 16.373056, 220, "Vienna",
"Vienna is the capital of the Republic of Austria.");
poi4.setDetailAction(BasicOpenARDemoActivity.CALLBACK_INTENT);
List<WikitudePOI> pois = new ArrayList<WikitudePOI>(); pois.add(poi1);
pois.add(poi2);
pois.add(poi3);
pois.add(poi4);
intent.addPOIs(pois); ((BasicOpenARDemoApplication) this.getApplication()).setPois(pois);
} /**
* helper-method to add icons to the intent.
*
* @param intent
* the intent
*/
private void addIcons(WikitudeARIntent intent) {
ArrayList<WikitudePOI> pois = intent.getPOIs(); Resources res = getResources();
pois.get(0).setIconresource(res.getResourceName(R.drawable.flag_japan));
pois.get(1).setIconresource(res.getResourceName(R.drawable.flag_italy));
pois.get(2).setIconresource(res.getResourceName(R.drawable.flag_usa));
pois.get(3).setIconresource(res.getResourceName(R.drawable.flag_austria));
// to use this, make sure you have the file present on the sdcard
// pois.get(3).setIconuri("content://com.IconCP/sdcard/flag_austria.png");
} /**
* {@inheritDoc}
*/
protected Dialog onCreateDialog(int dialogId) {
String message = this.getString(R.string.modelfile_not_found, modelFileName);
return new AlertDialog.Builder(this).setTitle(R.string.modelfile_not_found_title).setMessage(message)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// do nothing, just dismiss the dialog
}
}).create();
}
}