What should you have done by now?
- You should have followed the "Hello World" - Tutorial
- You should have followed the "Location-Based 3D Objects" - Tutorial or "Animate your T-Rex" - Tutorial
- You should have followed the "Stick it on the screen" - Tutorial
- You should have followed the "Server Events in junaio" - Tutorial
What will you learn?
Scan the QR Code on the right with junaio to see what you are getting.
- Using the hit functionality in junaio
- PHP Helper Library
- Download "The AR Shooter" - Tutorial zip
- When you search the web for AR, you will find quite a few examples talking about "AR Shooters". So you have a weapon and a target and you want to shoot at something. Of course, this is also possible with junaio and the developer API. This tutorial will show you how to.
- This Tutorial is based on the "Server Events in junaio" - Tutorial, if you have not done this one yet, please do this first.
- Start by changing some information to your Apple in the search.php as well as in the event.php.
The animation should no longer be shown upon the click of the Apple, but when it was hit. Also the interactionfeedback is changed to "hit". The apple POI will have to changed like this:
$poi = $jPoiBuilder->create3DLocationBasedPOI( "Apple", //name "$lat,$lng,$alt", //position WWW_ROOT . "/resources/apple_fast.md2_enc", //model WWW_ROOT . "/resources/apple2.png", //texture 50, //scale "", //description "", //thumbnail "apple1", //id "1.57,0,0", //orientation array("idle" => array("idle", 0), "hit" => array("shot", 50)), //animation specification "hit" //interactionfeedback );
- You will also need a crosshair, so the user can aim and a sling shot. The hit will always go through the center of the screen, so this is where your crosshairs should also be placed. Please create the following two GUI POIs.
Note that the sling has a "fire" customization, defining it as the weapon. So only then the sling is clicked, junaio will see whether any other POI was hit and send the information to your server.
//the sling $poi = new SinglePOI(); $poi = $jPoiBuilder->createGUIPOI( "sling", "0.5,0.05", WWW_ROOT."/resources/sling.md2_enc", WWW_ROOT."/resources/sling.png", "0.2", NULL, NULL, "sling", "1.425,1.35,1.45", $behaviourArray = array("idle" => array("idle", 0), "click" => array("shot", 80)), "click" ); //need to add a customization to determine it as the gun $customization = new Customization(); $customization->setName("fireCustomization"); $customization->setValue(""); $customization->setType("fire"); $customization->setNodeID("fire"); $poi->addCustomization($customization); //echo the POI $jPoiBuilder->outputPOI($poi); //create another POI for the cross hairs $poi = new SinglePOI(); $poi = $jPoiBuilder->createGUIPOI( "A Cross-Hairs", "0.5,0.5", WWW_ROOT . "/resources/crosshairs.md2_enc", WWW_ROOT . "/resources/crosshairs.png", .03, NULL, NULL, "cross", "0,1.507,3.14", array(), "click" ); //echo the POI $jPoiBuilder->outputPOI($poi);
- In your event.php, only listen for events from the type "hit". Ignore all others.
$eventType = $_POST['type']; //was a Apple clicked if(strpos($idHit, "apple") !== FALSE && $eventType == "hit") ...
- Lastly, if your users have hit the Apple 5 times, you need to remove the crosshairs and the sling as well.
- Please have a look at the download package for the entire example and have fun shooting at apples.
- Hello World!
- Trouble Shooting Hello World
- Images, videos and sounds
- Location-based 3D
- Animate T-Rex
- metaio Man vs. T-Rex
- Indoor location-based POIs
- Server events in junaio
- 360 degree views
- Images in front of you
- AR Shooter
- Hello GLUE!
- Trouble Shooting Hello GLUE
- 3D world interaction
- Movie textures in junaio
- More than 1 image
- Sometimes recognizing is enough
- junaio GLUE and events
Scan this marker with
junaio to see what you are
getting in this tutorial.