Skip to content

Commit

Permalink
futureproofing & bearing fix
Browse files Browse the repository at this point in the history
  • Loading branch information
johnwedgbury committed May 18, 2018
1 parent 93e72fb commit 6ac0f78
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public LocationScene(Context mContext, Activity mActivity, ArSceneView mArSceneV

deviceLocation = new DeviceLocation();
deviceOrientation = new DeviceOrientation();
deviceOrientation.resume();
}

public void processFrame(Frame frame) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package uk.co.appoly.arcorelocation.rendering;

import android.util.Log;

import com.google.ar.core.Anchor;
import com.google.ar.sceneform.AnchorNode;
import com.google.ar.sceneform.FrameTime;
Expand All @@ -16,12 +14,23 @@
public class LocationNode extends AnchorNode {

LocationMarker locationMarker;
private LocationNodeRender renderEvent;
private int distance;
private float scaleModifier = 1F;

public LocationNode(Anchor anchor, LocationMarker locationMarker) {
super(anchor);
this.locationMarker = locationMarker;
}

public float getScaleModifier() {
return scaleModifier;
}

public void setScaleModifier(float scaleModifier) {
this.scaleModifier = scaleModifier;
}

public LocationNodeRender getRenderEvent() {
return renderEvent;
}
Expand All @@ -30,7 +39,13 @@ public void setRenderEvent(LocationNodeRender renderEvent) {
this.renderEvent = renderEvent;
}

private LocationNodeRender renderEvent;
public int getDistance() {
return distance;
}

public void setDistance(int distance) {
this.distance = distance;
}

@Override
public void onUpdate(FrameTime frameTime) {
Expand All @@ -40,7 +55,6 @@ public void onUpdate(FrameTime frameTime) {
// However, if onUpdate is called explicitly or if the node is removed from the scene on a
// different thread during onUpdate, then getScene may be null.

Log.i("LocationNode", "Marker update called...");

for (Node n : getChildren()) {
if (getScene() == null) {
Expand Down Expand Up @@ -70,6 +84,7 @@ public void onUpdate(FrameTime frameTime) {
if (markerDistance > 3000)
scale *= 0.75F;

scale *= scaleModifier;

Vector3 cameraPosition = getScene().getCamera().getWorldPosition();
Vector3 cardPosition = n.getWorldPosition();
Expand All @@ -81,8 +96,8 @@ public void onUpdate(FrameTime frameTime) {
//locationMarker.node.setWorldScale(new Vector3(scale, scale, scale));
n.setWorldScale(new Vector3(scale, scale, scale));

if(renderEvent != null) {
renderEvent.render(markerDistance);
if (renderEvent != null) {
renderEvent.render(this);
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package uk.co.appoly.arcorelocation.rendering;

public interface LocationNodeRender {
void render(int distance);
void render(LocationNode node);
}
2 changes: 1 addition & 1 deletion examples/sceneform/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ dependencies {
implementation "com.android.support:appcompat-v7:27.1.0"
implementation "com.android.support:design:27.1.0"
//implementation 'uk.co.appoly.arcorelocation:arcore-location-debug@aar'
implementation 'com.github.appoly:ARCore-Location:1.0.0'
implementation 'com.github.appoly:ARCore-Location:1.0.1'
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

import uk.co.appoly.arcorelocation.LocationMarker;
import uk.co.appoly.arcorelocation.LocationScene;
import uk.co.appoly.arcorelocation.rendering.LocationNode;
import uk.co.appoly.arcorelocation.rendering.LocationNodeRender;
import uk.co.appoly.arcorelocation.utils.ARLocationPermissionHelper;

Expand Down Expand Up @@ -130,10 +131,10 @@ protected void onCreate(Bundle savedInstanceState) {

layoutLocationMarker.setRenderEvent(new LocationNodeRender() {
@Override
public void render(int distance) {
public void render(LocationNode node) {
View eView = exampleLayoutRenderable.getView();
TextView distanceTextView = eView.findViewById(R.id.textView2);
distanceTextView.setText(distance + "M");
distanceTextView.setText(node.getDistance() + "M");
}
});

Expand Down

0 comments on commit 6ac0f78

Please sign in to comment.