<?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>Jinten Blog &#187; ASライブラリ</title>
	<atom:link href="http://www.jinten.net/blog/category/aslibrary/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jinten.net/blog</link>
	<description>Flex ActionScript 関連覚書などなど</description>
	<lastBuildDate>Tue, 17 Aug 2010 05:45:00 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>[as3][FOAM]初めてのFOAM(2) 多角形の表示</title>
		<link>http://www.jinten.net/blog/archives/43</link>
		<comments>http://www.jinten.net/blog/archives/43#comments</comments>
		<pubDate>Tue, 12 Feb 2008 01:47:50 +0000</pubDate>
		<dc:creator>ken</dc:creator>
				<category><![CDATA[ActionScript3.0]]></category>
		<category><![CDATA[ASライブラリ]]></category>

		<guid isPermaLink="false">http://www.jinten.net/blog/archives/43</guid>
		<description><![CDATA[前回記事 初めてのFOAMの続きです。 今回は多角形の表示をします。 FOAMの基本的な使い方は前回の記事を参考にしてください。 var rigid:RigidBody = new RigidBody&#40;&#91; [...]]]></description>
			<content:encoded><![CDATA[<p>前回記事 <a href="http://www.jinten.net/blog/archives/41">初めてのFOAM</a>の続きです。</p>
<p>今回は多角形の表示をします。<br />
FOAMの基本的な使い方は前回の記事を参考にしてください。</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> rigid<span style="color: #000066; font-weight: bold;">:</span>RigidBody = <span style="color: #0033ff; font-weight: bold;">new</span> RigidBody<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>X位置<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#91;</span>Y位置<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#91;</span>サイズ<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#91;</span>頂点の座標配列<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
foam<span style="color: #000066; font-weight: bold;">.</span>addElement<span style="color: #000000;">&#40;</span>rigid<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>これが多角形を表示するコードです。<br />
メソッドの引数はほかにもあるのでいろいろ調節はできるようですが、<br />
まだ調査不足のためそのあたりはいずれ･･･。</p>
<p>今回のサンプルでのコードとしてはこのように書いています。</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">// 座標をランダムに決定。0-300で。(今回はswfのサイズが300×300なので)</span>
<span style="color: #6699cc; font-weight: bold;">var</span> rnd_x<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">300</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> rnd_y<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">300</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">// 多角形のサイズをランダムに決定。20-60。この数値は適当。</span>
<span style="color: #6699cc; font-weight: bold;">var</span> rnd_size<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">20</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">40</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">// 頂点数をランダムに決定。2-9。頂点数2なら直線、3なら三角形に。</span>
<span style="color: #6699cc; font-weight: bold;">var</span> rnd_num_vertices<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ceil</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">// createSymmetricPolygonメソッドで頂点座標の配列を返す。</span>
<span style="color: #6699cc; font-weight: bold;">var</span> rigid_arr<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = ShapeUtil<span style="color: #000066; font-weight: bold;">.</span>createSymmetricPolygon<span style="color: #000000;">&#40;</span>rnd_num_vertices<span style="color: #000066; font-weight: bold;">,</span> rnd_size<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">// RigidBodyインスタンスを生成し、foamエンジンへ追加。</span>
<span style="color: #6699cc; font-weight: bold;">var</span> rigid<span style="color: #000066; font-weight: bold;">:</span>RigidBody = <span style="color: #0033ff; font-weight: bold;">new</span> RigidBody<span style="color: #000000;">&#40;</span>rnd_x<span style="color: #000066; font-weight: bold;">,</span> rnd_y<span style="color: #000066; font-weight: bold;">,</span> rnd_size<span style="color: #000066; font-weight: bold;">,</span> rigid_arr<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
foam<span style="color: #000066; font-weight: bold;">.</span>addElement<span style="color: #000000;">&#40;</span>rigid<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>簡単ですね。<br />
ただ、ちょっと重いかな･･･。まだバージョン0.1.01だもんなぁ･･･。</p>
<p><a href="http://www.jinten.net/blog/?page_id=44">デモはこちら</a>。<br />
<img src='http://www.jinten.net/blog/wp-content/uploads/2008/02/foam_sample2.png' alt='screenshot' /></p>
<p>ソースコード全体は以下。<br />
<span id="more-43"></span></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span>  <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.*;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>generalrelativity<span style="color: #000066; font-weight: bold;">.</span>foam<span style="color: #000066; font-weight: bold;">.</span>dynamics<span style="color: #000066; font-weight: bold;">.</span>element<span style="color: #000066; font-weight: bold;">.</span>body<span style="color: #000066; font-weight: bold;">.*;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>generalrelativity<span style="color: #000066; font-weight: bold;">.</span>foam<span style="color: #000066; font-weight: bold;">.</span>dynamics<span style="color: #000066; font-weight: bold;">.</span>enum<span style="color: #000066; font-weight: bold;">.</span>Simplification<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>generalrelativity<span style="color: #000066; font-weight: bold;">.</span>foam<span style="color: #000066; font-weight: bold;">.</span>dynamics<span style="color: #000066; font-weight: bold;">.</span>force<span style="color: #000066; font-weight: bold;">.</span>Gravity<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>generalrelativity<span style="color: #000066; font-weight: bold;">.</span>foam<span style="color: #000066; font-weight: bold;">.</span>Foam<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>generalrelativity<span style="color: #000066; font-weight: bold;">.</span>foam<span style="color: #000066; font-weight: bold;">.</span>math<span style="color: #000066; font-weight: bold;">.</span>Vector<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>generalrelativity<span style="color: #000066; font-weight: bold;">.</span>foam<span style="color: #000066; font-weight: bold;">.</span>util<span style="color: #000066; font-weight: bold;">.</span>ShapeUtil<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span><span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;300&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;300&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> FoamSample1 <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> const W<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">300</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> const H<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">300</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> foam<span style="color: #000066; font-weight: bold;">:</span>Foam<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> FoamSample1<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">scaleMode</span> = <span style="color: #004993;">StageScaleMode</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NO_SCALE</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">align</span> = <span style="color: #004993;">StageAlign</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">BOTTOM</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//FOAMインスタンスの生成</span>
			foam = <span style="color: #0033ff; font-weight: bold;">new</span> Foam<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>foam<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//オブジェクトのドラッグ有効化</span>
			foam<span style="color: #000066; font-weight: bold;">.</span>useMouseDragger<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			foam<span style="color: #000066; font-weight: bold;">.</span>addGlobalForceGenerator<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> Gravity<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> Vector<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.3</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> wall_arr<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #009900; font-style: italic;">//ground</span>
			wall_arr = ShapeUtil<span style="color: #000066; font-weight: bold;">.</span>createRectangle<span style="color: #000000;">&#40;</span>W<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			foam<span style="color: #000066; font-weight: bold;">.</span>addElement<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> RigidBody<span style="color: #000000;">&#40;</span>W<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> Simplification<span style="color: #000066; font-weight: bold;">.</span>INFINITE_MASS<span style="color: #000066; font-weight: bold;">,</span> wall_arr<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			foam<span style="color: #000066; font-weight: bold;">.</span>addElement<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> RigidBody<span style="color: #000000;">&#40;</span>W<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> H<span style="color: #000066; font-weight: bold;">,</span> Simplification<span style="color: #000066; font-weight: bold;">.</span>INFINITE_MASS<span style="color: #000066; font-weight: bold;">,</span> wall_arr<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #009900; font-style: italic;">//wall</span>
			wall_arr = ShapeUtil<span style="color: #000066; font-weight: bold;">.</span>createRectangle<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">,</span> H<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			foam<span style="color: #000066; font-weight: bold;">.</span>addElement<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> RigidBody<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> H<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> Simplification<span style="color: #000066; font-weight: bold;">.</span>INFINITE_MASS<span style="color: #000066; font-weight: bold;">,</span> wall_arr<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			foam<span style="color: #000066; font-weight: bold;">.</span>addElement<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> RigidBody<span style="color: #000000;">&#40;</span>W<span style="color: #000066; font-weight: bold;">,</span> H<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> Simplification<span style="color: #000066; font-weight: bold;">.</span>INFINITE_MASS<span style="color: #000066; font-weight: bold;">,</span> wall_arr<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> clickHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			foam<span style="color: #000066; font-weight: bold;">.</span>addElement<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> Circle<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">150</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			foam<span style="color: #000066; font-weight: bold;">.</span>simulate<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> clickHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900; font-style: italic;">// add Rigid</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> rnd_x<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">300</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> rnd_y<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">300</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> rnd_size<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">20</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">40</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> rnd_num_vertices<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ceil</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> rigid_arr<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = ShapeUtil<span style="color: #000066; font-weight: bold;">.</span>createSymmetricPolygon<span style="color: #000000;">&#40;</span>rnd_num_vertices<span style="color: #000066; font-weight: bold;">,</span> rnd_size<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> rigid<span style="color: #000066; font-weight: bold;">:</span>RigidBody = <span style="color: #0033ff; font-weight: bold;">new</span> RigidBody<span style="color: #000000;">&#40;</span>rnd_x<span style="color: #000066; font-weight: bold;">,</span> rnd_y<span style="color: #000066; font-weight: bold;">,</span> rnd_size<span style="color: #000066; font-weight: bold;">,</span> rigid_arr<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			foam<span style="color: #000066; font-weight: bold;">.</span>addElement<span style="color: #000000;">&#40;</span>rigid<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.jinten.net/blog/archives/43/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[as3][FOAM]初めてのFOAM</title>
		<link>http://www.jinten.net/blog/archives/41</link>
		<comments>http://www.jinten.net/blog/archives/41#comments</comments>
		<pubDate>Sun, 03 Feb 2008 19:07:21 +0000</pubDate>
		<dc:creator>ken</dc:creator>
				<category><![CDATA[ActionScript3.0]]></category>
		<category><![CDATA[ASライブラリ]]></category>

		<guid isPermaLink="false">http://www.jinten.net/blog/archives/41</guid>
		<description><![CDATA[最近はBox2DFlashAS3と言うのがはやっているようですね。今更いろいろやろうにも出遅れた感が否めないので、ここはあえて違う物理エンジンをいじってみようと思います。 今回触ってみたのは、FOAMという物理エンジンで [...]]]></description>
			<content:encoded><![CDATA[<p>最近は<a href="http://box2dflash.sourceforge.net/">Box2DFlashAS3</a>と言うのがはやっているようですね。今更いろいろやろうにも出遅れた感が否めないので、ここはあえて違う物理エンジンをいじってみようと思います。</p>
<p>今回触ってみたのは、<a href="http://blog.generalrelativity.org/?p=17">FOAM</a>という物理エンジンです。<br />
バージョンは0.1.01。まだまだ開発版ということですかね。</p>
<p>ではでは、初めてなので、まずは使い方から。</p>
<p>必要なものは、Foamクラスのインスタンスです。</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> foam<span style="color: #000066; font-weight: bold;">:</span>Foam = <span style="color: #0033ff; font-weight: bold;">new</span> Foam<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>foam<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>しかも、FoamクラスはSpriteクラスを継承しているため、描画もしてくれます。<br />
なので、addChildしておきます。</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">foam<span style="color: #000066; font-weight: bold;">.</span>addGlobalForceGenerator<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> Gravity<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> Vector<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.3</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>Gravityクラスが重力になるようです。(まだ調査しきれてません･･･)<br />
これを、先ほどのfoamインスタンスのメソッド、addGlobalForceGeneratorに渡します。<br />
これで、重力発生です。</p>
<p>続いて、オブジェクトを配置します。<br />
FormインスタンスのメソッドaddElementに、ISimulatableインターフェースなインスタンスを渡してやります。<br />
円形や多角形、ベジェ曲線などがISimulatableインターフェースをimplementsしたクラスとして提供されています。<br />
今回は円形と四角を使ったサンプルを作ってみました。</p>
<p>デモは<a href='http://www.jinten.net/samples/foam_sample1.html' title='screenshot'>こちら。<img src='http://www.jinten.net/blog/wp-content/uploads/2008/02/foam_sample1.png' alt='screenshot' /></a></p>
<p>ソースは以下。</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #3f5fbf;">/**
* FOAM sample1
* @author jinten.net
*/</span>
<span style="color: #9900cc; font-weight: bold;">package</span>  <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.*;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>generalrelativity<span style="color: #000066; font-weight: bold;">.</span>foam<span style="color: #000066; font-weight: bold;">.</span>dynamics<span style="color: #000066; font-weight: bold;">.</span>element<span style="color: #000066; font-weight: bold;">.</span>body<span style="color: #000066; font-weight: bold;">.*;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>generalrelativity<span style="color: #000066; font-weight: bold;">.</span>foam<span style="color: #000066; font-weight: bold;">.</span>dynamics<span style="color: #000066; font-weight: bold;">.</span>enum<span style="color: #000066; font-weight: bold;">.</span>Simplification<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>generalrelativity<span style="color: #000066; font-weight: bold;">.</span>foam<span style="color: #000066; font-weight: bold;">.</span>dynamics<span style="color: #000066; font-weight: bold;">.</span>force<span style="color: #000066; font-weight: bold;">.</span>Gravity<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>generalrelativity<span style="color: #000066; font-weight: bold;">.</span>foam<span style="color: #000066; font-weight: bold;">.</span>Foam<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>generalrelativity<span style="color: #000066; font-weight: bold;">.</span>foam<span style="color: #000066; font-weight: bold;">.</span>math<span style="color: #000066; font-weight: bold;">.</span>Vector<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>generalrelativity<span style="color: #000066; font-weight: bold;">.</span>foam<span style="color: #000066; font-weight: bold;">.</span>util<span style="color: #000066; font-weight: bold;">.</span>ShapeUtil<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span><span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;300&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;300&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> FoamSample1 <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> const W<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">300</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> const H<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">300</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> foam<span style="color: #000066; font-weight: bold;">:</span>Foam<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> FoamSample1<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">scaleMode</span> = <span style="color: #004993;">StageScaleMode</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">NO_SCALE</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">align</span> = <span style="color: #004993;">StageAlign</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">BOTTOM</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//FOAMインスタンスの生成</span>
			foam = <span style="color: #0033ff; font-weight: bold;">new</span> Foam<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>foam<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//オブジェクトのドラッグ有効化</span>
			foam<span style="color: #000066; font-weight: bold;">.</span>useMouseDragger<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			foam<span style="color: #000066; font-weight: bold;">.</span>addGlobalForceGenerator<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> Gravity<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> Vector<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.3</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #009900; font-style: italic;">//circle</span>
			foam<span style="color: #000066; font-weight: bold;">.</span>addElement<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> Circle<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">30</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			foam<span style="color: #000066; font-weight: bold;">.</span>addElement<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> Circle<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">200</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">30</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> wall_arr<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #009900; font-style: italic;">//ground</span>
			wall_arr = ShapeUtil<span style="color: #000066; font-weight: bold;">.</span>createRectangle<span style="color: #000000;">&#40;</span>W<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			foam<span style="color: #000066; font-weight: bold;">.</span>addElement<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> RigidBody<span style="color: #000000;">&#40;</span>W<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> Simplification<span style="color: #000066; font-weight: bold;">.</span>INFINITE_MASS<span style="color: #000066; font-weight: bold;">,</span> wall_arr<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			foam<span style="color: #000066; font-weight: bold;">.</span>addElement<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> RigidBody<span style="color: #000000;">&#40;</span>W<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> H<span style="color: #000066; font-weight: bold;">,</span> Simplification<span style="color: #000066; font-weight: bold;">.</span>INFINITE_MASS<span style="color: #000066; font-weight: bold;">,</span> wall_arr<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #009900; font-style: italic;">//wall</span>
			wall_arr = ShapeUtil<span style="color: #000066; font-weight: bold;">.</span>createRectangle<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">,</span> H<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			foam<span style="color: #000066; font-weight: bold;">.</span>addElement<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> RigidBody<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> H<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> Simplification<span style="color: #000066; font-weight: bold;">.</span>INFINITE_MASS<span style="color: #000066; font-weight: bold;">,</span> wall_arr<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			foam<span style="color: #000066; font-weight: bold;">.</span>addElement<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> RigidBody<span style="color: #000000;">&#40;</span>W<span style="color: #000066; font-weight: bold;">,</span> H<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> Simplification<span style="color: #000066; font-weight: bold;">.</span>INFINITE_MASS<span style="color: #000066; font-weight: bold;">,</span> wall_arr<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			foam<span style="color: #000066; font-weight: bold;">.</span>simulate<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.jinten.net/blog/archives/41/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[AS3]3d物理エンジン</title>
		<link>http://www.jinten.net/blog/archives/38</link>
		<comments>http://www.jinten.net/blog/archives/38#comments</comments>
		<pubDate>Wed, 23 Jan 2008 12:23:51 +0000</pubDate>
		<dc:creator>ken</dc:creator>
				<category><![CDATA[ActionScript3.0]]></category>
		<category><![CDATA[ASライブラリ]]></category>

		<guid isPermaLink="false">http://www.jinten.net/blog/archives/38</guid>
		<description><![CDATA[ずいぶん前からその存在は知っていたんですが、 最近やっと出たみたいですね。 AS3 3D Physics Engine : WOW-Engine ということで、早速触ってみたんですが･･･。 情報が少ない！わからないこと [...]]]></description>
			<content:encoded><![CDATA[<p>ずいぶん前からその存在は知っていたんですが、<br />
最近やっと出たみたいですね。</p>
<p><a href="http://seraf.mediabox.fr/wow-engine/as3-3d-physics-engine-wow-engine/">AS3 3D Physics Engine : WOW-Engine</a></p>
<p>ということで、早速触ってみたんですが･･･。<br />
情報が少ない！わからないことばかり。</p>
<p>とりあえず今日は習作ということで。</p>
<p><a href="http://www.jinten.net/samples/wow_sample1.html" title='スクリーンショット'><img src='http://www.jinten.net/blog/wp-content/uploads/2008/01/screenshot.png' alt='スクリーンショット' />デモ</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jinten.net/blog/archives/38/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[pv3d]初めてのPaperVision3D(2)</title>
		<link>http://www.jinten.net/blog/archives/35</link>
		<comments>http://www.jinten.net/blog/archives/35#comments</comments>
		<pubDate>Tue, 22 Jan 2008 07:37:32 +0000</pubDate>
		<dc:creator>ken</dc:creator>
				<category><![CDATA[ActionScript3.0]]></category>
		<category><![CDATA[ASライブラリ]]></category>
		<category><![CDATA[papervision]]></category>

		<guid isPermaLink="false">http://www.jinten.net/blog/archives/35</guid>
		<description><![CDATA[今回も引き続き pv3d 2.0 tutorial list[pv3d.org]から。 前回でPaperVision3Dで3D描画を行うための世界は整っているので、 今回はその世界に3Dオブジェクトを追加して表示してみま [...]]]></description>
			<content:encoded><![CDATA[<p>今回も引き続き<br />
<a href="http://pv3d.org/pv3d-20-tutorial-list/">pv3d 2.0 tutorial list[pv3d.org]</a>から。</p>
<p>前回でPaperVision3Dで3D描画を行うための世界は整っているので、<br />
今回はその世界に3Dオブジェクトを追加して表示してみます。<br />
と、いってもチュートリアルの通りに進めたところ、すごく簡単でした。</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> material<span style="color: #000066; font-weight: bold;">:</span>ColorMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> ColorMaterial<span style="color: #000000;">&#40;</span>col<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.9</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
material<span style="color: #000066; font-weight: bold;">.</span>doubleSided = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> plane<span style="color: #000066; font-weight: bold;">:</span>Plane = <span style="color: #0033ff; font-weight: bold;">new</span> Plane<span style="color: #000000;">&#40;</span>material<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
scene<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>plane<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>こんな感じで、<br />
ColorMaterialのインスタンスを生成します。<br />
これが、「面」になるようで、ColorMaterialは、色の付いた面になるようです。</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">material<span style="color: #000066; font-weight: bold;">.</span>doubleSided = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>この部分では、面の裏側も色を塗ることを指定しています。<br />
この指定をしないと片面しか色を塗ってくれないようです。</p>
<p>Planeクラスは「平面」です。<br />
Planeクラスに先ほどの「面」を引数にして生成した後、シーンにaddChildします。</p>
<p>これで、3D空間へ平面を置くことができました。</p>
<p>Planeクラスのyawメソッドなどを呼ぶと平面を回転してくれます。<br />
どのメソッドでどのように回転するかなどは、チュートリアルのサイトの、<br />
<a href="http://pv3d.org/2007/12/21/basic-movement-explorer/">3d Object Movement Explorer</a>のページが参考になります。</p>
<p>平面の回転や移動等をしつつ、<br />
<a href="http://www.jinten.net/blog/archives/34">前回のソースコードサンプル</a>のようにEnterFrameイベントのリスナーで、<br />
renderer.renderSceneメソッドを呼べば、<br />
3Dの表示&#038;ちょっとしたアニメーションまで完成です。</p>
<p><a href='http://www.jinten.net/samples/pv3d_sample.html' title='demo'><br />
<img src="http://www.jinten.net/blog/wp-content/uploads/2008/01/pv3d_sample1.png" alt="スクリーンショット" /><br />
<br clear="left"/>デモ<br />
</a></p>
<p>ちなみに、全然関係ないんですが、今回参考にしたサイトの、<br />
<a href="http://pv3d.org/2008/01/06/7-basic-interactivity/">7. Basic Interactivity</a>で、</p>
<blockquote><p>When starting out with pv3d, many as3 <strong>ninjas</strong> don’t realize you need to enable interactivity in the viewport and the material before being able to listen to the various click events. </p></blockquote>
<p>ninjasって･･･忍者？忍者ってこんな自然に文章に混ざっても、英語圏で通じるレベルなのかぁ。ちょっと感動です。</p>
<p>とりあえず、チュートリアルそのままではアレなので少しだけ変えて、<br />
今回のソースコードも公開。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/**
* PaperVision3D sample
* @author jinten.net
*/</span>
package <span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
	<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">papervision3d</span>.<span style="color: #006600;">cameras</span>.<span style="color: #006600;">Camera3D</span>;
	<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">papervision3d</span>.<span style="color: #006600;">cameras</span>.<span style="color: #006600;">FreeCamera3D</span>;
	<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">papervision3d</span>.<span style="color: #006600;">materials</span>.<span style="color: #006600;">ColorMaterial</span>;
	<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">papervision3d</span>.<span style="color: #006600;">objects</span>.<span style="color: #006600;">primitives</span>.<span style="color: #006600;">Plane</span>;
	<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">papervision3d</span>.<span style="color: #006600;">render</span>.<span style="color: #006600;">BasicRenderEngine</span>;
	<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">papervision3d</span>.<span style="color: #006600;">scenes</span>.<span style="color: #006600;">Scene3D</span>;
	<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">papervision3d</span>.<span style="color: #006600;">view</span>.<span style="color: #006600;">Viewport3D</span>;
&nbsp;
	<span style="color: #66cc66;">&#91;</span>SWF<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">backgroundColor</span> = <span style="color: #ff0000;">&quot;#FFFFFF&quot;</span>, <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;400&quot;</span>, <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;300&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> pv3d_sample1 <span style="color: #0066CC;">extends</span> Sprite <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> scene:Scene3D;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> viewport:Viewport3D;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">camera</span>:Camera3D;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> renderer:BasicRenderEngine;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> planes:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> pv3d_sample1<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			scene = <span style="color: #000000; font-weight: bold;">new</span> Scene3D<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			initObjects<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			viewport = <span style="color: #000000; font-weight: bold;">new</span> Viewport3D<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">400</span>, <span style="color: #cc66cc;">300</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #0066CC;">camera</span> = <span style="color: #000000; font-weight: bold;">new</span> Camera3D<span style="color: #66cc66;">&#40;</span>planes<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			renderer = <span style="color: #000000; font-weight: bold;">new</span> BasicRenderEngine<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			addChild<span style="color: #66cc66;">&#40;</span>viewport<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, enterFrameHandler<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> enterFrameHandler<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&lt;</span> planes.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				planes<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">yaw</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">%</span>2==<span style="color: #cc66cc;">0</span>?<span style="color: #cc66cc;">2</span>:-<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #0066CC;">camera</span>.<span style="color: #006600;">x</span> = mouseX;
			<span style="color: #0066CC;">camera</span>.<span style="color: #006600;">y</span> = mouseY;
&nbsp;
			renderer.<span style="color: #006600;">renderScene</span><span style="color: #66cc66;">&#40;</span>scene, <span style="color: #0066CC;">camera</span>, viewport<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> initObjects<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			planes.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span>makePlane<span style="color: #66cc66;">&#40;</span>0xFF6666, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			planes.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span>makePlane<span style="color: #66cc66;">&#40;</span>0x66FF66, <span style="color: #cc66cc;">400</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			planes.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span>makePlane<span style="color: #66cc66;">&#40;</span>0x6666FF, -<span style="color: #cc66cc;">400</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			planes.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span>makePlane<span style="color: #66cc66;">&#40;</span>0xFFFF66, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">400</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			planes.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span>makePlane<span style="color: #66cc66;">&#40;</span>0x66FFFF, <span style="color: #cc66cc;">0</span>, -<span style="color: #cc66cc;">400</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			planes.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span>makePlane<span style="color: #66cc66;">&#40;</span>0xFF66FF, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">400</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			planes.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span>makePlane<span style="color: #66cc66;">&#40;</span>0x666666, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, -<span style="color: #cc66cc;">400</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> makePlane<span style="color: #66cc66;">&#40;</span>col:uint, x:<span style="color: #0066CC;">Number</span>, y:<span style="color: #0066CC;">Number</span>, z:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:Plane <span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> material:ColorMaterial = <span style="color: #000000; font-weight: bold;">new</span> ColorMaterial<span style="color: #66cc66;">&#40;</span>col, <span style="color: #cc66cc;">0.9</span><span style="color: #66cc66;">&#41;</span>;
			material.<span style="color: #006600;">doubleSided</span> = <span style="color: #000000; font-weight: bold;">true</span>;
&nbsp;
			<span style="color: #000000; font-weight: bold;">var</span> plane:Plane = <span style="color: #000000; font-weight: bold;">new</span> Plane<span style="color: #66cc66;">&#40;</span>material, <span style="color: #cc66cc;">300</span>, <span style="color: #cc66cc;">300</span><span style="color: #66cc66;">&#41;</span>;
			plane.<span style="color: #006600;">x</span> = x;
			plane.<span style="color: #006600;">y</span> = y;
			plane.<span style="color: #006600;">z</span> = z;
			scene.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>plane<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">return</span> plane;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.jinten.net/blog/archives/35/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[pv3d]初めてのPaperVision3D(1)</title>
		<link>http://www.jinten.net/blog/archives/34</link>
		<comments>http://www.jinten.net/blog/archives/34#comments</comments>
		<pubDate>Thu, 10 Jan 2008 05:47:11 +0000</pubDate>
		<dc:creator>ken</dc:creator>
				<category><![CDATA[ActionScript3.0]]></category>
		<category><![CDATA[ASライブラリ]]></category>
		<category><![CDATA[papervision]]></category>

		<guid isPermaLink="false">http://www.jinten.net/blog/archives/34</guid>
		<description><![CDATA[少し時間もあったので、最近流行のPaperVision3Dに手を出してみました。 で、3Dとかさっぱりわからないのですが、とにかく触ってれば、 必要に迫られて色々知識も増えていくだろうということでひとまず参考にしたサイト [...]]]></description>
			<content:encoded><![CDATA[<p>少し時間もあったので、最近流行のPaperVision3Dに手を出してみました。</p>
<p>で、3Dとかさっぱりわからないのですが、とにかく触ってれば、<br />
必要に迫られて色々知識も増えていくだろうということでひとまず参考にしたサイトはこちら。<br />
<a href="http://pv3d.org/pv3d-20-tutorial-list/">pv3d 2.0 tutorial list[pv3d.org]</a></p>
<p>まだ途中みたいですが、チュートリアルになってます。<br />
順に進めていくと、PaperVision3Dでの基本部分のコードの書き方がわかります。</p>
<p>まずは、3Dな世界の構築部分です。<br />
最低限必要なインスタンスは4種類。まずは、インスタンスを生成します。</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">viewport = <span style="color: #000000; font-weight: bold;">new</span> Viewport3D<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
scene = <span style="color: #000000; font-weight: bold;">new</span> Scene3D<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">camera</span> = <span style="color: #000000; font-weight: bold;">new</span> FreeCamera3D<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
renderer = <span style="color: #000000; font-weight: bold;">new</span> BasicRenderEngine<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>ちなみにScene3DクラスはSceneObject3Dのサブクラス、<br />
FreeCamera3DはCameraObject3Dのサブクラスです。<br />
シーンやカメラには他にも種類があるようですが、<br />
今回は参考にしたサイトで使っていたクラスをそのままです。</p>
<p>続いてViewport3DのインスタンスをaddChildに渡します。</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">addChild<span style="color: #66cc66;">&#40;</span>viewport<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>これで、描画ツリーに3D世界を追加完了。</p>
<p>最後にBasicRenderEngine.rendererメソッドを呼べば描画されます。</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">renderer.<span style="color: #006600;">renderScene</span><span style="color: #66cc66;">&#40;</span>scene, <span style="color: #0066CC;">camera</span>, viewport<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>このとき、scene、camera、viewportの各インスタンスを渡してあげます。</p>
<p>これだけ。</p>
<p>簡単ですね。</p>
<p>まだ3Dオブジェクトを何も置いていないので、何も表示されませんが、<br />
とりあえず今回はテンプレート的にソースコードを出しつつ今日はココまで。</p>
<p>コード全体は以下。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/**
* PaperVision3D sample
* @author jinten.net
*/</span>
package <span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
	<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">papervision3d</span>.<span style="color: #006600;">cameras</span>.<span style="color: #006600;">FreeCamera3D</span>;
	<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">papervision3d</span>.<span style="color: #006600;">render</span>.<span style="color: #006600;">BasicRenderEngine</span>;
	<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">papervision3d</span>.<span style="color: #006600;">scenes</span>.<span style="color: #006600;">Scene3D</span>;
	<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">papervision3d</span>.<span style="color: #006600;">view</span>.<span style="color: #006600;">Viewport3D</span>;
&nbsp;
	<span style="color: #66cc66;">&#91;</span>SWF<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">backgroundColor</span> = <span style="color: #ff0000;">&quot;#FFFFFF&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> pv3d_sample1 <span style="color: #0066CC;">extends</span> Sprite <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> viewport:Viewport3D;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> scene:Scene3D;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">camera</span>:FreeCamera3D;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> renderer:BasicRenderEngine;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> pv3d_sample1<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			viewport = <span style="color: #000000; font-weight: bold;">new</span> Viewport3D<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			scene = <span style="color: #000000; font-weight: bold;">new</span> Scene3D<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">camera</span> = <span style="color: #000000; font-weight: bold;">new</span> FreeCamera3D<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			renderer = <span style="color: #000000; font-weight: bold;">new</span> BasicRenderEngine<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			addChild<span style="color: #66cc66;">&#40;</span>viewport<span style="color: #66cc66;">&#41;</span>;
			addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, enterFrameHandler<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> enterFrameHandler<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			renderer.<span style="color: #006600;">renderScene</span><span style="color: #66cc66;">&#40;</span>scene, <span style="color: #0066CC;">camera</span>, viewport<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.jinten.net/blog/archives/34/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[as3][lib]Go animation system</title>
		<link>http://www.jinten.net/blog/archives/33</link>
		<comments>http://www.jinten.net/blog/archives/33#comments</comments>
		<pubDate>Mon, 17 Dec 2007 02:02:59 +0000</pubDate>
		<dc:creator>ken</dc:creator>
				<category><![CDATA[ASライブラリ]]></category>

		<guid isPermaLink="false">http://www.jinten.net/blog/archives/33</guid>
		<description><![CDATA[Flexからアニメーションをガリガリ作る時の標準は今はTweenerライブラリなんでしょうかね？ 新しく開発中っぽいアニメーション用のライブラリを見つけたのでメモ。 Go animation system (現在 clo [...]]]></description>
			<content:encoded><![CDATA[<p>Flexからアニメーションをガリガリ作る時の標準は今はTweenerライブラリなんでしょうかね？<br />
新しく開発中っぽいアニメーション用のライブラリを見つけたのでメモ。</p>
<p><a href="http://blog.mosessupposes.com/?p=12">Go animation system<br />
</a>(現在 closed betaらしい)<br />
 * とても軽量(およそ4K)<br />
 * 柔軟な設計で、高い拡張性を持つ。<br />
 * Fuseのようになんでもできるというようなものではない。<br />
  * ただし。Goを使ってFuseのようなものを作ることはできる。<br />
 * Goは特殊な書き方を要求しない。<br />
 * Goのエンジンは10から20000ものアニメーションを動かすことができる。<br />
 * 物理エンジンや３Dエンジンと一緒に使えるよう設計されている。<br />
 * GoのアプローチはCairngormフレームワークにインスパイアされている。</p>
<p>だ、そうです。<br />
「物理エンジンや３Dエンジンと一緒に使えるよう設計されている。」ってのが興味深いですね。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jinten.net/blog/archives/33/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[AS3]zip解凍</title>
		<link>http://www.jinten.net/blog/archives/23</link>
		<comments>http://www.jinten.net/blog/archives/23#comments</comments>
		<pubDate>Sun, 07 Oct 2007 01:24:44 +0000</pubDate>
		<dc:creator>ken</dc:creator>
				<category><![CDATA[ActionScript3.0]]></category>
		<category><![CDATA[ASライブラリ]]></category>

		<guid isPermaLink="false">http://www.jinten.net/blog/archives/23</guid>
		<description><![CDATA[as3でzipの操作用ライブラリ FZip ライセンスはzlib/libpng license 商用利用もOKなライセンスっぽい。 zipの解凍用で圧縮はできないのかな？このライブラリは。 .airファイルの中身をのぞい [...]]]></description>
			<content:encoded><![CDATA[<p>as3でzipの操作用ライブラリ</p>
<p><a href="http://codeazur.com.br/lab/fzip/">FZip</a><br />
ライセンスは<a href="http://opentechpress.jp/docs/licenses/zlib-license.shtml">zlib/libpng license</a><br />
商用利用もOKなライセンスっぽい。</p>
<p>zipの解凍用で圧縮はできないのかな？このライブラリは。<br />
.airファイルの中身をのぞいたりもできますね。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span> ?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span> mx :WindowedApplication xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> creationComplete=<span style="color: #ff0000;">&quot;init()&quot;</span><span style="color: #66cc66;">&gt;</span>
  <span style="color: #66cc66;">&lt;</span> mx :Script<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span> <span style="color: #66cc66;">!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
      <span style="color: #0066CC;">import</span> deng.<span style="color: #006600;">fzip</span>.<span style="color: #006600;">FZip</span>;
      <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> fzip:FZip;
      <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
        fzip = <span style="color: #000000; font-weight: bold;">new</span> FZip<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #000000; font-weight: bold;">var</span> req:URLRequest = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        req.<span style="color: #0066CC;">url</span> = <span style="color: #ff0000;">&quot;hogehoge.air&quot;</span>;
        fzip.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, loadComplete<span style="color: #66cc66;">&#41;</span>;
        fzip.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>req<span style="color: #66cc66;">&#41;</span>;
      <span style="color: #66cc66;">&#125;</span>
      <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> loadComplete<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
        <span style="color: #0066CC;">status</span> = fzip.<span style="color: #006600;">getFileCount</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>=<span style="color: #cc66cc;">0</span>;i<span style="color: #66cc66;">&amp;</span>lt;fzip .<span style="color: #006600;">getFileCount</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
          ta.<span style="color: #0066CC;">text</span> += fzip.<span style="color: #006600;">getFileAt</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">filename</span>+<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
          ta.<span style="color: #0066CC;">text</span> += fzip.<span style="color: #006600;">getFileAt</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getContentAsString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
          ta.<span style="color: #0066CC;">text</span> += <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
        <span style="color: #66cc66;">&#125;</span>
      <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
  <span style="color: #66cc66;">&lt;</span> <span style="color: #66cc66;">/</span>mx<span style="color: #66cc66;">&gt;</span>
  <span style="color: #66cc66;">&lt;</span> mx :TextArea id=<span style="color: #ff0000;">&quot;ta&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #66cc66;">/&gt;</span>
<span style="color: #66cc66;">&lt;</span> <span style="color: #66cc66;">/</span>mx:WindowedApplication<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.jinten.net/blog/archives/23/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
