Forgot password?
 立即注册
EasyAR Portal Tutorial View Content

EasyAR Getting started tutorial(1)-Show model

AlbertLee 2017-8-16 10:55

Show Model

Step 1:Develop overview



code: https://drive.google.com/open?id=0B6vjKDkZUGVsOGVsTXBWTzA0UUE
model resources: https://drive.google.com/open?id=0B6vjKDkZUGVsWmplM19STC1BUlk

Step 2:Import SDK

Create an Unity project, name it “HelloAR”.



Then, enter our official website: http://www.easyar.cn/view/download.html, and download “EasyAR2.0 package (for unity)




After extraction, import EasyAR_SDK_2.0.0_Basic.unitypackage into Unity.


This is what it looks like after import.




Step 3:Set up target image

First, prepare an target image, (jpg is recommended). For the sake of convenience, I used an ID card. I named this image “idback”.



Then, we can create a list names “StreamingAssets”. Drag the target image into this list.



During EasyARs developing, drag images directly into unity is the most common way. We can also use json to set up out project, we can create a json file under ‘StreamingAssets’ list, names it ‘targets’. Here’s the basic format.

{
"images" :
[
{
"image" : "idback.jpg",
"name" : "idback",
"size" : [8.56, 5.4],
"uid" : "uid-string, should NOT duplicate",
"meta" : "what ever string you like."
}
]
}

To set up images with json, the two necessary phrases are:


  • image ---- Import into unity with the format: name + postfix

  • name ---- Target image name

ps. If we want to set up multiple images , I imported an image named “argame00”, and we can set up json like below


{
"images" :
[
{
"image" : "argame00.jpg",
"name" : "argame"
},
{
"image" : "idback.jpg",
"name" : "idback",
"size" : [8.56, 5.4],
"uid" : "uid-string, should NOT duplicate",
"meta" : "what ever string you like."
}
]
}

Step 4:Get a key


After recognition, we need to enter the official website http://www.easyar.cn/view/open/app.html to apply key for our AR App


Click “Add application”, fill in your bundle id and Application name.



Like: HelloAR is my application name, mars is my company’s name, and the format is like this.



After created, we can check our Key.



Step 5:Import model resources

We can import prepared model resources into unity.



After imported into Unity, error messages may pop out, but we only need to delete “Standard Assets”.



Now, we prepared our model resources.



Step 6:Developing


Our preparation works are done, now, we can delete “Main Camera”, and drag EasyAR Camera into the panel



Then, fill in the Key we applied in the official website into “EasyAR Startup”.



Drag ImageTarget into the panel also.



Then, we can edit “ImageTargetBehaviour” script in ImageTarget. (This script’s main function to control model’s displaying and hiding. The script’s main content is like below:


You can find this source code in our official website. http://www.easyar.cn/doc_sdk/cn/Getting-Started/Setting-up-EasyAR-Unity-SDK.html


Next, we need to fill in the following information



For setting up Path, we have two ways: one way is to directly fill in target image name and postfix, another way is fill in json, like below:




Warning: we have to change the Storage” format into “Assets”.



关于Storage:



Next, we can create our AR model under the “Imagetarget”. We can drag materials we prepared into it, like below:



We can reset this model’s “Transform”.



Then, zoom its size to 0.1, spin the y-axis 270 degree. The effect is like below:



Finally, delete “Rigidbody”.



Step 7:Testing


Click on Player Settings




Fill in the information. Notes: Company Name has to be the exactly same as your key, (Mine was mars), same as Product Name(Mine was HelloAR)



Our Bundle Indentifier has to change to :


THE MOST IMPORTANT PART: Our Graphics API is using OpenGLES2.


Step 8:suggestions

During developing, you don’t have to set up EasyAR developing environment for the sake of efficiency. You can download EasyAR 2.0 samples and use HelloAR program in it. In that way, you can efficiently build up AR developing environment.