3
我目前是新增強現實編程,我想問一個關於cameraView的問題。我的目標是在特定的實際座標中顯示可點擊的圖像按鈕並將其顯示在cameraView中。在這種情況下,我想在我的cameraView(這是一個世界)裏面顯示的東西就是我的按鈕。在嘗試使用Wikitude/AndAR/Layar API之前,我決定調用其使用權限並且我正在使用DroidAR作爲庫和參考。然而,我似乎無法找到一種方法來顯示我想要的東西。我想就這個問題尋求幫助。請告訴我或指導我實現它的正確方法。非常感謝你 !以下是我目前使用droidAR庫SDK的代碼。Java Android增強現實應用程序圖像座標
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();
}
}
嗯,我試過,之前我去了當前DroidAR 。在訪問任何API之前,Wikitude有一些相當不好的權限,所以我繼續使用DroidAR。感謝您的幫助無論如何感謝您的建議。我忘了填寫已經使用過哪種類型的API/SDK的部分。我會立即編輯它們= D – CodeNewbie
嘗試使用它示例示例您不需要更改任何有關權限的內容,它只能在設備上使用,只需將數據作爲字符串數組傳遞給維基增強現實主題示例 –
的主要活動它的工作原理= D並且使用它並不麻煩,而不是請求使用其他API的權限。尼斯= D – CodeNewbie