Pregunta

I need to create an app for android and ios that can recognize the peaks of specific mountains in my country (italy. and.. about this sorry for my bad english, hope that you can understand it).
I'll use phonegap and wikitude.
I'll give you a specific run through of what I did (based on their setup guide phonegap plugin ios) to explain myself better.

The guide says:
1- create a PhoneGap project. Now, the folder was created in the right place and without any errors.
2a- Create the World folder in common www. I've manually created it.
2b- "The Example section include several examples how to create an ARchitect World." Here I assume I'm required to manually create my project World folder content and so I did. I've created a structure of empty files and folders following the examples (index.html, js/, css/, assets/* and .js file named after the project). I went on with the examples section of the guide. I've focused in particular on the POI examples since they are purpose of my app. I've cross-checked the parts of code mentioned there with the files I've found on github. Lastly I've copied the relevant files from them examples to my app World folder.
3- Build project for ios. Done with success.
4- Add the plugin with the specific command. This was completed without any error. The files in my World folder have been copied in my ios.
5- Launch the application with Xcode. I've taken a screenshot of the resulting folder (you can find the link in the comment below, I cant' post images XD).

Honestly I'm not even sure this was the right process because the guide is not really clear on that. I'm supposing that the .js files I have obtained from the step 2b here above are where the AR code I need is located, but the index is empty so these files are not linked and I dont' know what javascript would make them so. I'm not even certain that the code in the .js files works anymore since I've taken the files from each example folder and merged them in my project folder.

Now, if I try to launch the simulation as it is I obtain the standard phonegap "device ready" screen as in the index.html file from the www folder.
It is my understanding that the function 1.1 Image on Target is supposed to connect my www index with the World index but if I add it as it is it gives an unresponding link (I was expecting a blank page since my World index is empty). I have searched without success this function in Wikitude ARchitect v3.0 API Documentation and I don't know how to set it myself.

At this point I really need some guidance: I have read figuratively all their forum (I can almost say literally), I've read the guides various times and I've searched their references for the functions explained in the examples without success (in the guide's "javascript interface" section there are descriptions of the AR functions but no actually information on how to build and call them nor where to place them).

Sorry for the wall of text, I really hope you can provide me some assistance on how to proceed.

Thank you vey much.

P.S. I'm working with phonegap 3.3, Xcode 5.0.2, android developer tools v 22.3.0 with Eclipse 4.2.1. Work on a Mac Book pro with OS 10.8.5

¿Fue útil?

Solución 2

With last update the wikitude team have improved the base guide http://www.wikitude.com/developer/documentation/phonegap
This one provides additional help :D I've builded my own ar app based on the sample one and it's seems to work :D

Otros consejos

Here is a simple index.js (PhoneGap app related) which loads a Architect World that is bundled with the application:

var app = {
// Application Constructor
initialize: function() {
    this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
    document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicity call 'app.receivedEvent(...);'
onDeviceReady: function() {
    app.receivedEvent('deviceready');

    app.wikitudePlugin = cordova.require("com.wikitude.phonegap.WikitudePlugin.WikitudePlugin");
    app.wikitudePlugin.isDeviceSupported(app.onDeviceSupportedCallback, app.onDeviceNotSupportedCallback);
},

onDeviceSupportedCallback: function() {

    app.wikitudePlugin._onARchitectWorldLaunchedCallback = app.onArchitectWorldLaunched;
    app.wikitudePlugin._onARchitectWorldFailedLaunchingCallback = app.onArchitectWorldFailedLaunching;


    app.wikitudePlugin.loadARchitectWorld('www/res/ARchitectWorld/SimpleCircle.html');

    app.wikitudePlugin.setOnUrlInvokeCallback(app.onURLInvoked);
},
onDeviceNotSupportedCallback: function() {
    alert('device not supported');
},
onArchitectWorldLaunched: function(url) {
    alert('launched ' + url);
},
onArchitectWorldFailedLaunching: function(error) {
    alert('error ' + error);
},
onURLInvoked: function(url) {

    // TODO: impl. url parsing to know what to do with the given url.

    app.wikitudePlugin.close();
},


// Update DOM on a Received Event
receivedEvent: function(id) {
    var parentElement = document.getElementById(id);
    var listeningElement = parentElement.querySelector('.listening');
    var receivedElement = parentElement.querySelector('.received');

    listeningElement.setAttribute('style', 'display:none;');
    receivedElement.setAttribute('style', 'display:block;');

    console.log('Received Event: ' + id);
}

};

This code basically checks if the current device is capable of running AR World and if so, launches an Architect World that is part of your app bundle. And here is a simple Architect World which is showing a circle at a specific location.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="viewport" content="target-densitydpi=device-dpi, width = 540, user-scalable = 0" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Simple Circle</title>

<!-- Include the ARchitect library -->
<script src="architect://architect.js"></script>


<script>

function createCircle()
{
    AR.logger.activateDebugMode();


    var circle = new AR.Circle(2, {style: {fillColor: '#8F45FF'}});

    var drawableLocation = new AR.RelativeLocation(null, 10, 0);
    var geoObject = new AR.GeoObject(myGeoLocation, {drawables: {cam: circle}});

    AR.logger.info("circle created");
}

function sendCloseARViewRequest()
{
    // hideButton?status=hide could be anything, you just have to know what to do with the url in the PhoneGap world.
    document.location = 'architectsdk://hideButton?status=hide';
}

</script>
</head>

<body>

<button value="Create ARchitectObj" type="button" onclick="createCircle()">Create Circle</button>

<button value="Close" type="button" onclick="sendCloseARViewRequest()">Close</button>


</body>
</html> 

The Wikitude SDK contains a lot of documentation for all parts of the SDK (ObjC/Java reference, JS reference and a general documentation which describes the SDK usage. See Documentation.html and Reference/JavaScript Reference/index.html).

When you create a new PhoneGap project, add the Wikitude Plugin and your custom Architect World and then add the code to your index.js, you should have a running application which has AR capabilities.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top