I'm creating inside building AR navigation in android studio. I'm looking for a way to "connect" the anchor with other anchors, or maybe anchor nodes / nodes. I'm not sure which one to use. Based on first anchor that i will force user to create I want to draw rest of a nodes that will be relative to the position of the first anchor. I've tried methods shown below but without success. Any ideas ?
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());
}
}
I found a mistake already. To anyone else who'll need to position objects based on diffrent objects. Simply, had to setParent of a anchornode to arFragment. I hope this helps anyone in the future:
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);
}
}