我目前是增强现实编程的新手,我想问一个关于 cameraView 的问题。我的目标是在特定的现实坐标处显示一个可点击的 imageButton 并将其显示在 cameraView 中。在这种情况下,我想在我的 cameraView(这是一个世界)中显示的东西是我的按钮。在我决定调用它的使用权限很麻烦之前,我尝试使用 Wikiitude/AndAR/Layar API,而我目前正在使用 DroidAR 作为库和参考。但是我似乎无法找到正确显示我想要的内容的方法。我想就这个问题寻求帮助。请告诉我或指导我实现它的正确方法。非常感谢 !以下是我当前使用 droidAR 库 SDK 的代码。
public class DisplayAR extends Setup {
private static final float MIN_DIST = 15f;
private static final float MAX_DIST = 55f;
private Button b = null;
protected static final String LOG_TAG = "StaticDemoSetup";
World world;
GLCamera camera;
private TimeModifier timeModifier;
@Override
public void _a_initFieldsIfNecessary() {
// allow the user to send error reports to the developer:
}
@Override
public void _b_addWorldsToRenderer(GL1Renderer renderer,
GLFactory objectFactory, GeoObj currentPosition) {
camera = new GLCamera(new Vec(0, 0, 1));
world = new World(camera);
timeModifier = new TimeModifier(1);
RenderList l = new RenderList();
timeModifier.setChild(l);
world.add(timeModifier);
initI9Tests(world);
addTestGeoObj(world, camera);
renderer.addRenderElement(world);
}
private void addTestGeoObj(World w, GLCamera c) {
GeoObj o = new GeoObj();
w.add(o);
}
private void initI9Tests(World w) {
{
// transform android ui elements into opengl models:
b = new Button(getActivity());
b.setText("L.311");
MeshComponent button = GLFactory.getInstance().newTexturedSquare("buttonId", IO.loadBitmapFromView(b));
button.addChild(new AnimationFaceToCamera(camera, 0.5f));
button.setScale(new Vec(10, 10, 10));
button.setColor(Color.red());
button.setOnClickCommand(new CommandShowToast(getActivity(), "THIS IS L.311"));
GeoObj treangleGeo = new GeoObj();
treangleGeo.setVirtualPosition(new Vec(MIN_DIST, MAX_DIST, 0.0f));
treangleGeo.setComp(button);
w.add(treangleGeo);
}
}
@Override
public void _c_addActionsToEvents(EventManager eventManager,
CustomGLSurfaceView arView, SystemUpdater updater) {
ActionWASDMovement wasdAction = new ActionWASDMovement(camera, 25f,
50f, 20f);
ActionRotateCameraBuffered rotateAction = new ActionRotateCameraBuffered(
camera);
eventManager.addOnLocationChangedAction(new ActionCalcRelativePos(
world, camera));
updater.addObjectToUpdateCycle(wasdAction);
updater.addObjectToUpdateCycle(rotateAction);
arView.addOnTouchMoveAction(wasdAction);
eventManager.addOnOrientationChangedAction(rotateAction);
eventManager.addOnTrackballAction(new ActionMoveCameraBuffered(camera,
5, 25));
}
@Override
public void _d_addElementsToUpdateThread(SystemUpdater worldUpdater) {
// add the created world to be updated:
worldUpdater.addObjectToUpdateCycle(world);
}
@Override
public void _e2_addElementsToGuiSetup(GuiSetup guiSetup, Activity activity) {
guiSetup.setBottomMinimumHeight(50);
guiSetup.setBottomViewCentered();
}
}