Skip to content

Commit

Permalink
[ARKitEarth] updates
Browse files Browse the repository at this point in the history
  • Loading branch information
conceptdev committed Sep 29, 2017
1 parent cfe5bcb commit e482adf
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 70 deletions.
2 changes: 1 addition & 1 deletion ARKitEarth/ARKitSample/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Foundation;
using UIKit;

namespace ARKitSample
namespace ARKitEarth
{
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to application events from iOS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using ARKit;
using OpenTK;

namespace ARKitSample
namespace ARKitEarth
{
public static class Matrix4Extensions
{
Expand Down
2 changes: 1 addition & 1 deletion ARKitEarth/ARKitSample/Classes/SessionDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using SceneKit;
using UIKit;
using ARKit;
namespace ARKitSample
namespace ARKitEarth
{
public class SessionDelegate : ARSessionDelegate
{
Expand Down
44 changes: 6 additions & 38 deletions ARKitEarth/ARKitSample/GameViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using ARKit;
using CoreGraphics;

namespace ARKitSample
namespace ARKitEarth
{
public partial class GameViewController : UIViewController, IARSCNViewDelegate
{
Expand Down Expand Up @@ -47,11 +47,7 @@ public override void ViewDidLoad()
// Track changes to the session
SceneView.Session.Delegate = new SessionDelegate();

// Create a new scene
//var scene = SCNScene.FromFile("art.scnassets/ship");

// Set the scene to the view
//SceneView.Scene = scene;
// Create a new, empty scene
SceneView.Scene = new SCNScene();

// Add a tap gesture recognizer
Expand All @@ -73,18 +69,20 @@ public override void ViewWillAppear(bool animated)
// Run the view's session
SceneView.Session.Run(configuration, ARSessionRunOptions.ResetTracking);

var pos = new SCNVector3(1f, 0f, 1f);

// randomly choose a point to place the Earth
var pos = new SCNVector3 (-2f, 0f, -2f);


// earth r=0.2
var globe = SCNSphere.Create(0.2f);
var globeNode = new SCNNode { Position = pos, Geometry = globe };
globeNode.Geometry.Materials = LoadMaterials();
//globeNode.Transform = SCNMatrix4.CreateRotationX(0.4101524f); // 23.5 degrees
SceneView.Scene.RootNode.AddChildNode(globeNode);

globeNode.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy(0, 1, 0, 3)));


//moon r=0.08, orbit=0.6
var pivotNode = new SCNNode { Position = new SCNVector3(0, 0, 0) };
pivotNode.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy(0, 1, 0, 5)));
Expand All @@ -98,36 +96,6 @@ public override void ViewWillAppear(bool animated)

globeNode.AddChildNode(pivotNode);












// Find the ship and position it just in front of the camera
//var ship = SceneView.Scene.RootNode.FindChildNode("ship", true);


//ship.Position = new SCNVector3(2f, -2f, -9f);
//HACK: to see the jet move (circle around the viewer in a roll), comment out the ship.Position line above
// and uncomment the code below (courtesy @lobrien)

//var animation = SCNAction.RepeatActionForever(SCNAction.RotateBy(0, (float)Math.PI, (float)Math.PI, (float)1));
//var pivotNode = new SCNNode { Position = new SCNVector3(0.0f, 2.0f, 0.0f) };
//pivotNode.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy(0, -2, 0, 10)));
//ship.RemoveFromParentNode();
//pivotNode.AddChildNode(ship);
//SceneView.Scene.RootNode.AddChildNode(pivotNode);
//ship.Scale = new SCNVector3(0.1f, 0.1f, 0.1f);
//ship.Position = new SCNVector3(2f, -2f, -3f);
//ship.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy(0, 0, 2, 1)));

//ENDHACK
}


Expand Down
2 changes: 1 addition & 1 deletion ARKitEarth/ARKitSample/GameViewController.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ARKitEarth/ARKitSample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>ARKitSample</string>
<string>ARKitEarth</string>
<key>CFBundleIdentifier</key>
<string>com.xamarin.ARKitSample</string>
<string>com.xamarin.ARKitEarth</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion ARKitEarth/ARKitSample/Main.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using UIKit;

namespace ARKitSample
namespace ARKitEarth
{
public class Application
{
Expand Down
Binary file modified ARKitEarth/ARKitSample/art.scnassets/texture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 0 additions & 10 deletions ARKitEarth/Metadata.xml

This file was deleted.

19 changes: 4 additions & 15 deletions ARKitEarth/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
ARKit Sample
ARKit Earth
============

This sample is a simple ARKit augmented reality demo.
This sample is a simple ARKit augmented reality demo, based on this [Xamarin ARKit sample](https://developer.xamarin.com/samples/monotouch/ios11/ARKitSample/)

To test this sample you'll need to deploy it on a device running iOS 11 beta software.
To test this sample you'll need to deploy it on a device running iOS 11 software (the iPhone must be a 6s or newer).

![AR Jet](Screenshots/jet.png)
![Earth and Moon](Screenshots/earth.png)

By default, the sample presents a jet in a fixed location. To animate the jet around the viewer find the `HACK` in **GameViewController.cs**: comment out the line `ship.Position = new SCNVector3(2f, -2f, -9f);` and uncomment the code that creates an animation around a pivot node.

License
-------

Xamarin port changes are released under the MIT license

Author
------

Ported to Xamarin.iOS by Kevin Mullins, Larry O'Brien
Binary file added ARKitEarth/Screenshots/earth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed ARKitEarth/Screenshots/jet.png
Binary file not shown.

0 comments on commit e482adf

Please sign in to comment.