gpt4 book ai didi

java - 如何在 ARcore 的帮助下相对于一个 anchor 定位 anchor /节点/ anchor 节点?

转载 作者:行者123 更新时间:2023-11-30 12:07:44 29 4
gpt4 key购买 nike

我正在 android studio 中创建内部构建 AR 导航。我正在寻找一种方法将 anchor 与其他 anchor 或 anchor 节点/节点“连接”起来。我不确定使用哪一个。基于我将强制用户创建的第一个 anchor ,我想绘制相对于第一个 anchor 位置的其余节点。我尝试了下面显示的方法但没有成功。有什么想法吗?

private void getAnchors(DataSnapshot dataSnapshot){
double temp_x=0.0;
double temp_y=0.0;
double temp_z=0.0;
Vector3 wektor3;

for(DataSnapshot ds : dataSnapshot.getChildren())
{
ObjectConversion vars = ds.getValue(ObjectConversion.class);
temp_x = vars.getX();
temp_y = vars.getY();
temp_z = vars.getZ();

wektor3 = new Vector3((float)temp_x,(float)temp_y,(float)temp_z);

//Pose pose = new Pose(translation,rotation);
Anchor anchor = download_hit_result.createAnchor();
AnchorNode anchorNode = new AnchorNode(anchor);
Node node = new Node();

node.setParent(anchorNode);
node.setWorldPosition(wektor3);
node.setRenderable(andyRenderable);

//anchorNode.setParent(arFragment.getArSceneView().getScene());
//anchorNode.setRenderable(andyRenderable);
//anchorNode.setParent(arFragment.getArSceneView().getScene());
}
}

最佳答案

我已经发现了一个错误。对于任何其他需要根据不同对象定位对象的人。简单地说,必须将 anchor 节点的父节点设置为 arFragment。我希望这对以后的任何人都有帮助:

private void getAnchors(DataSnapshot dataSnapshot){
double temp_x=0.0;
double temp_y=0.0;
double temp_z=0.0;
long temp_val=0;
String temp_room="";
float[] translation= new float[3];
float[] rotation = {0.0f,0.0f,0.0f,0.0f};
Vector3 wektor3;
for(DataSnapshot ds : dataSnapshot.getChildren())
{
//TODO: create anchors with downloaded values when in the same position use hitpose.creatanchor with pose.

ObjectConversion vars = ds.getValue(ObjectConversion.class);
temp_x = vars.getX();
temp_y = vars.getY();
temp_z = vars.getZ();
temp_room = vars.getRoom();
temp_val=vars.getType();

translation[0]=(float) temp_x;
translation[1]=(float) temp_y;
translation[2]=(float) temp_z;
wektor3 = new Vector3((float)temp_x,(float)temp_y,(float)temp_z);
Pose pose = new Pose(translation,rotation);

Anchor anchorx = download_hit_result.getTrackable().createAnchor(pose);
AnchorNode anchorNodex = new AnchorNode(anchorx);
anchorNodex.setParent(arFragment.getArSceneView().getScene());
anchorNodex.setRenderable(andyRenderable);
}
}

关于java - 如何在 ARcore 的帮助下相对于一个 anchor 定位 anchor /节点/ anchor 节点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54693368/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com