Hey what's up on Mark Price you're at does slopes dotcom.
And we're going to get our project started.
So first things first is I already have X code open on my other screen here so I'm going to go to file
new project and then I'm going to place this somewhere.
So we're we're going to do is we're going to select augmented reality at K click next and we're going
to call this ramp up and content technology.
You can choose.
This is interesting.
This is important you can use to sync Sprite or metal on metal of course is very broad bare bones don't
pick metal unless you're planning on building kind of your own engine around it.
You can actually use Spryte kit with augmented reality as.
So you can do 2D stuff as well.
But we're going to cover the harder and more useful or practical use case which is seen kit working
with 3D and all this other information can stay the same.
We're going to be doing ours in swift of course.
Click next.
All right.
Good to go.
So a couple things or at least one thing is I will be doing less builds of the app in this section mostly
because every time I build I have to stop the video.
Go walk outside do the test and record the video and then put it back here in the video editor so you
can see what I'm actually doing.
It's not the easiest process here so you'll see that as you go along to it's it's your environment is
very important.
For instance if it's dark in a room it can detect the edges so you can't place things.
Also the size of the models 3D models and everything is super important because it's using a scale that
is actually in your real world environment.
So you know if I'm putting a 15 foot skate ramp in my room it's not going to work.
So I actually have to go outside and all those things are important now with augmented reality is that
we're just building and running and watching it.
But we'll make some good progress.
OK.
So let's take a look at our project see what we have Abdel.
Of course we've got this art MCNESS that's for scene kit.
All right.
And if you never use it you're going to learn to two birds with one stone market plus 3D games with
it.
Awesome.
So by default the project loads with a ship that SDN.
OK we can click it here and it's a model a 3D model.
All right pretty cool.
And one thing that's really important to know about a CN file or seen file is that it can hold one or
more objects.
OK so sometimes you can actually or you.
What I'm saying is you can use a scene file for one model or you can build out a whole level in it.
And that's where Apple does actually have a scene file for every single model and then they actually
have other seen files like let's say a level that has multiple other scenes included in it.
I know it sounds confusing cause you're thinking maybe a scene is like a level or an environment but
no scene can be anything.
And that's what Apple's doing.
And their example projects here and we'll will do something similar here.
So you can play around this pretty cool if you've never worked with it before.
And then it has a texture here and we're not going to use these will get rid of them soon enough and
we've got this view controller here.
All right pay attention to what's going on.
Very important stuff.
So we've got a scene view.
OK.
A scene view a RCN view.
OK this is our augmented reality view and this one has to do with the 3-D.
So this is scene kit plus augmented reality scene kit plus a R.K. notices right here.
It would be different.
In fact I think I have the docs over here.
If it was a sprite kit it would be a r s KVOA So a sprite kit and augmented reality but we're using
Sincock So that's right.
And then you need to implement the scene view or the ARCC view delegate.
OK that's how you can register for augmented reality or A-R kit notifications and callback functions.
The the protocol functions OK.
And so that's implemented here and if you go to the storyboard All right you'll notice that you have
a view controller with a scene view on it.
OK.
It's actually using the scene view as the base view and we'll change that in just a little bit here
and go ahead and plug your phone in.
OK plug your phone in and run the project.
And once it runs what you should see on your phone is a ship on your screen.
OK.
And that's the basic project care.
And so let's go back to the view controller that swift and first things first let's do some cleanup
here.
What I'm going to do is I'm going to rename this refactor rename and we're going to call this.
OK so my ex code keeps crashing and won't let me use the new refactor tool.
But the fact you can right click and go to refactor rename.
Obviously we're not doing that because it's not working.
So I'm going actually show you how to do it manually which is good and good to know anyway.
So class view controller what we're going to do is we're going to call this ramp place or AVC.
This is the this is a screen where you place the ramps.
OK.
So I'm going to save that here.
I'm going to change the file name to to ramp place or VC and then the last thing we need to do is just
go into the storyboard here and on the View Controller here click the I can appear the identity inspector
and a set of view controller.
Let's just call this ramp placer you see.
So we just did it manually.
No big deal.
So we used to do anyway before X code cotinine sides that new feature doesn't even work.
Goodness.
All right.
So a little more clean here.
Newgroup and we're going to call this controller and let's put in the ramp placer boom like that.
That's looking good.
Ok cool.
So see this this view here it's kind of putting the base view and the reason why I don't want that here
is because I can't I can't do anything with it I can't put buttons on.
I can't do anything.
And it's just it's not useful so what I'm actually going to do is I'm going to delete this scene view.
All right.
And I'm going to do instead is I'm going to grab a regular view and put it on here.
Now we have a view which is good.
That's right click the ramp placer and mixed reviews connected which it is.
So it did that for us automatically and noticed that we still have an outlet for the scene view.
So we do need to add that back here.
So what I'm going to type in here is our kit scene kit view and we will make it full screen like so
and we'll go ahead and pin up all four corners here.
No big deal.
We're just we're just making things a little bit better.
And then I'm going to right click ramp place for ABC and the scene view I'm just going to drag it from
here over to here to connect that outlet there.
Cool.
So that's looking good there.
So now that we have a rent placer here let's talk about a few things that are in here we've factored
it a little bit of clean up.
We move some these around.
And so if you did load scene viewed that delegate.
OK so we're just setting the delegate which is here.
So these callback functions are these protocol functions will be called shoats So statistics is just
going to show timing and frames per second on your screen.
It's not first person shooter.
OK frames per second.
And then what you actually do is you create a scene kit scene.
OK.
And then you load it into the scene view.
Because what needs to happen is your scene view it needs to have some type of 3D scene to render onto
the screen.
And in this case it's just a ship so even if it didn't have the scene you would see the camera but there'd
be no 3-D environment in there.
So this scene is grabbing something from the art folder or the archive and assets in this case it's
a ship scene.
If you had a whole like world with like roads and trees and stuff and you use that it would actually
load that into your into your 3-D view.
So we're just basically loading a scene.
And what I like to do we're not here yet.
What I do is actually create an empty scene that is going to hold all of your objects.
OK.
Versus just loading one scene like they did right here.
It's harder to work with this way.
They've got random ship that's just we want to kind of an empty world that we can play with like a playground
put things in case we're setting the scene and then here OK interview will appear at the time to view
floats.
Well let's actually look at this one first.
Any time the view disappears we actually pause the session.
OK.
And then when it reappears then we go ahead and we run the configuration session.
And so let's go to our documentation here and see what this means.
Our world tracking session configuration the air world tracking session configuration class provides
high precision motion tracking and enables features to help you place virtual contact in relation to
real world surfaces and situations where world tracking is not available.
The base class or session configuration provides simple motion tracking that permits less immersive
experiences to starting our session create a session configuration object with the options you want
and then call the run method on the session object on your view or your scene kit or your sprite kit
view.
Mark why are you reading stuff to us.
I came here to learn not to read well.
This is where I learned from the documentation you need to be reading this stuff they're going to explain
that way better than I am so really important stuff right you have to have a tracking session configuration
and it also mentioned to us if things aren't working so right it's not a great environment for the proper
A-R kit tracking it will default to a more simple a are a tracking setup so you've got to run your configuration
OK like so and any time you pause you have to rerun it here.
All right so that's it.
I mean that's it for as far as what the sample project gives you here and there.
Here are the callback or protocol functions.
It can fail with an error if the session was interrupted for some reason that maybe maybe a phone call
comes in you can handle that gracefully and at the end of this section and end this project or should
be walking you through Apple's very immersive R.K. example project so you can see all the things that
you can do and then you'll see how these things are more so implemented here so really good stuff.
We're going to call this video done.
It was just an overview that some clean up here.
Getting your mind ready to actually start building some 3D 3D stuff in our air world so that's it for
now.
Marc price at soap's dot com.
Let's move on board.