-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace ARPositionStrategy with ARPoint
- Loading branch information
1 parent
c5c1bd5
commit 7ab5368
Showing
11 changed files
with
173 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 43 additions & 5 deletions
48
app/src/main/java/com/kylecorry/trail_sense/tools/augmented_reality/ARMarker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,49 @@ | ||
package com.kylecorry.trail_sense.tools.augmented_reality | ||
|
||
import com.kylecorry.andromeda.canvas.ICanvasDrawer | ||
import com.kylecorry.sol.units.Coordinate | ||
import com.kylecorry.trail_sense.shared.canvas.PixelCircle | ||
import com.kylecorry.trail_sense.tools.augmented_reality.position.ARPositionStrategy | ||
import com.kylecorry.trail_sense.tools.augmented_reality.position.ARPoint | ||
import com.kylecorry.trail_sense.tools.augmented_reality.position.GeographicARPoint | ||
import com.kylecorry.trail_sense.tools.augmented_reality.position.SphericalARPoint | ||
|
||
interface ARMarker: ARPositionStrategy { | ||
fun draw(view: AugmentedRealityView, drawer: ICanvasDrawer, area: PixelCircle) | ||
fun onFocused(): Boolean | ||
fun onClick(): Boolean | ||
class ARMarker( | ||
private val point: ARPoint, | ||
private val canvasObject: CanvasObject, | ||
private val keepFacingUp: Boolean = false, | ||
private val onFocusedFn: (() -> Boolean) = { false }, | ||
private val onClickFn: () -> Boolean = { false } | ||
) { | ||
|
||
fun draw(view: AugmentedRealityView, drawer: ICanvasDrawer, area: PixelCircle) { | ||
drawer.push() | ||
if (keepFacingUp) { | ||
drawer.rotate(view.sideInclination, area.center.x, area.center.y) | ||
} | ||
canvasObject.draw(drawer, area) | ||
drawer.pop() | ||
} | ||
|
||
/** | ||
* Gets the location of the marker on the screen | ||
* @param view The AR view | ||
* @return The location of the marker | ||
*/ | ||
fun getViewLocation(view: AugmentedRealityView): PixelCircle { | ||
val coordinates = point.getHorizonCoordinate(view) | ||
val angularDiameter = point.getAngularDiameter(view) | ||
val diameter = view.sizeToPixel(angularDiameter) | ||
return PixelCircle( | ||
view.toPixel(coordinates), | ||
diameter / 2f | ||
) | ||
} | ||
|
||
fun onFocused(): Boolean { | ||
return onFocusedFn() | ||
} | ||
|
||
fun onClick(): Boolean { | ||
return onClickFn() | ||
} | ||
} |
96 changes: 0 additions & 96 deletions
96
app/src/main/java/com/kylecorry/trail_sense/tools/augmented_reality/ARMarkerImpl.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.