<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Takepepe.com &#187; Starling</title>
	<atom:link href="https://takepepe.com/tag/starling/feed/" rel="self" type="application/rss+xml" />
	<link>https://takepepe.com</link>
	<description>Designer::develop</description>
	<lastBuildDate>Sun, 16 Jun 2013 15:40:24 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>LeapMotion #001 Starling</title>
		<link>https://takepepe.com/leapmotion-001-starling/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=leapmotion-001-starling</link>
		<comments>https://takepepe.com/leapmotion-001-starling/#comments</comments>
		<pubDate>Mon, 06 May 2013 11:50:42 +0000</pubDate>
		<dc:creator>Takepepe</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[LeapMotion]]></category>
		<category><![CDATA[Starling]]></category>

		<guid isPermaLink="false">http://takepepe.com/?p=426</guid>
		<description><![CDATA[LeapMotion #001 Starling from Takepepe on Vimeo. １ヶ月ぶりの [...]]]></description>
				<content:encoded><![CDATA[<p><iframe src="http://player.vimeo.com/video/65551480" width="720" height="405" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<p><a href="http://vimeo.com/65551480">LeapMotion #001 Starling</a> from <a href="http://vimeo.com/user16458913">Takepepe</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>１ヶ月ぶりの投稿です。GW最終日、皆様いかがお過ごしですか？<br />
今回の投稿は、個人的に今年最も気になるガジェット「LeapMotion」についてです。</p>
<h6><a href="https://www.leapmotion.com/" target="_blank">・Leap Motion</a></h6>
<p><img src="http://takepepe.com/wp-content/uploads/2013/05/leap_logo.png" /></p>
<p>LeapMotionは端末の上1m四方空間内で、1ミリ単位で指やツール（ペン等）を検知するセンサーです。<br />
また、SDKレベルで数種類のジェスチャーを認識します。</p>
<p>つい先日、プレオーダーした人への発送延期がアナウンスされたばかりですが、<br />
自分は3月末にプレオーダー、デベロッパー登録したところ、2週間ほどで手元に届きました。<br />
発送延期の理由としては、完璧な状態として世に送り出したい、というような内容でした。<br />
7月22日が発送予定日とされていますが、実際どうなるかはまだわかりませんね。</p>
<p>まだ日本語のリソースが少ない状態ですので、コード解説にはいる前に<br />
DeveloperPortalの概要を写したものを交えて、簡単に解説したいと思います。</p>
<h2>Frame</h2>
<p>LeapMotionで値を取得するために使用するFrameオブジェクトの中には以下のものが含まれます。</p>
<h6>・Lists of tracking data</h6>
<div class="gray-rect">
Hands — すべての手<br />
Pointables — Pointableオブジェクトとして、すべての指とツール<br />
Fingers — すべての指<br />
Tools — すべてのツール<br />
Gestures — 開始、更新、終了のハンドラーを含むすべてのジェスチャー</div>
<h6>・Frame motion</h6>
<div class="gray-rect">
Rotation Axis — 回転軸を表現する方向ベクトル。<br />
Rotation Angle — 回転軸(右手の法則を使用して)のまわりで右回りの回転角。<br />
Rotation Matrix — 回転を表現するtransformマトリックス。<br />
Scale Factor — 拡大縮小を表現するファクター。<br />
Translation — 直線運動を表現するベクトル。
</div>
<h2>Hand model</h2>
<p>手について様々な情報を提供します。2本の手を認識しますが、右手左手の識別はしていません。</p>
<h6>・Hand attributes</h6>
<div class="gray-rect">
Palm Position — Leapの起点から計測した手のひら中心座標<br />
Palm Velocity — 秒速ミリメートル単位の、手のひらの移動速度<br />
Palm Normal —  手のひらの中心から、下方へ指す垂直方向のベクトル<br />
Direction — 手のひらの中心から、指へ向かうベクトル。<br />
Sphere Center — 手の屈曲に適当な球体の中心。(手でボールを持っているような感じ)<br />
Sphere Radius — 手の屈曲に適当な球体の半径。半径は手の形とともに変化します。
</div>
<h6>・Hand motion</h6>
<div class="gray-rect">
Rotation Axis — 回転軸を表現する方向ベクトル。<br />
Rotation Angle — 回転軸(右手の法則を使用して)のまわりで右回りの回転角。<br />
Rotation Matrix —回転を表現するtransformマトリックス。<br />
Scale Factor — 拡大縮小を表現するファクター。<br />
Translation — 直線運動を表現するベクトル。
</div>
<h6>・Finger and Tool lists</h6>
<p>検知した手に属する、指やツールの情報を取得できます。</p>
<div class="gray-rect">
Pointables — Pointableオブジェクトとして、すべての指とツール<br />
Fingers — すべての指<br />
Tools — すべてのツール
</div>
<h2>Finger and Tool models</h2>
<p>Leapはその視界内の指およびツールの両方を検知するおよび追跡します。</p>
<div class="gray-rect">
Length — オブジェクト(手から先端に及ぶ)の可視部の長さ。<br />
Width — オブジェクトの可視部の平均幅。<br />
Direction — オブジェクト(つまり基礎から先端まで)と同じ方角に指すユニット方向ベクトル。<br />
Tip Position — Leapの起点から計測した指先の座標<br />
Tip Velocity — 秒速ミリメートル単位の、指先の移動速度
</div>
<h2>Gestures</h2>
<p>Leapは特定の移動パターンをGesturesとして認識します。</p>
<div class="gray-rect">
Circle — 円をトレースする単一の指。<br />
Swipe — 手の直線運動。<br />
Key Tap — キーボード・キーを軽く打つかのような指の動作。<br />
Screen Tap — コンピューター・スクリーンを軽く打つかのような指の動作。
</div>
<h6>開発環境について</h6>
<p>現在サポートされている言語は、C++、C#、Objective-C、Java、Python、JavaScriptになります。<br />
DevelperPortalでは前述の概要の他に、各フレームワークに対応したライブラリの配布、<br />
ガイドライン、コミュニティ、アプリストア概要などが掲載されています。<br />
Leapに興味があるかたは是非覗いてみてください。</p>
<h6><a href="https://developer.leapmotion.com/documentation/guide/Leap_Overview">・Leap Motion Developer Portal</a></h6>
<h2>LeapMotion × Adobe AIR Starling</h2>
<p>
今回作成したデモについての解説です。<br />
AdobeAIRでStarlingのParticleSystemを使用して作成しています。
</p>
<h6><a href="http://gamua.com/starling/" target="_blank">・Starling Framework</a><br />
<a href="https://github.com/PrimaryFeather/Starling-Extension-Particle-System" target="_blank">・Starling-Extension-Particle-System</a></h6>
<p>
StarlingはStage3Dを使用しているのでapp.xmlに以下の設定を忘れずにしましょう。
</p>
<div class="gray-rect">
&lt;renderMode&gt;direct&lt;/renderMode&gt;<br />
&lt;depthAndStencil&gt;false&lt;/depthAndStencil&gt;
</div>
<p>
LeapをActionScriptで使用するために、以下のライブラリと付属のC++SDKをラップしているANEを使用します。<br />
導入方法については、下記ページの下部に書いてあるので、それぞれ開発環境にあったものを選んでください。<br />
自分はFlashBuilder4.7でした。
</p>
<h6><a href="https://github.com/logotype/LeapMotionAS3" target="_blank">・LeapMotionAS3</a></h6>
<p>
Starlingを使用したパーティクルのデモは<a href="http://clockmaker.jp/blog/" target="_blank">Clockmakerさん</a>や<a href="http://www.project-nya.jp/" target="_blank">にゃあプロジェクトさん</a>が充実していますので、<br />
そちらを参考にさせていただきました。
</p>
<h3>FL001.as</h3>
<pre class="brush: as3; title: ; notranslate">
package {
	
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageDisplayState;
	import flash.display.StageScaleMode;
	import flash.events.KeyboardEvent;
	import starling.core.Starling;
	
	[SWF(backgroundColor=&quot;#00164a&quot;, width=&quot;1440&quot;, height=&quot;900&quot;, frameRate=&quot;60&quot;)]
	
	public class FL001 extends Sprite {
		
		private var starling:Starling;
		
		public function FL001() {
			
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyDown);
			
			starling = new Starling(MainView, stage);
			starling.start();
			
		}
		
		private function onKeyDown(e:KeyboardEvent):void {
			
			if(stage.displayState == StageDisplayState.NORMAL){
				stage.displayState = StageDisplayState.FULL_SCREEN;
			} else {
				stage.displayState = StageDisplayState.NORMAL
			}
			
		}
		
		
	}
}

</pre>
<h3>MainView.as</h3>
<pre class="brush: as3; title: ; notranslate">
package {
	
	import flash.geom.Rectangle;
	import starling.core.Starling;
	import starling.display.Sprite;
	import starling.events.Event;
	import starling.events.ResizeEvent;
	import starling.extensions.ParticleDesignerPS;
	import starling.textures.Texture;
	import com.leapmotion.leap.LeapMotion;
	import com.leapmotion.leap.Pointable;
	import com.leapmotion.leap.events.LeapEvent;
	
	internal class MainView extends Sprite { 
		
		// 事前に「online particle editor」で.pexファイルとtexture.pngを用意しておきます
		// http://onebyonedesign.com/flash/particleeditor/
		
		[Embed(source = &quot;assets/particle.pex&quot;, mimeType = &quot;application/octet-stream&quot;)]
		private static var ParticleData:Class;
		
		[Embed(source = &quot;assets/texture.png&quot;)]
		private static var ParticleImage:Class;
		
		private var particles:Vector.&lt;ParticleDesignerPS&gt;;		
		private var count:int = 10;
		private var leap:LeapMotion;
		
		public function MainView() {
			addEventListener(Event.ADDED_TO_STAGE, onAddStage);
		}
		
		private function onAddStage(e:Event):void {
			
			setParticles();
			leap = new LeapMotion();
			leap.controller.addEventListener( LeapEvent.LEAPMOTION_FRAME, onLeapFrame );
			stage.addEventListener(ResizeEvent.RESIZE, onResizeStage);
			
		}
		
		private function setParticles():void{
			
			particles = new Vector.&lt;ParticleDesignerPS&gt;(10);
			for(var i:int = 0; i&lt;count ; i++){
				particles[i] = new ParticleDesignerPS( XML(new ParticleData()), Texture.fromBitmap(new ParticleImage()));
				particles[i].startSize = 100;
				particles[i].endSize = 100;
				particles[i].speed = 0;
				particles[i].start();
				Starling.juggler.add(particles[i]);
				addChild(particles[i]);
			}
			
		}
		
		private function onResizeStage(e:ResizeEvent):void {
			
			Starling.current.viewPort = new Rectangle(0, 0, e.width, e.height);
			stage.stageWidth = e.width;
			stage.stageHeight = e.height;
			
		}
		
		private function onLeapFrame(e:LeapEvent):void {
			
			var max:int = e.frame.pointables.length;
			for(var i:int = 0; i&lt;count ; i++){
				if( i &lt; max ){
					var pointable:Pointable = e.frame.pointables[i];
					particles[i].emitterX = (pointable.tipPosition.x)*3+stage.stageWidth/2;
					particles[i].emitterY = (pointable.tipPosition.y)*-3+stage.stageHeight;
					particles[i].gravityX = pointable.tipVelocity.x*-5;
					particles[i].gravityY = pointable.tipVelocity.y*5;
					particles[i].maxNumParticles = 50;
				}else{
					particles[i].maxNumParticles = 1;
				}
			}
			
		}
		
	}
}

</pre>
<p>１ヶ月いじった上で得た感想（というかぶちあたっている壁）です。</p>
<ol>
<li>指がLeapに向かって垂直に重なると検知できない。</li>
<li>細かなUI操作に向いていない</li>
<li>ジェスチャーはそのままでは利用しづらい</li>
</ol>
<p>
あくまで、現状公開されているSDKとライブラリを使用した上での感想です。<br />
概要を読む限りではワクワクするばかりですが、ちゃんとアプリケーションに落とし込むためには<br />
上記の問題をカバーしたフレームワークが必要だなと思いました。
</p>
<p>
今回の投稿はさらっと紹介しただけになってしまったので、<br />
次回はちょっとしたフレームワークと何か面白いネタで投稿できればいいなー。</p>
]]></content:encoded>
			<wfw:commentRss>https://takepepe.com/leapmotion-001-starling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

 Served from: takepepe.com @ 2026-04-12 17:16:08 by W3 Total Cache -->