1
00:00:05,640 --> 00:00:09,010
Hey what's up on Mark Price you're at does slopes dotcom.

2
00:00:09,040 --> 00:00:11,500
And we're going to get our project started.

3
00:00:11,500 --> 00:00:16,780
So first things first is I already have X code open on my other screen here so I'm going to go to file

4
00:00:16,900 --> 00:00:23,290
new project and then I'm going to place this somewhere.

5
00:00:23,290 --> 00:00:29,890
So we're we're going to do is we're going to select augmented reality at K click next and we're going

6
00:00:29,890 --> 00:00:35,110
to call this ramp up and content technology.

7
00:00:35,170 --> 00:00:36,180
You can choose.

8
00:00:36,220 --> 00:00:37,020
This is interesting.

9
00:00:37,090 --> 00:00:44,170
This is important you can use to sync Sprite or metal on metal of course is very broad bare bones don't

10
00:00:44,170 --> 00:00:47,330
pick metal unless you're planning on building kind of your own engine around it.

11
00:00:47,380 --> 00:00:51,150
You can actually use Spryte kit with augmented reality as.

12
00:00:51,180 --> 00:00:53,960
So you can do 2D stuff as well.

13
00:00:54,220 --> 00:00:59,560
But we're going to cover the harder and more useful or practical use case which is seen kit working

14
00:00:59,560 --> 00:01:02,680
with 3D and all this other information can stay the same.

15
00:01:02,680 --> 00:01:04,820
We're going to be doing ours in swift of course.

16
00:01:04,840 --> 00:01:05,750
Click next.

17
00:01:06,690 --> 00:01:07,190
All right.

18
00:01:08,030 --> 00:01:08,680
Good to go.

19
00:01:08,780 --> 00:01:16,700
So a couple things or at least one thing is I will be doing less builds of the app in this section mostly

20
00:01:16,700 --> 00:01:19,660
because every time I build I have to stop the video.

21
00:01:19,820 --> 00:01:27,050
Go walk outside do the test and record the video and then put it back here in the video editor so you

22
00:01:27,050 --> 00:01:28,610
can see what I'm actually doing.

23
00:01:28,780 --> 00:01:36,320
It's not the easiest process here so you'll see that as you go along to it's it's your environment is

24
00:01:36,320 --> 00:01:37,100
very important.

25
00:01:37,100 --> 00:01:40,820
For instance if it's dark in a room it can detect the edges so you can't place things.

26
00:01:40,820 --> 00:01:46,670
Also the size of the models 3D models and everything is super important because it's using a scale that

27
00:01:46,670 --> 00:01:48,320
is actually in your real world environment.

28
00:01:48,320 --> 00:01:52,410
So you know if I'm putting a 15 foot skate ramp in my room it's not going to work.

29
00:01:52,410 --> 00:01:55,660
So I actually have to go outside and all those things are important now with augmented reality is that

30
00:01:55,660 --> 00:01:58,140
we're just building and running and watching it.

31
00:01:58,730 --> 00:02:00,250
But we'll make some good progress.

32
00:02:00,550 --> 00:02:00,770
OK.

33
00:02:00,770 --> 00:02:03,520
So let's take a look at our project see what we have Abdel.

34
00:02:03,590 --> 00:02:08,630
Of course we've got this art MCNESS that's for scene kit.

35
00:02:08,630 --> 00:02:09,320
All right.

36
00:02:09,320 --> 00:02:16,010
And if you never use it you're going to learn to two birds with one stone market plus 3D games with

37
00:02:16,100 --> 00:02:16,560
it.

38
00:02:16,610 --> 00:02:17,730
Awesome.

39
00:02:17,750 --> 00:02:21,960
So by default the project loads with a ship that SDN.

40
00:02:22,020 --> 00:02:26,770
OK we can click it here and it's a model a 3D model.

41
00:02:26,810 --> 00:02:27,880
All right pretty cool.

42
00:02:27,890 --> 00:02:37,400
And one thing that's really important to know about a CN file or seen file is that it can hold one or

43
00:02:37,400 --> 00:02:38,350
more objects.

44
00:02:38,360 --> 00:02:41,730
OK so sometimes you can actually or you.

45
00:02:41,740 --> 00:02:46,450
What I'm saying is you can use a scene file for one model or you can build out a whole level in it.

46
00:02:46,880 --> 00:02:52,640
And that's where Apple does actually have a scene file for every single model and then they actually

47
00:02:53,780 --> 00:02:59,720
have other seen files like let's say a level that has multiple other scenes included in it.

48
00:02:59,720 --> 00:03:03,860
I know it sounds confusing cause you're thinking maybe a scene is like a level or an environment but

49
00:03:04,370 --> 00:03:06,350
no scene can be anything.

50
00:03:06,650 --> 00:03:07,890
And that's what Apple's doing.

51
00:03:08,360 --> 00:03:12,000
And their example projects here and we'll will do something similar here.

52
00:03:12,200 --> 00:03:15,700
So you can play around this pretty cool if you've never worked with it before.

53
00:03:15,770 --> 00:03:20,390
And then it has a texture here and we're not going to use these will get rid of them soon enough and

54
00:03:20,390 --> 00:03:22,940
we've got this view controller here.

55
00:03:22,940 --> 00:03:24,980
All right pay attention to what's going on.

56
00:03:24,980 --> 00:03:26,260
Very important stuff.

57
00:03:26,600 --> 00:03:29,600
So we've got a scene view.

58
00:03:29,800 --> 00:03:30,300
OK.

59
00:03:30,340 --> 00:03:32,520
A scene view a RCN view.

60
00:03:32,520 --> 00:03:38,060
OK this is our augmented reality view and this one has to do with the 3-D.

61
00:03:38,060 --> 00:03:43,220
So this is scene kit plus augmented reality scene kit plus a R.K. notices right here.

62
00:03:43,220 --> 00:03:44,300
It would be different.

63
00:03:44,300 --> 00:03:48,290
In fact I think I have the docs over here.

64
00:03:48,290 --> 00:03:53,840
If it was a sprite kit it would be a r s KVOA So a sprite kit and augmented reality but we're using

65
00:03:53,940 --> 00:03:55,310
Sincock So that's right.

66
00:03:55,730 --> 00:04:00,690
And then you need to implement the scene view or the ARCC view delegate.

67
00:04:00,980 --> 00:04:08,390
OK that's how you can register for augmented reality or A-R kit notifications and callback functions.

68
00:04:08,440 --> 00:04:11,080
The the protocol functions OK.

69
00:04:11,410 --> 00:04:17,220
And so that's implemented here and if you go to the storyboard All right you'll notice that you have

70
00:04:17,220 --> 00:04:19,420
a view controller with a scene view on it.

71
00:04:19,500 --> 00:04:19,800
OK.

72
00:04:19,800 --> 00:04:25,180
It's actually using the scene view as the base view and we'll change that in just a little bit here

73
00:04:25,770 --> 00:04:28,860
and go ahead and plug your phone in.

74
00:04:29,190 --> 00:04:32,340
OK plug your phone in and run the project.

75
00:04:32,520 --> 00:04:38,620
And once it runs what you should see on your phone is a ship on your screen.

76
00:04:38,760 --> 00:04:39,380
OK.

77
00:04:39,660 --> 00:04:41,740
And that's the basic project care.

78
00:04:41,790 --> 00:04:45,620
And so let's go back to the view controller that swift and first things first let's do some cleanup

79
00:04:45,630 --> 00:04:46,890
here.

80
00:04:46,920 --> 00:04:55,290
What I'm going to do is I'm going to rename this refactor rename and we're going to call this.

81
00:04:55,550 --> 00:04:59,960
OK so my ex code keeps crashing and won't let me use the new refactor tool.

82
00:05:00,050 --> 00:05:03,240
But the fact you can right click and go to refactor rename.

83
00:05:03,260 --> 00:05:05,330
Obviously we're not doing that because it's not working.

84
00:05:05,330 --> 00:05:08,830
So I'm going actually show you how to do it manually which is good and good to know anyway.

85
00:05:08,840 --> 00:05:14,600
So class view controller what we're going to do is we're going to call this ramp place or AVC.

86
00:05:14,600 --> 00:05:17,380
This is the this is a screen where you place the ramps.

87
00:05:17,390 --> 00:05:17,840
OK.

88
00:05:17,980 --> 00:05:19,370
So I'm going to save that here.

89
00:05:19,370 --> 00:05:26,560
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

90
00:05:26,570 --> 00:05:33,920
go into the storyboard here and on the View Controller here click the I can appear the identity inspector

91
00:05:34,040 --> 00:05:35,030
and a set of view controller.

92
00:05:35,030 --> 00:05:37,760
Let's just call this ramp placer you see.

93
00:05:37,800 --> 00:05:39,580
So we just did it manually.

94
00:05:39,590 --> 00:05:40,800
No big deal.

95
00:05:40,840 --> 00:05:45,350
So we used to do anyway before X code cotinine sides that new feature doesn't even work.

96
00:05:45,350 --> 00:05:46,340
Goodness.

97
00:05:46,340 --> 00:05:46,590
All right.

98
00:05:46,600 --> 00:05:48,170
So a little more clean here.

99
00:05:49,140 --> 00:06:00,010
Newgroup and we're going to call this controller and let's put in the ramp placer boom like that.

100
00:06:00,030 --> 00:06:00,960
That's looking good.

101
00:06:01,190 --> 00:06:03,370
Ok cool.

102
00:06:03,420 --> 00:06:10,630
So see this this view here it's kind of putting the base view and the reason why I don't want that here

103
00:06:11,020 --> 00:06:14,630
is because I can't I can't do anything with it I can't put buttons on.

104
00:06:14,640 --> 00:06:16,150
I can't do anything.

105
00:06:16,150 --> 00:06:22,480
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.

106
00:06:22,950 --> 00:06:23,580
All right.

107
00:06:23,660 --> 00:06:33,390
And I'm going to do instead is I'm going to grab a regular view and put it on here.

108
00:06:37,010 --> 00:06:38,650
Now we have a view which is good.

109
00:06:38,690 --> 00:06:41,840
That's right click the ramp placer and mixed reviews connected which it is.

110
00:06:41,840 --> 00:06:45,930
So it did that for us automatically and noticed that we still have an outlet for the scene view.

111
00:06:45,950 --> 00:06:48,080
So we do need to add that back here.

112
00:06:48,080 --> 00:06:58,220
So what I'm going to type in here is our kit scene kit view and we will make it full screen like so

113
00:06:59,800 --> 00:07:02,810
and we'll go ahead and pin up all four corners here.

114
00:07:02,980 --> 00:07:03,790
No big deal.

115
00:07:03,820 --> 00:07:06,790
We're just we're just making things a little bit better.

116
00:07:07,090 --> 00:07:11,290
And then I'm going to right click ramp place for ABC and the scene view I'm just going to drag it from

117
00:07:11,290 --> 00:07:14,300
here over to here to connect that outlet there.

118
00:07:15,170 --> 00:07:16,510
Cool.

119
00:07:16,580 --> 00:07:17,670
So that's looking good there.

120
00:07:17,780 --> 00:07:22,910
So now that we have a rent placer here let's talk about a few things that are in here we've factored

121
00:07:22,910 --> 00:07:24,170
it a little bit of clean up.

122
00:07:24,170 --> 00:07:26,300
We move some these around.

123
00:07:26,390 --> 00:07:29,550
And so if you did load scene viewed that delegate.

124
00:07:29,570 --> 00:07:33,550
OK so we're just setting the delegate which is here.

125
00:07:33,560 --> 00:07:38,650
So these callback functions are these protocol functions will be called shoats So statistics is just

126
00:07:38,660 --> 00:07:43,490
going to show timing and frames per second on your screen.

127
00:07:43,490 --> 00:07:45,300
It's not first person shooter.

128
00:07:45,440 --> 00:07:47,190
OK frames per second.

129
00:07:47,330 --> 00:07:52,480
And then what you actually do is you create a scene kit scene.

130
00:07:52,480 --> 00:07:53,240
OK.

131
00:07:53,330 --> 00:07:55,110
And then you load it into the scene view.

132
00:07:55,130 --> 00:08:01,330
Because what needs to happen is your scene view it needs to have some type of 3D scene to render onto

133
00:08:01,340 --> 00:08:02,090
the screen.

134
00:08:02,270 --> 00:08:06,830
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

135
00:08:06,830 --> 00:08:08,240
be no 3-D environment in there.

136
00:08:08,240 --> 00:08:14,410
So this scene is grabbing something from the art folder or the archive and assets in this case it's

137
00:08:14,420 --> 00:08:15,540
a ship scene.

138
00:08:15,830 --> 00:08:20,750
If you had a whole like world with like roads and trees and stuff and you use that it would actually

139
00:08:20,750 --> 00:08:23,380
load that into your into your 3-D view.

140
00:08:23,390 --> 00:08:25,920
So we're just basically loading a scene.

141
00:08:26,450 --> 00:08:27,970
And what I like to do we're not here yet.

142
00:08:27,980 --> 00:08:34,160
What I do is actually create an empty scene that is going to hold all of your objects.

143
00:08:34,250 --> 00:08:34,940
OK.

144
00:08:35,310 --> 00:08:38,840
Versus just loading one scene like they did right here.

145
00:08:38,860 --> 00:08:40,580
It's harder to work with this way.

146
00:08:40,580 --> 00:08:45,680
They've got random ship that's just we want to kind of an empty world that we can play with like a playground

147
00:08:45,710 --> 00:08:52,490
put things in case we're setting the scene and then here OK interview will appear at the time to view

148
00:08:52,490 --> 00:08:53,740
floats.

149
00:08:53,760 --> 00:08:54,960
Well let's actually look at this one first.

150
00:08:54,960 --> 00:08:58,380
Any time the view disappears we actually pause the session.

151
00:08:58,460 --> 00:08:58,850
OK.

152
00:08:58,850 --> 00:09:03,740
And then when it reappears then we go ahead and we run the configuration session.

153
00:09:03,740 --> 00:09:07,640
And so let's go to our documentation here and see what this means.

154
00:09:07,670 --> 00:09:13,550
Our world tracking session configuration the air world tracking session configuration class provides

155
00:09:13,550 --> 00:09:18,560
high precision motion tracking and enables features to help you place virtual contact in relation to

156
00:09:18,560 --> 00:09:22,890
real world surfaces and situations where world tracking is not available.

157
00:09:22,890 --> 00:09:28,220
The base class or session configuration provides simple motion tracking that permits less immersive

158
00:09:28,490 --> 00:09:33,860
experiences to starting our session create a session configuration object with the options you want

159
00:09:34,340 --> 00:09:40,750
and then call the run method on the session object on your view or your scene kit or your sprite kit

160
00:09:40,760 --> 00:09:41,510
view.

161
00:09:41,660 --> 00:09:43,370
Mark why are you reading stuff to us.

162
00:09:43,370 --> 00:09:45,800
I came here to learn not to read well.

163
00:09:46,340 --> 00:09:49,970
This is where I learned from the documentation you need to be reading this stuff they're going to explain

164
00:09:49,970 --> 00:09:55,160
that way better than I am so really important stuff right you have to have a tracking session configuration

165
00:09:55,190 --> 00:10:00,590
and it also mentioned to us if things aren't working so right it's not a great environment for the proper

166
00:10:00,590 --> 00:10:08,400
A-R kit tracking it will default to a more simple a are a tracking setup so you've got to run your configuration

167
00:10:08,700 --> 00:10:12,740
OK like so and any time you pause you have to rerun it here.

168
00:10:12,860 --> 00:10:15,170
All right so that's it.

169
00:10:15,170 --> 00:10:19,070
I mean that's it for as far as what the sample project gives you here and there.

170
00:10:19,070 --> 00:10:21,590
Here are the callback or protocol functions.

171
00:10:21,830 --> 00:10:26,540
It can fail with an error if the session was interrupted for some reason that maybe maybe a phone call

172
00:10:26,540 --> 00:10:32,500
comes in you can handle that gracefully and at the end of this section and end this project or should

173
00:10:32,500 --> 00:10:38,000
be walking you through Apple's very immersive R.K. example project so you can see all the things that

174
00:10:38,000 --> 00:10:44,070
you can do and then you'll see how these things are more so implemented here so really good stuff.

175
00:10:44,090 --> 00:10:45,170
We're going to call this video done.

176
00:10:45,170 --> 00:10:47,860
It was just an overview that some clean up here.

177
00:10:47,990 --> 00:10:54,230
Getting your mind ready to actually start building some 3D 3D stuff in our air world so that's it for

178
00:10:54,230 --> 00:10:54,380
now.

179
00:10:54,380 --> 00:10:56,500
Marc price at soap's dot com.

180
00:10:56,500 --> 00:10:57,630
Let's move on board.

