ARMonkeyKit

Easy Content Loading added to ARMonkeyKit

Posted by: ajclarkson on: April 23, 2010

Thanks to one of the features in JME, the obj to jme convertor, it is easy to provide a simple way for the application developer to load in custom models and content to associate to a marker.

If you want to make use of this in your ARMonkeyKit applications, take a look at the new example in the latest revision ARMaggie. This places a model of Maggie Simpson onto a marker. You can probably see how this works from the code but here is a brief explanation:

Making use of the Object Loader static class all you need to do is call the loadObjectFromFile method, providing a name to identify the model, and the location of the .obj file.

It is important that if you have a material file for the model, this is in the same directory as the .obj file.

This will then return a Node, which you can treat the same as any other content from the previous examples.

ARMonkeyKit OpenGL error resolved

Posted by: ajclarkson on: April 1, 2010

The latest version of ARMonkeyKit which is in the repository contains the fix for the OpenGL error which was created by adding bounding boxes to models. The issue was as a result of the synchronization object (SyncObject) which has now been replaced with a more elegant solution.

ARMonkeyKit OpenGL error found

Posted by: ajclarkson on: March 4, 2010

This is a quick post regarding a bug which exists in the framework. As mentioned in a previous post, the next step with this is to add a content manager to allow model and texture loading simply on behalf of the developer. However, in doing so a bug has been discovered with the OpenGL sub system that runs the camera feed.

The error can be invoked by adding jME bounding boxes to objects, which is very strange as this should have no direct affect on the camera feed.

The error which you get is:

OpenGL Invalid Value (1281)

Googling suggests that this is related to a texture size issue, however it seems strange that by adding a bounding box (which has nothing to do with the camera texture) suddenly this error occurs.

It is been worked on at present, and I’ll update this blog when it is sorted, in the meantime if any jME gurus have an idea why this may be happening feel free to leave a comment!

Cheers

Building an ARMonkeyKit application

Posted by: ajclarkson on: March 3, 2010

It’s as easy as 123..4

First things first, we are going to use the ARTeapotTorus as example code here, it’s in the framework sourcecode (armonkeykit.core.examples.patternmarkers)

1. The basics of the application, defining the class and the main method:

public class ARTeapotTorus extends ARMonkeyKitApp {

You can see here that we are extending ARMonkeyKitApp, this is the entry point to the framework, all applications which are using the framework must make use of this abstract class. It enforces the basic methods which allow you to build functionality. After including a super() call in the constructor it’s on to the main method so we can run this code:

public static void main (String[] args) {
ARTeapotTorus app = new ARTeapotTorus();
app.setConfigShowMode(ConfigShowMode.AlwaysShow);
app.start();
}
The two lines following the application creation come straight from the jMonkeyEngine which handles our 3D content, setConfigShowMode simply tells the application whether or not to show configuration dialogue (for screen resolution) at startup or not, and then app.start() runs the application.
2. The simpleInitARSystem method
The framework has support for two different types of fiducial marker at present. The type which we will use in our example applications is a Pattern Marker. This is a pattern which is known to the computer using ARToolkit’s pattern generator, the example ones which are included are pattHiro and pattKanji (in the ardata folder). It also supports the NyIDmarker model 2 system, which will be covered at a later date as this area of the framework is still in development.
With this in mind we initialise the marker processor which will be used:
markerProcessor = initPatternProcessor();
Now the system knows that we are dealing with the pattern based markers. In order to tell the system what to do when it detects a marker, we need to specify an event listener. The default listener which is included with the framework at the time of writing is a NodeTranslateListener. The function of this is to calculate the transformation of the marker, and apply it to any 3D content which is associated with it. This is the basic functionality of many AR applications.
rtl = new NodeRotateTranslateListener();
markerProcessor.registerEventListener(rtl);
Now the system knows what type of markers we want to use and what we want to use them for. The AR system is now initialised. Easy right?
3. addMarkers method
The other method which we will use from the ARMonkeyKitApp class is addMarkers. Here we specify what markers the system should look for, and set up relationships between those markers and 3D content. The framework does most of the heavy lifting here, so it is a few API calls on the developers behalf:
PatternMarker kanji = markerProcessor.createMarkerObject(“kanji”, 16,                               “ardata/patt.kanji”);
markerProcessor.registerMarker(kanji);
Here we have created a marker object and registered it with the system. The three parameters which are used are as follows:
  • String uniqueID – a unique identifier for the marker object
  • int Segments – the resolution of the pattern file. This is determined at pattern creation, for the example patterns it should always be 16 (the highest possible is 64)
  • String path – this is the filepath to the pattern file (not the pdf) where the system finds a representation of the pattern file. Again this is taken care of by the pattern generator, you just need to give the path.
Now that we have that taken care of, let’s create some content. jME makes this quite easy, let’s register a teapot to our marker. First we create a node for the teapot. This is very important. The node is what the eventlistener acts upon.
Node teapotAffectedNode = new Node(“Affected Teapot Node”);
Now we create a teapot:
Teapot tp = new Teapot(“ShinyTeapot”);
tp.setLocalScale(10f);
// rotate our teapot so its base sits on the marker
Quaternion q = new Quaternion();
q = q.fromAngleAxis(-FastMath.PI/2,new Vector3f(1f,0f,0f));
tp.setLocalRotation(q);
We then attach the teapot to our affected node, and then that to the root node of the scene:
teapotAffectedNode.attachChild(tp);
rootNode.attachChild(teapotAffectedNode);
Then we must make two final api calls, the second is vital.
rtl.associate(kanji, teapotAffectedNode);
markerProcessor.finaliseMarkers();
The first uses the EventListener to make an association between marker and content. The second call tells the system that we have added new markers. If this is not called then you will get an exception as the list of markers will not have been finalised and therefore cannot be used by the system.
That really is all there is to building a simple application which associates a 3D model to a marker and then allows you to manipulate the model by rotating the marker. The ARMonkeyKit framework is very powerful in removing code from the developer and just allowing them to concentrate on the content of the application.
Oh yeah… number 4
You may notice that the ARMonkeyKitApp mandates that you have a callUpdates() method in your code. For applications such as this, that method can stay empty as it adds complex functionality which isn’t required here.
Hopefully that helps with understanding the example code a bit more. The next development of the framework is to add a content manager which will allow easy loading of .obj 3D model files. Watch this space as always.

Getting up and running on ARMonkeyKit on Windows 7

Posted by: ajclarkson on: March 3, 2010

We are currently developing the framework in Windows 7 with JDK 1.6 and the eclipse IDE.

If you want to use ARMonkeyKit, download the source code via our Google Code project at: http://code.google.com/p/armonkeykit

Once you have imported it into your IDE you may need to make a couple of changes to your IDE. In eclipse the default workspace setting for “forbidden access restrictions” is to provide the user with an error. These access restrictions don’t actually prevent anything from working, and come from the ARToolkit code. In order to resolve this edit your project settings to ignore this type of warning. (In eclipse it can be found at Window>Preferences>Java>Compiler > Errors and Warnings then Deprecated and restricted API)

This should remove all access restriction errors from your project.

You will need the latest version of JMF installed to your machine (this is a requirement of the underlying toolkits)

ARMonkeyKit makes use of QuickTime libraries in order to work with your webcam. Therefore you must have QuickTime installed, the latest version is recommended for this. In order to allow JAVA to interface with quicktime another piece of software is required called WinVDIG. This software can be found at the following mirror. NB: Please use version 1.0.1 rather than the latest ones. Apple appear to have changed some code in the QuickTime libraries which has affected the performance of WinVDIG.

Upon completing the installation of WinVDIG you will be asked if you want to test the installation using QTCap.exe. Allow this and ensure that no error messages are shown, you should be good to go if so! (If you have errors, post a comment here and I will try my best to provide the solution)

Finally you may have to locate the QTJava.zip library which is on the build path of the project. As default the framework will search for this within your JRE folder. If it is not present here, it will likely be in the default install location: C:/Program Files/QuickTime/QTSystem/QTJava.zip

You should now have an errorless project with a properly configured build path. In order to confirm that everything is working, there are examples provided in the framework. Within the ardata folder you will find pattHiro.pdf and pattKanji.pdf files. Print both of these markers as they are used by the examples.

Once you have your markers, navigate to the armonkeykit.core.examples.patternmarkers package and run the ARTeapotTorus example. If all goes well you will see your webcam feed, and then holding the markers infront of the camera will display the models which are related to them. The next post will cover the basics of building a simple application such as the TeapotTorus one.

What is ARMonkeyKit?

Posted by: ajclarkson on: March 3, 2010

ARMonkeyKit is an open source framework which aims to enable rapid prototyping of Augmented Reality applications in the JAVA programming language.

Currently, the ARToolKit provides an easy way to build Augmented Reality applications in a number of languages, but unfortunately not JAVA. The toolkit takes care of many of the underlying challenges of Augmented Reality applications, such as marker detection algorithms and the application of basic 3D transformations. This makes it an ideal base for a number of applications.

Japanese developer Nyatla took on the challenge of porting the popular toolkit to JAVA, as well as a number of other platforms including android. From this NyARToolKit was launched, providing developers with the ease of use from ARToolkit, but in the JAVA language with options to interface with the JMF, Java3D and jOGL graphics libraries. Finally Augmented Reality with JAVA was here.

So where does ARMonkeyKit fit in?

As part of my Masters by Research Thesis at Durham University I am building AR applications, it is desirable for them to be in JAVA in order to allow future integrations with a number of other projects currently underway in our research group (Technology Enhanced Learning). While NyARToolkit provides a great way of building such applications, it is a port of ARToolkit and therefore some of its limitations carry across. ARMonkeyKit is an extension of this toolkit into a fully developed framework with a simple API to allow rapid prototyping of applications. The other major acheivement of ARMonkeyKit is the ability to interface with the jMonkeyEngine graphics and game libraries. This makes it even easier to create 3D content to use within AR environments. Working with Dr. Andrew Hatch we have released the framework as an open source project on Google Code

This blog will be updated with the latest developments from the framework and examples of how to get the most out of it, it will also act as a forum for feedback and questions by you, the end user and hopefully we will build an active community through the comments system.

An early tech demo of the system can be found on youtube, demonstrating the basic functionality running at high fps. Watch this space for more.

Follow

Get every new post delivered to your Inbox.