DOWNLOAD AND PRINT THIS FIRST!
Example requires a webcam.
When we first saw the GE Smart Grid website all we could think was WOW. Great 3D and messaging. Seeing the Augmented Reality section that mixed the FLARToolkit and Papervision really created something unique.
We found a few examples of people playing with it online but no real amounts of source code. Also did not know the HIRO file format was. It turns out you don't need a *.hiro file, you can swap it out with a *.pat file. There is even an online ARToolKit Maker Generator that is quick and easy to use.
Onto the source code:
This is a modified example taken from the provided example source code (The hello world of the FLARToolKit):
-
package net.saqoosha.flartoolkit.example {
-
-
import org.papervision3d.materials.BitmapFileMaterial;
-
import org.papervision3d.objects.DisplayObject3D;
-
import flash.events.Event;
-
import flash.events.MouseEvent;
-
import org.papervision3d.core.proto.DisplayObjectContainer3D;
-
import org.papervision3d.objects.primitives.Sphere;
-
-
import org.papervision3d.lights.PointLight3D;
-
import org.papervision3d.materials.WireframeMaterial;
-
import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
-
import org.papervision3d.materials.utils.MaterialsList;
-
import org.papervision3d.objects.primitives.Cube;
-
import org.papervision3d.objects.primitives.Plane;
-
-
-
[SWF(width=700,height=400,frameRate=30,backgroundColor=0x0)]
-
-
public class SimpleCube extends PV3DARApp {
-
-
private static const PATTERN_FILE:String = "resources/marker16.pat";
-
private static const CAMERA_FILE:String = "resources/camera_para.dat";
-
-
protected var plane:Plane;
-
protected var objectsContainer:DisplayObject3D;
-
protected var cube:Cube;
-
protected var sphere:Sphere
-
protected var wovenCube:Cube;
-
protected var imageMat:BitmapFileMaterial;
-
protected var fmat:FlatShadeMaterial;
-
protected var wmat:WireframeMaterial;
-
-
public function SimpleCube()
-
{
-
addEventListener(Event.INIT, onInit);
-
init(CAMERA_FILE, PATTERN_FILE);
-
}
-
-
private function onInit(e:Event):void
-
{
-
removeEventListener(Event.INIT, onInit);
-
-
//Create light source for shade material
-
var light:PointLight3D = new PointLight3D();
-
light.x = 1000;
-
light.y = 1000;
-
light.z = -1000;
-
-
//Create Materials
-
imageMat = new BitmapFileMaterial("resources/woven-logo.jpg", false);
-
fmat = new FlatShadeMaterial(light, 0xFFFFFF, 0x0);
-
wmat = new WireframeMaterial(0xff0000);
-
wmat.doubleSided = true;
-
-
//Create objects
-
objectsContainer = new DisplayObject3D();
-
plane = new Plane(wmat, 100, 100,1,1);
-
wovenCube = new Cube(new MaterialsList( { all: imageMat } ), 150, 150, 150);
-
cube = new Cube(new MaterialsList( { all: fmat } ), 20, 200, 20);
-
sphere = new Sphere(fmat, 20);
-
-
-
//Position elements
-
sphere.y = 200;
-
wovenCube.z += 100;
-
objectsContainer.z += 100;
-
-
//Add objects to my container
-
objectsContainer.addChild(sphere)
-
objectsContainer.addChild(wovenCube)
-
objectsContainer.addChild(cube)
-
-
//Add to base
-
_baseNode.addChild(plane);
-
_baseNode.addChild(objectsContainer);
-
-
}
-
-
override protected function _onEnterFrame(e:Event = null):void
-
{
-
super._onEnterFrame(e);
-
sphere.rotationY += 10;
-
wovenCube.rotationZ += 10;
-
}
-
-
}
-
-
}
As you can see from this line:
-
private static const PATTERN_FILE:String = "resources/marker16.pat";
We replaced the *.hiro file with a *.pat file.
To get this example to work you will have to DOWNLOAD AND PRINT THIS FIRST!
Download the full source
and / or
View the interactive example.
Learn more about the FLARToolKit
If you or your clients need any help getting started feel free to contact our Interactive Agency.


Your code gives “Incompatible override” error.
Well that is a rather accusatory statement. :-D
Aside from that perhaps you could send the full error so we have a chance to give you a solution to the problem you seem to be having.
hello,
i’m doing something like this, but ii want to put a movieclip on a plane. can you help me?
Thanks for putting this example together. I’m trying to wrap myself around this ART stuff, in Flash… and just need a good starting point for it to begin making sense.
Couple of initial questions:
1. Is the camera_para.dat file something I’ll never need to edit? What created it, and how can I edit it if I need to? I tried changing the extension to .txt, but upon openning it looks like a mess.
2. In line 54 of PV3DARApp.as:
this._camera3d = new FLARCamera3D(this._param);
Is this basically where the main connection between what the FLARToolkit is proecessing passes the information to the PV3D scene? I have played around with PV3D a bit in the past, and was just trying to sort out what I’d have to grab from your example to replace my mouse controlled camera in my old/simple PV3D scenes, to control with a webcam and marker.
Thanks for taking the time to answer my questions.
Best,
Stephen
Please provide the .FLA in http://woveninteractive.com/testing/FLARToolKit.zip also.
@ Ashish. There was not a .FLA for this project. It was compiled via FlashDevelop / Flex SDK. Take a look at this article to learn more. – http://papervision2.com/1-preparing-your-tools/
If I have time I will create a version that you can compile with just Flash CS3 / 4.
Charlie