我想在我的项目中使用 DroidAR 库,但示例代码不起作用 https://github.com/bitstars/droidar/wiki/Example-code-how-to-create-an-object-with-GPS -coordinates-and-display-its-distance 我在我的项目中使用此代码
^
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Button button = new Button(this);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ArActivity.startWithSetup(MainActivity.this,
new DefaultARSetup() {
@Override
public void addObjectsTo(GL1Renderer renderer,
final World world, GLFactory objectFactory) {
Location l = new Location("");
l.setLatitude(51.533144);
l.setLongitude(46.038401);
Obj o = new GeoObj(l);
o.setComp(objectFactory.newCube());
o.setComp(new Entity() {
private Updateable p;
private float waitTimeInMilliseconds = 1000;
UpdateTimer timer = new UpdateTimer(
waitTimeInMilliseconds, null);
@Override
public boolean accept(Visitor visitor) {
return false;
}
@Override
public boolean update(float timeDelta,
Updateable parent) {
p = parent;
if (timer.update(timeDelta, parent)) {
// true once a second, do the
// calculation here:
float distanceOfGeoObjToUser = Vec.distance(
((GeoObj) p)
.getVirtualPosition(),
world.getMyCamera()
.getPosition());
Log.d("dist",
String.valueOf(distanceOfGeoObjToUser));
}
return true;
}
@Override
public void setMyParent(Updateable parent) {
this.p = parent;
}
@Override
public Updateable getMyParent() {
return p;
}
});
world.add(o);
}
});
}
});
setContentView(button);
}
}
应用程序正在加载但不显示任何内容但在日志中我看到了这个
Current location was unknown, cant do steps