Saqoosha

  1. About
  2. Archives
  3. Search
  4. Say
Language:

FLARToolKit スタートガイド

Required

- Adobe Flash CS3 or later
- FLARToolKit
- Papervision3D (rev. 817 or later)
- Webcam
- Printed marker & marker data

Download - source of FLARToolKit

http://saqoosha.net/lab/FLARToolKit/FLARToolKit-starter-kit.zip

Let's get started!

If you are familiar using Papervision3D, this FLARToolKit will be easy to control. You can do whatever you want as if you control Papervision 3D.
If you are non-Papervision3D user, don't be afraid! It is much fun and easy to control.
One thing you should take care of is that a coordinate system is different from Papervision3D's.
The global coordinate system of Papervision3D is left-handed, but the object on the marker of FLARToolKit will become following image.

marker-axis

Sample source code

You ONLY need to understand how SimpleCube.as works. Other sources are ....well, you can forget about them.

line 24:

init('Data/camera_para.dat', 'Data/flarlogo.pat');

Initialize FLARToolKit.
The 1st argument is a path for camera corrective file. You can leave it as default.
The 2nd argument is a definition file of marker pattern. You need to define the pattern for the marker. e.g. flarlogo.pat is for flarlogo-marker.pdf.

line 27:

private function _onInit(e:Event):void {

Once init call is successfully over, this function is called. You can adjust 3D object here.
If you can not call this function and error message comes out, you should check the availability of pattern-file OR condition of Webcam.

line 30, 31:

var wmat:WireframeMaterial = new WireframeMaterial(0xff0000, 1, 2);
_plane = new Plane(wmat, 80, 80);

These codes discriminate how the marker works fine or not.
They publish the Plane as a dummy, as same size of as marker(color Red, 2px line, 80mm)

line 32:

_plane.rotationX = 180;

As I discribed above, Papervision3D and FLARToolKit have an opposite coordinate system.
This code adjust the coordinate system.

line 33:

_markerNode.addChild(_plane);

Papervision3D normally "addChild" Scene3D, FLARToolKit needs to "addChild" a special node as it controls 3D object following the marker.
The special node is _markerNode.
Once you "addChild" _markerNode, the object follows the marker automatically.

line 44, 45:

var fmat:FlatShadeMaterial = new FlatShadeMaterial(light, 0xff22aa, 0x75104e);
_cube = new Cube(new MaterialsList({all: fmat}), 40, 40, 40);

Now let's play with "Pink Cube" on the marker.
Size: 40mm*40mm*40mm. The half size of the marker.

line 46:

_cube.z = 20;

The Cube is based on the center/core(=zero point).
Here is the tips: Transforming +20 , Z makes the object is right on the top of marker.

Now the time to play FLARToolKit!

Here we go! Let's follow the steps.
1. Open SimpleCube.fla with Flash Authoring
2. Publish it! then you can see the contents with Webcam
Note: If you are not connect with Webcam, you will see the error messages.
If you can not see the contents although you connect with Webcam, you need to set-up Webcam.
[right-click => setting => Camera. you should choose "USB Video Class Video" on Mac OS]
3. Capture the marker, then you will see the object.

see? it is easy!

Thank you for reading this description :)

See, this is easy!! If you can control Papervision3D, why don't you control FLARToolKit too?! Let's have fun, let's move virtual kids!

Powered by Facebook Comments